boot_lucid: Inference of LUCID model based on bootstrap resampling

View source: R/boot_lucid.R

boot_lucidR Documentation

Inference of LUCID model based on bootstrap resampling

Description

Generate R bootstrap replicates of LUCID parameters and derive confidence interval (CI) based on bootstrap. Bootstrap replicates are generated by nonparametric resampling, implemented with the ordinary method of boot::boot. Supports lucid_model = "early", lucid_model = "parallel", and lucid_model = "serial".

Usage

boot_lucid(
  G,
  Z,
  Y,
  lucid_model = NULL,
  CoG = NULL,
  CoY = NULL,
  model,
  conf = 0.95,
  R = 100,
  verbose = FALSE,
  min_valid = 2L
)

Arguments

G

Exposures, a numeric vector, matrix, or data frame. Categorical variable should be transformed into dummy variables. If a matrix or data frame, rows represent observations and columns correspond to variables.

Z

Omics data: for LUCID early integration, a numeric matrix/data frame; for LUCID in parallel, a list of numeric matrices/data frames. Rows correspond to observations and columns correspond to variables.

Y

Outcome, a numeric vector. Categorical variable is not allowed. Binary outcome should be coded as 0 and 1.

lucid_model

Optional; "early", "parallel", or "serial". Auto-detected from class(model) when omitted (the normal case), so this rarely needs to be set explicitly – it exists for backward compatibility with scripts written before auto-detection. If supplied, it is cross-checked against model's actual class and an error is raised on a mismatch. Bootstrap inference is implemented for all three model types.

CoG

Optional, covariates to be adjusted for estimating the latent cluster. A numeric vector, matrix or data frame. Categorical variable should be transformed into dummy variables.

CoY

Optional, covariates to be adjusted for estimating the association between latent cluster and the outcome. A numeric vector, matrix or data frame. Categorical variable should be transformed into dummy variables.

model

A LUCID model fitted by estimate_lucid. If the fitted model uses nonzero penalties, boot_lucid will automatically refit a zero-penalty model as fallback because bootstrap inference is only supported for Rho_G = Rho_Z_Mu = Rho_Z_Cov = 0.

conf

A numeric scalar between 0 and 1 to specify confidence level(s) of the required interval(s).

R

An integer to specify number of bootstrap replicates for LUCID model. If feasible, it is recommended to set R >= 1000.

verbose

A flag indicates whether detailed information is printed in console. Default is FALSE.

min_valid

Minimum number of bootstrap replicates that must yield finite estimates before confidence limits can be formed. The default, 2, is the mathematical floor. Replicates that fail are counted and warned about, and a small number of replicates raises a warning that the limits are unstable, but neither suppresses the limits; only fewer than min_valid surviving replicates yields NA limits.

Value

A list containing:

beta

Bootstrap CI table(s) for G-to-X effects. For lucid_model = "parallel", this is a list by omics layer and includes the multinomial intercept plus exposures in G (not CoG).

mu

Bootstrap CI table(s) for cluster-specific means of omics features. For lucid_model = "parallel", this is a list by omics layer.

gamma

Bootstrap CI table for X-to-Y parameters.

stage

For lucid_model = "serial", a list of stage-wise CI tables (each stage contains beta, mu, and gamma for the final stage only).

bootstrap

The boot object returned by boot::boot.

Examples


# use simulated data (a small subset keeps the example quick)
G <- sim_data$G[1:150, , drop = FALSE]
Z <- sim_data$Z[1:150, , drop = FALSE]
Y_normal <- sim_data$Y_normal[1:150]

# fit lucid model
fit1 <- estimate_lucid(G = G, Z = Z, Y = Y_normal, lucid_model = "early",
family = "normal", K = 2,
seed = 1008, max_itr = 20, max_tot.itr = 50)

# conduct bootstrap resampling (lucid_model is auto-detected from fit1's class)
# a small R keeps the example quick; `conf` sets the CI level (default 0.95)
boot1 <- suppressWarnings(
  boot_lucid(G = G, Z = Z, Y = Y_normal, model = fit1, R = 3, conf = 0.9)
)


LUCIDus documentation built on Sept. 3, 2026, 1:06 a.m.