| Title: | Shrinkage Principal Fitted Components with Information Complexity-Based Model Selection |
|---|---|
| Description: | Implements shrinkage principal fitted components for sufficient dimension reduction in high-dimensional regression and classification. Provides regularised covariance estimation using Oracle Approximating Shrinkage and Maximum Entropy Covariance, structural-dimension selection using conventional and information-complexity criteria, response-guided feature screening, reduced-space prediction, and simulation utilities. Methodological foundations include Cook and Forzani (2008) <doi:10.1214/08-STS275>, Chen et al. (2010) <doi:10.1109/TSP.2010.2053029>, Bozdogan (2000) <doi:10.1006/jmps.1999.1277>, and Olorede and Yahya (2019) <doi:10.48550/arXiv.1909.13017>. |
| Authors: | Kabir Opeyemi Olorede [aut, cre, cph] |
| Maintainer: | Kabir Opeyemi Olorede <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0.9000 |
| Built: | 2026-10-06 12:28:28 UTC |
| Source: | https://github.com/ilovemaths/spfcicomp |
Fits SPFC models using several covariance estimators and compares their downstream predictive performance, runtime, shrinkage behaviour, and variable-selection output.
benchmark_spfc( X, y, d, ytype = c("auto", "continuous", "categorical"), methods = c("mec", "oas", "sre", "sde", "cse"), variable_method = "adaptive_weighted_l1", quantile_cut = 0.75, validation = c("resubstitution", "holdout", "cv"), test_fraction = 0.3, folds = 5, validation_seed = 123, verbose = TRUE, ... )benchmark_spfc( X, y, d, ytype = c("auto", "continuous", "categorical"), methods = c("mec", "oas", "sre", "sde", "cse"), variable_method = "adaptive_weighted_l1", quantile_cut = 0.75, validation = c("resubstitution", "holdout", "cv"), test_fraction = 0.3, folds = 5, validation_seed = 123, verbose = TRUE, ... )
X |
Numeric predictor matrix. |
y |
Response vector. |
d |
Structural dimension. |
ytype |
Character. One of |
methods |
Character vector of covariance estimators to compare. |
variable_method |
Variable-selection method. |
quantile_cut |
Quantile threshold for adaptive variable selection. |
validation |
Character. Validation strategy. One of |
test_fraction |
Proportion of observations allocated to the test set
when |
folds |
Number of folds used when |
validation_seed |
Random seed used for train-test splitting or cross-validation fold creation. |
verbose |
Logical. If |
... |
Additional arguments passed to |
A list of class spfc_benchmark.
set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) bench <- benchmark_spfc( X, y, d = 1, ytype = 'continuous', methods = c('oas', 'sre'), variable_method = 'adaptive_weighted_l1', quantile_cut = 0.75, validation = 'resubstitution', verbose = FALSE ) bench$summaryset.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) bench <- benchmark_spfc( X, y, d = 1, ytype = 'continuous', methods = c('oas', 'sre'), variable_method = 'adaptive_weighted_l1', quantile_cut = 0.75, validation = 'resubstitution', verbose = FALSE ) bench$summary
Computes confusion matrix, accuracy, sensitivity, specificity, precision, and F1 score for binary classification.
binary_classification_metrics(observed, predicted, positive = NULL)binary_classification_metrics(observed, predicted, positive = NULL)
observed |
Observed binary response. |
predicted |
Predicted binary class labels. |
positive |
Optional positive class label. If |
A list containing the confusion matrix and classification metrics.
obs <- factor(c('A', 'A', 'B', 'B')) pred <- factor(c('A', 'B', 'B', 'B'), levels = levels(obs)) binary_classification_metrics(obs, pred, positive = 'B')obs <- factor(c('A', 'A', 'B', 'B')) pred <- factor(c('A', 'B', 'B', 'B'), levels = levels(obs)) binary_classification_metrics(obs, pred, positive = 'B')
Extract SPFC Fit from Complete Workflow
## S3 method for class 'spfc' coef(object, ...)## S3 method for class 'spfc' coef(object, ...)
object |
Object returned by |
... |
Additional arguments. |
Estimated SPFC direction matrix from the fitted SPFC component.
Extracts the estimated SPFC direction matrix.
## S3 method for class 'spfc_fit' coef(object, ...)## S3 method for class 'spfc_fit' coef(object, ...)
object |
Object returned by |
... |
Additional arguments. |
Numeric matrix of estimated SPFC directions.
Fits shrinkage principal fitted components using several covariance estimators and evaluates the reduced model fitted on the resulting SPFC scores.
compare_covariance_methods( X, y, d, methods = c("mec", "oas", "sre", "sde", "cse"), ytype = c("auto", "continuous", "categorical"), nslices = 5, poly_degree = 1, gamma = 0.1, rho = 0.5, centre_x = TRUE, scale_x = FALSE, classifier = c("auto", "glm", "ridge_logistic"), eps = 1e-08, verbose = TRUE )compare_covariance_methods( X, y, d, methods = c("mec", "oas", "sre", "sde", "cse"), ytype = c("auto", "continuous", "categorical"), nslices = 5, poly_degree = 1, gamma = 0.1, rho = 0.5, centre_x = TRUE, scale_x = FALSE, classifier = c("auto", "glm", "ridge_logistic"), eps = 1e-08, verbose = TRUE )
X |
Numeric predictor matrix. |
y |
Response vector. |
d |
Number of reduction directions. |
methods |
Character vector of covariance estimators. Available options
are |
ytype |
Character. One of |
nslices |
Number of slices for continuous responses. |
poly_degree |
Polynomial degree for continuous response basis. |
gamma |
Ridge constant for SRE. |
rho |
Convex shrinkage intensity for CSE. |
centre_x |
Logical. If |
scale_x |
Logical. If |
classifier |
Character. One of |
eps |
Positive numerical floor for eigenvalues. |
verbose |
Logical. If |
A list containing a summary table and full fitted objects.
set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) cmp <- compare_covariance_methods( X, y, d = 1, methods = c('oas', 'sre'), ytype = 'continuous', poly_degree = 2, verbose = FALSE ) cmp$summaryset.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) cmp <- compare_covariance_methods( X, y, d = 1, methods = c('oas', 'sre'), ytype = 'continuous', poly_degree = 2, verbose = FALSE ) cmp$summary
Create K-fold Cross-validation Folds
create_cv_folds(y, folds = 5, seed = 123, stratify = TRUE)create_cv_folds(y, folds = 5, seed = 123, stratify = TRUE)
y |
Response vector. |
folds |
Number of folds. |
seed |
Random seed. |
stratify |
Logical. If TRUE, stratify factor, character, logical, or numeric two-class responses. |
Integer vector of fold labels.
y <- seq_len(12) create_cv_folds(y, folds = 3, seed = 123, stratify = FALSE)y <- seq_len(12) create_cv_folds(y, folds = 3, seed = 123, stratify = FALSE)
Creates a factorial simulation design grid for SPFC simulation studies.
create_spfc_design_grid( response_type = c("continuous", "categorical"), n_values = c(50, 100), p_values = c(20, 50), d_values = c(1, 2), s_values = c(5), rho_x_values = c(0.2, 0.5, 0.8), snr_values = c(1, 2), signal_strength_values = c(0.8, 1.2), cov_methods = c("mec", "oas", "sre", "sde", "cse"), variable_methods = c("adaptive_weighted_l1", "c1f_extension"), nrep = 10 )create_spfc_design_grid( response_type = c("continuous", "categorical"), n_values = c(50, 100), p_values = c(20, 50), d_values = c(1, 2), s_values = c(5), rho_x_values = c(0.2, 0.5, 0.8), snr_values = c(1, 2), signal_strength_values = c(0.8, 1.2), cov_methods = c("mec", "oas", "sre", "sde", "cse"), variable_methods = c("adaptive_weighted_l1", "c1f_extension"), nrep = 10 )
response_type |
Character vector. One or both of |
n_values |
Sample sizes. |
p_values |
Predictor dimensions. |
d_values |
True structural dimensions. |
s_values |
Sparsity levels. |
rho_x_values |
Predictor correlation values. |
snr_values |
Signal-to-noise ratios for continuous responses. |
signal_strength_values |
Signal strengths for categorical responses. |
cov_methods |
Covariance estimators. |
variable_methods |
Variable-selection methods. |
nrep |
Number of Monte Carlo replicates per design setting. |
A data frame containing the full simulation design.
create_spfc_design_grid( response_type = 'continuous', n_values = 30, p_values = 8, d_values = 1, s_values = 3, rho_x_values = 0.3, snr_values = 2, cov_methods = 'oas', variable_methods = 'adaptive_weighted_l1', nrep = 1 )create_spfc_design_grid( response_type = 'continuous', n_values = 30, p_values = 8, d_values = 1, s_values = 3, rho_x_values = 0.3, snr_values = 2, cov_methods = 'oas', variable_methods = 'adaptive_weighted_l1', nrep = 1 )
Create Train-test Split
create_train_test_split(y, test_fraction = 0.3, seed = 123, stratify = TRUE)create_train_test_split(y, test_fraction = 0.3, seed = 123, stratify = TRUE)
y |
Response vector. |
test_fraction |
Proportion assigned to test set. |
seed |
Random seed. |
stratify |
Logical. If TRUE, stratify factor, character, logical, or numeric two-class responses. |
A list with train and test indices.
y <- seq_len(20) create_train_test_split( y, test_fraction = 0.25, seed = 123, stratify = FALSE )y <- seq_len(20) create_train_test_split( y, test_fraction = 0.25, seed = 123, stratify = FALSE )
Computes a convex combination of the sample covariance matrix and a spherical target matrix.
cse(x, rho = 0.5)cse(x, rho = 0.5)
x |
Numeric predictor matrix. |
rho |
Convex shrinkage intensity between 0 and 1. |
A list with covariance matrix covx, shrinkage intensity rho,
and method label.
set.seed(1) X <- matrix(rnorm(120), nrow = 20, ncol = 6) est <- cse(X, rho = 0.5) dim(est$covx)set.seed(1) X <- matrix(rnorm(120), nrow = 20, ncol = 6) est <- cse(X, rho = 0.5) dim(est$covx)
Unified interface for covariance estimators used in shrinkage principal fitted components regression.
estimate_covariance( X, y = NULL, ytype = c("auto", "continuous", "categorical"), method = c("mec", "oas", "sre", "sde", "cse"), nslices = 5, gamma = 0.1, rho = 0.5, eps = 1e-08 )estimate_covariance( X, y = NULL, ytype = c("auto", "continuous", "categorical"), method = c("mec", "oas", "sre", "sde", "cse"), nslices = 5, gamma = 0.1, rho = 0.5, eps = 1e-08 )
X |
Numeric predictor matrix. |
y |
Optional response vector. Required when |
ytype |
Character. One of |
method |
Covariance estimator. One of |
nslices |
Number of slices for MEC with continuous responses. |
gamma |
Ridge constant for SRE. |
rho |
Convex shrinkage intensity for CSE. |
eps |
Positive numerical floor for eigenvalues. |
A list containing the covariance estimate, shrinkage intensity, and method diagnostics.
set.seed(1) X <- matrix(rnorm(120), nrow = 20, ncol = 6) est <- estimate_covariance(X, method = 'oas') c(method = est$method, rho = est$rho)set.seed(1) X <- matrix(rnorm(120), nrow = 20, ncol = 6) est <- estimate_covariance(X, method = 'oas') c(method = est$method, rho = est$rho)
Evaluates a model fitted on reduced SPFC scores.
evaluate_reduced_model(object, Z, y, threshold = 0.5, positive = NULL)evaluate_reduced_model(object, Z, y, threshold = 0.5, positive = NULL)
object |
Object returned by |
Z |
Numeric reduced-score matrix. |
y |
Observed response. |
threshold |
Classification threshold for binary responses. |
positive |
Optional positive class label. |
A list of evaluation metrics.
set.seed(1) Z <- matrix(rnorm(40), nrow = 20, ncol = 2) y <- Z[, 1] - 0.5 * Z[, 2] + rnorm(20, sd = 0.4) mod <- fit_reduced_model(Z, y, ytype = 'continuous') evaluate_reduced_model(mod, Z, y)set.seed(1) Z <- matrix(rnorm(40), nrow = 20, ncol = 2) y <- Z[, 1] - 0.5 * Z[, 2] + rnorm(20, sd = 0.4) mod <- fit_reduced_model(Z, y, ytype = 'continuous') evaluate_reduced_model(mod, Z, y)
Evaluate SPFC with K-fold Cross-validation
evaluate_spfc_cv( X, y, d, ytype = c("auto", "continuous", "categorical"), cov_method = c("mec", "oas", "sre", "sde", "cse"), folds = 5, seed = 123, nslices = 5, poly_degree = 1, variable_method = c("adaptive_weighted_l1", "c1f_extension"), selection_rule = c("c1f", "quantile", "fixed"), threshold = NULL, quantile_cut = 0.75, centre_x = TRUE, scale_x = FALSE, ... )evaluate_spfc_cv( X, y, d, ytype = c("auto", "continuous", "categorical"), cov_method = c("mec", "oas", "sre", "sde", "cse"), folds = 5, seed = 123, nslices = 5, poly_degree = 1, variable_method = c("adaptive_weighted_l1", "c1f_extension"), selection_rule = c("c1f", "quantile", "fixed"), threshold = NULL, quantile_cut = 0.75, centre_x = TRUE, scale_x = FALSE, ... )
X |
Predictor matrix. |
y |
Response vector. |
d |
Structural dimension. |
ytype |
Response type. |
cov_method |
Covariance estimator. |
folds |
Number of folds. |
seed |
Random seed. |
nslices |
Number of response slices. |
poly_degree |
Polynomial degree. |
variable_method |
Variable selection method. |
selection_rule |
Character screening rule: |
threshold |
Optional finite numeric screening threshold. It is required for |
quantile_cut |
Variable selection threshold. |
centre_x |
Logical. |
scale_x |
Logical. |
... |
Additional arguments passed to spfc_fit(). |
A list containing fold-level and aggregate validation results.
set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) cv <- evaluate_spfc_cv( X, y, d = 1, ytype = 'continuous', cov_method = 'oas', folds = 3, seed = 123, poly_degree = 2, selection_rule = 'quantile', quantile_cut = 0.75 ) cv$aggregateset.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) cv <- evaluate_spfc_cv( X, y, d = 1, ytype = 'continuous', cov_method = 'oas', folds = 3, seed = 123, poly_degree = 2, selection_rule = 'quantile', quantile_cut = 0.75 ) cv$aggregate
Evaluate SPFC with Train-test Validation
evaluate_spfc_train_test( X, y, train_idx, test_idx, d, ytype = c("auto", "continuous", "categorical"), cov_method = c("mec", "oas", "sre", "sde", "cse"), nslices = 5, poly_degree = 1, variable_method = c("adaptive_weighted_l1", "c1f_extension"), selection_rule = c("c1f", "quantile", "fixed"), threshold = NULL, quantile_cut = 0.75, centre_x = TRUE, scale_x = FALSE, ... )evaluate_spfc_train_test( X, y, train_idx, test_idx, d, ytype = c("auto", "continuous", "categorical"), cov_method = c("mec", "oas", "sre", "sde", "cse"), nslices = 5, poly_degree = 1, variable_method = c("adaptive_weighted_l1", "c1f_extension"), selection_rule = c("c1f", "quantile", "fixed"), threshold = NULL, quantile_cut = 0.75, centre_x = TRUE, scale_x = FALSE, ... )
X |
Predictor matrix. |
y |
Response vector. |
train_idx |
Training indices. |
test_idx |
Test indices. |
d |
Structural dimension. |
ytype |
Response type. |
cov_method |
Covariance estimator. |
nslices |
Number of response slices. |
poly_degree |
Polynomial degree. |
variable_method |
Variable selection method. |
selection_rule |
Character screening rule: |
threshold |
Optional finite numeric screening threshold. It is required for |
quantile_cut |
Variable selection threshold. |
centre_x |
Logical. |
scale_x |
Logical. |
... |
Additional arguments passed to spfc_fit(). |
A list containing fit, reduced model, predictions, and test metrics.
set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) split <- create_train_test_split( y, test_fraction = 0.25, seed = 123, stratify = FALSE ) ans <- evaluate_spfc_train_test( X, y, train_idx = split$train, test_idx = split$test, d = 1, ytype = 'continuous', cov_method = 'oas', poly_degree = 2, selection_rule = 'quantile', quantile_cut = 0.75 ) ans$evaluationset.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) split <- create_train_test_split( y, test_fraction = 0.25, seed = 123, stratify = FALSE ) ans <- evaluate_spfc_train_test( X, y, train_idx = split$train, test_idx = split$test, d = 1, ytype = 'continuous', cov_method = 'oas', poly_degree = 2, selection_rule = 'quantile', quantile_cut = 0.75 ) ans$evaluation
Fits a downstream predictive model using the reduced SPFC score matrix.
fit_reduced_model( Z, y, ytype = c("auto", "continuous", "categorical"), classifier = c("auto", "glm", "ridge_logistic"), standardize = TRUE )fit_reduced_model( Z, y, ytype = c("auto", "continuous", "categorical"), classifier = c("auto", "glm", "ridge_logistic"), standardize = TRUE )
Z |
Numeric reduced predictor matrix. |
y |
Response vector. |
ytype |
Character. One of |
classifier |
Character. Classification model. One of |
standardize |
Logical. If |
A list containing the fitted downstream model and metadata.
set.seed(1) Z <- matrix(rnorm(40), nrow = 20, ncol = 2) y <- Z[, 1] - 0.5 * Z[, 2] + rnorm(20, sd = 0.4) fit_reduced_model(Z, y, ytype = 'continuous')set.seed(1) Z <- matrix(rnorm(40), nrow = 20, ncol = 2) y <- Z[, 1] - 0.5 * Z[, 2] + rnorm(20, sd = 0.4) fit_reduced_model(Z, y, ytype = 'continuous')
Extract Reduced Scores from Complete Workflow
## S3 method for class 'spfc' fitted(object, ...)## S3 method for class 'spfc' fitted(object, ...)
object |
Object returned by |
... |
Additional arguments. |
Reduced SPFC score matrix.
Extracts the reduced SPFC score matrix.
## S3 method for class 'spfc_fit' fitted(object, ...)## S3 method for class 'spfc_fit' fitted(object, ...)
object |
Object returned by |
... |
Additional arguments. |
Numeric matrix of reduced SPFC scores.
Computes the Maximum Entropy Covariance estimator for sufficient dimension reduction. The response is first sliced. Slice-specific covariance matrices are computed, the entropy-maximising slice covariance is selected, and an entropy-guided covariance estimate is stabilised by a convex shrinkage step.
mec( x, y, ytype = c("auto", "continuous", "categorical"), nslices = 5, eps = 1e-08 )mec( x, y, ytype = c("auto", "continuous", "categorical"), nslices = 5, eps = 1e-08 )
x |
Numeric predictor matrix. |
y |
Response vector. |
ytype |
Character. One of |
nslices |
Number of slices for continuous responses. |
eps |
Positive numerical floor for eigenvalues. |
A list with covariance matrix covx, shrinkage intensity rho,
method label, response type, number of slices used, and entropy values.
set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) est <- mec(X, y, ytype = 'continuous', nslices = 5) c(method = est$method, rho = est$rho)set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) est <- mec(X, y, ytype = 'continuous', nslices = 5) c(method = est$method, rho = est$rho)
Computes an OAS-type stabilised covariance estimator with an additional convex shrinkage step.
oas(x)oas(x)
x |
Numeric predictor matrix. |
A list with covariance matrix covx, shrinkage intensity rho,
and method label.
set.seed(1) X <- matrix(rnorm(120), nrow = 20, ncol = 6) est <- oas(X) c(method = est$method, rho = est$rho)set.seed(1) X <- matrix(rnorm(120), nrow = 20, ncol = 6) est <- oas(X) c(method = est$method, rho = est$rho)
Plots information criteria returned by spfc_select_dimension().
plot_dimension_selection( dsel, criterion = c("AIC", "BIC", "CAIC", "ICOMP_IFIM", "ICOMP_MISSPEC", "CICOMP") )plot_dimension_selection( dsel, criterion = c("AIC", "BIC", "CAIC", "ICOMP_IFIM", "ICOMP_MISSPEC", "CICOMP") )
dsel |
Object returned by |
criterion |
Character. Criterion to plot. |
Invisibly returns the plotted data.
set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) dsel <- spfc_select_dimension( X, y, d_grid = 1:2, cov_method = 'oas', ytype = 'continuous', poly_degree = 2, verbose = FALSE ) plot_dimension_selection(dsel, criterion = 'ICOMP_IFIM')set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) dsel <- spfc_select_dimension( X, y, d_grid = 1:2, cov_method = 'oas', ytype = 'continuous', poly_degree = 2, verbose = FALSE ) plot_dimension_selection(dsel, criterion = 'ICOMP_IFIM')
Produces a base R boxplot for a selected simulation metric across covariance estimators.
plot_metric_by_covariance(results, metric, main = NULL, ylab = NULL)plot_metric_by_covariance(results, metric, main = NULL, ylab = NULL)
results |
Data frame returned by |
metric |
Character. Name of the metric column to plot. |
main |
Optional plot title. |
ylab |
Optional y-axis label. |
Invisibly returns the formula used for plotting.
results <- data.frame( cov_method = rep(c('oas', 'sre'), each = 2), rmse = c(0.50, 0.55, 0.62, 0.59), runtime_sec = c(0.01, 0.012, 0.008, 0.009), subspace_distance = c(0.20, 0.22, 0.28, 0.25) ) plot_metric_by_covariance(results, metric = 'rmse')results <- data.frame( cov_method = rep(c('oas', 'sre'), each = 2), rmse = c(0.50, 0.55, 0.62, 0.59), runtime_sec = c(0.01, 0.012, 0.008, 0.009), subspace_distance = c(0.20, 0.22, 0.28, 0.25) ) plot_metric_by_covariance(results, metric = 'rmse')
Plot RMSE by Covariance Method
plot_rmse_by_covariance(results)plot_rmse_by_covariance(results)
results |
Simulation results data frame. |
Invisibly returns the plotting formula.
results <- data.frame( cov_method = rep(c('oas', 'sre'), each = 2), rmse = c(0.50, 0.55, 0.62, 0.59), runtime_sec = c(0.01, 0.012, 0.008, 0.009), subspace_distance = c(0.20, 0.22, 0.28, 0.25) ) plot_rmse_by_covariance(results)results <- data.frame( cov_method = rep(c('oas', 'sre'), each = 2), rmse = c(0.50, 0.55, 0.62, 0.59), runtime_sec = c(0.01, 0.012, 0.008, 0.009), subspace_distance = c(0.20, 0.22, 0.28, 0.25) ) plot_rmse_by_covariance(results)
Plot Runtime by Covariance Method
plot_runtime_by_covariance(results)plot_runtime_by_covariance(results)
results |
Simulation results data frame. |
Invisibly returns the plotting formula.
results <- data.frame( cov_method = rep(c('oas', 'sre'), each = 2), rmse = c(0.50, 0.55, 0.62, 0.59), runtime_sec = c(0.01, 0.012, 0.008, 0.009), subspace_distance = c(0.20, 0.22, 0.28, 0.25) ) plot_runtime_by_covariance(results)results <- data.frame( cov_method = rep(c('oas', 'sre'), each = 2), rmse = c(0.50, 0.55, 0.62, 0.59), runtime_sec = c(0.01, 0.012, 0.008, 0.009), subspace_distance = c(0.20, 0.22, 0.28, 0.25) ) plot_runtime_by_covariance(results)
Produces a reduced-score plot from an object returned by spfc_fit().
plot_spfc_scores(fit, y = NULL, dims = c(1, 2), main = NULL)plot_spfc_scores(fit, y = NULL, dims = c(1, 2), main = NULL)
fit |
Object returned by |
y |
Optional response vector used for colouring or grouping. |
dims |
Integer vector of length 1 or 2 indicating SPFC score dimensions. |
main |
Optional plot title. |
Invisibly returns the plotted data.
set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) fit <- spfc_fit(X, y, d = 1, ytype = 'continuous', cov_method = 'oas', poly_degree = 2) plot_spfc_scores(fit, y = y, dims = 1)set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) fit <- spfc_fit(X, y, d = 1, ytype = 'continuous', cov_method = 'oas', poly_degree = 2) plot_spfc_scores(fit, y = y, dims = 1)
Plot Subspace Distance by Covariance Method
plot_subspace_distance_by_covariance(results)plot_subspace_distance_by_covariance(results)
results |
Simulation results data frame. |
Invisibly returns the plotting formula.
results <- data.frame( cov_method = rep(c('oas', 'sre'), each = 2), rmse = c(0.50, 0.55, 0.62, 0.59), runtime_sec = c(0.01, 0.012, 0.008, 0.009), subspace_distance = c(0.20, 0.22, 0.28, 0.25) ) plot_subspace_distance_by_covariance(results)results <- data.frame( cov_method = rep(c('oas', 'sre'), each = 2), rmse = c(0.50, 0.55, 0.62, 0.59), runtime_sec = c(0.01, 0.012, 0.008, 0.009), subspace_distance = c(0.20, 0.22, 0.28, 0.25) ) plot_subspace_distance_by_covariance(results)
Generates fitted values, probabilities, or predicted classes from an object
returned by fit_reduced_model().
predict_reduced_model( object, Z, type = c("response", "class", "link"), threshold = 0.5 )predict_reduced_model( object, Z, type = c("response", "class", "link"), threshold = 0.5 )
object |
Object returned by |
Z |
Numeric reduced-score matrix. |
type |
Character. One of |
threshold |
Classification threshold for binary probabilities. |
Numeric predictions or factor class labels.
set.seed(1) Z <- matrix(rnorm(40), nrow = 20, ncol = 2) y <- Z[, 1] - 0.5 * Z[, 2] + rnorm(20, sd = 0.4) mod <- fit_reduced_model(Z, y, ytype = 'continuous') head(predict_reduced_model(mod, Z, type = 'response'))set.seed(1) Z <- matrix(rnorm(40), nrow = 20, ncol = 2) y <- Z[, 1] - 0.5 * Z[, 2] + rnorm(20, sd = 0.4) mod <- fit_reduced_model(Z, y, ytype = 'continuous') head(predict_reduced_model(mod, Z, type = 'response'))
Predict from Ridge Logistic Regression
## S3 method for class 'ridge_logistic_fit' predict(object, newdata, type = c("class", "response"), ...)## S3 method for class 'ridge_logistic_fit' predict(object, newdata, type = c("class", "response"), ...)
object |
Object returned by |
newdata |
Numeric reduced predictor matrix. |
type |
Character. One of |
... |
Additional arguments. |
Predicted classes or probabilities.
Predict SPFC Scores from Complete Workflow
## S3 method for class 'spfc' predict(object, newdata, ...)## S3 method for class 'spfc' predict(object, newdata, ...)
object |
Object returned by |
newdata |
Numeric matrix or data frame of new predictor observations. |
... |
Additional arguments. |
Numeric matrix of predicted SPFC scores.
Projects new predictor observations into the estimated SPFC reduced space.
## S3 method for class 'spfc_fit' predict(object, newdata, ...)## S3 method for class 'spfc_fit' predict(object, newdata, ...)
object |
Object returned by |
newdata |
Numeric matrix or data frame of new predictor observations. |
... |
Additional arguments. |
Numeric matrix of predicted SPFC scores.
Print Complete SPFC Workflow
## S3 method for class 'spfc' print(x, ...)## S3 method for class 'spfc' print(x, ...)
x |
Object returned by |
... |
Additional arguments. |
Invisibly returns x.
Print SPFC Benchmark
## S3 method for class 'spfc_benchmark' print(x, ...)## S3 method for class 'spfc_benchmark' print(x, ...)
x |
Object returned by |
... |
Additional arguments. |
Invisibly returns x.
Print an SPFC Fit
## S3 method for class 'spfc_fit' print(x, ...)## S3 method for class 'spfc_fit' print(x, ...)
x |
Object returned by |
... |
Additional arguments. |
Invisibly returns x.
Print Summary of Complete SPFC Workflow
## S3 method for class 'summary.spfc' print(x, ...)## S3 method for class 'summary.spfc' print(x, ...)
x |
Object returned by |
... |
Additional arguments. |
Invisibly returns x.
Print Summary of SPFC Benchmark
## S3 method for class 'summary.spfc_benchmark' print(x, ...)## S3 method for class 'summary.spfc_benchmark' print(x, ...)
x |
Object returned by |
... |
Additional arguments. |
Invisibly returns x.
Print Summary of an SPFC Fit
## S3 method for class 'summary.spfc_fit' print(x, ...)## S3 method for class 'summary.spfc_fit' print(x, ...)
x |
Object returned by |
... |
Additional arguments. |
Invisibly returns x.
Ranks covariance estimators according to a chosen performance metric.
rank_covariance_methods(summary, metric, smaller_is_better = TRUE)rank_covariance_methods(summary, metric, smaller_is_better = TRUE)
summary |
Data frame returned by |
metric |
Metric column used for ranking. |
smaller_is_better |
Logical. If |
Ranked data frame.
summary <- data.frame( cov_method = c('oas', 'sre'), mean_rmse = c(0.50, 0.60) ) rank_covariance_methods(summary, metric = 'mean_rmse')summary <- data.frame( cov_method = c('oas', 'sre'), mean_rmse = c(0.50, 0.60) ) rank_covariance_methods(summary, metric = 'mean_rmse')
Runs an SPFC simulation design grid sequentially.
run_spfc_design( design, base_seed = 123, d_grid = 1:5, criteria = c("AIC", "BIC", "CAIC", "ICOMP_IFIM", "CICOMP"), selection_rule = "c1f", nslices = 5, poly_degree = 2, gamma = 0.1, rho = 0.5, save_every = NULL, save_path = "spfc_simulation_partial.rds", verbose = TRUE )run_spfc_design( design, base_seed = 123, d_grid = 1:5, criteria = c("AIC", "BIC", "CAIC", "ICOMP_IFIM", "CICOMP"), selection_rule = "c1f", nslices = 5, poly_degree = 2, gamma = 0.1, rho = 0.5, save_every = NULL, save_path = "spfc_simulation_partial.rds", verbose = TRUE )
design |
Data frame returned by |
base_seed |
Integer base seed. |
d_grid |
Candidate structural dimensions evaluated for each simulation design row. |
criteria |
Character vector of information criteria used for structural-dimension selection. |
selection_rule |
Character screening rule passed to |
nslices |
Number of slices. |
poly_degree |
Polynomial degree. |
gamma |
Ridge constant for SRE. |
rho |
Convex shrinkage intensity for CSE. |
save_every |
Optional integer. If supplied, intermediate results are saved every |
save_path |
Optional path for intermediate RDS output. |
verbose |
Logical. If |
A data frame of simulation results.
design <- create_spfc_design_grid( response_type = 'continuous', n_values = 30, p_values = 8, d_values = 1, s_values = 3, rho_x_values = 0.3, snr_values = 2, cov_methods = 'oas', variable_methods = 'adaptive_weighted_l1', nrep = 1 ) ans <- run_spfc_design( design, base_seed = 123, d_grid = 1, criteria = 'AIC', selection_rule = 'c1f', poly_degree = 2, verbose = FALSE ) ans[, c('cov_method', 'criterion', 'fitted_d', 'rmse')]design <- create_spfc_design_grid( response_type = 'continuous', n_values = 30, p_values = 8, d_values = 1, s_values = 3, rho_x_values = 0.3, snr_values = 2, cov_methods = 'oas', variable_methods = 'adaptive_weighted_l1', nrep = 1 ) ans <- run_spfc_design( design, base_seed = 123, d_grid = 1, criteria = 'AIC', selection_rule = 'c1f', poly_degree = 2, verbose = FALSE ) ans[, c('cov_method', 'criterion', 'fitted_d', 'rmse')]
Run a Small SPFC Simulation Study
run_spfc_simulation( response_type = c("continuous", "categorical"), nrep = 10, n = 100, p = 50, d = 1, s = 5, rho_x = 0.5, snr = 1, signal_strength = 1, cov_methods = c("mec", "oas", "sre", "sde", "cse"), variable_methods = c("adaptive_weighted_l1", "c1f_extension"), seed = 123 )run_spfc_simulation( response_type = c("continuous", "categorical"), nrep = 10, n = 100, p = 50, d = 1, s = 5, rho_x = 0.5, snr = 1, signal_strength = 1, cov_methods = c("mec", "oas", "sre", "sde", "cse"), variable_methods = c("adaptive_weighted_l1", "c1f_extension"), seed = 123 )
response_type |
Character. |
nrep |
Number of Monte Carlo replicates. |
n |
Sample size. |
p |
Number of predictors. |
d |
Structural dimension. |
s |
Number of active variables. |
rho_x |
Predictor correlation. |
snr |
Signal-to-noise ratio for continuous response. |
signal_strength |
Signal strength for categorical response. |
cov_methods |
Covariance estimators to compare. |
variable_methods |
Variable-selection methods to compare. |
seed |
Random seed. |
A data frame of simulation results.
ans <- run_spfc_simulation( response_type = 'continuous', nrep = 1, n = 30, p = 8, d = 1, s = 3, rho_x = 0.3, snr = 2, cov_methods = c('oas', 'sre'), variable_methods = 'adaptive_weighted_l1', seed = 123 ) ans[, c('cov_method', 'rmse', 'subspace_distance')]ans <- run_spfc_simulation( response_type = 'continuous', nrep = 1, n = 30, p = 8, d = 1, s = 3, rho_x = 0.3, snr = 2, cov_methods = c('oas', 'sre'), variable_methods = 'adaptive_weighted_l1', seed = 123 ) ans[, c('cov_method', 'rmse', 'subspace_distance')]
Computes AIC, BIC, CAIC, ICOMP(IFIM), ICOMP(Misspec), and CICOMP for a model fitted on reduced SPFC scores.
score_information_criteria(reduced_model, n, eps = 1e-10)score_information_criteria(reduced_model, n, eps = 1e-10)
reduced_model |
Object returned by |
n |
Sample size. |
eps |
Small positive numerical floor. |
A one-row data frame of information criteria.
set.seed(1) Z <- matrix(rnorm(40), nrow = 20, ncol = 2) y <- Z[, 1] - 0.5 * Z[, 2] + rnorm(20, sd = 0.4) mod <- fit_reduced_model(Z, y, ytype = 'continuous') score_information_criteria(mod, n = length(y))set.seed(1) Z <- matrix(rnorm(40), nrow = 20, ncol = 2) y <- Z[, 1] - 0.5 * Z[, 2] + rnorm(20, sd = 0.4) mod <- fit_reduced_model(Z, y, ytype = 'continuous') score_information_criteria(mod, n = length(y))
Computes a diagonal covariance estimator by retaining only the diagonal elements of the sample covariance matrix.
sde(x)sde(x)
x |
Numeric predictor matrix. |
A list with covariance matrix covx, shrinkage intensity rho,
and method label.
set.seed(1) X <- matrix(rnorm(120), nrow = 20, ncol = 6) est <- sde(X) c(method = est$method, rho = est$rho)set.seed(1) X <- matrix(rnorm(120), nrow = 20, ncol = 6) est <- sde(X) c(method = est$method, rho = est$rho)
Simulate Binary High-Dimensional Classification Data
simulate_spfc_binary( n = 100, p = 50, d = 1, s = 5, rho_x = 0.5, signal_strength = 1, seed = NULL )simulate_spfc_binary( n = 100, p = 50, d = 1, s = 5, rho_x = 0.5, signal_strength = 1, seed = NULL )
n |
Sample size. |
p |
Number of predictors. |
d |
Structural dimension. |
s |
Number of active variables. |
rho_x |
Predictor correlation. |
signal_strength |
Signal strength in the logistic model. |
seed |
Optional random seed. |
A list containing X, y, true directions, active set, and covariance.
sim <- simulate_spfc_binary( n = 30, p = 8, d = 1, s = 3, rho_x = 0.3, signal_strength = 1, seed = 123 ) table(sim$y)sim <- simulate_spfc_binary( n = 30, p = 8, d = 1, s = 3, rho_x = 0.3, signal_strength = 1, seed = 123 ) table(sim$y)
Generates data directly from a principal fitted components inverse model,
so the nominal structural dimension is identifiable by construction. For
d = 1, the inverse mean uses f(Y) = Y. For d = 2, it uses the two
population-orthonormal basis functions Y and (Y^2 - 1)/sqrt(2) with
Y ~ N(0,1). The inverse-mean loading matrix is constructed so that the true
sufficient reduction subspace is the sparse matrix returned as B_true,
even when the residual predictor covariance is correlated.
simulate_spfc_continuous( n = 100, p = 50, d = 1, s = 5, rho_x = 0.5, snr = 1, n_test = n, seed = NULL )simulate_spfc_continuous( n = 100, p = 50, d = 1, s = 5, rho_x = 0.5, snr = 1, n_test = n, seed = NULL )
n |
Training sample size. |
p |
Number of predictors. |
d |
Structural dimension. The validated thesis DGP supports 1 or 2. |
s |
Number of active variables. |
rho_x |
AR(1) correlation parameter of the inverse-model residual covariance. |
snr |
Inverse-model signal-to-noise ratio in the sufficient coordinates. |
n_test |
Independent test-sample size. Defaults to |
seed |
Optional random seed. |
An independent test sample is generated from the same inverse model for honest out-of-sample prediction assessment.
A list containing training and test data, true PFC quantities, sparse reduction directions, active set, and residual covariance.
sim <- simulate_spfc_continuous( n = 30, p = 8, d = 1, s = 3, rho_x = 0.3, snr = 2, n_test = 10, seed = 123 ) c(train_n = length(sim$y), test_n = length(sim$y_test))sim <- simulate_spfc_continuous( n = 30, p = 8, d = 1, s = 3, rho_x = 0.3, snr = 2, n_test = 10, seed = 123 ) c(train_n = length(sim$y), test_n = length(sim$y_test))
Fits a complete Shrinkage Principal Fitted Components workflow, including optional structural dimension selection, SPFC fitting, reduced model fitting, evaluation, and variable selection.
spfc( X, y, d = NULL, d_grid = 1:3, ytype = c("auto", "continuous", "categorical"), cov_method = c("mec", "oas", "sre", "sde", "cse"), selector = c("AIC", "BIC", "CAIC", "ICOMP_IFIM", "ICOMP_MISSPEC", "CICOMP"), nslices = 5, poly_degree = 1, variable_method = c("adaptive_weighted_l1", "c1f_extension"), selection_rule = c("c1f", "quantile", "fixed"), threshold = NULL, quantile_cut = 0.75, validation = c("resubstitution", "holdout", "cv"), test_fraction = 0.3, folds = 5, validation_seed = 123, centre_x = TRUE, scale_x = FALSE, verbose = TRUE, ... )spfc( X, y, d = NULL, d_grid = 1:3, ytype = c("auto", "continuous", "categorical"), cov_method = c("mec", "oas", "sre", "sde", "cse"), selector = c("AIC", "BIC", "CAIC", "ICOMP_IFIM", "ICOMP_MISSPEC", "CICOMP"), nslices = 5, poly_degree = 1, variable_method = c("adaptive_weighted_l1", "c1f_extension"), selection_rule = c("c1f", "quantile", "fixed"), threshold = NULL, quantile_cut = 0.75, validation = c("resubstitution", "holdout", "cv"), test_fraction = 0.3, folds = 5, validation_seed = 123, centre_x = TRUE, scale_x = FALSE, verbose = TRUE, ... )
X |
Numeric predictor matrix. |
y |
Response vector. |
d |
Optional structural dimension. If |
d_grid |
Candidate structural dimensions used when |
ytype |
Character. One of |
cov_method |
Covariance estimator. One of |
selector |
Criterion for selecting structural dimension when |
nslices |
Number of slices for continuous responses. |
poly_degree |
Polynomial degree for continuous response basis. |
variable_method |
Variable selection method. |
selection_rule |
Character screening rule: |
threshold |
Optional finite numeric screening threshold. It is required for |
quantile_cut |
Quantile threshold for variable selection. |
validation |
Character. Validation strategy. One of |
test_fraction |
Numeric value between 0 and 1 giving the test-set
proportion when |
folds |
Integer number of folds to use when |
validation_seed |
Integer seed used for train-test splitting or cross-validation fold creation. |
centre_x |
Logical. If |
scale_x |
Logical. If |
verbose |
Logical. If |
... |
Additional arguments passed to |
A list of class spfc containing the complete workflow.
set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) obj <- spfc( X, y, d = 1, ytype = 'continuous', cov_method = 'oas', poly_degree = 2, selection_rule = 'quantile', quantile_cut = 0.75, validation = 'resubstitution', verbose = FALSE ) objset.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) obj <- spfc( X, y, d = 1, ytype = 'continuous', cov_method = 'oas', poly_degree = 2, selection_rule = 'quantile', quantile_cut = 0.75, validation = 'resubstitution', verbose = FALSE ) obj
Fits a shrinkage principal fitted components model by replacing the unstable covariance object in the PFC reduction step with a selected shrinkage covariance estimator.
spfc_fit( X, y, d, fy = NULL, ytype = c("auto", "continuous", "categorical"), cov_method = c("mec", "oas", "sre", "sde", "cse"), nslices = 5, poly_degree = 1, gamma = 0.1, rho = 0.5, centre_x = TRUE, scale_x = FALSE, eps = 1e-08 )spfc_fit( X, y, d, fy = NULL, ytype = c("auto", "continuous", "categorical"), cov_method = c("mec", "oas", "sre", "sde", "cse"), nslices = 5, poly_degree = 1, gamma = 0.1, rho = 0.5, centre_x = TRUE, scale_x = FALSE, eps = 1e-08 )
X |
Numeric predictor matrix with observations in rows and variables in columns. |
y |
Response vector. |
d |
Number of reduction directions. |
fy |
Optional user-supplied response basis matrix. |
ytype |
Character. One of |
cov_method |
Covariance estimator. One of |
nslices |
Number of response slices for continuous responses. |
poly_degree |
Polynomial degree for continuous response basis construction. |
gamma |
Ridge constant for SRE. |
rho |
Convex shrinkage intensity for CSE. |
centre_x |
Logical. If |
scale_x |
Logical. If |
eps |
Positive numerical floor for eigenvalues. |
A spfc_fit object containing reduced scores, directions, fitted
covariance objects, response basis, preprocessing metadata, and diagnostics.
set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) fit <- spfc_fit( X, y, d = 1, ytype = 'continuous', cov_method = 'oas', poly_degree = 2 ) coef(fit)set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) fit <- spfc_fit( X, y, d = 1, ytype = 'continuous', cov_method = 'oas', poly_degree = 2 ) coef(fit)
Fits SPFC models across candidate dimensions and scores classical and information-complexity-based criteria.
spfc_select_dimension( X, y, d_grid = 1:3, cov_method = c("mec", "oas", "sre", "sde", "cse"), ytype = c("auto", "continuous", "categorical"), nslices = 5, poly_degree = 1, gamma = 0.1, rho = 0.5, centre_x = TRUE, scale_x = FALSE, classifier = c("auto", "glm"), eps = 1e-08, verbose = TRUE )spfc_select_dimension( X, y, d_grid = 1:3, cov_method = c("mec", "oas", "sre", "sde", "cse"), ytype = c("auto", "continuous", "categorical"), nslices = 5, poly_degree = 1, gamma = 0.1, rho = 0.5, centre_x = TRUE, scale_x = FALSE, classifier = c("auto", "glm"), eps = 1e-08, verbose = TRUE )
X |
Numeric predictor matrix. |
y |
Response vector. |
d_grid |
Integer vector of candidate structural dimensions. |
cov_method |
Covariance estimator. One of |
ytype |
Character. One of |
nslices |
Number of slices for MEC with continuous responses. |
poly_degree |
Polynomial degree for continuous response basis. |
gamma |
Ridge constant for SRE. |
rho |
Convex shrinkage intensity for CSE. |
centre_x |
Logical. If |
scale_x |
Logical. If |
classifier |
Character. One of |
eps |
Small positive numerical floor. |
verbose |
Logical. If |
A list containing the criterion table and selected dimensions by criterion.
set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) dsel <- spfc_select_dimension( X, y, d_grid = 1:2, cov_method = 'oas', ytype = 'continuous', poly_degree = 2, verbose = FALSE ) dsel$selectedset.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) dsel <- spfc_select_dimension( X, y, d_grid = 1:2, cov_method = 'oas', ytype = 'continuous', poly_degree = 2, verbose = FALSE ) dsel$selected
Selects variables using either the thesis-safe adaptive weighted L1 route or the experimental C1F-informed extension route.
spfc_select_variables( fit, method = c("adaptive_weighted_l1", "c1f_extension"), selection_rule = c("c1f", "quantile", "fixed"), reduced_model = NULL, threshold = NULL, quantile_cut = 0.75, gamma = 1, c1f_calibration = c("icomp_hd_floor", "robust_universal", "raw"), eps = 1e-10 )spfc_select_variables( fit, method = c("adaptive_weighted_l1", "c1f_extension"), selection_rule = c("c1f", "quantile", "fixed"), reduced_model = NULL, threshold = NULL, quantile_cut = 0.75, gamma = 1, c1f_calibration = c("icomp_hd_floor", "robust_universal", "raw"), eps = 1e-10 )
fit |
Object returned by |
method |
Character. One of |
selection_rule |
Character. One of |
reduced_model |
Fitted reduced model used to obtain the model-parameter covariance when |
threshold |
Numeric threshold applied to variable importance scores.
If |
quantile_cut |
Numeric quantile used when |
gamma |
Positive adaptivity exponent for |
c1f_calibration |
Character. |
eps |
Small positive numerical constant. |
A data frame containing variable indices, importance scores, weights, and selected status.
set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) fit <- spfc_fit(X, y, d = 1, ytype = 'continuous', cov_method = 'oas', poly_degree = 2) reduced_model <- fit_reduced_model( fit$Z, y, ytype = 'continuous' ) sel <- spfc_select_variables( fit, method = 'c1f_extension', selection_rule = 'c1f', reduced_model = reduced_model ) sel[, c('variable', 'shrunk_importance', 'selected')]set.seed(1) X <- matrix(rnorm(180), nrow = 30, ncol = 6) y <- X[, 1] - 0.7 * X[, 2] + rnorm(30, sd = 0.5) fit <- spfc_fit(X, y, d = 1, ytype = 'continuous', cov_method = 'oas', poly_degree = 2) reduced_model <- fit_reduced_model( fit$Z, y, ytype = 'continuous' ) sel <- spfc_select_variables( fit, method = 'c1f_extension', selection_rule = 'c1f', reduced_model = reduced_model ) sel[, c('variable', 'shrunk_importance', 'selected')]
Computes a ridge-stabilised covariance estimator by adding a positive constant to the diagonal of the sample covariance matrix.
sre(x, gamma = 0.1)sre(x, gamma = 0.1)
x |
Numeric predictor matrix. |
gamma |
Ridge constant. |
A list with covariance matrix covx, ridge intensity rho,
and method label.
set.seed(1) X <- matrix(rnorm(120), nrow = 20, ncol = 6) est <- sre(X, gamma = 0.1) c(method = est$method, rho = est$rho)set.seed(1) X <- matrix(rnorm(120), nrow = 20, ncol = 6) est <- sre(X, gamma = 0.1) c(method = est$method, rho = est$rho)
Computes a sine-angle distance between two subspaces.
subspace_distance(B_true, B_hat)subspace_distance(B_true, B_hat)
B_true |
True basis matrix. |
B_hat |
Estimated basis matrix. |
Numeric subspace distance.
B1 <- matrix(c(1, 0, 0), ncol = 1) B2 <- matrix(c(0.9, 0.1, 0), ncol = 1) subspace_distance(B1, B2)B1 <- matrix(c(1, 0, 0), ncol = 1) B2 <- matrix(c(0.9, 0.1, 0), ncol = 1) subspace_distance(B1, B2)
Aggregates Monte Carlo simulation results by covariance estimator, variable-selection method, and design factors.
summarise_spfc_simulation(results)summarise_spfc_simulation(results)
results |
Data frame returned by |
A summary data frame.
results <- run_spfc_simulation( response_type = 'continuous', nrep = 1, n = 30, p = 8, d = 1, s = 3, rho_x = 0.3, snr = 2, cov_methods = c('oas', 'sre'), variable_methods = 'adaptive_weighted_l1', seed = 123 ) summarise_spfc_simulation(results)results <- run_spfc_simulation( response_type = 'continuous', nrep = 1, n = 30, p = 8, d = 1, s = 3, rho_x = 0.3, snr = 2, cov_methods = c('oas', 'sre'), variable_methods = 'adaptive_weighted_l1', seed = 123 ) summarise_spfc_simulation(results)
Summarise Complete SPFC Workflow
## S3 method for class 'spfc' summary(object, ...)## S3 method for class 'spfc' summary(object, ...)
object |
Object returned by |
... |
Additional arguments. |
A list of class summary.spfc.
Summarise SPFC Benchmark
## S3 method for class 'spfc_benchmark' summary(object, metric = NULL, smaller_is_better = NULL, ...)## S3 method for class 'spfc_benchmark' summary(object, metric = NULL, smaller_is_better = NULL, ...)
object |
Object returned by |
metric |
Optional selection metric. |
smaller_is_better |
Optional logical indicating whether smaller values are better. |
... |
Additional arguments. |
A list of class summary.spfc_benchmark.
Summarise an SPFC Fit
## S3 method for class 'spfc_fit' summary(object, ...)## S3 method for class 'spfc_fit' summary(object, ...)
object |
Object returned by |
... |
Additional arguments. |
A list containing key SPFC summary components.
Compute Variable-Selection Performance
variable_selection_metrics(selected, active_set, p)variable_selection_metrics(selected, active_set, p)
selected |
Integer vector of selected variable indices. |
active_set |
Integer vector of truly active variable indices. |
p |
Total number of variables. |
A list of precision, recall, F1, false positives, and false negatives.
variable_selection_metrics( selected = c(1, 2, 5), active_set = c(1, 2, 3), p = 8 )variable_selection_metrics( selected = c(1, 2, 5), active_set = c(1, 2, 3), p = 8 )