bootstrap_orthoMTL: Bootstrap Inference for orthoMTL Coefficients

View source: R/bootstrap.R

bootstrap_orthoMTLR Documentation

Bootstrap Inference for orthoMTL Coefficients

Description

Estimates coefficient variability and statistical relevance by comparing bootstrapped models (real signal) against null models (permuted outcomes). This two-pronged approach answers: (1) how stable is each coefficient across resamples, and (2) is each coefficient distinguishable from what would be obtained by chance.

Usage

bootstrap_orthoMTL(
  X,
  Y,
  lambda = 1,
  alpha = 0,
  step_size = 0.1,
  K = NULL,
  disjoint = FALSE,
  schedule = c("sqrt", "log", "const", "linear"),
  survival = FALSE,
  censored.mat = NULL,
  n_repeats = 100,
  n_cores = 2,
  seed = NULL,
  verbose = TRUE
)

Arguments

X

A numeric matrix of predictor variables with dimensions n x p.

Y

A numeric matrix of response labels with dimensions n x numTasks. May contain NA for censored observations.

lambda

Regularisation parameter for the orthogonal penalty.

alpha

Elastic-net mixing parameter in [0, 1], passed through to orthoMTL. Default: 0.

step_size

Step size for gradient descent. Default: 0.1.

K

Constraint matrix of dimensions numTasks x numTasks. Default: NULL (identity).

disjoint

Logical. Enforce disjoint supports? Default: FALSE.

schedule

Character; the gradient-step decay schedule passed to orthoMTL for every resample/permutation fit. One of "sqrt" (default), "log", "const", "linear". Because bootstrap refits the model many times, switching to "log" or "const" – which reach the same optimum in far fewer iterations – can substantially cut total runtime; see the schedule argument of orthoMTL for details.

survival

Logical. Use censored survival loss? Default: FALSE.

censored.mat

A numeric indicator matrix of dimensions n x numTasks. Required when survival = TRUE.

n_repeats

Number of bootstrap/permutation repeats. Default: 100.

n_cores

Number of cores for parallel execution. Default: 2.

seed

Optional base random seed. Default: NULL (no seed is set; repeats vary via the ambient RNG state and the run is not reproducible). If supplied, repeat i uses set.seed(seed + i) for i in 1:n_repeats, so the whole run becomes reproducible while still varying across repeats.

verbose

Logical. Print progress information? Default: TRUE.

Details

Real bootstrap: For each repeat, rows of X, Y, and censored.mat are resampled with replacement. The model is refit with identical hyperparameters. This produces a distribution of coefficient values reflecting estimation variability.

Null permutation: For each repeat, rows of Y and censored.mat are permuted without replacement while X remains fixed. This breaks the association between features and outcomes, producing a null distribution of coefficients.

Comparing real vs null distributions for each feature and task indicates whether observed coefficients are distinguishable from noise. Visualise with plot_bootstrap.

Value

An object of class "bootstrap_orthoMTL" containing:

results

A tidy data.frame with columns id (feature name), time (task/threshold), coeff (coefficient value), group ("real" or "null"), and repeat_id (integer).

coefficients_real

A list of n_repeats coefficient matrices (each p x numTasks).

coefficients_null

A list of n_repeats coefficient matrices from permuted outcomes.

obj_real

Numeric vector of final objective values for real bootstrap models.

obj_null

Numeric vector of final objective values for null permutation models.

n_repeats

Number of repeats.

n_features

Number of features.

n_tasks

Number of tasks.

feature_names

Character vector of feature names.

task_names

Character vector of task names.

call

The matched function call.

See Also

orthoMTL, plot_bootstrap

Examples


set.seed(42)
n <- 30; p <- 5; n_tasks <- 3
X <- matrix(rnorm(n * p), n, p)
colnames(X) <- paste0("V", seq_len(p))
SurvTime <- rexp(n, rate = 0.1)
Event <- rbinom(n, 1, 0.7)
thresholds <- c(4, 6, 10)

Y <- create_longitudinal_labels(SurvTime, Event, thresholds)
W <- create_indicator_matrix(Y)
K <- create_constraint_matrix(n_tasks)

boot_res <- bootstrap_orthoMTL(
  X = X, Y = Y, lambda = 1e-3, step_size = 0.1,
  K = K, survival = TRUE, censored.mat = W,
  n_repeats = 5, n_cores = 1, verbose = FALSE
)

print(boot_res)
head(boot_res$results)


orthoMTL documentation built on Aug. 23, 2026, 5:10 p.m.