coef.GeDSgam_GeDSboost: Coef Method for GeDSgam, GeDSboost

View source: R/S3methods_GeDSboost-GeDSgam.R

coef.GeDSgam,boostR Documentation

Coef Method for GeDSgam, GeDSboost

Description

Method for the function coef that allows to extract the estimated coefficients of a "GeDSgam" class or "GeDSboost" class object.

Usage

## S3 method for class 'GeDSgam'
coef(object, n = 3L, ...)

## S3 method for class 'GeDSboost'
coef(object, n = 3L, ...)

Arguments

object

The "GeDSgam" class or "GeDSboost" class object from which the coefficients should be extracted.

n

Integer value (2, 3 or 4) specifying the order (= degree + 1) of the FGB-GeDS/GAM-GeDS fit whose coefficients should be extracted.

  • If n = 2L: the piecewise polynomial coefficients of the univariate GeDS base-learners and linear base-learners are provided (the B-spline coefficients are accessible through x$final_model$linear.fit$theta); for bivariate GeDS base-learners and class(object) == "GeDSboost", the B-spline coefficients for each iteration where the corresponding bivariate base-learner was selected are provided; for bivariate base-learners and class(object) == "GeDSgam", the final local-scoring B-spline coefficients are provided.

  • If n = 3L or n = 4L: B-spline coefficients are provided for both univariate and bivariate GeDS learners.

By default n is equal to 3L. Non-integer values will be passed to the function as.integer.

...

Potentially further arguments (required by the definition of the generic function). These will be ignored, but with a warning.

Value

A named vector containing the required coefficients of the fitted multivariate predictor model.

See Also

coef for the standard definition; NGeDSgam and NGeDSboost for examples.

Examples

data(mtcars)
# Convert specified variables to factors
categorical_vars <- c("cyl", "vs", "am", "gear", "carb")
mtcars[categorical_vars] <- lapply(mtcars[categorical_vars], factor)

Gmodgam <- NGeDSgam(mpg ~ f(disp, hp) + f(qsec) + carb,
                    data = mtcars, family = gaussian, phi = 0.7)

# Piecewise polynomial coefficients of the (univariate) GeDS and linear learners
coef(Gmodgam, n = 2)$`f(qsec)`
coef(Gmodgam, n = 2)$carb
# B-spline coefficients of the bivariate learner
coef(Gmodgam, n = 2)$`f(disp, hp)`

Gmodboost <- NGeDSboost(mpg ~ f(disp, hp) + f(qsec) + carb,
                        data = mtcars, family = mboost::Gaussian(), shrinkage = 0.7)

# Piecewise polynomial coefficients of the (univariate) GeDS and linear learners
coef(Gmodboost, n = 2)$`f(qsec)`
coef(Gmodboost, n = 2)$carb
# B-spline coefficients of the bivariate learner at each boosting iteration
# this was selected
coef(Gmodboost, n = 2)$`f(disp, hp)`


GeDS documentation built on June 30, 2025, 9:07 a.m.