[R] Function update problem

lun li lun_li at hotmail.com
Thu Feb 13 10:51:05 CET 2003

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.


Can anyone help?



More information about the R-help mailing list