plot.intsel_cv: Plots for 'intsel_cv'

View source: R/plot.intsel_cv.R

plot.intsel_cvR Documentation

Plots for intsel_cv

Description

Plot the solution path or cross-validation curves produced by intsel_cv().

Usage

## S3 method for class 'intsel_cv'
plot(x, type = "cv-curve", ...)

Arguments

x

The intsel_cv object.

type

Character string, "solution-path" to generate a solution path with marks at lambda.min and lambda.1se; "cv-curve" to generate a cross-validation curve.

...

Other graphical parameters to plot

Value

The "solution-path" plot produces a coefficient profile plot of the coefficient paths for a fitted intsel model. The "cv-curve" plot is the cvm (red dot) for each lambda with its standard error (vertical bar). The two vertical dashed lines corresponds to the lambda.min and lambda.1se.

See Also

intsel, intsel_cv.

Examples

n <- 1000
p.int <- 5
p.noint <- 3
intercept <- TRUE
p.screen <- 5

p.int.expand <- p.int*(p.int-1)/2
p.main <- p.int + p.noint
x <- matrix(rnorm(n * p.main), nrow = n, ncol = p.main)

# true model
# logit(p) = 0.1 + 0.3 x1 + 0.3 x2 + 0.3 x8 + 0.2 * x1 * x2

beta.true <- rep(0, p.main)
beta.true[c(1, 2, p.main)] <- 0.3
eta <- x %*% beta.true + 0.2 * x[, 1] * x[, 2]

if (intercept) eta <- eta + 0.1

py <- 1/(1 + exp(-eta))

y <- rbinom(n, 1, py)

nlam <- 30
lambdas <- exp(seq(log(0.1), log(0.00005), length.out = nlam))

# All the pairwise two-way interactions for the first p.screen variables 
# are included in the model and screened in a data-driven manner.
cv <- intsel_cv(x = x,
                y = y,
                p.screen =5,
                intercept = intercept,
                stepsize_init = 1,
                lambda = lambdas,
                nfolds = 5,
                foldid = NULL)
plot(cv)
plot(cv, type = "solution-path") 

intsel documentation built on April 12, 2025, 1:33 a.m.