Re: [R] What will produce NA for lm()?

From: Gabor Grothendieck <>
Date: Sun 07 May 2006 - 17:12:04 EST

If a column is a linear combo of other columns, i.e. the model matrix is not of full column rank, you can get an NA as there is no unique answer, e.g. in the following x2 is a linear combo of x1 and the intercept so the coefficient of x2 is NA:

DF <- data.frame(y = rnorm(5), x1 = 1:5, x2 = 1:5 + 1) lm(y ~., DF)

On 5/7/06, Guojun Zhu <> wrote:
> I still works on the similar questions. I have a data
> frame, say d, with 33+1 colums (20 of them are 0/1
> dummy variables) and about 1000 rows. Now I do the
> linear regression and get a NA for one of the dummy
> variables, say a. I check the data frame, using
> "d[d$a %in% 1,]" and found there are one row with no
> NA at all. And there are 800 0s in d$a. I know if
> there is no 1 in d$a or the no one full non-NA rwo
> with d$a==1, I will get NA for d$a. But I do not
> expect a NA in my case. What is other possibility to
> produce NA d$a? thanks.
> ______________________________________________
> mailing list
> PLEASE do read the posting guide!
> mailing list PLEASE do read the posting guide! Received on Sun May 07 17:15:47 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 Sun 07 May 2006 - 18:10:08 EST.

Mailing list information is available at Please read the posting guide before posting to the list.