[Gretl-users] Question about bundles in loops

Allin Cottrell cottrell at wfu.edu
Tue Sep 18 19:47:44 EDT 2012


On Tue, 18 Sep 2012, Logan Kelly wrote:

> I am using a loop to estimate several models, and I would like to 
> store the results of each estimate in a bundle, i.e. the results 
> from model1 should be stored in bundel1. So what I need is an 
> array of bundles.
>
> I would like to do something like
>
> loop m = 1..ModelCount
>    string results = "results$m"
>    bundle @results
>    @results["bla bla"] = bla bla
> endloop
>
> The problem is I cannot declare a bundle in a loop.

What version of gretl are you running, on what platform? I'm not 
aware of any problem with declaring bundles in a loop. The following 
works fine here:

<hansl>
loop i=1..2 --quiet
   bundle bun$i
   bun$i["i"] = i
endloop

print bun1
print bun2
</hansl>

This gives (slightly trimmed):

bundle bun1:
  i = 1

bundle bun2:
  i = 2

There's no such object in gretl as an "array of bundles", as such, 
but you can create a bundle of bundles if you want.

Allin Cottrell


More information about the Gretl-users mailing list