I want to do a polynomial regression for polynomials from 1 to 10:
library(ISLR)
attach(Auto)
myvec <- vector(length=10)
for (i in 1:length(myvec)){
myvec[i]<-lm(mpg~poly(acceleration, i, raw=TRUE))
}
But
summary(myvec[3])
is different from:
summary(var1 <- lm(mpg~poly(acceleration, 3, raw=TRUE)))
How can I put output of functions into vectors with their original output type?