optspan {MapGAM} | R Documentation |
Determine the Optimal Span Size for modgam
Description
Determines the optimal span size for modgam
, a spatial generalized additive model (GAM) with a two-dimensional LOESS smooth for location, by minimizing the AIC.
Usage
optspan(formula, data, offset,spans = seq(0.05, 0.95, by = 0.05), m ="adjusted",
family = binomial(), verbose =TRUE, degree = 1, ...)
Arguments
formula |
a formula expression for the model, with the response on the left of a ~ oprator, and the predictors on the right. If fitting a Cox additive model, the response must be a survival object as returned by the Surv function. A built-in nonparametric smoothing term is indicated by |
data |
a data frame containing the variables in the model. |
offset |
the name in data that will be used as offset in the model. It will be ignored if offset is specified in |
spans |
a vector of candidate span sizes that the optimal span is chosen from. |
m |
the model type. Options are "crude" or "adjusted" (default). If "crude", only the spatial smooth term for location is included in the model. If "adjusted", all covariates in the data set (columns >= 4) are included in the model. |
family |
a family function or the result of a call to a family function. (See |
verbose |
a logical argument; if TRUE shows the AIC for each candidate span size. |
degree |
a smoothing parameter used in |
... |
any additional arguments to pass to the gam function. |
Value
The optimal span size, determined by minimizing the AIC
Note
This function does not return model predictions–only the optimal span size. To obtain model predictions use the modgam function.
Author(s)
Lu Bai, Scott Bartell, Robin Bliss, and Veronica Vieira
Send bug reports to sbartell@uci.edu.
See Also
Examples
data(MAdata)
optspan(data=MAdata, m="crude")
data(CAdata)
optspan(Surv(time,event)~AGE+factor(INS)+lo(X,Y), data=CAdata,
spans=c(0.1,0.2,0.3),family="survival")