[R] weird question about lm() and data.frame

From: Guojun Zhu <shmilylemon_at_yahoo.com>
Date: Fri 05 May 2006 - 15:17:37 EST


I am still battling with my project :(

I have a line like this

lm(month.model$next.ret~.,month.model,na.action=na.omit)

month.model is a data frame with lots of columns. One of them is "Oth", a dummy variable. I checked month.model, there are two rows with number 1 and others are either 0 or NA. the two rows with Oth==1 have no NA. I have totally about 900 rows. But after the regression, the Oth's coefficient is NA. I do not understand.

Another issue is also about NA. I offen use something like "model[model$Oth==1,]", but it will not only gives rows with oth==1, but also gives some rows with all item as NA. I then changed this into " month.model[(month.model$Oth==1)&(!is.na(month.model$next.ret)),]" and it gives the same result. Finally I change it into
"
month.model[(month.model$Oth==1)&(!is.na(month.model$Oth)),]"
and it works. next.ret is a column for sure. Can anyone explain this to me?



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri May 05 15:34:17 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 05 May 2006 - 18:10:01 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.