Page 1 of 1

How do I append an equation to a group in a loop?

Posted: Wed Sep 02, 2015 3:41 pm
by macro
For example, in this code:

Code: Select all

dofor s = gdp cons gce gov
    linreg(define = eq) s
    # unemp{1 to 4}
    
    group my_model eq>>s
end dofor s

display %modelsize(my_model)
the result is a model with only one equation, because the model is overwritten by each group statement in the loop. How do I append equations to a model, in a loop or otherwise?

Re: How do I append an equation to a group in a loop?

Posted: Wed Sep 02, 2015 4:07 pm
by TomDoan
You can use model=model+equation

Code: Select all

declare model my_model
dofor s = gdp cons gce gov
    linreg(define = eq) s
    # unemp{1 to 4}
    compute my_model=my_model+eq
end dofor s

Re: How do I append an equation to a group in a loop?

Posted: Wed Sep 02, 2015 4:13 pm
by macro
Perfect! And it supports any variable with the model type, even items from a hash[model] aggregator. Thank you!