predict.asp: Semiparametric regression prediction.

View source: R/predict.asp.r

predict.aspR Documentation

Semiparametric regression prediction.

Description

Takes a fitted asp object produced by asp2 and obtains predictions at new data values.

Usage

## S3 method for class 'asp'
predict(object,newdata,se,...)

Arguments

object

a fitted asp object as produced by asp2(). Does not work with basis="os".

newdata

a data frame containing the values of the predictors at which predictions are required. The columns should have the same name as the predictors. Further, minima and maxima should currently coincide with those of the predictors.

se

when this is TRUE standard error estimates are returned for each prediction. The default is FALSE.

...

other arguments.

Details

Takes a fitted asp object produced by asp2() and obtains predictions at new data values as specified by the ‘newdata’ argument. If ‘se=TRUE’ then standard error estimates are also obtained.

Value

If se=FALSE then a vector of predictions at ‘newdata’ is returned. If se=TRUE then a list with components named ‘fit’ and ‘se’ is returned. The ‘fit’ component contains the predictions. The ‘se’ component contains standard error estimates.

Author(s)

Manuel Wiesenfarth, based on implementation of M.P. Wand (package SemiPar).

See Also

plot.asp, summary.asp

Examples

data(fossil,package="SemiPar")
attach(fossil)
fit <- asp2(strontium.ratio~f(age, basis="tps"))
newdata.age <- data.frame(age=c(90,100,110,120,130))
preds <-  predict(fit,newdata=newdata.age,se=TRUE)
print(preds)

# Use predict to avoid centering of smooths in case of scatterplot 
# smoothing
  fit <- asp2(strontium.ratio~f(age,basis="tps"))
  newdata.age <-data.frame(age=seq(90,130,length.out=50) )
  preds <- predict(fit,newdata=newdata.age,se=TRUE)
  plot(age,strontium.ratio)
  lines(newdata.age$age,preds$fit,col="red")
  lines(unlist(newdata.age),preds$fit+2*preds$se,col="blue")
  lines(unlist(newdata.age),preds$fit-2*preds$se,col="green")

AdaptFitOS documentation built on July 21, 2022, 5:10 p.m.