View source: R/predict.savvSh.R
| predict.savvySh_model | R Documentation |
Generate predictions (fitted values) or extract regression coefficients from a
savvySh_model object returned by savvySh. This function allows you to
specify one or more shrinkage estimators (via the estimator parameter) available
in the model. If no estimator is specified, all available estimators are used and their
results are returned in a named list.
## S3 method for class 'savvySh_model'
predict(
object,
newx = NULL,
type = c("response", "coefficients"),
estimator = NULL,
...
)
object |
A fitted |
newx |
A numeric matrix of new predictor data for which to generate predictions.
This argument is required if |
type |
A character string specifying the output type. Options are |
estimator |
A character vector naming one or more shrinkage estimator(s) to use.
These must match names present in |
... |
Additional arguments (currently unused). |
The behavior depends on the value of type:
"response":Generates predicted values using the coefficient estimates
from the specified shrinkage estimator(s) for new data supplied via newx.
"coefficients":Extracts the regression coefficient vector(s) corresponding to the specified estimator(s). Coefficient names are assigned based on whether an intercept is present (for Linear shrinkage, no intercept).
If no estimator is specified, the function returns results for all available estimators
as a named list. If a single estimator is specified (or only one is provided in the vector), the result
is returned as a numeric vector (for coefficients) or a numeric vector of predictions (for response).
If type = "response", the function returns:
A numeric vector of predicted values if exactly one estimator is specified;
Otherwise, a named list of numeric vectors, one for each specified estimator.
If type = "coefficients", the function returns:
A named numeric vector of regression coefficients if exactly one estimator is specified;
Otherwise, a named list of numeric vectors corresponding to each specified estimator.
Ziwei Chen, Vali Asimit, Marina Anca Cidota, Jennifer Asimit
Maintainer: Ziwei Chen <ziwei.chen.3@citystgeorges.ac.uk>
savvySh for fitting slab and shrinkage linear models,
coef.savvySh_model for direct coefficient extraction.
# Generate simulated data
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")
# Generate predictions for new data
new_x <- matrix(rnorm(10 * 5), 10, 5)
preds <- predict(fit, newx = new_x, type = "response")
# Extract coefficients for specific estimators
coefs_st <- predict(fit, type = "coefficients", estimator = "St")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.