資産の価格を予測するためにVARモデルを構築していますが、私の方法が統計的に適切かどうか、含めたテストが関連するかどうか、入力変数に基づいて信頼できる予測を確保するためにさらに必要な場合は知りたいと思います。
以下は、グレンジャーの因果関係を確認し、選択したVARモデルを予測する現在のプロセスです。
require("forecast")
require("vars")
#Read Data
da=read.table("VARdata.txt", header=T)
dac <- c(2,3) # Select variables
x=da[,dac]
plot.ts(x)
summary(x)
#Run Augmented Dickey-Fuller tests to determine stationarity and differences to achieve stationarity.
ndiffs(x[, "VAR1"], alpha = 0.05, test = c("adf"))
ndiffs(x[, "VAR2"], alpha = 0.05, test = c("adf"))
#Difference to achieve stationarity
d.x1 = diff(x[, "VAR1"], differences = 2)
d.x2 = diff(x[, "VAR2"], differences = 2)
dx = cbind(d.x1, d.x2)
plot.ts(dx)
#Lag optimisation
VARselect(dx, lag.max = 10, type = "both")
#Vector autoregression with lags set according to results of lag optimisation.
var = VAR(dx, p=2)
#Test for serial autocorrelation using the Portmanteau test
#Rerun var model with other suggested lags if H0 can be rejected at 0.05
serial.test(var, lags.pt = 10, type = "PT.asymptotic")
#ARCH test (Autoregressive conditional heteroscedasdicity)
arch.test(var, lags.multi = 10)
summary(var)
#Granger Causality test
#Does x1 granger cause x2?
grangertest(d.x2 ~ d.x1, order = 2)
#Does x2 granger cause x1?
grangertest(d.x1 ~ d.x2, order = 2)
#Forecasting
prd <- predict(var, n.ahead = 10, ci = 0.95, dumvar = NULL)
print(prd)
plot(prd, "single")
この方法は適切ですか?