coef.transreg: Extract Coefficients

View source: R/functions.R

coef.transregR Documentation

Extract Coefficients

Description

Extracts coefficients from an object of class [transreg].

Usage

## S3 method for class 'transreg'
coef(object, stack = NULL, ...)

Arguments

object

object of class 'transreg'

stack

character "sta" (standard stacking) or "sim" (simultaneous stacking)

...

(not applicable)

Value

Returns estimated coefficients. The output is a list with two slots: slot 'alpha' with the estimated intercept (scalar), and slot 'beta' with the estimated slopes (vector).

References

Armin Rauschenberger, Zied Landoulsi, Mark A. van de Wiel, and Enrico Glaab (2023). "Penalised regression with multiple sets of prior effects". Bioinformatics 39(12):btad680. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/bioinformatics/btad680")}. (Click here to access PDF.)

See Also

Methods for objects of class [transreg] include coef and predict.

Examples

#--- simulation ---
set.seed(1)
n <- 100; p <- 500
X <- matrix(rnorm(n=n*p),nrow=n,ncol=p)
beta <- rnorm(p)
prior <- beta + rnorm(p)
y <- X %*% beta

#--- glmnet (without prior effects) ---
object <- glmnet::cv.glmnet(y=y,x=X,alpha=0)
beta_hat <- coef(object,s="lambda.min")[-1]
mean((beta-beta_hat)^2)

#--- transreg (with prior effects) ---
object <- transreg(y=y,X=X,prior=prior,alpha=0)
beta_hat <- coef(object)$beta
mean((beta-beta_hat)^2) # decrease in MSE?


transreg documentation built on June 10, 2025, 5:14 p.m.