mars_ls: mars_ls

View source: R/MARGE_package.R

mars_lsR Documentation

mars_ls

Description

MARS estimation function for independent Gaussian response data. If non-Gaussian response data is used and a family function is specified (i.e., a GLM is used) then mars_ls applies a glm on the final selected basis function.

Usage

mars_ls(
  X_pred,
  Y,
  pen = 2,
  tols = 1e-05,
  M = 21,
  minspan = NULL,
  print.disp = FALSE,
  family = "gaussian",
  nb = FALSE,
  ...
)

Arguments

X_pred

: a matrix of the predictor variables (note that this matrix excludes the intercept term).

Y

: the response variable.

pen

: a set penalty that is used for the GCV. The default is 2.

tols

: a set tolerance for monitoring the convergence for the RSS between the parent and candidate model (this is the lack-of-fit criterion used for MARS). The default is 0.00001.

M

: a set threshold for the number of basis functions to be used. The default is 21.

minspan

: a set minimum span value. The default is minspan = NULL.

print.disp

: a logical argument, do you want to print the output? The default is FALSE.

family

: the specified "exponential" family if a GLM is used (only applied on the final model fit). The default is family = "gaussian".

nb

: a logical argument, is the model a negative binomial model? The default is FALSE.

...

: further arguments passed to or from other methods.

Details

Note that no argument is provided for an "additive structure only" model but one could just use the gam() function from mgcv instead.

Value

mars_ls returns a list of calculated values consisting of:

B_final : the final selected basis model matrix.

GCV_mat : a matrix of GCV values for each fitted model.

min_GCV_own : the GCV for the final selected model.

y_pred : the fitted values from the final selected model.

final_mod : the final selected model matrix.

Author(s)

Jakub Stoklosa and David I. Warton.

References

Friedman, J. (1991). Multivariate adaptive regression splines. The Annals of Statistics, 19, 1–67.

Milborrow, S. (2017a). Notes on the earth package. Package vignette. Available at: http://127.0.0.1:31355/library/earth/doc/earth-notes.pdf.

Milborrow, S. (2017b). earth: Multivariate Adaptive Regression Splines. R package version 4.4.7. Available at http://CRAN.R-project.org/package = earth.

Stoklosa, J. and Warton, D.I. (2018). A generalized estimating equation approach to multivariate adaptive regression splines. Journal of Computational and Graphical Statistics, 27, 245–253.

See Also

marge

Examples

# Load the "leptrine" presence-absence data.

data(leptrine)

dat1 <- leptrine[[1]]  # Training data.
Y <- dat1$Y            # Response variable.

X_pred <- dat1[, -c(3:10)]  # Design matrix using only two (of nine) predictors.

# Set MARS tuning parameters.

family <- "binomial"   # The selected "exponential" family.
nb <- FALSE            # Is this a negative binomial model?
tols <- 0.0001         # A set tolerance (stopping condition) in the forward pass for MARS.
M <- 21                # A set threshold for the maximum number of basis functions to be used.
print.disp <- FALSE    # Print ALL the output?
pen <- 2               # Penalty to be used in GCV.
minspan <- NULL        # A set minimum span value.

# Fit the MARS models (about ~ 20 secs.)

mod <- mars_ls(X_pred, Y, pen, tols, M, minspan, print.disp, family, nb)

JakubStats/marge documentation built on Feb. 25, 2024, 9:38 p.m.