modgam
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.
optspan(formula, data, offset,spans = seq(0.05, 0.95, by = 0.05), m ="adjusted",
family = binomial(), verbose =TRUE, degree = 1, ...)
The optimal span size, determined by minimizing the AIC
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 lo
for loess smooth terms. The two-dimensional predictor (e.g.,geolocation) should be specified as auguments in lo()
. formula
can be missing if data
is well structured and family
is specified.
a data frame containing the variables in the model. data
can be missing if formula
is specified. If formula
is missing, the data must be structured so that the outcome variable is in the 1st (1st and 2nd for survival data) column and X and Y location values are in the 2nd and 3rd (3rd and 4th for survival data) columns. Any additional columns will be entered as covariates with linear effects in the model.
the name in data that will be used as offset in the model. It will be ignored if offset is specified in formula
.
a vector of candidate span sizes that the optimal span is chosen from.
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.
a family function or the result of a call to a family function. (See family
for details of family functions. famil = "survival"
for survival data.
a logical argument; if TRUE shows the AIC for each candidate span size.
a smoothing parameter used in modgam
.
any additional arguments to pass to the gam function.
Lu Bai, Scott Bartell, Robin Bliss, and Veronica Vieira
Send bug reports to sbartell@uci.edu.
predgrid
,
modgam
,
colormap
.
# \donttest{
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")
# }
Run the code above in your browser using DataLab