Aditya Damani
2010-Aug-23 03:09 UTC
[R] Fitting VAR and doing Johansen's cointegration test in R
Hi, Could someone please tell me the R codes for fitting VAR(p) (Vector Auto Regressive) models and doing the Johansen?s cointegration tests. TIA Aditya
John C Frain
2010-Aug-23 12:52 UTC
[R] Fitting VAR and doing Johansen's cointegration test in R
Look at the econometrics and time series Task wiew on the CRAN web site John On 23 August 2010 04:09, Aditya Damani <adicool4u at gmail.com> wrote:> Hi, > > Could someone please tell me the R codes for fitting VAR(p) (Vector > Auto Regressive) models and doing the Johansen?s cointegration tests. > > TIA > Aditya > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- John C Frain Economics Department Trinity College Dublin Dublin 2 Ireland www.tcd.ie/Economics/staff/frainj/home.html mailto:frainj at tcd.ie mailto:frainj at gmail.com
Owe Jessen
2010-Aug-23 15:12 UTC
[R] Fitting VAR and doing Johansen's cointegration test in R
Am 23.08.2010 05:09, schrieb Aditya Damani:> Hi, > > Could someone please tell me the R codes for fitting VAR(p) (Vector > Auto Regressive) models and doing the Johansen?s cointegration tests. > > TIA > Aditya > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >Just feeling like doing some homework for free... require(vars) require(urca) reps <- 1000 # length of time series A <- matrix(NA,nrow=reps,ncol=3) colnames(A) <- c("a","b","c") A[1,] <- rnorm(3) # starting values for(i in 2:reps){# generate time series A[i,] <- c(0.1+0.2*i+0.7*A[i-1,1]+0.1*A[i-1,2]+0.1*A[i-1,3]+rnorm(1), 0.5+0.1*i+0.6*A[i-1,2]-0.2*A[i-1,1]-0.2*A[i-1,3]+rnorm(1), 0.9+0.2*i+A[i-1,3]+0.1*A[i-1,1]+0.15*A[i-1,2]+rnorm(1) ) } (a.ct <- ur.df(A[,"a"],type="trend")) (b.ct <- ur.df(A[,"b"],type="trend")) (c.ct <- ur.df(A[,"c"],type="trend")) VARselect(A,type="both") var.p1 <- VAR(A,1,type="both") summary(var.p1) jo <- ca.jo(A) summary(jo) -- Owe Jessen Nettelbeckstr. 5 24105 Kiel post at owejessen.de http://privat.owejessen.de