Learn R Programming

ePCR (version 0.11.0)

bootstrapRegCoefs: Bootstrapped testing of regression coefficients in a penalized model

Description

The purpose of this function is to evaluate a p-value-like statistic for penalized regression coefficients. A fixed number of bootstrapped datasets are generated, and the model coefficients are fitted to these bootstrapped datasets using the pre-determined lambda.

Usage

bootstrapRegCoefs(fit, lambda, boot = 1000, epsilon = 10^-6)

Value

Significance values for regression coefficients, defined as the proportion of bootstrapped model fits where coefficient did not shrink within epsilon of zero or where it did not flip sign.

Arguments

fit

A regularized regression model fit as provided by the glmnet-package

lambda

The pre-fixed corresponding optimal lambda value, typically determined using cross-validation (e.g. cv.glmnet$lambda.1se or cv.glmnet$lambda.min in glmnet)

boot

The number of bootstrapped datasets to generate

epsilon

The tolerance around beta = 0 to still count estimates as zero

Examples

Run this code
if (FALSE) {
# Computationally too intensive to run bootstrapped fits <5s
data(TYKSSIMU)
library(survival)
x <- as.matrix(xMEDISIMU)
y <- yMEDISIMU[,"surv"]
nlambda <- 30
psp1 <- new("PSP", alphaseq=c(0, 0.5, 1), nlambda = nlambda, folds = 3, x = x, y = y, seeds = 1)
.Object <- psp1
alphaopt <- psp1@optimum["Alpha"]
bs <- bootstrapRegCoefs(fit = psp1@fit, lambda = psp1@optimum["Lambda"], boot = 100)
# Histogram of bootstrapped ps
hist(bs$ps, breaks=100)
}

Run the code above in your browser using DataLab