Filling a matrix on a loop

For questions regarding programming in the EViews programming language.

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

jtovalle92
Posts: 2
Joined: Sun Jul 19, 2020 10:19 pm

Filling a matrix on a loop

Postby jtovalle92 » Sun Jul 26, 2020 8:53 am

Hello everyone,

I am new to the world of eviews and I am trying to make a program that will allow me to do a rolling regression using the residues of one equation as input for the another (main) equation. So I have a ferw questions that I hope will help me:

1. For each loop I need to store the residuals of the first equation in column "j" of a an empty matrix.
2. For each loop I need to store the coefficients of the second equation in row "i" of another matrix
3. My dependent variable has lags (+15) so I can't forecast, however, I would like to rescue the last fitted value and store it aswell on a vector

To give some context, what I am trying to do is to use the residues of an estimated equation with 5 years of data, as inputs to another equation, I need to do it for 20 years, always with 5 year windows and 1 day steps so it is a rolling regression

I hope you can help me,

best regards, JTO

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

Re: Filling a matrix on a loop

Postby EViews Gareth » Sun Jul 26, 2020 1:17 pm

1. You probably don't need, or want, to use matrices to store residuals. You want to use series objects.

After every estimation the residuals are stored in the RESID series. If you want to make a more permanent copy, you can just create a new series equal to RESID after estimation.

Code: Select all

series myresid = RESID


2. For storing coefficients, there are plenty of examples in the FAQ.


3. Why can't you forecast?
Follow us on Twitter @IHSEViews

jtovalle92
Posts: 2
Joined: Sun Jul 19, 2020 10:19 pm

Re: Filling a matrix on a loop

Postby jtovalle92 » Sun Jul 26, 2020 5:52 pm

EViews Gareth wrote:1. You probably don't need, or want, to use matrices to store residuals. You want to use series objects.

After every estimation the residuals are stored in the RESID series. If you want to make a more permanent copy, you can just create a new series equal to RESID after estimation.

Code: Select all

series myresid = RESID


2. For storing coefficients, there are plenty of examples in the FAQ.


3. Why can't you forecast?


I guess point 3 is the most important since I am trying to do 1. and 2. in order to solve 3.
So every time it try to forecast my equation it shows an error message: "Forecast does not support dependent variables with leads or lags"
My idea was to store all resid series in a matrix (around ~5000 series of resid), since these are part of my second equation that I need to forecast. Same with coefficient

I came up with colplace() that works fine. But I am kind of stuck without forecast tool

any thoughts? My dependent variable is log(USD(t+15)/USD(t))

thanks!

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: Filling a matrix on a loop

Postby startz » Sun Jul 26, 2020 6:07 pm

Perhaps in the program change the smpl and the use eq.forecast.

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

Re: Filling a matrix on a loop

Postby EViews Gareth » Sun Jul 26, 2020 6:18 pm

Change your dependent variable to be log(USD(t)/USD(t-15))
Follow us on Twitter @IHSEViews

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: Filling a matrix on a loop

Postby startz » Sun Jul 26, 2020 6:56 pm

EViews Gareth wrote:Change your dependent variable to be log(USD(t)/USD(t-15))

While lagging the independent variables appropriately.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 34 guests