collecting fitted values/stats for rolling panel regression

For questions regarding programming in the EViews programming language.

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

makas12
Posts: 10
Joined: Tue Jun 30, 2015 12:03 pm

collecting fitted values/stats for rolling panel regression

Postby makas12 » Tue Jun 30, 2015 12:09 pm

I would like to capture fair value and residuals along with various rolling stats - R-squared, t-stats etc. I can create an array to capture stats in a fair value, but I would like to capture a lot of data for each roll including fair value/residuals along with regression stats/coefficients. What is the best way to do this? Any examples would be of great help. thanks,

makas12
Posts: 10
Joined: Tue Jun 30, 2015 12:03 pm

Re: collecting fitted values/stats for rolling panel regress

Postby makas12 » Wed Jul 01, 2015 7:48 am

Gareth - thanks for your response. I can use equation.fit and equation.makeresid function. For each of the cross sections in the panel, I would like to pick the last reading (last fitted value and last residual). I lose ids if I make a matrix out of the series. So, I combine the fitted values and residuals using a group. How do I extract the last reading from this group? Eventually, I would like to build a series of the last readings of the rolling samples.

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

Re: collecting fitted values/stats for rolling panel regress

Postby EViews Gareth » Wed Jul 01, 2015 7:58 am

Set the sample to the be the last observation, then use the stom command
Follow us on Twitter @IHSEViews

makas12
Posts: 10
Joined: Tue Jun 30, 2015 12:03 pm

Re: collecting fitted values/stats for rolling panel regress

Postby makas12 » Mon Jul 20, 2015 6:32 am

Thanks. To get the last element of the fitted series, I have added following code (last three lines below):

Code: Select all

.
.
!numMonths = 12
matrix(!numCountries,!numMonths) fittedHolder
.
.
.
for !horizon = 1 to !numMonths
  smpl @first @last-!numMonths+!horizon
  equation.eqSolve ******
  eqSolve.fit fittedSeries
  smpl s1 @last-!numMonths+!horizon @last-!numMonths+!horizon   
  stom(fittedSeries,fittedHolder,s1)
next


Unforutnately, I get the error "Error in Sample: Illegal date S1 in "Smpl s1 @LAST-12+1 @LAST-12+1". I am not sure why first sample line in the loop would go through but the second one would not. Also, the rolling regression code in the examples also uses the sample code in a similar manner. Any thoughts on what I am doing wrong? thanks,

makas12
Posts: 10
Joined: Tue Jun 30, 2015 12:03 pm

Re: collecting fitted values/stats for rolling panel regress

Postby makas12 » Mon Jul 20, 2015 7:17 am

Another approach I tried:

In my previous post, I changed

Code: Select all

smpl s1 @last-!numMonths+!horizon @last-!numMonths+!horizon   
stom(fittedSeries,fittedHolder,s1)


to

Code: Select all

smpl @last-!numMonths+!horizon @last-!numMonths+!horizon   
colplace(fittedHolder,fittedSeries,!i)


But then I get an error - MAtrix size mismatch in "colplace(fittedHolder,fittedSeries,1)". Wondering what I am doing wrong in resizing the sample?

makas12
Posts: 10
Joined: Tue Jun 30, 2015 12:03 pm

Re: collecting fitted values/stats for rolling panel regress

Postby makas12 » Mon Jul 20, 2015 12:44 pm

Hello all - any thoughts on this? I cannot figure out how I can pick the last point of a series in a panel and store it in a matrix in a rolling time horizon or an expanding time horizon regression?

I can do that for t stats and coefficients with ease using :

Code: Select all

colplace(statsTstat,eqSolve.@tstats,!i)


But can't seem to figure out a way to capture the fitted series for each of the panel entries in a matrix form. so if I have 5 entities and 3 rolls, would like to create a matrix like this?
1 2 3 4 5
Ent 1 * * * * *
Ent 2 * * * * *
Ent 3 * * * * *
Ent 4 * * * * *
Ent 5 * * * * *

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

