Re: [R] 'Fitting' a model at predefined points

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 26 Jan 2007 - 06:47:04 GMT

You called your variables V1 and V2. You need to supply new values of V1 and V2, not x and y.

On Thu, 25 Jan 2007, akintayo holder wrote:

> Hi,
> I have a linear model ("mod1 <- lm(V3~V1+V2) and I would like to get the
> model's prediction at values of V1 and V2 not included in the original
> sample.
>
> samp <- read.table("data.dat",nrows=100)
> attach(samp)
> out.poly <- lm(V3 ~ V1 + V2)
>
> If I try to use out.poly to predict values for the function I run into
> problems. It seems that it isn't possible to use a new data frame for the
> predict() or fitted() functions.
>
> predict(out.poly, data.frame(x=V1, y=V2)) uses the original data
> predict(out.poly, data.frame(x=V1, y=V2), newdata=gene.dat)
> - uses the original data also, complaining of the decrease in rows.
>
> If any one could point me in the correct direction, it would be appreciated.
>
> Thanks
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley@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@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
and provide commented, minimal, self-contained, reproducible code.
Received on Fri Jan 26 17:50:41 2007

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 Fri 26 Jan 2007 - 07:30:29 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.