[R] How to perform an ols estimation with lm ignoring NA values

David Winsemius dwinsemius at comcast.net
Thu Oct 22 14:30:23 CEST 2009


On Oct 22, 2009, at 6:56 AM, Francesca Pancotto wrote:

>
> Dear R community,
> probably my question is obvious but I did not find any solution yet by
> browsind the mailing list results.
> I need to perform a simple ols regression in a dataset with cross  
> section
> data, where no temporal dimension is inserted. In this data set  
> there are
> missing values. I would like the software to perform the ols  
> regression
> but to just ignore these data and consider the rest.
>
> I tried to use the function na.action=na.omit in
>
> lm( y~x, na.action=na.omit)
> but it seems to exert no effect on the function.

You would not expect to see a change in behavior since that is the  
default na.action for the lm function:

?lm

Some details about x and y would help in understanding why you think  
the output is not what should be expected. If you are not going to  
provide an example dataset with dput(x) and dput(y) then at the very  
least provide summary(x) and summary(y).


-- 

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list