Description Usage Arguments Details Value References See Also Examples
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.
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,
...
)
|
formula |
A GAM formula, as used in |
data |
A dataframe containing the variables in the model. |
gam.function |
A character object that indicates which GAM function should be used. Options are
|
pred.loss |
See |
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 |
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 |
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 |
maxit |
A vector a length 2 for stage 1 and stage 2. See |
intercept |
Should the intercept be included in the model. |
... |
Additional parameters to pass to |
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.
An object of class "gam"
as described in gamObject
.
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.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.