library(doParallel)
library(pforeach)
cl <- makePSOCKcluster(detectCores())
registerDoParallel(cl)
ptm <- proc.time()
y=rnorm(1000,1,3)
windowSize=300
######### Below function is best for rolling window analysis and parallel
processing #############
#z1 <- foreach(i=seq(1, (length(y)-windowSize+1), 1), .combine=rbind, .packages="vrtest") %dopar%
z1 <- foreach(i=seq(1, (length(y)-windowSize+1), 1), .packages="vrtest") %dopar%
{
Y <- i:(i+windowSize-1)
VR.pval=AutoBoot.test(as.matrix(Y), nboot=5,wild="Normal")
VR.boot.pval[i]=VR.pval$pval
}
stopCluster(cl)
print(proc.time() - ptm)
print(VR.boot.pval)
有人可以通过上述代码为我提供帮助吗?
当我运行它们时,我得到NA为输出。