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@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
p...@owejessen.de
http://privat.owejessen.de
______________________________________________
R-help@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.