Dear all,

I am trying an automatic model selection for a multiple linear regression using function lm and update. But, I meet a problem when using update. The problem is the function update can not update when variables as a vector(for example,x is a matrix with 100 regression variables). The code is as below:

> model<-lm(y~x1,singular.ok=T,na.action=na.omit)
> for(i in 1:100){
> model<-update(model,.~.+x[,i],singular.ok=T,na.action=na.omit)}

If the above code is represented as below, I can get the correct result. However, I must use the loops.

model<-lm(y~x1,singular.ok=T,na.action=na.omit)
model<-update(model,.~.+x[,1],singular.ok=T,na.action=na.omit)
model<-update(model,.~.+x[,2],singular.ok=T,na.action=na.omit)
       ......
model<-update(model,.~.+x[,100],singular.ok=T,na.action=na.omit)
Can anyone help?

Cheers,

Lun

______________________________________________
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to