[R] VAR forecasts and out-of-sample prediction

manta mantino84 at libero.it
Fri Nov 27 11:46:05 CET 2009


Dear users,
I am struggling with this issue. I want to estimate a VAR(1) for three
variables, say beta1 beta2 beta3, using monthly observations from January
1984 to September 2009. In-sample period January 1984 to December 2003,
out-of-sample January 2004 to September 2009. This is what I have done at
the moment

betas<-read.table("C:\\Users\\Manta\\Desktop\\betas.txt",header=T,dec=",")
BETA<-ts(betas,start=(1984),frequency=12)
BETAS<-TSdata(output=BETA)
VAR1<-estVARXls(window(BETAS,end=c(2003,12)),max.lag=1)
pr<-forecast(VAR1,horizon=1)
pr3<-forecast(VAR1,horizon=3)
pr12<-forecast(VAR1,horizon=12)

and the model is estimated correctly (same estimates as found using other
softwares)
Then the tricky part: I want to estimate the betas for January 2004, March
2004 and January 2005 (that is, 1-3-12 months horizon). BUT, when estimating
March 2004, I just want March 2004, and not also again January 2004 and
February 2004. Same thing for January 2005. I tried to use the function
horizonForecasts but it seems not working properly. Then, I want to compare
the forecasts with the actual betas in order to get RMSE and MAE. So I tried
the following:

betas[241,]-pr$forecast
error
BETA[241,]-pr$forecast
non-numeric argument to binary operator
BETAS[241,]-pr$forecast
incorrect number of dimensions

So, I do not know how to solve this. This computation then needs to be put
in a loop, with expanding (or rolling, that's not a big issue), so then I
will compare betas forecasts for February 2004 (April 2004 and February
2005) with the actual data and so on.

Thanks in advance!

-- 
View this message in context: http://old.nabble.com/VAR-forecasts-and-out-of-sample-prediction-tp26540692p26540692.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list