Skip to contents

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. 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)
#> [1] 0.8051971

#--- 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?
#> [1] 0.4545027