Extract Coefficients From a Cross-Validated Parity Regression Model Object
Source:R/coef.cv.savvyPR.R
coef.cv.savvyPR.RdExtracts the estimated coefficients corresponding to the optimal tuning parameters
from a fitted cross-validated parity regression model object. It seamlessly handles models
optimized using either the "budget" or "target" parameterization method.
Usage
# S3 method for class 'cv.savvyPR'
coef(object, ...)Arguments
- object
A fitted model object of class
cv.savvyPR.- ...
Additional arguments passed to the
predict.cv.savvyPRmethod.
Value
A named numeric vector of the estimated coefficients from the optimally tuned model. If the model was fitted with an intercept, it will be included as the first element.
Details
Extract Coefficients From a Cross-Validated Parity Regression Model Object
This function is an S3 method for the generic coef function. It extracts the coefficients
of the optimal model identified during the cross-validation procedure. The extraction is
internally delegated to the predict.cv.savvyPR method with type = "coefficients".
Author
Ziwei Chen, Vali Asimit and Pietro Millossovich
Maintainer: Ziwei Chen <ziwei.chen.3@citystgeorges.ac.uk>
Examples
# \donttest{
# Generate synthetic data
set.seed(123)
x <- matrix(rnorm(100 * 10), 100, 10)
y <- rnorm(100)
# Example 1: Extract coefficients from a Budget-based CV model
cv_model_budget <- cv.savvyPR(x, y, method = "budget", model_type = "PR3")
coef(cv_model_budget)
#> (Intercept) V1 V2 V3 V4 V5
#> 0.121472732 0.006337954 -0.001822032 -0.013154427 0.014446491 0.002972443
#> V6 V7 V8 V9 V10
#> -0.003339690 0.006577223 0.011071163 -0.006271348 0.013027130
# Example 2: Extract coefficients from a Target-based CV model
cv_model_target <- cv.savvyPR(x, y, method = "target", model_type = "PR1")
coef(cv_model_target)
#> (Intercept) V1 V2 V3 V4 V5
#> 0.136924965 0.064600519 -0.004278701 -0.147137309 0.138133764 0.070178978
#> V6 V7 V8 V9 V10
#> -0.037301365 0.092952017 0.109651727 -0.049499797 0.137003676
# }