[R] can predict ignore rows with insufficient info

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Sep 17 08:29:12 CEST 2003


On Tue, 16 Sep 2003, Peter Whiting wrote:

> On Tue, Sep 16, 2003 at 04:17:59PM -0400, Thomas W Blackwell wrote:
> > Peter  -
> > 
> > Your subsequent email seems just right.  You have to determine
> > ahead of time which rows can be estimated.
> 
> It seems that predict removes rows with insufficient information
> (ie, if I replace "ALBANY" with NA and refactor everything works)
> - I wonder why it doesn't exhibit the same behavior when it
> encounters a new level - just eliminate the row and go on...
> 
> Somewhat related: I had been assuming (incorrectly)
> that length(x) would equal length(const$days) after
> x<-predict(g,const) - this isn't the case if any of the rows of
> const don't contain enough info for the model.  Those rows are
> eliminated - I'd have expected them to just be NAs in the result.

That depends on the setting of option na.action: the factory-fresh default 
is na.omit, which is what you are seeing.  As from R 1.8.0 it will use a 
default of na.pass for predict.lm.

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




More information about the R-help mailing list