mypredict.gam: Prediction for GAM Fits

View source: R/mypredict.gam.R

mypredict.gamR Documentation

Prediction for GAM Fits

Description

Obtains spatial effects predictions and optionally estimates standard errors and confidence intervals of those predictions from a fitted generalized additive model object.

Usage

mypredict.gam(object, newdata, se.fit = FALSE, type=c("all","spatial"),
              reference = "median", level = 0.05,verbose=FALSE) 

Arguments

object

a fitted gam object.

newdata

a data frame containing the values at which predictions are required. This argument can be missing, in which case predictions are made at the same values used to compute the object. Only two-dimentional predictor need be present by name in newdata.

se.fit

if TRUE, pointwise standard errors and confidence intervals are computed along with the predictions.

type

use type="spatial" to estimate spatial effect, and use type="all"(default) to estimate the effect of all covariates included in the model.

reference

the type of reference for the estimated effect. If reference = "median", the output will be the estimated effect difference (or log ratio) compared to the median effect. If reference = "mean",the output will be the estimated effect difference (or log-ratio) compared to the mean effect.If reference is a data frame indicating a specific geolocation, the output will be the estimated effect difference (or log-ratio) compared to the effect of the geolocation specified by reference.

level

the siginificance level used when se.fit=TRUE.

verbose

a logical value indicating whether to print filling values for newdata. The default is verbose = FALSE.

Value

pred

the estimated effect difference or (log ratio) compare to the effect specified by reference.

se

the standard errors along with the predictions.

conf.low

the lower bounds for pointwise (1-level) confidence intervals.

conf.high

the higher bounds for pointwise (1-level) confidence intervals.

Author(s)

Lu Bai

Send bug reports to sbartell@uci.edu.

References

Hastie TJ, Tibshirani RJ. Generalized Additive Models. (Chapman & Hall/CRC Monographs on Statistics & Applied Probability, Boca Raton, Florida, 1990).

See Also

modgam, predict.gamcox.

Examples


data(MAdata)							
data(MAmap)
gamgrid <- predgrid(MAdata, map=MAmap)

fit <- gam(Case~lo(Xcoord,Ycoord,span=0.2)+Smoking,data=MAdata,family=binomial())
pred1 = mypredict.gam(fit)
colormap(list(fit=pred1$pred,grid=data.frame(X=MAdata$X,Y=MAdata$Y)),map=MAmap)

pred2 = mypredict.gam(fit,gamgrid)
colormap(list(fit=pred2$pred,grid=data.frame(X=gamgrid$X,Y=gamgrid$Y)),map=MAmap)

pred3 = mypredict.gam(fit,gamgrid,se.fit=TRUE)
colormap(list(fit=pred3$pred,conf.low = pred3$conf.low, conf.high = pred3$conf.high, 
          grid=data.frame(X=gamgrid$X,Y=gamgrid$Y)),map=MAmap,contours = "interval")




MapGAM documentation built on July 26, 2023, 5:12 p.m.