subsets of model equations

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

cj123
Posts: 4
Joined: Tue Mar 05, 2024 1:18 pm

subsets of model equations

Postby cj123 » Tue Mar 05, 2024 3:08 pm

Hello, I have a question with regards to model objects, and making models that are subsets of larger models.

Assume you have a model object, in a work file with 1000 estimated equations (call them y1, y2, ….y1000), model name mod1. I am attempting to take a subset of that model, call it mod2 with a subset of mod1’s equations (y400, y401,…y499) and run a simulation with this partial model. As the equations in the full model change quarterly (new equations added or dropped etc.), I am looking for a way to specify the equations to pull to create a new model object (that is a subset of the whole model), as opposed to specifying the equations to drop.

Assume mod1 is the full 1000 equation model, I am trying to make an object called mod2 which has equations y400,y401,…y499. I assumed there would be a command like:

Copy mod1 mod2
Mod2.keep y400, y401, y402, ... y499

or alternativly, something like:

model mod2
mod2.merge mod1::y400
mod2.merge mod1::y401
.....

Where all of the other equations would be dropped from the mod2 except those specified to keep (or only those explicitely staed are merged with the new model). Since equations change quarterly, I cannot use the mod2.drop command, and specify the compliment of the set (y400,y401,…) since the list is dynamic, and it is very large. I notice however, that using the model.merge command, I can only copy over the entire model, and not a model subset (my equations are txt format in the model object). I would love if anyone has any insight into solving this problem! :)

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13323
Joined: Tue Sep 16, 2008 5:38 pm

Re: subsets of model equations

Postby EViews Gareth » Tue Mar 05, 2024 3:12 pm

Not sure I understand the logic behind what gets included. Do you just have a list of equations you want included?
Follow us on Twitter @IHSEViews

cj123
Posts: 4
Joined: Tue Mar 05, 2024 1:18 pm

Re: subsets of model equations

Postby cj123 » Tue Mar 05, 2024 8:02 pm

Hi, Gareth—

This is correct. There is a subset of equations that get pulled (the endogenous variables that I want to put in the smaller model will stay the same each vintage). However, if for example the coefficients or equation specification changes in the full model across vintages, I want to ensure that I can re-run my code, and generate the new subset model. Since the model is large (>500 equations) and the smaller model that is a subset is also big (approx 100 equations), it would be too much to manually update this model quarterly.

Thank you

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13323
Joined: Tue Sep 16, 2008 5:38 pm

Re: subsets of model equations

Postby EViews Gareth » Tue Mar 05, 2024 8:26 pm

So just create a new empty model, and add the equations you want in it? What am I missing?
Follow us on Twitter @IHSEViews

cj123
Posts: 4
Joined: Tue Mar 05, 2024 1:18 pm

Re: subsets of model equations

Postby cj123 » Wed Mar 06, 2024 7:56 am

Yes, but I do not want to manually add them every time, since the equations can change over time.

Say for example I want to pull the endogenous variable y400 from mod1, and put in in mod2. I would have to run the command:

mod2.add y400=mx+b (this works no problem)

However, each quarter the equation specification or the coeffecients could change, so I am looking for a way to say:

mod2.add mod1::y400, or source the equation of endogenous variable y400 from mod1 and add it to mod2 without explicitely specifying the equation itself (it would take the equation specification of the endogenous variable from the main model). I am looking to automate this, as my mod1 is over 500 equations, and mod2 is over 100, so if I have to manually respecify equation changes between vintages, there could be problems.

Alternativly, I could drop all of the equations I do not need from the main model, and save it as mod2, however since equations get added to the main mod1 it would be easier to specify the equations that I need to pull from the model (as these do not change).

I hope this provides some clarity

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13323
Joined: Tue Sep 16, 2008 5:38 pm

Re: subsets of model equations

Postby EViews Gareth » Wed Mar 06, 2024 8:43 am

Ah, now I see the issue.

Perhaps:

Code: Select all

%eqn = mod1.@spec("y400")
mod2.append {%eqn}


in a loop to loop through the variables you want.
Follow us on Twitter @IHSEViews

cj123
Posts: 4
Joined: Tue Mar 05, 2024 1:18 pm

Re: subsets of model equations

Postby cj123 » Wed Mar 06, 2024 8:54 am

This is exactly what I was looking for, and you have no idea how long I was playing around.

Thank you Gareth, once again. Really appreciate your help.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 17 guests