Re: [R] restore NAs in residuals

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Mon, 3 Dec 2007 16:27:49 +0000 (GMT)

You need to use na.action=na.exclude, _and_ to use the proper extractor function residuals() rather than pick up a component of the fitted object by partial matching.

See ?residuals.lm and ?naresid

On Mon, 3 Dec 2007, rem la wrote:

> Dear All,
>
> I have two vectors:
>
> tt = c(6.87, 7.43, 6.4, 4.5, 5.5, 5.87, NA, NA, NA, 7.7)
> year = 1966:1975
>
> Residuals
>
> lm(tt~year)$res
>
> do not contain NAs for the three years of missing temperature tt. Is there a
> simple way to get these NAs back into the residual's vector?
>
> Thank you,
> Sorama

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 03 Dec 2007 - 16:30:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 03 Dec 2007 - 17:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.