mgcv (version 0.1-1)

predict.gam: Prediction from fitted GAM model

Description

Takes a fitted gam object prodced by gam() produces predictions given a new set of vaules for the model covariates. All predictions are on the scale of the linear predictor.

Usage

predict.gam(object,newdata,type,se.fit)

Arguments

object
a fitted gam object as produced by gam().
newdata
A data frame containing the values of the model covariates at which predictions are required. This must be provided.
type
When this has the value "link" (default) the linear predictor (possibly with associated standard errors) is returned. When type="terms" each component of the linear predictor is returned seperately (possibly with standard errors
se.fit
when this is TRUE (not default) standard error estimates are returned for each prediction.

Value

  • If se.fit is TRUE then a 2 item list is returned with items (both arrays) fit and se.fit containing predictions and associated standard error estimates, otherwise and array of predictions is returned. The dimensions of the returned arrys depends on whether type is "terms" or not: if it is then the array is 2 dimensional with each term in the linear predictor separate, otherwise the array is 1 dimensional and contains the linear predictor itself (or s.e.s).

WARNING

Note that the behaviour of this function is not identical to predict.gam() in Splus.

References

Gu and Wahba (1991) Minimizing GCV/GML scores with multiple smoothing parameters via the Newton method. SIAM J. Sci. Statist. Comput. 12:383-398

Wood (2000) Modelling and Smoothing Parameter Estimation with Multiple Quadratic Penalties. JRSSB 62(2)

http://www.ruwpa.st-and.ac.uk/simon.html

See Also

gam plot.gam

Examples

Run this code
library(mgcv)
n<-200
sig2<-4
x0 <- runif(n, 0, 1)
x1 <- runif(n, 0, 1)
x2 <- runif(n, 0, 1)
x3 <- runif(n, 0, 1)
pi <- asin(1) * 2
y <- 2 * sin(pi * x0)
y <- y + exp(2 * x1) - 3.75887
y <- y + 0.2 * x2^11 * (10 * (1 - x2))^6 + 10 * (10 * x2)^3 * (1 - x2)^10 - 1.396
e <- rnorm(n, 0, sqrt(abs(sig2)))
y <- y + e
b<-gam(y~s(x0)+s(x1)+s(x2)+s(x3))
newd<-data.frame(x0=(0:30)/30,x1=(0:30)/30,x2=(0:30)/30,x3=(0:30)/30)
pred<-predict.gam(b,newd)

Run the code above in your browser using DataLab