Re: [R] safe prediction from lm

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Thu 28 Sep 2006 - 15:57:05 GMT

See ?SafePrediction for how it works in R.

Also the example here:
http://www.mayin.org/ajayshah/KB/R/html/o9.html

On 9/28/06, Spencer Jones <ssj1364@gmail.com> wrote:
> I am fitting a regression model with a bs term and then making predictions
> based on the model. According to some info on the internet at
> http://www.stat.auckland.ac.nz/~yee/smartpred/DummiesGuide.txt
>
> there are some problems with using predict.lm when you have a model with
> terms such as bs,ns,or poly. However when I used one of the examples they
> said would illustrate the problems I get virtually the same results using
> the standard predict function and "safe prediction" method they propose. Has
> lm been updated so that it can handle terms such as bs,ns, and poly
> automatically? I am using R 2.3.0
>
> this is their example:
>
> n <- 100
> set.seed(86) # For reproducibility of the random numbers
> x <- sort(runif(n))
> y <- sort(runif(n))
> fit <- lm(y ~ bs(x, df=5))
> plot(x, y,col="blue")
> lines(x, fitted(fit), col="black")
> newx <- seq(0, 1, len=n)
> points(newx, predict(fit, data.frame(x=newx)), type="l", col=red, err=-1)
>
>
> thanks,
>
> Spencer
>
> [[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.
>



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 Sep 29 02:48:32 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 Thu 28 Sep 2006 - 17:30:06 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.