[R] Error: invalid type(list) for variable when using lm()

Tianchan Niu niu at isis.georgetown.edu
Tue Nov 16 20:07:34 CET 2010


Dear All,I would like to do multiple regression in R. I used: lm(y~X),
where y is a n by 1 vector, and X is a n by m matrix. I kept getting the error
message:Error in model.frame.default(formula = y ~ X,  :  invalid type (list) for variable 'X'. However, when I used: lm(y~X[,1]+X[,2]+X[,3]+…+X[,m]), it
works well, but this is not the form I prefer, it makes my codes complicated.Please help.Thank you very much,Jane


More information about the R-help mailing list