[R] Forecast using VAR model

Dhivya Narayanasamy dhiv.shreya at gmail.com
Sun May 21 07:05:03 CEST 2017


I am building a VAR model to forecast of bivariate timeseries. But it shows
flat forecast.

So I would like to use recursive window forecasting technique using VAR
model. Will it give what i expect (Avoid flat forecast) ? or should i have
to go with other package.

> datax.zoo <- read.zoo(datax)> datax.ts <- ts(datax.zoo)> v1b <- VARselect(datax.ts, lag.max = 10, type = "const")> v1b
$selection
AIC(n)  HQ(n)  SC(n) FPE(n)
     9      7      5      9

$criteria
                  1            2            3            4
5            6            7
AIC(n)     9.686513     9.657172     9.632444     9.625856
9.621148     9.619425     9.615396
HQ(n)      9.688951     9.661234     9.638131     9.633167
9.630085     9.629987     9.627583
SC(n)      9.693514     9.668839     9.648778     9.646856
9.646815     9.649759     9.650397
FPE(n) 16099.014774 15633.507506 15251.665643 15151.510512
15080.352425 15054.392389 14993.864861
                  8            9           10
AIC(n)     9.615430     9.615116     9.615990
HQ(n)      9.629241     9.630552     9.633051
SC(n)      9.655098     9.659451     9.664991
FPE(n) 14994.366572 14989.661383 15002.762011
> var7 = VAR(datax.ts, p=7)> serial.test(var7, lags.pt=10, type = "PT.asymptotic")

    Portmanteau Test (asymptotic)

data:  Residuals of VAR object var7Chi-squared = 22.745, df = 12,
p-value = 0.02997
> grangertest(datax.ts[,1] ~ datax.ts[,2], order = 7)Granger causality test
Model 1: datax.ts[, 1] ~ Lags(datax.ts[, 1], 1:7) + Lags(datax.ts[,
2], 1:7)Model 2: datax.ts[, 1] ~ Lags(datax.ts[, 1], 1:7)
  Res.Df Df      F    Pr(>F)    1   5686                        2
5693 -7 16.105 < 2.2e-16 ***---Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01
‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1> grangertest(datax.ts[,2] ~  datax.ts[,1],
order = 7)Granger causality test
Model 1: datax.ts[, 2] ~ Lags(datax.ts[, 2], 1:7) + Lags(datax.ts[,
1], 1:7)Model 2: datax.ts[, 2] ~ Lags(datax.ts[, 2], 1:7)
  Res.Df Df      F Pr(>F)1   5686                 2   5693 -7 1.5618 0.1418
> g <- forecast(var7, h = 600)> plot(g)


Also the 'P' value  from portmanteau test shows auto correlation is present
is my VAR model. Here is my raw data you can find :
https://drive.google.com/file/d/0B7I0DT-PiG4RenVkdXV3OFJLYVk/view?usp=sharing


Thank you.

Regards
> Dhivya Narayanasamy

	[[alternative HTML version deleted]]



More information about the R-help mailing list