Extract Coefficients for a Slab and Shrinkage Linear Regression Model
Source:R/coef.savvySh.R
coef.savvySh_model.RdExtracts the regression coefficients from a savvySh_model object. You may specify one or
more shrinkage estimators through the estimator parameter. If no estimator is specified,
the function returns coefficients for all available estimators as a named list.
Usage
# S3 method for class 'savvySh_model'
coef(object, estimator = NULL, ...)Arguments
- object
A fitted
savvySh_modelobject produced bysavvySh.- estimator
A character vector naming one or more estimators from which to extract coefficients. Valid names are those stored in
object$coefficients(e.g.,"St","DSh","Sh","SR","GSR", etc.). IfNULL, coefficients for all available estimators are returned.- ...
Additional arguments passed to
predict.savvySh_model.
Value
A named numeric vector of regression coefficients if a single estimator is specified, or a named list of such vectors if multiple estimators are requested.
Details
This function internally calls predict.savvySh_model with type = "coefficients"
to retrieve the desired coefficient estimates. If multiple estimators are requested (or if none is specified,
in which case all are returned), the output is a named list in which each element is a numeric vector of coefficients.
The coefficient vectors are named according to whether an intercept is present (for Linear shrinkage, no intercept).
If a single estimator is specified, a single named numeric vector is returned.
See also
predict.savvySh_model for generating predictions,
savvySh for fitting slab and shrinkage linear models.
Author
Ziwei Chen, Vali Asimit, Marina Anca Cidota, Jennifer Asimit
Maintainer: Ziwei Chen <ziwei.chen.3@citystgeorges.ac.uk>
Examples
# Generate simulated data for example
set.seed(123)
x <- matrix(rnorm(100 * 5), 100, 5)
y <- rnorm(100)
# Fit a Multiplicative shrinkage model
fit <- savvySh(x, y, model_class = "Multiplicative", include_Sh = TRUE)
# Extract coefficients for all available estimators (St and DSh by default)
all_coefs <- coef(fit)
#> Warning: No estimator specified. Returning results for all available estimators: St, DSh, Sh
# Extract coefficients for a specific estimator
st_coefs <- coef(fit, estimator = "St")
print(st_coefs)
#> (Intercept) V1 V2 V3 V4 V5
#> -0.030182101 -0.004972245 0.080777553 0.007865334 -0.047038277 0.119823968