[R] Fit values for NA's in linear regression

Liaw, Andy andy_liaw at merck.com
Fri Jun 17 19:02:26 CEST 2005


I posted a bad example.  The question would only make sense if NAs are all
in the response.  Here's try #2:

I believe you can not get fitted values for cases where y is missing
directly from the model object.  You can, however, use predict(lm.object,
newdata=mydata[!complete.cases(mydata)]) to get the predictions for those
with missing y.

Andy

> From: Luca Wacker
> 
> Hi,
> 
> To obtain estimates for some missing values in my data I fitted a 
> linear regression and then used the command fitted(model) to get the 
> fitted values from the model, but R doesn't return any values for the 
> NA's. I can calculate the fitted values from the estimates obtained 
> from the summary of model, but that's not very handy. Is 
> there a way to 
> include the missing values in the analysis and get fitted values for 
> the NA's? I tried to use with the function na.action, but that didn't 
> work.
> 
> 
> thanks
> 
> Luca
> 
> ______________________________________________
> 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