views:

237

answers:

2

Hi

I've fitted a VECM model in R, and converted in to a VAR representation. I would like to use this model to predict the future value of a response variable based on different scenarios for the explanatory variables.

Here is the code for the model:

library(urca)
library(vars)

input <-read.csv("data.csv")
ts <- ts(input[16:52,],c(2000,1),frequency=4)
dat1 <- cbind(ts[,"dx"], ts[,"u"], ts[,"cci"],ts[,"bci"],ts[,"cpi"],ts[,"gdp"])

args('ca.jo')
vecm <- ca.jo(dat1, type = 'trace', K = 2, season = NULL,spec="longrun",dumvar=NULL)
vecm.var <- vec2var(vecm,r=2)

Now what I would like do is to predict "dx" into the future by varying the others. I am not sure if something like "predict dx if u=30,cpi=15,bci=50,gdp=..." in the next period would work. So what I have in mind is something along the lines of: increase "u" by 15% in the next period (which would obviously impact on all the other variables as well, including "dx") and predict the impact into the future.

Also, I am not sure if the "vec2var" step is necessary, so please ignore it if you think it is redundant.

Thanks
Karl

+1  A: 

Here you go - ??forecast gave vars::predict, Predict method for objects of class varest and vec2var as an answer, which looks precisely as you want it. Increasing u looks like impulse response analysis, so look it up!

Alex
+1  A: 

This subject is covered very nicely in Chapters 4 and 8 of Bernhard Pfaff's book, "Analysis of Integrated and Cointegrated Time Series with R", for which the vars and urca packages were written.

The vec2var step is necessary if you want to use the predict functionality that's available.

A more complete answer was provided on the R-Sig-Finance list. See also this related thread.

Shane
I am actually using the book that you refer to, but it doesn't quite spell out how I could do what I am trying to do, and neither do the answers above. The answer to my question on R-Sig-Finance is close, but I can't use it because it extracts the lm from an object "varest", whereas I don't see how that van be done with a "vec2var" object.
Karl