Skip to contents

Prints a summarized output of a fitted parity regression model object. It clearly displays the model's configuration and the resulting estimated coefficients.

Usage

# S3 method for class 'savvyPR'
print(x, digits = max(3, getOption("digits") - 3), ...)

Arguments

x

A fitted model object of class "savvyPR" returned by savvyPR.

digits

Significant digits to be used in the printout.

...

Additional arguments passed to the generic print function.

Value

Invisibly returns a data frame summarizing the model, including the parameterization method, number of non-zero coefficients, intercept status, and lambda value.

Details

Print a Parity Regression Model Object

This function is an S3 method for the generic print function. It formats and prints the matched call that produced the savvyPR object, followed by a summary data frame. This summary includes:

  • The parameterization method used ("budget" or "target").

  • The number of non-zero coefficients.

  • Whether an intercept was included.

  • The penalty value (lambda), if any was applied.

Finally, it prints a data frame of the estimated coefficients.

See also

Author

Ziwei Chen, Vali Asimit and Pietro Millossovich
Maintainer: Ziwei Chen <ziwei.chen.3@citystgeorges.ac.uk>

Examples

# Generate synthetic data
set.seed(123)
n <- 100
p <- 10
x <- matrix(rnorm(n * p), n, p)
beta <- matrix(rnorm(p), p, 1)
y <- x %*% beta + rnorm(n, sd = 0.5)

# Fit and print a Budget-based model
fit_budget <- savvyPR(x, y, method = "budget", val = 0.05)
print(fit_budget)
#> 
#> Call:  savvyPR(x = x, y = y, method = "budget", val = 0.05) 
#> 
#>  Method Number of Non-Zero Coefficients Intercept Included Lambda Value
#>  budget                              11                Yes           NA
#> 
#> Coefficients:
#>  Coefficient Estimate
#>  (Intercept)   0.0500
#>           X1  -1.0050
#>           X2  -1.1010
#>           X3   0.1240
#>           X4  -0.1422
#>           X5  -2.6292
#>           X6   1.0761
#>           X7   0.2992
#>           X8   2.3617
#>           X9   0.6847
#>          X10  -0.4447

# Fit and print a Target-based model
fit_target <- savvyPR(x, y, method = "target", val = 1)
print(fit_target)
#> 
#> Call:  savvyPR(x = x, y = y, method = "target", val = 1) 
#> 
#>  Method Number of Non-Zero Coefficients Intercept Included Lambda Value
#>  target                              11                Yes           NA
#> 
#> Coefficients:
#>  Coefficient Estimate
#>  (Intercept)   0.0447
#>           X1  -1.0194
#>           X2  -1.1191
#>           X3   0.1741
#>           X4  -0.1824
#>           X5  -2.6378
#>           X6   1.0870
#>           X7   0.3327
#>           X8   2.3795
#>           X9   0.6990
#>          X10  -0.4613