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 <[EMAIL PROTECTED]> 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.