Hi all, I try to simulate an ADF test rolling on a window.
The thing is that it seems I´m doing well...applying to al AR(1) model with unit root. I see in some econometrical papers that the t-stat maximum and minimum should have negative values on the quantiles 0,01 to 0,03 and in my case only the minimum are negative values. ¿It is posible I´m doing wrong calculus on lm? I m getting mad Ob <- 100 Re <- 50 H2<-matrix(0,Ob,Re) for (j in 1:Re){ for (i in 2:Ob){ H2[i, j] <-1+ 1*H2[i-1, j]+rnorm(1) } } H3<-matrix(0,Ob,Re) for (i in 2:Ob){ for (j in 1:Re){ H3[i,j]<-H2[i,j]-H2[i-1,j] }} a3<-H3[2:nrow(H3),1:ncol(H3)] a2<-H2[1:(nrow(H2)-1),1:ncol(H2)] write.csv(a3,"a3.csv") write.csv(a2,"a2.csv") a3<-read.csv("a3.csv") a2<-read.csv("a2.csv") delta<-round(Ob*(1/3)) fg<-matrix(0,nrow(H3)-delta+1,Re) for (j in 1:Re){ for (i in delta:nrow(H3) ){ z2<-(i-delta+1) z3<-i fg[i-delta+1,j]<-coef(summary(lm(a3[z2:z3,j+1]~(1+a2[z2:z3,j+1]) ) ))[2,"t value"] print(j) } } MaxrollingT<-apply(fg, 1, max) MinrollingT<-apply(fg, 1, min) Diffrolling<-MaxrollingT-MinrollingT Meanrolling<-apply(fg, 1, mean) write.csv(MaxrollingT, file = "MaxrollingT.csv") write.csv(MinrollingT, file = "MinrollingT.csv") write.csv(Diffrolling, file = "DiffrollingT.csv") write.csv(Meanrolling, file = "Meanrolling.csv") print(c(quantile(MaxrollingT,0.01),quantile(MinrollingT,0.01))) print(c(quantile(MaxrollingT,0.015),quantile(MinrollingT,0.015))) print(c(quantile(MaxrollingT,0.02),quantile(MinrollingT,0.02))) print(c(quantile(MaxrollingT,0.025),quantile(MinrollingT,0.025))) [[alternative HTML version deleted]]
______________________________________________ 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.