Hi Jim,
Thanks very much for your reply and suggestions. Although the statement
Preg[,k]<-coef(lm(tt~sel_col)) is applying lm() between the same vectors,
the contents of one of the vectors (sel_col) should be changing with each
cycle through the outer loop. My mistake is that I didn't specify
inf
Actually now that I read it closer, I see what your problem is. what
did you think the statement:
Preg[,k]<-coef(lm(tt~sel_col))
was going to do? Preg is a 200x100 matrix and you are only storing
two values (the coefficients) so they will be repeated 100 times in
the column. So there is nothin
Exactly what problem are you having? There is nothing wrong with
nested for loops, so what is leading you to believe you have a
problem? I ran your program and it seems to terminate. Most of the
time seems to have been spent in the following statement:
if(!all(is.na(sel_col)))
Hi,
I guess my question is really more about the nested for loop construct and
whether it is doing what I intend it to do in my code in the previous post.
I would be grateful if anyone who has used nested loops could let me know if
I am doing something wrong.
Thanks,
rcoder
rcoder wrote:
>
Hi everyone,
I'm experiencing difficulty getting the results I want when I use a nested
for loop. I have a data set to which I perform some calculations, and then
try to apply a regression over a rolling window. The code runs, but the
regression results I am getting (intercept and slope) are simp
5 matches
Mail list logo