Learn R Programming

mvs (version 2.0.0)

coef.StaPLR: Extract coefficients from a "StaPLR" object.

Description

Extract base- and meta-level coefficients from a "StaPLR" object at the CV-optimal values of the penalty parameters.

Usage

# S3 method for StaPLR
coef(object, cvlambda = "lambda.min", ...)

Value

An object with S3 class "StaPLRcoef".

Arguments

object

Fitted "StaPLR" model object.

cvlambda

By default, the coefficients are extracted at the CV-optimal values of the penalty parameters. Choosing "lambda.1se" will extract them at the largest values within one standard error of the minima.

...

Further arguments to be passed to coef.cv.glmnet.

Author

Wouter van Loon <w.s.van.loon@fsw.leidenuniv.nl>

Examples

Run this code
# \donttest{
set.seed(012)
n <- 1000
cors <- seq(0.1,0.7,0.1)
X <- matrix(NA, nrow=n, ncol=length(cors)+1)
X[,1] <- rnorm(n)

for(i in 1:length(cors)){
  X[,i+1] <- X[,1]*cors[i] + rnorm(n, 0, sqrt(1-cors[i]^2))
}

beta <- c(1,0,0,0,0,0,0,0)
eta <- X %*% beta
p <- exp(eta)/(1+exp(eta))
y <- rbinom(n, 1, p)
view_index <- rep(1:(ncol(X)/2), each=2)

fit <- StaPLR(X, y, view_index)
coef(fit)$meta

new_X <- matrix(rnorm(16), nrow=2)
predict(fit, new_X)# }

Run the code above in your browser using DataLab