Re: collecting fitted values/stats for rolling panel regress

Postby EViews Gareth » Mon Jul 20, 2015 1:13 pm

makas12 wrote:Another approach I tried:

In my previous post, I changed

Code: Select all

smpl s1 @last-!numMonths+!horizon @last-!numMonths+!horizon   
stom(fittedSeries,fittedHolder,s1)


to

Code: Select all

smpl @last-!numMonths+!horizon @last-!numMonths+!horizon   
colplace(fittedHolder,fittedSeries,!i)


But then I get an error - MAtrix size mismatch in "colplace(fittedHolder,fittedSeries,1)". Wondering what I am doing wrong in resizing the sample?


You'll still need an stom command as well as the smpl and colplace.
Follow us on Twitter @IHSEViews

gsourop
Posts: 18
Joined: Wed Nov 11, 2015 11:46 am

Re: collecting fitted values/stats for rolling panel regress

Postby gsourop » Fri Nov 20, 2015 6:06 am

Hi everyone,
I would like some advise in the following. I want to make more than one regressions (in my example 2) a) ls Delta_lspot c(1) c(2)model_ppp , b)ls Delta_lspot c(3) c(4)model_irp
and I want the coefficients to be saved on a single matrix. The coefficients derived from (a): for c(1): to cells a11(first raw first column) to a15(first raw 5th column)
for c(2): to cells a21(second raw first column) to a25(second raw 5th column)
The coefficients derived from (b): for c(3): to cells a31(third raw first column) to a35(third raw 5th column)
for c(4): to cells a41(fourth raw first column) to a45(fourth raw 5th column)
Until now I have done the following:

matrix(4,5) coefmat
!j=0
!j=!j+1
for %i model_ppp model_irp
for !horizon=1 to 5
smpl 1974m01 1978m12+!horizon
equation eq{!horizon}{%i}.ls Delta_lspot c {%i}
colplace(coefmat,eq{!horizon}{%i}.@coefs,!horizon)
next
next

When I run the above I get the message "Matrix size mismatch" Does anyone know how to do this?

Thanks in advance.

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

Re: collecting fitted values/stats for rolling panel regress

Postby EViews Gareth » Fri Nov 20, 2015 6:57 am

Probably easier to just assign the elements one at a time.

Code: Select all

Coefmat(1,1) = eq.@coef(1)
Follow us on Twitter @IHSEViews

gsourop
Posts: 18
Joined: Wed Nov 11, 2015 11:46 am

Re: collecting fitted values/stats for rolling panel regress

Postby gsourop » Sat Nov 21, 2015 7:13 am

Thanks for the advise!

I have another question though.
if my initial equation was y=c(1)+c(2)x1 +c(3)x2
and I recursively estimated my coefficients
for t=1 c(1,t) c(2,t) c(3,t)
for t=t+1 c(1,t+1) c(2,t+1) c(3,t+1)
for t=t+2 c(1,t+2) c(2,t+2) c(3,t+2)

and so on until t=432

My total sample has 504 observations (1973m01 to 2014m12), and my coefficient matrix is of size [3,432] (I used the first 72=504-432 observations in order to make my first estimation) and then recursively estimated my coefficients.

So c(1) c(2) c(3) are parts of a matrix [3,432] and x1,x2 are variables that include 504 observations each
All I want to end up is to simple compute:

y1,t=c(1,t)+c(2,t)x1 +c(3,t)x2 where x1 and x2 are going to be the 73 observation (1979m01), of each variable respectively
y1,t+1=c(1,t+1)+c(2,t+1)x1 +c(3,t+1)x2 where x1 and x2 are going to be the 74 observation (1979m02), of each variable respectively
and so on until the end of my sampling period (2014m12).

Thanks Gareth for all the help until now, I appreciate it!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 20 guests