Scotty Nelson <poorboy44 <at> hotmail.com> writes:

> I'm trying to build a for loop, where I estimate a series of models with
> different sets of (time series) data.
> However my for loop doesn't recognize the "i" 
> 
> ##################### code################
> window.1=anomalies.CAK[(positions(anomalies.CAK)>=timeDate("1/1/1971") &
> positions(anomalies.CAK)<=timeDate("6/30/1991") )]
> ....
> window.14=anomalies.CAK[(positions(anomalies.CAK)>=timeDate("1/1/1984") &
> positions(anomalies.CAK)<=timeDate("6/30/2004") ),]
> 
> for (i in 1:14){
>       ar1mods[1] = lm ( formula = window.i~ ar(1) )
> }

The easiest would be to put the selection of the cases into the loop, and always
use the same formula. You could also use formula=paste("window.",i,sep=""). That
approach will work for the simple example, but you might run into eval-problems
later (though probably not for lm). 

# B.D. Ripley val(subst) workaround
#http://finzi.psych.upenn.edu/R/Rhelp02a/archive/16599.html


Dieter

______________________________________________
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.

Reply via email to