Page 1 of 1

Filling a matrix on a loop

Posted: Sun Jul 26, 2020 8:53 am
by jtovalle92
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

Re: Filling a matrix on a loop

Posted: Sun Jul 26, 2020 1:17 pm
by EViews Gareth
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?

Re: Filling a matrix on a loop

Posted: Sun Jul 26, 2020 5:52 pm
by jtovalle92
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!

Re: Filling a matrix on a loop

Posted: Sun Jul 26, 2020 6:07 pm
by startz
Perhaps in the program change the smpl and the use eq.forecast.

Re: Filling a matrix on a loop

Posted: Sun Jul 26, 2020 6:18 pm
by EViews Gareth
Change your dependent variable to be log(USD(t)/USD(t-15))

Re: Filling a matrix on a loop

Posted: Sun Jul 26, 2020 6:56 pm
by startz
Change your dependent variable to be log(USD(t)/USD(t-15))
While lagging the independent variables appropriately.