[R] A suggestion for predict function(s)
Liaw, Andy
andy_liaw at merck.com
Thu Apr 14 02:45:23 CEST 2005
> From: Ross Darnell
>
> Liaw, Andy wrote:
> > I must respectfully disagree. Why carry extra copies of
> data arround? This
> > is probably OK for small to medium sized data, but
> definitely not for large
> > data.
> >
> > Besides, in your example, it may do different things
> depending on whether
> > newdata is supplied: model.matrix is not necessarily the
> same as the
> > original data frame. You need a bit more work to get the
> right model.matrix
> > that correspond to the newdata. It's not clear to me
> whether you want to
> > return model matrix or model frame, but in either case it's
> not sufficient
> > to just use `newdata'.
> >
> > Andy
> >
> >
> >>From: Ross Darnell
> >>
> >>Maybe a useful addition to the predict functions would be to
> >>return the
> >>values of the predictor variables. It just (unless there are
> >>problems)
> >>requires an extra line. I have inserted an example below.
> >>
> >>"predict.glm" <-
> >> function (object, newdata = NULL, type = c("link", "response",
[snip]
> >>
> >>Ross Darnell
> >>--
> >>School of Health and Rehabilitation Sciences
> >>University of Queensland, Brisbane QLD 4072 AUSTRALIA
> >>Email: <r.darnell at uq.edu.au>
> >>Phone: +61 7 3365 6087 Fax: +61 7 3365 4754 Room:822,
> >>Therapies Bldg.
> >>http://www.shrs.uq.edu.au/shrs/school_staff/ross_darnell.html
>
> A good point but what is the value of storing a large set of
> predicted
> values when the values of the explanatory variables are lost
> (predicted
> values of what?). I thought the purpose of objects was that they were
> self explanatory (pardon the pun).
>
> Maybe we could make it optional.
If what you are looking for is a way to track the observations, I'd suggest
simply adding rownames of newdata as names of the predicted values. Storing
names is much cheaper than the entire data frame of predictors. (And in R,
data frames _must_ have unique row names.)
Cheers,
Andy
> Ross Darnell
> --
> Email: <r.darnell at uq.edu.au>
>
>
>
More information about the R-help
mailing list