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

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
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:

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

On 5/7/06, Guojun Zhu <shmilylemon@yahoo.com> 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.
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help