Rolling Regression with a VAR

For questions regarding programming in the EViews programming language.

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

awaidy
Posts: 4
Joined: Thu Jun 27, 2019 11:48 pm

Rolling Regression with a VAR

Postby awaidy » Mon Jul 15, 2019 7:52 am

Hello all,

I am working with a workfile (attached) and I want to do a 4-period ahead forecast with a VAR. The data is quarterly from 1960q1 through 2017q4.

So, this is what I want it to do:
1. Estimate a VAR over 40 observations ((40/4) = 10 years) and then forecast 4 periods ahead.
2. The forecasted 4th-period-ahead value should be stored in a new series e_cpi against the last date of the estimation sample. So, for example, if a VAR was estimated till 1970q4, then the forecasted value should be stored against 1970q4 in e_cpi. That is basically finding the inflationary expectations.


I have written the following code:

Code: Select all

smpl @all

!window_length = 40
!no_rolls = 192 'The times it need to roll. Total observations to be rolled on =232-40=192
!steps_ahead = 4 '4 period year ahead forecast

series e_cpi 'This will store our forecasted values

for !i=0 to (!no_rolls)
'Specifying the VAR on 40 observations
   smpl @first+!i @first+!window_length+!i-1 'You need -1 to push back the last quarter.
'So for first VAR, it will go from 1960q1 to 1970q4.
   var var_!i.ls(noconst) 1 5 d(log_gdp_i1) d(d(cpi_log_i2)) d(reverse_rate_i1)
'I have differenced for stationarity.
'Forecasting over the next four periods
   smpl @first+!window_length+!i @first+!window_length+!i+!steps_ahead-1
'Remember @first+windowlength lands you on 1971q1 for the first iteration.
   var_!i.forecast(e) _!i 
'Storing the value into a separate series
   %date1 = @otod(!window_length+!steps_ahead-1+!i)
   scalar x = @elem(CPI_LOG_I2_!i, %date1)    'This takes the forecasted value from the forecasted series
   e_cpi(39+!i) = x 'Because the forecasted value should be stored against 1965q4
next

show e_cpi


I have tried to add comments where I could. When I did it with annual data, it worked just fine.

1. But with quarterly data, I am getting this error:
Log of non positive number in "VAR VAR_!I.LS(NOCONST) 1
5 D(LOG_GDP_I1) D(D(CPI_LOG_I2)) D(REVERSE_RATE_I1)".
Even though I have already taken the log of the required variables and there is no negative value in any of the series. I am using EViews 10.

2. Is there an easier way to do this? I know this code generates series and clogs the workfile, but I am just interested in e_cpi (inflationary expectations.

Any help would be appreciated. Thank you. I am stuck over this and have no clue.

Best Regards,
Awaid Yasin.
Attachments
wrkf_Eviews.WF1
(20.55 KiB) Downloaded 271 times

awaidy
Posts: 4
Joined: Thu Jun 27, 2019 11:48 pm

Re: Rolling Regression with a VAR

Postby awaidy » Mon Jul 15, 2019 7:57 am

Also, I found basic programs that forecast with an equation. But I was having difficulties adapting them to a VAR. Probably because the coefficient matrix of a VAR would be different?

Please help :)

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

Re: Rolling Regression with a VAR

Postby EViews Gareth » Mon Jul 15, 2019 7:57 am

Try taking out the (e) option on your forecast command.
Follow us on Twitter @IHSEViews

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

Re: Rolling Regression with a VAR

Postby EViews Gareth » Mon Jul 15, 2019 8:01 am

Ah, you just posted the data. From the data - d(reverse_rate_i1) is constant under the sample 1978q2-1988q1, so including 5 lags of a constant will yield singularities.
Follow us on Twitter @IHSEViews

a.rachmasyaputri
Posts: 5
Joined: Sun Nov 29, 2020 8:03 am

Re: Rolling Regression with a VAR

Postby a.rachmasyaputri » Sun Feb 07, 2021 7:37 am

Hai All,

I have data from government bond yield. I try to build spillover index with VAR Variance Decomposition dan spillover plot with rolling-sample analysis. Can you explain how to run VAR Variance Decomposition with rolling regression.

Best Regards,


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 26 guests