Re: [R] How to use lm.predict to obtain fitted values?

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sun 21 May 2006 - 04:54:02 EST

On 5/20/06, Larry Howe <larry.howe@comjet.com> wrote:
> On Friday 19 May 2006 17:35, Peter Ehlers wrote:
> > Larry Howe wrote:
> > > I have had a similar issue recently, and looking at the archives of this
> > > list, I see other cases of it as well. It took me a while to figure out
> > > that the variable name in the data frame must be identical to the
> > > variable name in the model. I don't see this mentioned in the
> > > documentation of predict.lm, and R issues no warning in this case.
> > >
> > > How would I go about officially requesting that this is mentioned, either
> > > in the documentation, or as a warning?
> > >
> > > Sincerely,
> > > Larry Howe
> >
> > Here's what I would do before officially requesting anything: read
> > 'An Introduction to R', especially section 11.3:
> >
> > predict(object, newdata=data.frame)
> > The data frame supplied must have variables specified with the same
> > labels as the original.
> >
> > Seems pretty explicit.
> >
> > As well, the predict.lm help page has, under Arguments:
> >
> > newdata An optional data frame in which to look for variables with
> > which to predict.
> >
> > That, too, seems unambiguous; i.e. you can't predict with values of z
> > when z is not in your formula.
> >
> > Peter Ehlers

>

> My fault, I should have read ALL the manuals before posing my question. I only
> read the 2445 page Reference Manual. I also read Intro to R, but that was
> some time ago.
>

> "An optional data frame in which to look for variables with which to predict."
> means almost nothing to me. Specifically it doesn't translate to me, as an
> engineer and software developer, but not a statistician, that the names have
> to match, and furthermore if they don't match, R fails silently.
>
> Larry Howe

I have had offline conversations not related to this thread by others who were also confused by this so I agree it would be worthwhile to clarify it.



R-help@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 Received on Sun May 21 05:19:56 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 21 May 2006 - 06:10:14 EST.

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