Thanks Sven.  That is clever!   I suppose that there is some danger in referring to a list in a bundle since variable ID numbers can change when a variable is deleted?  

I think the implication is that anything that is computed based on the list  needs  to be added to the bundle in the initial bundle setup function.  This is the approach I'm currently taking, but wondering if there is something more elegant.
<hansl>
function scalar RLSStein(series y, list EXOG, matrix R, matrix r, string Loss)    
    bundle rr = Stein_setup(y, EXOG, R, r, Loss)     #this uses the list, but other functions don't
    scalar err = aw(&rr)
    scalar err = Stein_estimate(&rr)
    scalar err = Stein_printout(&rr)
    return 0
end function
</hansl>

Or, one has to use a list argument in any subsequent (private) function call that needs it and references the bundle.

<hansl>
function scalar RLSStein(series y, list EXOG, matrix R, matrix r, string Loss)    
    bundle rr = Stein_setup(y, EXOG, R, r, Loss)
    scalar err = aw(&rr, EXOG)
    scalar err = Stein_estimate(&rr)
    scalar err = Stein_printout(&rr)
    return 0
end function

function scalar aw(bundle *b, list EXOG)
      [stuff] 
return 0
end function
</hansl>

I'm not sure I'm describing this properly because I'm still trying get my head around this bundle concept.    I'm making some progress.  Slow progress, but progress nonetheless.   As you can guess, I'm trying to write a function to estimate Stein-rules.  

Thanks again,
Lee

On Sat, Nov 17, 2012 at 12:20 PM, Sven Schreiber <svetosch@gmx.net> wrote:



On 11/17/2012 05:45 PM, Lee Adkins wrote:
> Can a bundle contain a list?  If so, how? If not, are there
> any preferred workarounds?
>

I was going to say yes it should be able to, but I just learned this
isn't in the specs. So I was getting curious and this is what I came up
with so far:

The following code transfers the list to the bundle, so that the number
of the series is stored within the bundle (as a scalar under the key
"testlist_nelem"), the series themselves are stored (under the keys
"testlist_serX", where X was the position of the series in the list),
and finally the original names of the series are also stored in the
bundle, as strings (under the keys "testlist_nameX").

In principle one should be able to wrap this in a function, I guess.

cheers,
sven

<hansl>
nulldata 100

list testlist = dataset # so far the only series will be 'index'

bundle proto

# populate the bundle with the list contents
n = nelem(testlist)
proto["testlist_nelem"] = n
loop i=1..n
    sprintf serieskey "testlist_ser%d", i
    sprintf namekey "testlist_name%d", i
    proto[namekey] = "$i"       # saves the original name of the series
    proto[serieskey] = i        # saves the series
endloop

# how to retrieve those series
m = proto["testlist_nelem"]
loop i=1..m
    series newser$i = proto["testlist_ser$i"]
    string message = "Retrieved copy of '" ~ proto["testlist_name$i"] ~
"'."
    print "@message"
endloop
</hansl>



_______________________________________________
Gretl-users mailing list
Gretl-users@lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users



--
Lee Adkins
Professor of Economics
lee.adkins@okstate.edu

learneconometrics.com