Fig2.12: Reproduce Figure 2.12

View source: R/carbotax.R

Fig2.12R Documentation

Reproduce Figure 2.12

Description

Reproduces Figure 2.12 from the book. If you specify any options, your results may look different.

Usage

Fig2.12(cvfit, parlist = list(mfrow = c(1, 2), mar = c(5, 5, 5, 0.5)))

Arguments

cvfit

cv.ncvreg() fit to the TCGA data; see examples

parlist

List of arguments to pass to par()

Examples

# Set up data
attachData(Koussounadis2014)
sDay <- splines::ns(sData$Day, df=2)
X0 <- model.matrix(~ Treatment*sDay, sData)[,-1]
multiplier <- rep(0:1, c(ncol(X0), ncol(X)))
XX <- cbind(X0, X)

# Fit
fold <- c(4, 3, 10, 7, 3, 2, 5, 9, 6, 9, 7, 4, 4, 2, 1, 7, 1, 4, 6, 9, 5, 9, 9,
          6, 4, 8, 2, 2, 5, 5, 1, 1, 5, 7, 9, 9, 8, 7, 4, 5,  4, 2, 8, 9, 3, 1,
          8, 8, 10, 10, 3, 8, 3, 3, 9, 5, 1, 10, 10, 2, 7, 2, 4, 4, 8, 7, 6, 6,
          7, 10, 3, 6, 10, 2, 7, 5, 2, 6, 6, 1, 1, 4, 6, 10, 7, 8, 10, 8, 1, 5,
          5, 10, 6, 10, 3, 1, 3, 8, 2, 9, 3)
cvfit <- cv.ncvreg(XX, y, penalty.factor=multiplier, penalty='lasso', fold=fold)

# Plot
Fig2.12(cvfit)


pbreheny/hdrm documentation built on Jan. 17, 2024, 8:53 p.m.