[R] model selection using ANOVA
Stephan Kolassa
Stephan.Kolassa at gmx.de
Tue Mar 31 21:52:32 CEST 2009
Hi Alina,
your approach sounds problematic - you can always get a smaller RSS if
you add terms to your model, so your approach will always go for larger
models, and you will end up overfitting. Consider information criteria,
e.g., AIC or BIC, which "penalize" larger models. References for AIC are
Burnham & Anderson; other people prefer BIC.
Then you can do something like
models <- list()
AICs <- rep(NA, n)
models[[1]] <- lm(...); AICs[1] <- AIC(model[[1]])
...
models[[n]] <- lm(...); AICs[n] <- AIC(model[[n]])
which.min(AICs)
depending on your specific needs.
HTH,
Stephan
Alina Sheyman schrieb:
> I've created a number of models using lm and now want to pick one with the
> smallest standard error or the smallest RSS,
> I can get a list of RSS using anova function, but is the any way I can then
> select one with the smallest RSS from the list?
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list