Hi
I have very large dependent nested for loops that are quite expensive
computationally. It takes weeks and does not end to give me results. Could
anyone please guide how could I use apply function or any other suggestion
for such big and dependent loops in R? A sample code is as follows.
w = NULL
for(j in 1:1000)
{
x = rnorm(2000)
z = x[1]
for(i in 2:2000)
{
z = x[i]+5*z[i-1]
if(z>4 | z<1) {
w[j]=i
break
} else {
w[j] = 0
}
}
}
Thank you
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.