| Title: | Regularised and Information-Theoretic Sufficient Dimension Reduction |
|---|---|
| Description: | Implements covariance-stabilised sufficient dimension reduction for continuous responses, with an additional sparse engine for continuous, categorical, and right-censored survival responses and information-theoretic structural dimension selection. Supported methods include sliced inverse regression, sliced average variance estimation, directional regression, and principal Hessian directions. Sample, ridge, Oracle Approximating Shrinkage, Ledoit-Wolf, and Maximum Entropy Covariance (MEC) estimators are provided alongside prediction, resampling, simulation, and diagnostic utilities. The sufficient dimension reduction methods build on Li (1991) <doi:10.1080/01621459.1991.10475035>, Li (1992) <doi:10.1080/01621459.1992.10476258>, and Li and Wang (2007) <doi:10.1198/016214507000000536>. Covariance shrinkage follows Olorede and Yahya (2019) <doi:10.48550/arXiv.1909.13017>, Ledoit and Wolf (2004) <doi:10.1016/S0047-259X(03)00096-4> and Chen et al. (2010) <doi:10.1109/TSP.2010.2053029>. |
| Authors: | Kabir Olorede [aut, cre] |
| Maintainer: | Kabir Olorede <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.4.0 |
| Built: | 2026-10-12 23:11:18 UTC |
| Source: | https://github.com/ilovemaths/risdr |
The package implements SIR, SAVE, DR, and pHd for continuous responses, together with covariance regularisation, information-theoretic structural dimension selection, prediction, resampling, simulation, and diagnostic utilities.
Use fit_risdr() to estimate an SDR model and predict.risdr() to obtain
predictions for new observations. Use select_dimension_cv(),
select_dimension_cv_icomp(), or select_dimension_ladle() for
complementary structural-dimension diagnostics.
fit_risdr() retains its continuous-response scope. Use
fit_risdr_sparse() for joint dimension and sparsity selection with
continuous, categorical, and right-censored survival responses, or
fit_risdr_dual() for sample-space PCA reduction when predictors outnumber
observations. fit_risdr_sparse_realdata() adds variance screening.
See the sparse-survival vignette for the frozen thesis conventions.
Maintainer: Kabir Olorede [email protected]
Useful links:
Report bugs at https://github.com/ilovemaths/risdr/issues
Adjusted coefficient of determination
adjusted_r_squared(y_true, y_pred, d)adjusted_r_squared(y_true, y_pred, d)
y_true |
Observed response values. |
y_pred |
Predicted response values. |
d |
Number of predictors in the downstream model. |
Numeric adjusted R-squared.
adjusted_r_squared( c(2, 4, 6, 8, 10), c(2.2, 3.8, 5.7, 8.1, 9.8), d = 1 )adjusted_r_squared( c(2, 4, 6, 8, 10), c(2.2, 3.8, 5.7, 8.1, 9.8), d = 1 )
AR(1) covariance matrix
ar1_covariance(p, rho)ar1_covariance(p, rho)
p |
Dimension. |
rho |
Correlation parameter. |
Covariance matrix.
ar1_covariance(p = 4, rho = 0.5)ar1_covariance(p = 4, rho = 0.5)
Computes cumulative scale-invariant covariance complexity from leading eigenvalues and converts the complexity profile to relative weights.
C1F(evals, positive_only = TRUE, cumulative = TRUE, tol = 1e-10)C1F(evals, positive_only = TRUE, cumulative = TRUE, tol = 1e-10)
evals |
Numeric vector of eigenvalues. |
positive_only |
Logical; retain only positive eigenvalues. |
cumulative |
Logical; compute cumulative C1F values. |
tol |
Numerical tolerance. |
A list with C1F values, induced weights, and processed eigenvalues.
Choose dimension from criteria table
choose_dimension( d_table, selector = c("cicomp", "icomp", "bic", "caic", "aic") )choose_dimension( d_table, selector = c("cicomp", "icomp", "bic", "caic", "aic") )
d_table |
Data frame returned by select_dimension(). |
selector |
Criterion used for selection. |
Selected structural dimension.
scores <- as.matrix(mtcars[, c("wt", "hp", "disp")]) dimension_table <- select_dimension(scores, mtcars$mpg, d_max = 2) choose_dimension(dimension_table, selector = "bic")scores <- as.matrix(mtcars[, c("wt", "hp", "disp")]) dimension_table <- select_dimension(scores, mtcars$mpg, d_max = 2) choose_dimension(dimension_table, selector = "bic")
Computes Directional Regression using the canonical pairwise-slice formulation.
compute_dr( X, y, Sigma = NULL, nslices = 6, slice_type = c("quantile", "equal_width"), stabilize_slices = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), eps = 1e-08 )compute_dr( X, y, Sigma = NULL, nslices = 6, slice_type = c("quantile", "equal_width"), stabilize_slices = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), eps = 1e-08 )
X |
Numeric predictor matrix. |
y |
Numeric response vector. |
Sigma |
Covariance matrix used for standardisation. |
nslices |
Number of response slices. |
slice_type |
Slicing strategy. |
stabilize_slices |
Logical. Stabilise slice covariance matrices. |
stabilization |
Stabilisation method. |
eps |
Eigenvalue floor. |
Directional Regression is computed using the pairwise-slice formulation.
where
A list containing DR kernel, eigenvalues, directions, scores, and slices.
X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) fit <- compute_dr(X, y = mtcars$mpg, nslices = 4) head(fit$eigenvalues)X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) fit <- compute_dr(X, y = mtcars$mpg, nslices = 4) head(fit$eigenvalues)
Compute one reduced-model information criterion
compute_ic( y, Z, criterion = c("cicomp", "icomp", "aic", "caic", "bic"), response_type = c("continuous", "categorical", "survival"), delta = NULL, n_active = NULL, support_penalty = FALSE, tol = 1e-10 )compute_ic( y, Z, criterion = c("cicomp", "icomp", "aic", "caic", "bic"), response_type = c("continuous", "categorical", "survival"), delta = NULL, n_active = NULL, support_penalty = FALSE, tol = 1e-10 )
y |
Response vector. |
Z |
Reduced predictors. |
criterion |
Criterion name. |
response_type |
Response type. |
delta |
Optional event indicator. |
n_active |
Optional active-support size. |
support_penalty |
Include active-support size in effective df. |
tol |
Numerical tolerance. |
Scalar criterion value.
Compute all reduced-model information criteria
compute_ic_values( y, Z, response_type = c("continuous", "categorical", "survival"), delta = NULL, n_active = NULL, support_penalty = FALSE, tol = 1e-10 )compute_ic_values( y, Z, response_type = c("continuous", "categorical", "survival"), delta = NULL, n_active = NULL, support_penalty = FALSE, tol = 1e-10 )
y |
Response vector. |
Z |
Reduced predictors. |
response_type |
Response type. |
delta |
Optional event indicator. |
n_active |
Optional active-support size. |
support_penalty |
Include active-support size in effective df. |
tol |
Numerical tolerance. |
Named numeric vector containing AIC, BIC, CAIC, ICOMP, CICOMP, log-likelihood, effective df, and C1F.
Computes AIC, BIC, CAIC, ICOMP, and CICOMP for a fitted linear model.
compute_information_criteria(fit, complexity = c("C1", "C1F"), eps = 1e-10)compute_information_criteria(fit, complexity = c("C1", "C1F"), eps = 1e-10)
fit |
A fitted lm object. |
complexity |
Character string. Complexity measure, either "C1" or "C1F". |
eps |
Eigenvalue floor. |
Named numeric vector of criteria.
fit <- stats::lm(mpg ~ wt + hp, data = mtcars) compute_information_criteria(fit)fit <- stats::lm(mpg ~ wt + hp, data = mtcars) compute_information_criteria(fit)
For mode = "c1f", the regularised covariance matrix is decomposed into
original-coordinate C1F contributions. Variables with larger contribution
receive smaller soft-threshold weights, matching the direction of the
historical C1F weighting rule while avoiding the invalid mapping of
eigenvalue indices directly to predictor indices. inverse_c1f reverses
that weighting. uniform returns equal weights.
compute_penalty_weights( Sigma, mode = c("c1f", "inverse_c1f", "uniform"), tol = 1e-10 )compute_penalty_weights( Sigma, mode = c("c1f", "inverse_c1f", "uniform"), tol = 1e-10 )
Sigma |
Regularised covariance matrix. |
mode |
One of |
tol |
Numerical tolerance. |
Numeric vector of variable-level penalty weights with mean one.
Compute Principal Hessian Directions
compute_phd(X, y, Sigma = NULL, eps = 1e-08)compute_phd(X, y, Sigma = NULL, eps = 1e-08)
X |
Numeric predictor matrix. |
y |
Numeric response vector. |
Sigma |
Covariance matrix used for standardisation. |
eps |
Eigenvalue floor. |
A list containing pHd kernel, eigenvalues, directions, scores.
X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) fit <- compute_phd(X, y = mtcars$mpg) head(fit$eigenvalues)X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) fit <- compute_phd(X, y = mtcars$mpg) head(fit$eigenvalues)
Compute Sliced Average Variance Estimation
compute_save( X, y, Sigma = NULL, nslices = 6, slice_type = c("quantile", "equal_width"), stabilize_slices = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), eps = 1e-08 )compute_save( X, y, Sigma = NULL, nslices = 6, slice_type = c("quantile", "equal_width"), stabilize_slices = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), eps = 1e-08 )
X |
Numeric predictor matrix. |
y |
Numeric response vector. |
Sigma |
Covariance matrix used for standardisation. |
nslices |
Number of response slices. |
slice_type |
Slicing strategy. |
stabilize_slices |
Logical. Stabilise slice covariance matrices. |
stabilization |
Stabilisation method. |
eps |
Eigenvalue floor. |
A list containing SAVE kernel, eigenvalues, directions, scores, and slices.
X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) fit <- compute_save(X, y = mtcars$mpg, nslices = 4) head(fit$eigenvalues)X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) fit <- compute_save(X, y = mtcars$mpg, nslices = 4) head(fit$eigenvalues)
Projects new predictor observations onto estimated SDR directions.
compute_scores(newX, directions)compute_scores(newX, directions)
newX |
New predictor matrix or data frame. |
directions |
Matrix of SDR directions. |
Matrix of SDR scores.
X <- as.matrix(mtcars[1:5, c("wt", "hp", "disp")]) directions <- diag(3)[, 1:2, drop = FALSE] compute_scores(X, directions)X <- as.matrix(mtcars[1:5, c("wt", "hp", "disp")]) directions <- diag(3)[, 1:2, drop = FALSE] compute_scores(X, directions)
General SDR kernel dispatcher
compute_sdr( X, y, method = c("dr", "sir", "save", "phd"), Sigma = NULL, nslices = 6, ... )compute_sdr( X, y, method = c("dr", "sir", "save", "phd"), Sigma = NULL, nslices = 6, ... )
X |
Numeric predictor matrix. |
y |
Numeric response vector. |
method |
SDR method. |
Sigma |
Covariance matrix. |
nslices |
Number of slices. |
... |
Additional arguments passed to internal methods. |
SDR fit components.
X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) Sigma <- cov_oas(X) fit <- compute_sdr( X, y = mtcars$mpg, method = "sir", Sigma = Sigma, nslices = 4 ) dim(fit$scores)X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) Sigma <- cov_oas(X) fit <- compute_sdr( X, y = mtcars$mpg, method = "sir", Sigma = Sigma, nslices = 4 ) dim(fit$scores)
Compute Sliced Inverse Regression
compute_sir( X, y, Sigma = NULL, nslices = 6, slice_type = c("quantile", "equal_width"), eps = 1e-08 )compute_sir( X, y, Sigma = NULL, nslices = 6, slice_type = c("quantile", "equal_width"), eps = 1e-08 )
X |
Numeric predictor matrix. |
y |
Numeric response vector. |
Sigma |
Covariance matrix used for standardisation. |
nslices |
Number of response slices. |
slice_type |
Slicing strategy. |
eps |
Eigenvalue floor. |
A list containing SIR kernel, eigenvalues, directions, scores, and slices.
X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) fit <- compute_sir(X, y = mtcars$mpg, nslices = 4) head(fit$eigenvalues)X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) fit <- compute_sir(X, y = mtcars$mpg, nslices = 4) head(fit$eigenvalues)
Computes Bozdogan-type maximal covariance complexity.
cov_complexity_C1(Sigma, eps = 1e-10)cov_complexity_C1(Sigma, eps = 1e-10)
Sigma |
A covariance matrix. |
eps |
Eigenvalue floor. |
Numeric complexity value.
Computes the scale-invariant C1F covariance complexity measure.
cov_complexity_C1F(Sigma, eps = 1e-10)cov_complexity_C1F(Sigma, eps = 1e-10)
Sigma |
A covariance matrix. |
eps |
Eigenvalue floor. |
Numeric complexity value.
Computes the spectral condition number of a covariance matrix.
cov_condition_number(Sigma, eps = 1e-12)cov_condition_number(Sigma, eps = 1e-12)
Sigma |
A covariance matrix. |
eps |
Small positive value used to avoid division by zero. |
Numeric condition number.
Sigma <- cov(mtcars[, c("disp", "hp", "wt")]) cov_condition_number(Sigma)Sigma <- cov(mtcars[, c("disp", "hp", "wt")]) cov_condition_number(Sigma)
Provides diagnostic eigenvalue summaries for a covariance matrix.
cov_diagnostics(Sigma, tol = 1e-06)cov_diagnostics(Sigma, tol = 1e-06)
Sigma |
A covariance matrix. |
tol |
Threshold for effective rank. |
A list of covariance diagnostics.
Sigma <- cov(mtcars[, c("disp", "hp", "wt")]) cov_diagnostics(Sigma)Sigma <- cov(mtcars[, c("disp", "hp", "wt")]) cov_diagnostics(Sigma)
Computes the number of eigenvalues exceeding a threshold.
cov_effective_rank(Sigma, tol = 1e-06)cov_effective_rank(Sigma, tol = 1e-06)
Sigma |
A covariance matrix. |
tol |
Positive threshold. |
Effective rank.
Sigma <- cov(mtcars[, c("disp", "hp", "wt")]) cov_effective_rank(Sigma)Sigma <- cov(mtcars[, c("disp", "hp", "wt")]) cov_effective_rank(Sigma)
Computes a practical Ledoit-Wolf type shrinkage estimator toward a scaled identity target.
cov_lw(X)cov_lw(X)
X |
Numeric matrix or data frame. |
A covariance matrix.
X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) Sigma <- cov_lw(X) attr(Sigma, "shrinkage")X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) Sigma <- cov_lw(X) attr(Sigma, "shrinkage")
Computes a maximum-entropy motivated covariance estimator for SDR.
cov_mec( X, y, nslices = 6, response_type = c("continuous", "categorical", "survival"), delta = NULL, alpha = NULL, eps = 1e-06, ... )cov_mec( X, y, nslices = 6, response_type = c("continuous", "categorical", "survival"), delta = NULL, alpha = NULL, eps = 1e-06, ... )
X |
Numeric matrix or data frame. |
y |
Numeric response vector. |
nslices |
Number of response slices. |
response_type |
Response type. One of |
delta |
Optional event indicator for survival data. |
alpha |
Convex weight assigned to the entropy-maximising slice covariance. If NULL, alpha is chosen adaptively from the condition number of the pooled covariance. |
eps |
Small positive eigenvalue floor used for log-determinant stability. |
... |
Additional arguments passed to internal methods. |
The estimator uses response slicing to obtain slice-specific covariance matrices, selects the covariance matrix with maximum log-determinant entropy, and combines it with the pooled covariance matrix through convex shrinkage.
For censored survival responses, the function accepts delta and applies
a survival-aware response construction before slicing.
A covariance matrix with attributes containing the shrinkage weight and entropy diagnostics.
X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) Sigma <- cov_mec(X, y = mtcars$mpg, nslices = 4) attr(Sigma, "alpha") attr(Sigma, "entropy_slice")X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) Sigma <- cov_mec(X, y = mtcars$mpg, nslices = 4) attr(Sigma, "alpha") attr(Sigma, "entropy_slice")
Computes a simplified Oracle Approximating Shrinkage (OAS) covariance estimator for stabilising the sample covariance matrix.
cov_oas(X)cov_oas(X)
X |
Numeric matrix or data frame. |
A covariance matrix.
X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) Sigma <- cov_oas(X) attr(Sigma, "shrinkage")X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) Sigma <- cov_oas(X) attr(Sigma, "shrinkage")
Computes a convex shrinkage covariance estimator of the form
where is the sample covariance matrix and is a scaled identity target.
cov_ridge(X, lambda = 0.1)cov_ridge(X, lambda = 0.1)
X |
Numeric matrix or data frame. |
lambda |
Shrinkage intensity in |
A covariance matrix.
X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) cov_ridge(X, lambda = 0.2)X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) cov_ridge(X, lambda = 0.2)
Computes the usual unbiased sample covariance matrix.
cov_sample(X)cov_sample(X)
X |
Numeric matrix or data frame. |
A covariance matrix.
X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) cov_sample(X)X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) cov_sample(X)
Computes relative weights from any information criterion column.
criterion_weights( d_table, criterion = c("AIC", "BIC", "CAIC", "ICOMP", "CICOMP") )criterion_weights( d_table, criterion = c("AIC", "BIC", "CAIC", "ICOMP", "CICOMP") )
d_table |
Dimension selection table. |
criterion |
Criterion column name. |
Data frame with criterion differences and weights.
scores <- as.matrix(mtcars[, c("wt", "hp", "disp")]) dimension_table <- select_dimension(scores, mtcars$mpg, d_max = 2) criterion_weights(dimension_table, criterion = "BIC")scores <- as.matrix(mtcars[, c("wt", "hp", "disp")]) dimension_table <- select_dimension(scores, mtcars$mpg, d_max = 2) criterion_weights(dimension_table, criterion = "BIC")
Constructs low-rank sample-space scores without forming a p by p covariance matrix. This is useful when the number of predictors is very large.
dual_pca_scores( X, dual_rank = NULL, variance_explained = NULL, center = TRUE, scale_X = TRUE, eps = 1e-10 )dual_pca_scores( X, dual_rank = NULL, variance_explained = NULL, center = TRUE, scale_X = TRUE, eps = 1e-10 )
X |
Numeric predictor matrix with observations in rows. |
dual_rank |
Number of dual components to retain. |
variance_explained |
Optional cumulative variance threshold. |
center |
Logical; if TRUE, centre predictors. |
scale_X |
Logical; if TRUE, scale predictors. |
eps |
Numerical tolerance. |
A list containing scores, loadings, singular values, centre, scale, and retained rank.
Dispatches to the requested covariance estimator. For MEC, the function
supports continuous, categorical, and censored survival responses by passing
response_type and delta to cov_mec().
estimate_cov( X, y = NULL, method = c("sample", "ridge", "oas", "lw", "mec"), nslices = 6, response_type = c("continuous", "categorical", "survival"), delta = NULL, ... )estimate_cov( X, y = NULL, method = c("sample", "ridge", "oas", "lw", "mec"), nslices = 6, response_type = c("continuous", "categorical", "survival"), delta = NULL, ... )
X |
Numeric matrix or data frame. |
y |
Optional response vector required for MEC. |
method |
Covariance estimator. |
nslices |
Number of slices for MEC. |
response_type |
Response type. One of |
delta |
Optional event indicator for survival data. |
... |
Additional arguments passed to internal covariance estimators. |
A covariance matrix.
X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) estimate_cov(X, method = "oas") estimate_cov( X, y = mtcars$mpg, method = "mec", nslices = 4 )X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) estimate_cov(X, method = "oas") estimate_cov( X, y = mtcars$mpg, method = "mec", nslices = 4 )
Computes common prediction metrics.
evaluate_prediction(y_true, y_pred, d = NULL)evaluate_prediction(y_true, y_pred, d = NULL)
y_true |
Observed response values. |
y_pred |
Predicted response values. |
d |
Optional number of reduced predictors. |
A data frame of prediction metrics.
evaluate_prediction( y_true = c(2, 4, 6, 8, 10), y_pred = c(2.2, 3.8, 5.7, 8.1, 9.8), d = 1 )evaluate_prediction( y_true = c(2, 4, 6, 8, 10), y_pred = c(2.2, 3.8, 5.7, 8.1, 9.8), d = 1 )
Repeats V-fold cross-validation for a fixed SDR and covariance-estimator combination. Failed folds are retained with diagnostic messages.
evaluate_prediction_cv( X, y, sdr_method = c("dr", "sir", "save", "phd"), cov_method = c("sample", "ridge", "oas", "lw", "mec"), d, v = 5, repeats = 10, nslices = 6, standardize = TRUE, stabilize = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), seed = NULL, cov_args = list(), stabilization_args = list(), sdr_args = list(), ... )evaluate_prediction_cv( X, y, sdr_method = c("dr", "sir", "save", "phd"), cov_method = c("sample", "ridge", "oas", "lw", "mec"), d, v = 5, repeats = 10, nslices = 6, standardize = TRUE, stabilize = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), seed = NULL, cov_args = list(), stabilization_args = list(), sdr_args = list(), ... )
X |
Numeric predictor matrix or data frame. |
y |
Numeric continuous response vector. |
sdr_method |
SDR method. |
cov_method |
Covariance estimator. |
d |
Fixed structural dimension. |
v |
Number of folds. |
repeats |
Number of cross-validation repetitions. |
nslices |
Number of response slices. |
standardize |
Logical. Standardise within each training fold. |
stabilize |
Logical. Stabilise the estimated covariance matrix. |
stabilization |
Covariance stabilisation method. |
seed |
Optional random seed. |
cov_args |
Named list of covariance-estimator arguments. |
stabilization_args |
Named list of stabilisation arguments. |
sdr_args |
Named list of SDR-kernel arguments. |
... |
Backward-compatible component arguments. |
A list containing a one-row summary and fold-level results.
Extract SDR loadings
extract_loadings(directions, variables = NULL)extract_loadings(directions, variables = NULL)
directions |
Matrix of SDR directions. |
variables |
Variable names. |
A data frame of loadings.
Removes predictors with variance below a specified quantile.
filter_low_variance(X, variance_quantile = 0.25)filter_low_variance(X, variance_quantile = 0.25)
X |
Predictor matrix. |
variance_quantile |
Quantile threshold. |
Filtered matrix.
Fits a linear regression model using the first d SDR scores.
fit_downstream_lm(scores, y, d)fit_downstream_lm(scores, y, d)
scores |
Matrix of SDR scores. |
y |
Numeric response vector. |
d |
Structural dimension. |
A fitted lm object.
scores <- as.matrix(mtcars[, c("wt", "hp")]) fit_downstream_lm(scores, y = mtcars$mpg, d = 2)scores <- as.matrix(mtcars[, c("wt", "hp")]) fit_downstream_lm(scores, y = mtcars$mpg, d = 2)
Fits sufficient dimension reduction models with optional covariance regularisation and information-theoretic structural dimension selection.
fit_risdr( X, y, sdr_method = c("dr", "sir", "save", "phd"), cov_method = c("sample", "ridge", "oas", "lw", "mec"), stabilize = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), nslices = 6, d = NULL, d_max = 10, selector = c("cicomp", "icomp", "bic", "caic", "aic"), standardize = TRUE, complexity = c("C1", "C1F"), cov_args = list(), stabilization_args = list(), sdr_args = list(), ... )fit_risdr( X, y, sdr_method = c("dr", "sir", "save", "phd"), cov_method = c("sample", "ridge", "oas", "lw", "mec"), stabilize = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), nslices = 6, d = NULL, d_max = 10, selector = c("cicomp", "icomp", "bic", "caic", "aic"), standardize = TRUE, complexity = c("C1", "C1F"), cov_args = list(), stabilization_args = list(), sdr_args = list(), ... )
X |
Numeric predictor matrix or data frame. |
y |
Numeric continuous response vector. |
sdr_method |
SDR method: "dr", "sir", "save", or "phd". |
cov_method |
Covariance estimator: "sample", "ridge", "oas", "lw", or "mec". |
stabilize |
Logical. If TRUE, stabilises the estimated covariance matrix. |
stabilization |
Stabilisation method. |
nslices |
Number of slices for inverse regression methods. |
d |
Optional structural dimension. If NULL, selected by criterion. |
d_max |
Maximum candidate structural dimension. |
selector |
Criterion for selecting d. |
standardize |
Logical. If TRUE, column-standardises X before covariance estimation. |
complexity |
Complexity measure for ICOMP: "C1" or "C1F". |
cov_args |
Named list of arguments for the selected covariance estimator. |
stabilization_args |
Named list of arguments for covariance stabilisation. |
sdr_args |
Named list of arguments for the selected SDR kernel. |
... |
Backward-compatible component arguments. New code should use the three explicit argument lists. |
An object of class "risdr".
simulated <- simulate_risdr_data( n = 60, p = 6, d = 2, seed = 2026 ) fit <- fit_risdr( X = simulated$X, y = simulated$y, sdr_method = "sir", cov_method = "oas", nslices = 4, d = 1, d_max = 3 ) fitsimulated <- simulate_risdr_data( n = 60, p = 6, d = 2, seed = 2026 ) fit <- fit_risdr( X = simulated$X, y = simulated$y, sdr_method = "sir", cov_method = "oas", nslices = 4, d = 1, d_max = 3 ) fit
Constructs a low-rank PCA score representation, fits the unified RISDR core in that score space, maps the dense and selected sparse SDR directions back to the original predictor coordinates, and ranks variables using the Euclidean loading norm across only the selected sparse directions.
fit_risdr_dual( X, y, delta = NULL, response_type = c("continuous", "categorical", "survival"), dual_rank = 100L, variance_explained = NULL, d = NULL, d_max = 10L, nslices = 4L, sdr_method = c("dr", "sir", "save", "phd"), cov_method = c("mec", "oas", "lw", "sample", "ridge"), selector = c("cicomp", "icomp", "aic", "caic", "bic"), lambda_grid = seq(0, 0.3, length.out = 10L), adapt_weights = TRUE, weight_mode = c("c1f", "inverse_c1f", "uniform"), support_penalty = FALSE, standardize_dual = TRUE, gene_select_top = NULL, gene_select_quantile = 0.99, center = TRUE, scale_X = TRUE, verbose = TRUE, ... )fit_risdr_dual( X, y, delta = NULL, response_type = c("continuous", "categorical", "survival"), dual_rank = 100L, variance_explained = NULL, d = NULL, d_max = 10L, nslices = 4L, sdr_method = c("dr", "sir", "save", "phd"), cov_method = c("mec", "oas", "lw", "sample", "ridge"), selector = c("cicomp", "icomp", "aic", "caic", "bic"), lambda_grid = seq(0, 0.3, length.out = 10L), adapt_weights = TRUE, weight_mode = c("c1f", "inverse_c1f", "uniform"), support_penalty = FALSE, standardize_dual = TRUE, gene_select_top = NULL, gene_select_quantile = 0.99, center = TRUE, scale_X = TRUE, verbose = TRUE, ... )
X |
Numeric high-dimensional predictor matrix. |
y |
Response vector. For survival data, observed time. |
delta |
Optional 0/1 event indicator. |
response_type |
One of |
dual_rank |
Maximum retained PCA rank. |
variance_explained |
Optional cumulative variance threshold. |
d |
Optional fixed structural dimension. If |
d_max |
Maximum candidate structural dimension. |
nslices |
Number of slices, or slices per censoring-status group. |
sdr_method |
SDR method. |
cov_method |
Covariance method. |
selector |
Information criterion used to select |
lambda_grid |
Sparsity tuning grid. |
adapt_weights |
Logical. Use adaptive penalty weights. |
weight_mode |
Adaptive weighting mode. |
support_penalty |
Logical. Include active support in criterion df. |
standardize_dual |
Logical. Standardise retained PCA scores inside
|
gene_select_top |
Optional number of top-ranked variables. |
gene_select_quantile |
Quantile used when |
center |
Logical. Centre predictors before dual PCA. |
scale_X |
Logical. Scale predictors before dual PCA. |
verbose |
Logical. Emit progress messages. |
... |
Additional arguments passed to |
The inner RISDR standardisation scale is explicitly undone before mapping directions through the PCA loadings. The returned reduced predictors are taken directly from the fitted core and are therefore exactly aligned with the model used for information-criterion selection.
This entry point uses the frozen sparse thesis engine. The
existing fit_risdr() and fit_risdr_realdata() interfaces retain their
continuous-response behaviour from version 0.3.1. Survival fits use Efron
Cox partial likelihood. Apparent fit statistics and loading ranks are
exploratory and do not establish external predictive validity.
An object of class risdr_dual.
set.seed(2026) X <- matrix(rnorm(80 * 6), 80) colnames(X) <- paste0("G", 1:6) time <- rexp(80, rate = exp(0.5 * X[, 1])) delta <- rep(c(0L, 1L), 40) fit <- fit_risdr_dual( X, time, delta = delta, response_type = "survival", sdr_method = "sir", cov_method = "oas", nslices = 4, dual_rank = 4, verbose = FALSE, d_max = 2, lambda_grid = c(0, 0.05) ) fit$d predict(fit, X[1:2, , drop = FALSE], type = "risk")set.seed(2026) X <- matrix(rnorm(80 * 6), 80) colnames(X) <- paste0("G", 1:6) time <- rexp(80, rate = exp(0.5 * X[, 1])) delta <- rep(c(0L, 1L), 40) fit <- fit_risdr_dual( X, time, delta = delta, response_type = "survival", sdr_method = "sir", cov_method = "oas", nslices = 4, dual_rank = 4, verbose = FALSE, d_max = 2, lambda_grid = c(0, 0.05) ) fit$d predict(fit, X[1:2, , drop = FALSE], type = "risk")
Fit RISDR to real high-dimensional data
fit_risdr_realdata( X, y, delta = NULL, response_type = c("continuous", "binary", "multiclass", "survival"), variance_quantile = 0.25, d = NULL, ... )fit_risdr_realdata( X, y, delta = NULL, response_type = c("continuous", "binary", "multiclass", "survival"), variance_quantile = 0.25, d = NULL, ... )
X |
Predictor matrix. |
y |
Response vector. |
delta |
Optional survival censoring indicator. |
response_type |
Response type. |
variance_quantile |
Variance filtering threshold. |
d |
Optional fixed structural dimension passed to |
... |
Additional arguments passed to fit_risdr(). |
Fitted RISDR workflow object.
Fits an SDR model using a regularised covariance estimator, a selected inverse-regression kernel, adaptive sparse direction estimation, and information-criterion profiling jointly over structural dimension and sparsity tuning parameter.
fit_risdr_sparse( X, y, delta = NULL, response_type = c("continuous", "categorical", "survival"), sdr_method = c("dr", "sir", "save", "phd"), cov_method = c("mec", "oas", "lw", "sample", "ridge", "user"), stabilize = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), nslices = 6L, d = NULL, d_max = 10L, selector = c("cicomp", "icomp", "bic", "caic", "aic"), standardize = TRUE, complexity = "C1F", lambda_grid = seq(0, 0.3, length.out = 10L), adapt_weights = TRUE, weight_mode = c("c1f", "inverse_c1f", "uniform"), penalty_weights = NULL, support_penalty = FALSE, cov_fun = NULL, shrinkage = 1e-04, tol = 1e-10, ... )fit_risdr_sparse( X, y, delta = NULL, response_type = c("continuous", "categorical", "survival"), sdr_method = c("dr", "sir", "save", "phd"), cov_method = c("mec", "oas", "lw", "sample", "ridge", "user"), stabilize = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), nslices = 6L, d = NULL, d_max = 10L, selector = c("cicomp", "icomp", "bic", "caic", "aic"), standardize = TRUE, complexity = "C1F", lambda_grid = seq(0, 0.3, length.out = 10L), adapt_weights = TRUE, weight_mode = c("c1f", "inverse_c1f", "uniform"), penalty_weights = NULL, support_penalty = FALSE, cov_fun = NULL, shrinkage = 1e-04, tol = 1e-10, ... )
X |
Numeric predictor matrix or data frame. |
y |
Response vector. For survival data, observed survival time. |
delta |
Optional 0/1 event indicator for survival data. |
response_type |
One of |
sdr_method |
One of |
cov_method |
One of |
stabilize |
Logical. Stage-3 thesis fits require covariance
stabilisation and therefore currently require |
stabilization |
Stabilisation method passed to |
nslices |
Number of response slices, or slices per censoring-status group for survival data. |
d |
Optional fixed structural dimension. If |
d_max |
Maximum candidate structural dimension. |
selector |
One of |
standardize |
Logical. Standardise predictor columns before fitting. |
complexity |
Retained for compatibility. The Stage-3 thesis engine uses the scale-invariant C1F complexity in ICOMP/CICOMP. |
lambda_grid |
Non-negative sparsity tuning grid. |
adapt_weights |
Logical. Use covariance-derived adaptive weights. |
weight_mode |
One of |
penalty_weights |
Optional user-supplied variable-level weights. |
support_penalty |
Logical. If |
cov_fun |
Optional user-defined covariance estimator. |
shrinkage |
Ridge shrinkage parameter used by |
tol |
Numerical tolerance. |
... |
Additional arguments passed only to a user covariance estimator. |
For d = NULL, every candidate dimension from 1 through d_max is
evaluated over the complete lambda_grid. The requested selector then
chooses the final (d, lambda) pair. For explicit d, the same audit grid
is retained but the final dimension is fixed and only lambda is selected
within that dimension.
This entry point uses the frozen sparse thesis engine. The
existing fit_risdr() and fit_risdr_realdata() interfaces retain their
continuous-response behaviour from version 0.3.1. Survival fits use Efron
Cox partial likelihood. Apparent fit statistics and loading ranks are
exploratory and do not establish external predictive validity.
An object of class risdr containing the complete (d, lambda)
selection grid, profiled dimension table, selected sparse directions,
reduced predictors, covariance diagnostics, and compatibility fields.
set.seed(2026) X <- matrix(rnorm(80 * 6), 80) colnames(X) <- paste0("G", 1:6) time <- rexp(80, rate = exp(0.5 * X[, 1])) delta <- rep(c(0L, 1L), 40) fit <- fit_risdr_sparse( X, time, delta = delta, response_type = "survival", sdr_method = "sir", cov_method = "oas", nslices = 4, d_max = 2, lambda_grid = c(0, 0.05) ) fit$d predict(fit, X[1:2, , drop = FALSE], type = "risk")set.seed(2026) X <- matrix(rnorm(80 * 6), 80) colnames(X) <- paste0("G", 1:6) time <- rexp(80, rate = exp(0.5 * X[, 1])) delta <- rep(c(0L, 1L), 40) fit <- fit_risdr_sparse( X, time, delta = delta, response_type = "survival", sdr_method = "sir", cov_method = "oas", nslices = 4, d_max = 2, lambda_grid = c(0, 0.05) ) fit$d predict(fit, X[1:2, , drop = FALSE], type = "risk")
Fit RISDR to real high-dimensional data
fit_risdr_sparse_realdata( X, y, delta = NULL, response_type = c("continuous", "binary", "multiclass", "categorical", "survival"), variance_quantile = 0.25, ... )fit_risdr_sparse_realdata( X, y, delta = NULL, response_type = c("continuous", "binary", "multiclass", "categorical", "survival"), variance_quantile = 0.25, ... )
X |
Predictor matrix. |
y |
Response vector. |
delta |
Optional survival censoring indicator. |
response_type |
Response type. |
variance_quantile |
Variance filtering threshold. |
... |
Additional arguments passed to fit_risdr_sparse(). |
This entry point uses the frozen sparse thesis engine. The
existing fit_risdr() and fit_risdr_realdata() interfaces retain their
continuous-response behaviour from version 0.3.1. Survival fits use Efron
Cox partial likelihood. Apparent fit statistics and loading ranks are
exploratory and do not establish external predictive validity.
Fitted RISDR workflow object. Fit RISDR to a real-data predictor matrix
Applies outcome cleaning, low-variance screening, the unified RISDR core, and descriptive loading-based variable ranking. The wrapper returns the reduced predictors computed by the core itself so that centring and standardisation are not silently bypassed.
"multiclass", "categorical", or "survival".
low-variance screen.
An object of class risdr_realdata.
Accepts either an explicit dense direction matrix or a historical kernel
object containing directions or vectors.
fit_sparse_grid( kernel_obj = NULL, directions = NULL, d = 2L, lambda_grid = seq(0, 0.5, length.out = 25L), penalty_weights = NULL, adapt_weights = FALSE, Sigma = NULL, weight_mode = c("c1f", "inverse_c1f", "uniform"), tol = 1e-10 )fit_sparse_grid( kernel_obj = NULL, directions = NULL, d = 2L, lambda_grid = seq(0, 0.5, length.out = 25L), penalty_weights = NULL, adapt_weights = FALSE, Sigma = NULL, weight_mode = c("c1f", "inverse_c1f", "uniform"), tol = 1e-10 )
kernel_obj |
Optional historical kernel object. |
directions |
Optional dense direction matrix. |
d |
Structural dimension. |
lambda_grid |
Numeric vector of tuning values. |
penalty_weights |
Optional user-supplied penalty weights. |
adapt_weights |
Logical; derive weights from |
Sigma |
Optional covariance matrix. |
weight_mode |
Adaptive weighting mode. |
tol |
Numerical tolerance. |
Sparse-grid object.
Mean absolute error
mae(y_true, y_pred)mae(y_true, y_pred)
y_true |
Observed response values. |
y_pred |
Predicted response values. |
Numeric MAE.
mae(c(2, 4, 6, 8), c(2.2, 3.8, 5.7, 8.1))mae(c(2, 4, 6, 8), c(2.2, 3.8, 5.7, 8.1))
Create cross-validation folds
make_cv_folds(n, v = 5, seed = NULL)make_cv_folds(n, v = 5, seed = NULL)
n |
Sample size. |
v |
Number of folds. |
seed |
Optional random seed. |
Integer vector of fold memberships.
Constructs response slices for inverse regression-based sufficient dimension reduction methods.
make_slices(y, nslices = 6, type = c("quantile", "equal_width"))make_slices(y, nslices = 6, type = c("quantile", "equal_width"))
y |
Numeric continuous response vector. |
nslices |
Number of slices. |
type |
Slicing strategy. Currently supports "quantile" and "equal_width". |
Integer vector of slice memberships.
slices <- make_slices(mtcars$mpg, nslices = 4) table(slices)slices <- make_slices(mtcars$mpg, nslices = 4) table(slices)
Mean absolute percentage error
mape(y_true, y_pred)mape(y_true, y_pred)
y_true |
Observed response values. |
y_pred |
Predicted response values. |
Numeric MAPE.
mape(c(2, 4, 6, 8), c(2.2, 3.8, 5.7, 8.1))mape(c(2, 4, 6, 8), c(2.2, 3.8, 5.7, 8.1))
Plot cross-validation dimension selection result
plot_cv_dimension(cv, metric = NULL, ...)plot_cv_dimension(cv, metric = NULL, ...)
cv |
Object returned by select_dimension_cv(). |
metric |
Metric to plot. |
... |
Additional arguments passed to internal methods. |
Invisibly returns the CV table.
Plot dimension selection criteria
plot_dimension_selection( fit, criteria = c("AIC", "BIC", "CAIC", "ICOMP", "CICOMP"), ... )plot_dimension_selection( fit, criteria = c("AIC", "BIC", "CAIC", "ICOMP", "CICOMP"), ... )
fit |
Object of class "risdr". |
criteria |
Character vector of criteria to plot. |
... |
Additional graphical arguments passed to |
Invisibly returns dimension table.
Plot ladle dimension diagnostic
plot_ladle(ladle, ...)plot_ladle(ladle, ...)
ladle |
Object returned by select_dimension_ladle(). |
... |
Additional graphical arguments passed to |
Invisibly returns ladle table.
Displays the largest absolute loadings for a selected SDR direction.
plot_loadings(fit, direction = 1, top = 15, ...)plot_loadings(fit, direction = 1, top = 15, ...)
fit |
Object of class "risdr". |
direction |
Direction index. |
top |
Number of variables to display. |
... |
Additional graphical arguments passed to |
Invisibly returns loading table.
Plots observed versus predicted values.
plot_prediction(y_true, y_pred, ...)plot_prediction(y_true, y_pred, ...)
y_true |
Observed response values. |
y_pred |
Predicted response values. |
... |
Additional graphical arguments passed to |
Invisibly returns plotted data.
Plots residuals against predicted values.
plot_residuals(y_true, y_pred, ...)plot_residuals(y_true, y_pred, ...)
y_true |
Observed response values. |
y_pred |
Predicted response values. |
... |
Additional graphical arguments passed to |
Invisibly returns plotted data.
Scree plot of SDR eigenvalues
plot_scree(fit, n_eigen = 20, type = "b", ...)plot_scree(fit, n_eigen = 20, type = "b", ...)
fit |
Object of class "risdr". |
n_eigen |
Number of eigenvalues to display. |
type |
Plot type passed to base R plot(). |
... |
Additional graphical arguments passed to |
Invisibly returns eigenvalues plotted.
Plots the response against a selected SDR direction.
plot_sufficient(fit, direction = 1, ...)plot_sufficient(fit, direction = 1, ...)
fit |
Object of class "risdr". |
direction |
SDR direction to plot. |
... |
Additional graphical arguments passed to |
Invisibly returns plotted data.
Plots the first two selected SDR scores, optionally coloured by response.
plot_sufficient2d( fit, directions = c(1, 2), colour_by_y = TRUE, groups = 4, ... )plot_sufficient2d( fit, directions = c(1, 2), colour_by_y = TRUE, groups = 4, ... )
fit |
Object of class "risdr". |
directions |
Integer vector of length 2. |
colour_by_y |
Logical. If TRUE, colours points by response quantile group. |
groups |
Number of response colour groups. |
... |
Additional graphical arguments passed to |
Invisibly returns plotted data.
Predict from downstream SDR regression model
predict_downstream_lm(fit_lm, scores_new, d)predict_downstream_lm(fit_lm, scores_new, d)
fit_lm |
Fitted linear model from fit_downstream_lm(). |
scores_new |
Matrix of new SDR scores. |
d |
Structural dimension. |
Numeric vector of predictions.
Predict method for risdr objects
## S3 method for class 'risdr' predict(object, newX, d = NULL, ...)## S3 method for class 'risdr' predict(object, newX, d = NULL, ...)
object |
Object of class "risdr". |
newX |
New predictor matrix or data frame. |
d |
Optional structural dimension. |
... |
Additional arguments passed to internal methods. |
Numeric vector of predictions.
simulated <- simulate_risdr_data( n = 60, p = 6, d = 2, seed = 2026 ) fit <- fit_risdr( X = simulated$X, y = simulated$y, sdr_method = "sir", cov_method = "oas", nslices = 4, d = 1, d_max = 3 ) predict(fit, newX = simulated$X[1:5, , drop = FALSE])simulated <- simulate_risdr_data( n = 60, p = 6, d = 2, seed = 2026 ) fit <- fit_risdr( X = simulated$X, y = simulated$y, sdr_method = "sir", cov_method = "oas", nslices = 4, d = 1, d_max = 3 ) predict(fit, newX = simulated$X[1:5, , drop = FALSE])
Projects new observations using the training centring, scaling, and selected directions. Survival predictions are Cox linear predictors or relative risks; they are not predicted survival times.
## S3 method for class 'risdr_sparse' predict( object, newX, type = c("response", "scores", "link", "risk", "class", "probs"), ... ) ## S3 method for class 'risdr_dual' predict( object, newX, type = c("response", "scores", "link", "risk", "class", "probs"), ... )## S3 method for class 'risdr_sparse' predict( object, newX, type = c("response", "scores", "link", "risk", "class", "probs"), ... ) ## S3 method for class 'risdr_dual' predict( object, newX, type = c("response", "scores", "link", "risk", "class", "probs"), ... )
object |
A sparse or dual RISDR fit. |
newX |
Numeric predictor matrix or data frame, with named columns. |
type |
Prediction type. |
... |
Additional arguments passed to the downstream prediction method. |
Predictions or a score matrix, according to type.
Prediction correlation
prediction_correlation(y_true, y_pred)prediction_correlation(y_true, y_pred)
y_true |
Observed response values. |
y_pred |
Predicted response values. |
Pearson correlation.
prediction_correlation( c(2, 4, 6, 8), c(2.2, 3.8, 5.7, 8.1) )prediction_correlation( c(2, 4, 6, 8), c(2.2, 3.8, 5.7, 8.1) )
Prepare survival response
prepare_survival_response(time, delta)prepare_survival_response(time, delta)
time |
Survival time vector. |
delta |
Event indicator vector. |
Cleaned survival response list.
Print risdr object
## S3 method for class 'risdr' print(x, ...)## S3 method for class 'risdr' print(x, ...)
x |
Object of class "risdr". |
... |
Additional arguments passed to internal methods. |
Invisibly returns x.
Print method for dual RISDR objects
## S3 method for class 'risdr_dual' print(x, ...)## S3 method for class 'risdr_dual' print(x, ...)
x |
Object of class |
... |
Additional arguments passed to internal methods. |
Print real-data RISDR workflow
## S3 method for class 'risdr_realdata' print(x, ...)## S3 method for class 'risdr_realdata' print(x, ...)
x |
Object of class risdr_realdata. |
... |
Additional arguments. |
Invisibly returns x.
Print risdr object
## S3 method for class 'risdr_sparse' print(x, ...)## S3 method for class 'risdr_sparse' print(x, ...)
x |
Object of class "risdr". |
... |
Additional arguments passed to internal methods. |
Invisibly returns x.
Print real-data RISDR workflow
## S3 method for class 'risdr_sparse_realdata' print(x, ...)## S3 method for class 'risdr_sparse_realdata' print(x, ...)
x |
Object of class risdr_realdata. |
... |
Additional arguments. |
Print summary of risdr object
## S3 method for class 'summary.risdr' print(x, ...)## S3 method for class 'summary.risdr' print(x, ...)
x |
Object of class "summary.risdr". |
... |
Additional arguments passed to internal methods. |
Invisibly returns x.
Print summary of risdr object
## S3 method for class 'summary.risdr_sparse' print(x, ...)## S3 method for class 'summary.risdr_sparse' print(x, ...)
x |
Object of class "summary.risdr_sparse". |
... |
Additional arguments passed to internal methods. |
Invisibly returns x.
Projection matrix
projection_matrix(B)projection_matrix(B)
B |
Basis matrix. |
Projection matrix.
B <- matrix(c(1, 0, 0, 0, 1, 0), nrow = 3) projection_matrix(B)B <- matrix(c(1, 0, 0, 0, 1, 0), nrow = 3) projection_matrix(B)
Coefficient of determination
r_squared(y_true, y_pred)r_squared(y_true, y_pred)
y_true |
Observed response values. |
y_pred |
Predicted response values. |
Numeric R-squared.
r_squared(c(2, 4, 6, 8), c(2.2, 3.8, 5.7, 8.1))r_squared(c(2, 4, 6, 8), c(2.2, 3.8, 5.7, 8.1))
Root mean squared error
rmse(y_true, y_pred)rmse(y_true, y_pred)
y_true |
Observed response values. |
y_pred |
Predicted response values. |
Numeric RMSE.
rmse(c(2, 4, 6, 8), c(2.2, 3.8, 5.7, 8.1))rmse(c(2, 4, 6, 8), c(2.2, 3.8, 5.7, 8.1))
Run one SDR simulation replication
run_one_simulation( n = 200, p = 50, d = 2, rho = 0.6, sigma = 1, model = "linear_quadratic", beta_type = "coordinate", sdr_method = "dr", cov_method = "oas", nslices = 6, selector = "cicomp", d_max = 10, seed = NULL )run_one_simulation( n = 200, p = 50, d = 2, rho = 0.6, sigma = 1, model = "linear_quadratic", beta_type = "coordinate", sdr_method = "dr", cov_method = "oas", nslices = 6, selector = "cicomp", d_max = 10, seed = NULL )
n |
Sample size. |
p |
Number of predictors. |
d |
Structural dimension. |
rho |
Correlation parameter. |
sigma |
Error standard deviation. |
model |
Data-generating model. |
beta_type |
Type of true central subspace basis. |
sdr_method |
SDR method. |
cov_method |
Covariance method. |
nslices |
Number of slices. |
selector |
Dimension selection criterion. |
d_max |
Maximum candidate dimension. |
seed |
Optional random seed. The test sample uses |
A data frame with simulation results.
Run SDR simulation study
run_risdr_simulation( R = 200, rho_values = c(0.3, 0.6, 0.9), methods = c("sir", "save", "dr", "phd"), cov_methods = c("sample", "oas", "mec"), seed = NULL, ... )run_risdr_simulation( R = 200, rho_values = c(0.3, 0.6, 0.9), methods = c("sir", "save", "dr", "phd"), cov_methods = c("sample", "oas", "mec"), seed = NULL, ... )
R |
Number of replications. |
rho_values |
Correlation values. |
methods |
SDR methods. |
cov_methods |
Covariance methods. |
seed |
Optional starting seed for reproducible replications. |
... |
Additional arguments passed to |
Data frame of simulation results.
Fits linear models on SDR scores for candidate dimensions and computes information criteria.
select_dimension( scores, y, d_max = 10, complexity = c("C1", "C1F"), eps = 1e-10 )select_dimension( scores, y, d_max = 10, complexity = c("C1", "C1F"), eps = 1e-10 )
scores |
Matrix of SDR scores. |
y |
Numeric response vector. |
d_max |
Maximum candidate dimension. |
complexity |
Complexity measure for ICOMP. |
eps |
Eigenvalue floor. |
A data frame of criteria by candidate dimension.
scores <- as.matrix(mtcars[, c("wt", "hp", "disp")]) dimension_table <- select_dimension( scores = scores, y = mtcars$mpg, d_max = 2 ) dimension_tablescores <- as.matrix(mtcars[, c("wt", "hp", "disp")]) dimension_table <- select_dimension( scores = scores, y = mtcars$mpg, d_max = 2 ) dimension_table
Selects structural dimension by V-fold cross-validation. For each candidate dimension, SDR is fitted on the training folds, a downstream linear regression is fitted using the reduced predictors, and prediction error is evaluated on the validation fold.
select_dimension_cv( X, y, sdr_method = c("dr", "sir", "save", "phd"), cov_method = c("sample", "ridge", "oas", "lw", "mec"), d_max = 10, v = 5, nslices = 6, standardize = TRUE, stabilize = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), metric = c("RMSE", "MAE"), seed = NULL, cov_args = list(), stabilization_args = list(), sdr_args = list(), ... )select_dimension_cv( X, y, sdr_method = c("dr", "sir", "save", "phd"), cov_method = c("sample", "ridge", "oas", "lw", "mec"), d_max = 10, v = 5, nslices = 6, standardize = TRUE, stabilize = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), metric = c("RMSE", "MAE"), seed = NULL, cov_args = list(), stabilization_args = list(), sdr_args = list(), ... )
X |
Numeric predictor matrix or data frame. |
y |
Numeric continuous response vector. |
sdr_method |
SDR method. |
cov_method |
Covariance estimator. |
d_max |
Maximum candidate structural dimension. |
v |
Number of folds. |
nslices |
Number of slices. |
standardize |
Logical. If TRUE, standardises predictors inside each training fold. |
stabilize |
Logical. If TRUE, stabilises covariance matrix. |
stabilization |
Stabilisation method. |
metric |
Prediction metric used for selection. |
seed |
Optional random seed. |
cov_args |
Named list of arguments for the covariance estimator. |
stabilization_args |
Named list of arguments for covariance stabilisation. |
sdr_args |
Named list of arguments for the SDR kernel. |
... |
Backward-compatible component arguments. |
A list containing the CV table, selected dimension, and fold-level results.
Combines out-of-fold prediction error with rescaled BIC, CAIC, or CICOMP
penalties. The tuning constant lambda controls the contribution of the
information-criterion component.
select_dimension_cv_icomp( X, y, sdr_method = c("dr", "sir", "save", "phd"), cov_method = c("sample", "ridge", "oas", "lw", "mec"), d_max = 10, v = 5, nslices = 6, standardize = TRUE, stabilize = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), complexity = c("C1", "C1F"), lambda = 1, seed = NULL, cov_args = list(), stabilization_args = list(), sdr_args = list(), ... )select_dimension_cv_icomp( X, y, sdr_method = c("dr", "sir", "save", "phd"), cov_method = c("sample", "ridge", "oas", "lw", "mec"), d_max = 10, v = 5, nslices = 6, standardize = TRUE, stabilize = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), complexity = c("C1", "C1F"), lambda = 1, seed = NULL, cov_args = list(), stabilization_args = list(), sdr_args = list(), ... )
X |
Numeric predictor matrix or data frame. |
y |
Numeric continuous response vector. |
sdr_method |
SDR method. |
cov_method |
Covariance estimator. |
d_max |
Maximum candidate structural dimension. |
v |
Number of cross-validation folds. |
nslices |
Number of response slices. |
standardize |
Logical. Standardise within each training fold. |
stabilize |
Logical. Stabilise the estimated covariance matrix. |
stabilization |
Covariance stabilisation method. |
complexity |
Covariance complexity measure. |
lambda |
Non-negative information-criterion weight. |
seed |
Optional random seed. |
cov_args |
Named list of covariance-estimator arguments. |
stabilization_args |
Named list of stabilisation arguments. |
sdr_args |
Named list of SDR-kernel arguments. |
... |
Backward-compatible component arguments. |
A list containing selected dimensions, the aggregated cross-validation table, and fold-level results.
Computes a simple ladle-type diagnostic by combining normalised eigenvalue information with a bootstrap-based subspace instability measure.
select_dimension_ladle( X, y, sdr_method = c("dr", "sir", "save", "phd"), cov_method = c("sample", "ridge", "oas", "lw", "mec"), d_max = 10, B = 100, nslices = 6, standardize = TRUE, stabilize = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), seed = NULL, cov_args = list(), stabilization_args = list(), sdr_args = list(), ... )select_dimension_ladle( X, y, sdr_method = c("dr", "sir", "save", "phd"), cov_method = c("sample", "ridge", "oas", "lw", "mec"), d_max = 10, B = 100, nslices = 6, standardize = TRUE, stabilize = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), seed = NULL, cov_args = list(), stabilization_args = list(), sdr_args = list(), ... )
X |
Numeric predictor matrix or data frame. |
y |
Numeric continuous response vector. |
sdr_method |
SDR method. |
cov_method |
Covariance estimator. |
d_max |
Maximum candidate structural dimension. |
B |
Number of bootstrap replications. |
nslices |
Number of slices. |
standardize |
Logical. If TRUE, standardises predictors. |
stabilize |
Logical. If TRUE, stabilises covariance matrix. |
stabilization |
Stabilisation method. |
seed |
Optional random seed. |
cov_args |
Named list of covariance-estimator arguments. |
stabilization_args |
Named list of stabilisation arguments. |
sdr_args |
Named list of SDR-kernel arguments. |
... |
Backward-compatible component arguments. |
A list containing ladle table, selected dimension, and bootstrap distances.
Simulates data from a sufficient dimension reduction model with an autoregressive covariance structure. The function returns the true orthonormal central subspace basis, which allows simulation studies to evaluate both prediction accuracy and subspace recovery.
simulate_risdr_data( n = 200, p = 50, d = 2, rho = 0.6, sigma = 1, signal_strength = 1, model = c("linear_quadratic", "symmetric", "interaction", "linear"), beta_type = c("coordinate", "random_sparse", "random_dense"), beta = NULL, seed = NULL )simulate_risdr_data( n = 200, p = 50, d = 2, rho = 0.6, sigma = 1, signal_strength = 1, model = c("linear_quadratic", "symmetric", "interaction", "linear"), beta_type = c("coordinate", "random_sparse", "random_dense"), beta = NULL, seed = NULL )
n |
Sample size. |
p |
Number of predictors. |
d |
Structural dimension. |
rho |
AR(1) correlation parameter. |
sigma |
Error standard deviation. |
signal_strength |
Multiplicative strength of the regression signal. |
model |
Data-generating model. |
beta_type |
Type of true central subspace basis. |
beta |
Optional user-supplied |
seed |
Optional random seed. |
A list containing the simulated predictors, response, true basis, latent sufficient predictors, population covariance matrix, signal, error, and simulation settings.
simulated <- simulate_risdr_data( n = 60, p = 6, d = 2, rho = 0.4, seed = 2026 ) dim(simulated$X) head(simulated$y) crossprod(simulated$beta)simulated <- simulate_risdr_data( n = 60, p = 6, d = 2, rho = 0.4, seed = 2026 ) dim(simulated$X) head(simulated$y) crossprod(simulated$beta)
Computes slice-specific covariance matrices.
slice_covariances( X, slices, stabilize = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), eps = 1e-06 )slice_covariances( X, slices, stabilize = TRUE, stabilization = c("eigenfloor", "ridge", "nearest_pd"), eps = 1e-06 )
X |
Numeric matrix. |
slices |
Integer slice memberships. |
stabilize |
Logical. If TRUE, stabilises each slice covariance matrix. |
stabilization |
Stabilisation method. |
eps |
Eigenvalue floor. |
A list of covariance matrices.
X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) slices <- make_slices(mtcars$mpg, nslices = 4) covariances <- slice_covariances(X, slices) names(covariances)X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) slices <- make_slices(mtcars$mpg, nslices = 4) covariances <- slice_covariances(X, slices) names(covariances)
Computes slice-specific means of predictors.
slice_means(X, slices)slice_means(X, slices)
X |
Numeric matrix. |
slices |
Integer slice memberships. |
Matrix of slice means with rows corresponding to slices.
X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) slices <- make_slices(mtcars$mpg, nslices = 4) slice_means(X, slices)X <- as.matrix(mtcars[, c("disp", "hp", "wt")]) slices <- make_slices(mtcars$mpg, nslices = 4) slice_means(X, slices)
Computes empirical slice probabilities.
slice_proportions(slices)slice_proportions(slices)
slices |
Integer slice memberships. |
Numeric vector of slice proportions.
slices <- make_slices(mtcars$mpg, nslices = 4) slice_proportions(slices)slices <- make_slices(mtcars$mpg, nslices = 4) slice_proportions(slices)
Constructs slice labels for continuous, categorical, or censored survival responses. For censored survival data, double slicing is used by first splitting on censoring status and then slicing observed time within each status group.
slice_response( y, nslices = 5L, response_type = c("continuous", "categorical", "survival"), delta = NULL )slice_response( y, nslices = 5L, response_type = c("continuous", "categorical", "survival"), delta = NULL )
y |
Response vector. For survival data, observed time. |
nslices |
Number of slices for continuous data or per censoring-status group for survival data. |
response_type |
One of |
delta |
Optional 0/1 event indicator for survival data. |
A list containing integer slice labels and metadata.
Produces a summary table of slice frequencies and response ranges.
slice_summary(y, slices)slice_summary(y, slices)
y |
Numeric response vector. |
slices |
Integer slice memberships. |
A data frame summarising slices.
slices <- make_slices(mtcars$mpg, nslices = 4) slice_summary(mtcars$mpg, slices)slices <- make_slices(mtcars$mpg, nslices = 4) slice_summary(mtcars$mpg, slices)
Stabilises a covariance matrix using one of several available methods.
stabilize_cov( Sigma, method = c("eigenfloor", "ridge", "nearest_pd"), eps = 1e-06, lambda = 1e-04, keep_diag = TRUE )stabilize_cov( Sigma, method = c("eigenfloor", "ridge", "nearest_pd"), eps = 1e-06, lambda = 1e-04, keep_diag = TRUE )
Sigma |
A square symmetric covariance matrix. |
method |
Stabilisation method. |
eps |
Positive eigenvalue floor for eigenfloor method. |
lambda |
Ridge parameter for ridge method. |
keep_diag |
Logical. Used by nearest positive definite method. |
A stabilised covariance matrix.
Sigma <- matrix(c(1, 1, 1, 1), nrow = 2) stabilize_cov(Sigma, method = "eigenfloor")Sigma <- matrix(c(1, 1, 1, 1), nrow = 2) stabilize_cov(Sigma, method = "eigenfloor")
Stabilises a symmetric covariance matrix by replacing eigenvalues smaller than a positive threshold with that threshold.
stabilize_eigenfloor(Sigma, eps = 1e-06)stabilize_eigenfloor(Sigma, eps = 1e-06)
Sigma |
A square symmetric covariance matrix. |
eps |
Positive eigenvalue floor. |
A symmetric positive definite covariance matrix.
Sigma <- matrix(c(1, 1, 1, 1), nrow = 2) eigen(stabilize_eigenfloor(Sigma))$valuesSigma <- matrix(c(1, 1, 1, 1), nrow = 2) eigen(stabilize_eigenfloor(Sigma))$values
Stabilises a covariance matrix by projecting it to the nearest positive definite matrix using Matrix::nearPD().
stabilize_nearest_pd(Sigma, keep_diag = TRUE)stabilize_nearest_pd(Sigma, keep_diag = TRUE)
Sigma |
A square symmetric covariance matrix. |
keep_diag |
Logical. If TRUE, keeps original diagonal where possible. |
A symmetric positive definite covariance matrix.
Sigma <- matrix(c(1, 1, 1, 1), nrow = 2) eigen(stabilize_nearest_pd(Sigma))$valuesSigma <- matrix(c(1, 1, 1, 1), nrow = 2) eigen(stabilize_nearest_pd(Sigma))$values
Stabilises a covariance matrix by adding a positive multiple of the identity matrix.
stabilize_ridge(Sigma, lambda = 1e-04)stabilize_ridge(Sigma, lambda = 1e-04)
Sigma |
A square symmetric covariance matrix. |
lambda |
Ridge stabilisation parameter. |
A symmetric positive definite covariance matrix.
Sigma <- matrix(c(1, 1, 1, 1), nrow = 2) eigen(stabilize_ridge(Sigma))$valuesSigma <- matrix(c(1, 1, 1, 1), nrow = 2) eigen(stabilize_ridge(Sigma))$values
Computes Frobenius distance between projection matrices.
subspace_distance(B_hat, B)subspace_distance(B_hat, B)
B_hat |
Estimated basis matrix. |
B |
True basis matrix. |
Numeric subspace distance.
B <- matrix(c(1, 0, 0, 0, 1, 0), nrow = 3) transformed <- B %*% diag(c(2, 3)) subspace_distance(transformed, B)B <- matrix(c(1, 0, 0, 0, 1, 0), nrow = 3) transformed <- B %*% diag(c(2, 3)) subspace_distance(transformed, B)
Summarise simulation results
summarise_simulation(sim_results)summarise_simulation(sim_results)
sim_results |
Data frame from run_risdr_simulation(). |
Summary data frame.
Summarise sparsity pattern
summarise_sparsity(V, tol = 1e-08)summarise_sparsity(V, tol = 1e-08)
V |
Direction matrix. |
tol |
Threshold for active support. |
Sparsity summary.
Summarise risdr object
## S3 method for class 'risdr' summary(object, ...)## S3 method for class 'risdr' summary(object, ...)
object |
Object of class "risdr". |
... |
Additional arguments passed to internal methods. |
A list summary.
Summary method for dual RISDR objects
## S3 method for class 'risdr_dual' summary(object, top_n = 20L, ...)## S3 method for class 'risdr_dual' summary(object, top_n = 20L, ...)
object |
Object of class |
top_n |
Number of selected variables to print. |
... |
Additional arguments passed to internal methods. |
Summarise risdr object
## S3 method for class 'risdr_sparse' summary(object, ...)## S3 method for class 'risdr_sparse' summary(object, ...)
object |
Object of class "risdr". |
... |
Additional arguments passed to internal methods. |
A list summary.
Weighted soft-threshold operator
weighted_soft_threshold(z, lambda, weights = NULL, tol = 1e-10)weighted_soft_threshold(z, lambda, weights = NULL, tol = 1e-10)
z |
Numeric vector. |
lambda |
Non-negative tuning parameter. |
weights |
Penalty weights. |
tol |
Numerical tolerance. |
Thresholded vector.
Weighted sparse directions from dense SDR directions
weighted_sparsify_directions(V, lambda, weights = NULL, tol = 1e-10)weighted_sparsify_directions(V, lambda, weights = NULL, tol = 1e-10)
V |
Dense direction matrix. |
lambda |
Non-negative tuning parameter. |
weights |
Variable-level penalty weights. |
tol |
Numerical tolerance. |
Sparse direction matrix.