BSanders
2011-Feb-01 06:25 UTC
[R] How can I index multiple linear models? (Without getting a warning.)
My code looks like this: lin = NA for(i in 1:15){ lin[i] = lm(reservesub[,3]~ reservesub[,i+3]) } For which I'm given 15 warning messages which say : "1: In lin[i] = lm(reservesub[, 3] ~ reservesub[, i + 3]) : number of items to replace is not a multiple of replacement length" I'm am able to generate the 15 different models and get the coefficients. I am able to access each coefficient, for example , the slope of the third model can be called using lin[[3]][2], which is helpful, but none of the other objects that go along with the linear model, like residuals, are accessible (for me.) I feel like I'm missing something kind of fundamental here, but I can't put my finger on it. Thanks in advance. Barry Sanders. -- View this message in context: http://r.789695.n4.nabble.com/How-can-I-index-multiple-linear-models-Without-getting-a-warning-tp3250535p3250535.html Sent from the R help mailing list archive at Nabble.com.
Dieter Menne
2011-Feb-01 07:19 UTC
[R] How can I index multiple linear models? (Without getting a warning.)
BSanders wrote:> > > ..... > lin[i] = lm(reservesub[,3]~ reservesub[,i+3]) > > For which I'm given 15 warning messages which say : > > "1: In lin[i] = lm(reservesub[, 3] ~ reservesub[, i + 3]) : > number of items to replace is not a multiple of replacement length" >lin = list() for(i in 1:15){ b = rnorm(10) q = rnorm(10) #lin[i] = lm(b~q) #warnings lin[[i]] = lm(b~q) #warnings } Dieter -- View this message in context: http://r.789695.n4.nabble.com/How-can-I-index-multiple-linear-models-Without-getting-a-warning-tp3250535p3250594.html Sent from the R help mailing list archive at Nabble.com.
Seemingly Similar Threads
- Newb Prediction Question using stepAIC and predict(), is R wrong?
- ANOVA between linear models.
- Estimate of variance and prediction for multiple linear regression
- Variance of the prediction in the linear regression model (Theory and programming)
- combining zoo series with an overlapping index?