Dear R Contributors I am asking for some suggestions on how to organize output of a series of regressions and tests in an intelligent way. I estimate a series of Var models with increasing numbers of lags and the perform a Wald test to control Granger Causality: I would like to learn a way to do it that allows me not to produce copy and past code.
This is what I do: Estimate var models with increasing number of lags, V.6<-VAR(cbind(index1,ma_fin),p=6,type="both") V.7<-VAR(cbind(index1,ma_fin),p=7,type="both") V.8<-VAR(cbind(index1,ma_fin),p=8,type="both") V.9<-VAR(cbind(index1,ma_fin),p=9,type="both") then observe results and control significance of regressors: summary(V.6) summary(V.7) summary(V.8) summary(V.9) summary(V.10) then use the estimated var to perform the test: wald_fin7.1<-wald.test(b=coef(V.7$varresult[[1]]), Sigma=vcov(V.7$varresult[[1]]), Terms=c(2,4,6,8,10,12)) wald_fin8.1<-wald.test(b=coef(V.8$varresult[[1]]), Sigma=vcov(V.8$varresult[[1]]), Terms=c(2,4,6,8,10,12,14)) wald_fin9.1<-wald.test(b=coef(V.9$varresult[[1]]), Sigma=vcov(V.9$varresult[[1]]), Terms=c(2,4,6,8,10,12,14,16)) wald_fin10.1<-wald.test(b=coef(V.10$varresult[[1]]), Sigma=vcov(V.10$varresult[[1]]), Terms=c(2,4,6,8,10,12,14,16,18)) #then collect tests result in a table: wald_fin<-rbind(wald_fin7.1$result$chi2, wald_fin12.1$result$chi2,wald_fin21.1$result$chi2, wald_fin7.2$result$chi2, wald_fin12.2$result$chi2,wald_fin21.2$result$chi2) My idea is that it is possible to create all this variable with a loop across the objects names but it is a level of coding much higher than my personal knowledge and ability. I hope anyone can help Thanks in advance -- Francesca ---------------------------------- Francesca Pancotto, PhD Università di Modena e Reggio Emilia Viale A. Allegri, 9 40121 Reggio Emilia Office: +39 0522 523264 Web: https://sites.google.com/site/francescapancotto/ ---------------------------------- [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.