Page 1 of 1

Storing residual standard errors in a recursive regression

Posted: Tue Apr 08, 2014 5:31 am
by ylijohtaja
Hi

I have modified the example rolling regression programs to work as a recursive FMOLS estimation storing the recursive coefficient estimates. Everything works fine. However, in addition to storing the coefficients I would need to get the residual standard error for each recursive estimation. How could I do that?

Many thanks in advance (the current program is shown below, I use Eviews7).

' get size of workfile
!length = @obsrange

' set window size
!window = 32

' set step size
!step = 1

' declare equation for estimation
equation eq1

' calculate number of rolls
!nrolls = @round((!length-!window+1)/!step)

' matrix to store coefficient estimates
matrix(2,!nrolls) coefmat ' where 2 is the number of coefficients

' variable keeping track of how many rolls we've done
!j=0

' move sample !step obs at a time
for !i = 1 to !length-!window+1-!step step !step
!j=!j+1

' set sample to estimation period
smpl @first @first+!i+!window-2

' estimate equation
eq1.cointreg(method=fmols, trend=const, regtend=none, lag=a, info=sic, kern=Bart,bw=andrews) p di

' store coefficients
colplace(coefmat,eq1.@coefs,!j)
next

show coefmat

Re: Storing residual standard errors in a recursive regressi

Posted: Tue Apr 08, 2014 8:14 am
by EViews Gareth

Code: Select all

' get size of workfile !length = @obsrange ' set window size !window = 32 ' set step size !step = 1 ' declare equation for estimation equation eq1 ' calculate number of rolls !nrolls = @round((!length-!window+1)/!step) ' matrix to store coefficient estimates matrix(2,!nrolls) coefmat ' where 2 is the number of coefficients 'vector to store ses vector(!nrolls) sevec ' variable keeping track of how many rolls we've done !j=0 ' move sample !step obs at a time for !i = 1 to !length-!window+1-!step step !step !j=!j+1 ' set sample to estimation period smpl @first @first+!i+!window-2 ' estimate equation eq1.cointreg(method=fmols, trend=const, regtend=none, lag=a, info=sic, kern=Bart,bw=andrews) p di ' store coefficients colplace(coefmat,eq1.@coefs,!j) next 'store se sevec(!j) = eq1.@se show coefmat

Re: Storing residual standard errors in a recursive regressi

Posted: Tue Apr 08, 2014 8:47 am
by ylijohtaja
Many thanks Gareth,
There is one remaining problem: the 'sevec' vector contains only nulls except for the last period.

Re: Storing residual standard errors in a recursive regressi

Posted: Tue Apr 08, 2014 9:05 am
by EViews Gareth
That's because I put it outside the Next by mistake. Move it inside the loop.

Re: Storing residual standard errors in a recursive regressi

Posted: Wed May 21, 2014 3:35 am
by sdgdas
In this rolling regression program how can I store the standard errors., Also I am using Eview 5 version does it work fine with Sevec command?

'run rolling regression

' declare equation for estimation
equation eq1

'matrix to store coefficient estimates
matrix(6,120) coefmat ' where 3 is the number of coefficients

'variable keeping track of how many rolls we've done
!j=0

' move sample !step obs at a time
for !i = 1 to 120
!j=!j+1

' set sample to estimation period
smpl 1969Q1+!j 1984Q1+!j

' estimate equation - where the equation is y=c(1) + c(2)*x1 + c(3)*x2
eq1.ls PCE_COREAR PCE_COREAR(-1) PCE_COREAR(-2) PCE_COREAR(-3) UNEMPGAP(-1) INFEXP(-1) IMP_PCECOREAR(-1)

'store coefficients
colplace(coefmat,eq1.@coefs,!j)

'store se
sevec(!j) = eq1.@se

next

show coefmat

Re: Storing residual standard errors in a recursive regressi

Posted: Wed May 21, 2014 7:33 am
by EViews Glenn
Note that your equation doesn't have an intercept.

Have you looked in SEVEC after you ran the program?

Re: Storing residual standard errors in a recursive regressi

Posted: Wed May 21, 2014 8:29 am
by sdgdas
My program is not recognizing sevec, sorry I didn't define it. But not sure how to define it.

Re: Storing residual standard errors in a recursive regressi

Posted: Wed May 21, 2014 9:33 am
by EViews Glenn

Code: Select all

vector(120) sevec