Hi everyone, I am writing a code for cointegration between n (n=6 initially) pairs.
I have done the whole thing for 2 variables. There is a function coint(x1,x2) that takes 2 inputs x1 and x2 and does the following: coint<-function (x1,x2) { adfdata(x1) adfdata(x2) engle<-lm(x1~x2) residual<-resid(engle) adfresd(residual, k=1) par(mfrow=c(2,1)) ts.plot(x1) ts.plot(x2) ts.plot(residual) } Where X1,x2,..,x6 are time series of length 250 or more Where adfdata() is a function that calculates the adf test for x1 and x2. There are 6 variables in total (x1,x2,...,x6) and I want to calculate this function coint for the permutation of these variables. That is coint(x1,x2); coint(x1,x3); coint(x1,x4);...coint(x6,x5) (without repetition because x1,x1 are cointegrated already) I thought about creating an array with the combinations Xi,Xj and apply the function to each combination in the array but I could not get it to work... I would really appreciate if someone could help me on this! Thank you, Kind regards, Thiago ______________________________________________ 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.