[R] problem with predict()

Liaw, Andy andy_liaw at merck.com
Fri Jun 28 20:58:51 CEST 2002


> From: Thomas Lumley [mailto:tlumley at u.washington.edu]
> Sent: Friday, June 28, 2002 2:17 PM
> 
> On Fri, 28 Jun 2002, Liaw, Andy wrote:
> 
> > As Prof. Ripley guessed, the X data is less than full rank. 
>  I'm surprised
> > that lm didn't issue warning.  summary() does say:
> >
> > Coefficients: (17 not defined because of singularities)
> >
> > I'm also surprised that with such a fitted object, 
> predict(model) works, but
> > not predict(model, data), where data is the original data 
> used to fit the
> > model.  This does not seem to be user-friendly...
> 
> There's something to be said for more warnings, but I think 
> what predict
> does is reasonable.
> 
> If you have fitted a model to rank-deficient data then you 
> can predict on
> data with the same rank deficiency.  In particular, you can 
> predict on the
> original data, as predict(model) does.  However, you can't 
> predict on new
> data unless they have the same rank-deficiencies, and since this is
> something that can't be tested stably it make sense to refuse 
> to predict
> on new data.

But in that case shouldn't there be a more informative error message?  If
that's the desired behavior, I'd check for rank deficiency in the fitted
object, and issue an error if newdata is supplied, rather than waiting for
something to break downstream.

Just my $0.02...

Andy

> 
> 	-thomas
> >

------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message.  If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it.

==============================================================================

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list