Learn R Programming

transreg (version 1.0.5)

coef.transreg: Extract Coefficients

Description

Extracts coefficients from an object of class [transreg].

Usage

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

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).

Arguments

object

object of class `transreg`

stack

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

...

(not applicable)

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. 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

Run this code
#--- 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?

Run the code above in your browser using DataLab