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

Gabor Grothendieck ggrothendieck at gmail.com
Sun May 7 09:12:04 CEST 2006

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 <shmilylemon at 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 at 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

More information about the R-help mailing list