coef.bridge: Extract coefficients from a fitted bridge object

View source: R/methods.R

coef.bridgeR Documentation

Extract coefficients from a fitted bridge object

Description

Extract original-scale intercept and slope coefficients from a fitted bridge object.

Usage

## S3 method for class 'bridge'
coef(object, s = c("lambda.1se", "lambda.min"), ...)

Arguments

object

Fitted object returned by bridge, with p predictors in its training design.

s

Numeric fitted penalty value(s). Values must match object$lambda exactly; no interpolation is used. Omitting this argument returns all fitted penalties.

The character selector lambda.min requests the smallest fitted penalty. Use a CV object for the selector lambda.1se.

...

Additional arguments accepted for compatibility.

Details

The returned matrix retains its dimensions for a single selected penalty.

Value

Numeric matrix with p + 1 rows and one column per selected penalty, even when only one penalty is selected. The first row is (Intercept); subsequent rows are original-scale slopes in the training predictor order.

Author(s)

Bahadir Yuzbasi
Maintainer: Bahadir Yuzbasi b.yzb@hotmail.com

See Also

predict.bridge, bridge

Examples

# Reproducible synthetic demonstration: 100 observations, eight predictors.
set.seed(2019)
beta <- c(3, 1.5, 0, 0, 2, 0, 0, 0)
p <- length(beta)
beta <- matrix(beta, nrow = p, ncol = 1)
n <- 100
X <- matrix(rnorm(n * p), nrow = n, ncol = p)
y <- as.numeric(X %*% beta + rnorm(n))

# Five penalties keep this help example fast; the default is 100.
model1 <- bridge(X, y, q = 1, nlambda = 5)
# A single selected penalty still gives a coefficient matrix.
coefficients <- coef(model1, s = model1$lambda[2])
coefficients
dim(coefficients)
# Omitting s extracts the full fitted coefficient path.
dim(coef(model1))

rbridge documentation built on Oct. 13, 2026, 9:08 a.m.