Hi all,
I am running R version 2.4.0 on Windows XP. I am new and have the following
question:
I have a dataset of columns named x1, x2, x3...xn. I would like to write a
linear regression using lm that looks like this:
lm(y~x1+x2+x3+...+xn)
If I try to use the following code, I only get the model for y~x1+xn:
n<-ncol(dataset)
model<-lm(y~x1)
for(i in 1:n) {
model.new<-update(model, .~.+dataset[,i])
}
The purpose of this is so I can use stepAIC with model.new as the upper scope
and model as the lower.
I know there must be a simple way to do this, but I am not yet familiar with
much syntax. Any help appreciated!
--
Brooke LaFlamme
Cornell University
______________________________________________
[email protected] 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.