[R] NA handling with lm

Adaikalavan Ramasamy ramasamy at cancer.org.uk
Fri Jul 29 12:01:30 CEST 2005


Also have a look at this thread from last week
https://stat.ethz.ch/pipermail/r-help/2005-July/074550.html

Regards, Adai



On Thu, 2005-07-28 at 18:59 +0200, Petr Pikal wrote:
> Hallo
> 
> On 28 Jul 2005 at 18:44, Andreas Cordes wrote:
> 
> > Hi,
> > I have a problem that is hopefully easily solvable, but I dont find
> > the clue in the documentation. I am examining a linear model. One of
> > the variables has NA values. Even though na.action=na.omit, i get NA
> > as results for this variable. Can I use lm in such a case to get
> > estimates? Or do I have to do some form of imputation before doing so?
> > Here is the call and the results, hope you can help. Best regards,
> > Andreas
> > ----------------------------------------------------------------------
> > ----------------------- lm(formula = ESSIK ~ ALTER + as.factor(S2) +
> > as.factor(S15A) +
> >     as.factor(S8) + as.factor(LAND) + as.factor(S18B) +
> >     as.factor(BERUF) + as.factor(KIRCHE) + as.factor(H_EINKOM) +
> >     as.factor(PARTNERS), na.action = na.omit)
> > 
> > Residuals:
> >      Min       1Q   Median       3Q      Max
> > -17.0675  -2.0151   0.4267   2.7644   9.7333
> > 
> > Coefficients: (2 not defined because of singularities)
> 
> Problem is not in NA handling but that some of your coeficients 
> can be represented as linear combination of other coeficients. You 
> have to omit them.
> 
> HTH
> Petr
> 
> 
> >                       Estimate Std. Error t value Pr(>|t|)   
> > (Intercept)          23.755915   1.844110  12.882  < 2e-16 ***
> > [...]
> > as.factor(BERUF)7    -1.236836   0.701323  -1.764 0.077942 . 
> > as.factor(KIRCHE)1   -0.811751   0.237699  -3.415 0.000649 ***
> > as.factor(H_EINKOM)2        NA         NA      NA       NA   
> > as.factor(H_EINKOM)3        NA         NA      NA       NA   
> > as.factor(PARTNERS)1  2.057070   0.342546   6.005 2.23e-09 ***
> > 
> > ______________________________________________
> > 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
> 
> Petr Pikal
> petr.pikal at precheza.cz
> 
> ______________________________________________
> 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