[R] creating subsets within lm()
Thomas Groen
tagroen at gmail.com
Thu Jul 30 12:04:20 CEST 2009
Dear All,
the lm() function has the possibility to create a subset of the
possible explaining variables that you have. However, in the help
there is no example how to use this subset option. I tried the
following:
model<-lm(dependent.data$MPFD~.,data=explaining.data,subset=c(1,0,0,0,0,0,0,0,1,1,0,0))
MPFD is the dependent variable stored in the data frame
dependent.data, and all 12 explaining variables are stored in the data
frame explaining.data.
However, this yields a model with only an intercept, and the comment
"Coefficients: (12 not defined because of singularities)"
I hope anyone would be able to give me an example how to do this correctly.
Kind regards,
Thomas
More information about the R-help
mailing list