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
Storing residual standard errors in a recursive regression
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
ylijohtaja
- Posts: 10
- Joined: Mon Sep 06, 2010 9:06 am
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13584
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Storing residual standard errors in a recursive regressi
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
-
ylijohtaja
- Posts: 10
- Joined: Mon Sep 06, 2010 9:06 am
Re: Storing residual standard errors in a recursive regressi
Many thanks Gareth,
There is one remaining problem: the 'sevec' vector contains only nulls except for the last period.
There is one remaining problem: the 'sevec' vector contains only nulls except for the last period.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13584
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Storing residual standard errors in a recursive regressi
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
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
'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
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Storing residual standard errors in a recursive regressi
Note that your equation doesn't have an intercept.
Have you looked in SEVEC after you ran the program?
Have you looked in SEVEC after you ran the program?
Re: Storing residual standard errors in a recursive regressi
My program is not recognizing sevec, sorry I didn't define it. But not sure how to define it.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Storing residual standard errors in a recursive regressi
Code: Select all
vector(120) sevecWho is online
Users browsing this forum: No registered users and 2 guests
