optspan: Determine the Optimal Span Size for 'modgam'

optspanR 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 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.

data

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.

offset

the name in data that will be used as offset in the model. It will be ignored if offset is specified in formula.

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 family for details of family functions. famil = "survival" for survival data.

verbose

a logical argument; if TRUE shows the AIC for each candidate span size.

degree

a smoothing parameter used in modgam.

...

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

predgrid, modgam, colormap.

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")


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