gam3: 3 Stage Framework for GAM

Description Usage Arguments Details Value References See Also Examples

View source: R/gam3.R

Description

Executes the 3 stage framework for GAM. This function uses a modified version of cv.gglasso from the gglasso package, and GAM functions from the mgcv package.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
gam3(
  formula,
  data,
  gam.function = "gam",
  pred.loss = "L2",
  nfolds = c(5, 5),
  foldid,
  loss = "ls",
  nlambda = c(100, 100),
  lambda.factor = ifelse(nobs < nvars, 0.05, 0.001),
  lambda = list(NULL, NULL),
  pf = list(sqrt(bs), sqrt(bs)),
  eps = c(1e-08, 1e-08),
  maxit = c(3e+08, 3e+08),
  intercept = TRUE,
  ...
)

Arguments

formula

A GAM formula, as used in gam.

data

A dataframe containing the variables in the model.

gam.function

A character object that indicates which GAM function should be used. Options are "gam" and "bam". See the mgcv package for more details.

pred.loss

See cv.gglasso for details.

nfolds

A vector of length 2 providing the number of folds for cross-validtion in stage 1 and stage 2.

foldid

A list of length 2 providing the folds for each observations for cross-validation in stage 1 and stage 2.

loss

See gglasso for details.

nlambda

A vector of length 2 providing the number of lambda values to use in stage 1 and stage 2.

lambda.factor

A numeric value specifying the lambda.factor. See gglasso for details.

lambda

A list of length 2 providing the lambda sequences to use for stage 1 and stage 2.

pf

A list of length 2 providing the penalty factors to use for stage 1 and stage 2.

eps

A vector of length 2 for stage 1 and stage 2. See gglasso for details.

maxit

A vector a length 2 for stage 1 and stage 2. See gglasso for details.

intercept

Should the intercept be included in the model.

...

Additional parameters to pass to gam.function

Details

Executes the 3 stage framework for GAM. This function uses a modified version of cv.gglasso from the gglasso package, and GAM functions from the mgcv package.

Value

An object of class "gam" as described in gamObject.

References

Wood, S.N. (2017) Generalized Additive Models: an introduction with R (2nd edition), CRC

Yang, Y. and Zou, H. (2015),A Fast Unified Algorithm for Computing Group-Lasso Penalized Learning Problems. Statistics and Computing. 25(6), 1129-1141.

See Also

gglasso, gam, bam

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
require(mgcv)
require(gglasso)

probs <- c(0.1, 0.1, 0.1, 0.1, 0.1, 0.5)
simulated_data <- gamSim2(n = 1000, p = 200, test.n = 200, sigma = 0.1, probs = probs)
data <- simulated_data$data
m <- 2
k <- 8

terms <- paste("s(", names(data)[-1], ", bs = 'ps', ", "m = ", m, ", k = ", k, ")", sep = "")
formula <- as.formula(paste("y ~", paste(terms, collapse = " + ")))
lambda.factor <- 0.0001
gam3.mod <- gam3(formula, data, gam.function = "bam", lambda.factor = lambda.factor)

scottmanski/TAGAM documentation built on Aug. 3, 2020, 10:50 a.m.