I’m using the vars package and want to predict some values from the calculated models:
# Get the model
x1 <- rnorm(15)
y1 <- x1 + rnorm(15)
trainFrame=data.frame(x1,y1);
model=VAR(trainFrame, p=3);
pr1=predict(model, trainFrame);
# Forecast values with new data
x2 <- rnorm(15)
y2 <- x2 + rnorm(15)
newFrame=data.frame(x2,y2);
pr2=predict(model, newFrame);
Comparing the two prediction vectors pr1 and pr2 shows that they are the same.
How can I get the actual forecast values and not again the forecasts from the training data?
Here you call the predict method for objects with class attribute
varest.n.ahead forecasts are computed recursively for the estimated VAR.
No need to give the training Frame to predict.