### Install TRexSelector Package from GitHub Source: https://cran.r-project.org/web/packages/TRexSelector/readme/README.html Installs the developer version of the 'TRexSelector' package from GitHub using the devtools package. Ensure devtools is installed first. ```R install.packages("devtools") devtools::install_github("jasinmachkour/TRexSelector") ``` -------------------------------- ### Example Usage of TRexSelector Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Demonstrates how to use the screen_trex function with sample data to obtain selected variables. Requires loading data and setting a random seed. ```R data("Gauss_data") X <- Gauss_data$X y <- c(Gauss_data$y) set.seed(123) res <- screen_trex(X = X, y = y) selected_var <- res$selected_var selected_var ``` -------------------------------- ### Install tlars Package from GitHub Source: https://cran.r-project.org/web/packages/TRexSelector/readme/README.html Installs the developer version of the 'tlars' package from GitHub using the devtools package. Ensure devtools is installed first. ```R install.packages("devtools") devtools::install_github("jasinmachkour/tlars") ``` -------------------------------- ### Install TRexSelector Package from CRAN Source: https://cran.r-project.org/web/packages/TRexSelector/readme/README.html Installs the stable version of the 'TRexSelector' package from CRAN. This can be done after installing the 'tlars' package. ```R install.packages("TRexSelector") ``` -------------------------------- ### R Simulation Setup for TRexSelector Source: https://cran.r-project.org/web/packages/TRexSelector/vignettes/TRexSelector_usage_and_simulations.html Sets up simulation parameters, including data dimensions, true active variables, target FDR levels, and Monte Carlo runs. Initializes result matrices for False Discovery Proportion (FDP) and True Positive Proportion (TPP). ```R set.seed(1234) n <- 100 # number of observations p <- 150 # number of variables # Parameters num_act <- 10 # number of true active variables beta <- rep(0, times = p) # coefficient vector (all zeros first) beta[sample(seq(p), size = num_act, replace = FALSE)] <- 1 # coefficient vector (active variables with non-zero coefficients) true_actives <- which(beta > 0) # indices of true active variables tFDR_vec <- c(0.1, 0.15, 0.2, 0.25) # target FDR levels MC <- 100 # number of Monte Carlo runs per stopping point # Initialize results vectors FDP <- matrix(NA, nrow = MC, ncol = length(tFDR_vec)) TPP <- matrix(NA, nrow = MC, ncol = length(tFDR_vec)) ``` -------------------------------- ### Install TRexSelector Package Source: https://cran.r-project.org/web/packages/TRexSelector/vignettes/TRexSelector_usage_and_simulations.html Installs the 'TRexSelector' R package. Users can choose between the stable CRAN version or the developer version from GitHub. ```R # Option 1: Install stable version from CRAN install.packages("TRexSelector") # Option 2: install developer version from GitHub install.packages("devtools") devtools::install_github("jasinmachkour/TRexSelector") ``` -------------------------------- ### Install tlars Package from CRAN Source: https://cran.r-project.org/web/packages/TRexSelector/readme/README.html Installs the stable version of the 'tlars' package from CRAN. This is a prerequisite for installing TRexSelector. ```R install.packages("tlars") ``` -------------------------------- ### Install tlars Package Source: https://cran.r-project.org/web/packages/TRexSelector/vignettes/TRexSelector_usage_and_simulations.html Installs the 'tlars' package, a dependency for TRexSelector. Choose between the stable CRAN version or the developer version from GitHub. ```R # Option 1: Install stable version from CRAN install.packages("tlars") # Option 2: install developer version from GitHub install.packages("devtools") devtools::install_github("jasinmachkour/tlars") ``` -------------------------------- ### Generate High-Dimensional Gaussian Data Source: https://cran.r-project.org/web/packages/TRexSelector/readme/README.html Generates a synthetic high-dimensional Gaussian dataset for testing variable selection methods. It includes setup for dimensions, coefficients, and the data matrix X and response vector y. ```R library(TRexSelector) # Setup n <- 75 # number of observations p <- 150 # number of variables num_act <- 3 # number of true active variables beta <- c(rep(1, times = num_act), rep(0, times = p - num_act)) # coefficient vector true_actives <- which(beta > 0) # indices of true active variables num_dummies <- p # number of dummy predictors (also referred to as dummies) # Generate Gaussian data set.seed(123) X <- matrix(stats::rnorm(n * p), nrow = n, ncol = p) y <- X %*% beta + stats::rnorm(n) ``` -------------------------------- ### Open TRexSelector Package Help Pages Source: https://cran.r-project.org/web/packages/TRexSelector/readme/README.html Loads the TRexSelector package and opens its main help page. Individual functions like 'trex', 'random_experiments', etc., can also be accessed via '?'. ```R library(TRexSelector) help(package = "TRexSelector") ?trex ?random_experiments ?lm_dummy ?add_dummies ?add_dummies_GVS ?FDP ?TPP ``` -------------------------------- ### Basic TRex Selector Usage Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Demonstrates the basic usage of the `trex` function with sample data. Ensure the `Gauss_data` is loaded and the response vector `y` is correctly formatted. ```R data("Gauss_data") X <- Gauss_data$X y <- c(Gauss_data$y) set.seed(1234) res <- trex(X = X, y = y) selected_var <- res$selected_var selected_var ``` -------------------------------- ### Initialize Numerical Zero for Computations Source: https://cran.r-project.org/web/packages/TRexSelector/vignettes/TRexSelector_usage_and_simulations.html Sets a variable 'eps' to the machine epsilon for numerical stability in subsequent computations, particularly for comparing floating-point numbers to zero. ```R # Numerical zero olds <- .Machine$double.eps ``` -------------------------------- ### Run Random Experiments with TRex Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html This snippet demonstrates how to run random experiments using the `random_experiments` function with sample data. It initializes random seed, loads data, and calls the function to obtain results, specifically focusing on the relative occurrences matrix. ```R set.seed(123) data("Gauss_data") X <- Gauss_data$X y <- c(Gauss_data$y) res <- random_experiments(X = X, y = y) relative_occurrences_matrix <- res$phi_T_mat relative_occurrences_matrix ``` -------------------------------- ### BibTeX Entry for TRexSelector Preprint Source: https://cran.r-project.org/web/packages/TRexSelector/citation.html BibTeX entry for citing the TRexSelector research paper on arXiv. This is useful for LaTeX documents. ```bibtex @Article{ title = {The Terminating-Random Experiments Selector: Fast High-Dimensional Variable Selection with False Discovery Rate Control}, author = {Jasin Machkour and Michael Muma and Daniel P. Palomar}, journal = {arXiv preprint arXiv:2110.06048}, year = {2022}, url = {https://arxiv.org/abs/2110.06048}, } ``` -------------------------------- ### lm_dummy Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Performs one random experiment of the T-Rex selector, including dummy generation, appending, and forward selection. This function is a core component for simulating and analyzing the T-Rex selection process. ```APIDOC ## lm_dummy ### Description Run one random experiment of the T-Rex selector, i.e., generates dummies, appends them to the predictor matrix, and runs the forward selection algorithm until it is terminated after T_stop dummies have been selected. ### Usage ```R lm_dummy( X, y, model_tlars, T_stop = 1, num_dummies = ncol(X), method = "trex", GVS_type = "IEN", type = "lar", corr_max = 0.5, lambda_2_lars = NULL, early_stop = TRUE, verbose = TRUE, intercept = FALSE, standardize = TRUE ) ``` ### Arguments * `X` (matrix) - Real valued predictor matrix. * `y` (numeric) - Response vector. * `model_tlars` (object) - Object of the class tlars_cpp. It contains all state variables of the previous T-LARS step (necessary for warm-starts, i.e., restarting the forward selection process exactly where it was previously terminated). * `T_stop` (numeric) - Number of included dummies after which the random experiments (i.e., forward selection processes) are stopped. * `num_dummies` (numeric) - Number of dummies that are appended to the predictor matrix. * `method` (character) - 'trex' for the T-Rex selector, 'trex+GVS' for the T-Rex+GVS selector, 'trex+DA+AR1' for the T-Rex+DA+AR1 selector, 'trex+DA+equi' for the T-Rex+DA+equi selector, 'trex+DA+BT' for the T-Rex+DA+BT selector, 'trex+DA+NN' for the T-Rex+DA+NN selector. * `GVS_type` (character) - 'IEN' for the Informed Elastic Net, 'EN' for the ordinary Elastic Net. * `type` (character) - 'lar' for 'LARS' and 'lasso' for Lasso. * `corr_max` (numeric) - Maximum allowed correlation between any two predictors from different clusters. * `lambda_2_lars` (numeric) - lambda_2-value for LARS-based Elastic Net. * `early_stop` (logical) - If TRUE, then the forward selection process is stopped after T_stop dummies have been included. Otherwise the entire solution path is computed. * `verbose` (logical) - If TRUE progress in computations is shown when performing T-LARS steps on the created model. * `intercept` (logical) - If TRUE an intercept is included. * `standardize` (logical) - If TRUE the predictors are standardized and the response is centered. ### Value Object of the class tlars_cpp. ### Examples ```R set.seed(123) eps <- .Machine$double.eps n <- 75 p <- 100 X <- matrix(stats::rnorm(n * p), nrow = n, ncol = p) beta <- c(rep(3, times = 3), rep(0, times = 97)) y <- X %*% beta + rnorm(n) res <- lm_dummy(X = X, y = y, T_stop = 1, num_dummies = 5 * p) beta_hat <- res$get_beta()[seq(p)] support <- abs(beta_hat) > eps support ``` ``` -------------------------------- ### Run Single Random Experiment for T-Rex Selector Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Performs one random experiment for the T-Rex selector, including generating dummies, appending them, and running forward selection. Useful for warm-starts with T-LARS. ```R set.seed(123) olds <- .Machine$double.eps n <- 75 p <- 100 X <- matrix(stats::rnorm(n * p), nrow = n, ncol = p) beta <- c(rep(3, times = 3), rep(0, times = 97)) y <- X %*% beta + rnorm(n) res <- lm_dummy(X = X, y = y, T_stop = 1, num_dummies = 5 * p) beta_hat <- res$get_beta()[seq(p)] support <- abs(beta_hat) > eps support ``` -------------------------------- ### Run Multiple Random Experiments Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Executes K early-terminated T-Rex random experiments to compute relative occurrence matrices. Supports parallel processing and various selector methods. ```R random_experiments( X, y, K = 20, T_stop = 1, num_dummies = ncol(X), method = "trex", GVS_type = "EN", type = "lar", corr_max = 0.5, lambda_2_lars = NULL, early_stop = TRUE, lars_state_list, verbose = TRUE, intercept = FALSE, standardize = TRUE, dummy_coef = FALSE, parallel_process = FALSE, parallel_max_cores = min(K, max(1, parallel::detectCores(logical = FALSE))), seed = NULL, eps = .Machine$double.eps ) ``` -------------------------------- ### add_dummies_GVS Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Generates and appends dummy predictors to a predictor matrix for the T-Rex+GVS selector. This function is useful for preparing data for advanced selection methods. ```APIDOC ## add_dummies_GVS ### Description Generate num_dummies dummy predictors as required for the T-Rex+GVS selector and append them to the predictor matrix X. ### Usage ```R add_dummies_GVS(X, num_dummies, corr_max = 0.5) ``` ### Arguments * `X` (matrix) - Real valued predictor matrix. * `num_dummies` (numeric) - Number of dummies that are appended to the predictor matrix. Has to be a multiple of the number of original variables. * `corr_max` (numeric) - Maximum allowed correlation between any two predictors from different clusters. ### Value Enlarged predictor matrix for the T-Rex+GVS selector. ### Examples ```R set.seed(123) n <- 50 p <- 100 X <- matrix(stats::rnorm(n * p), nrow = n, ncol = p) add_dummies_GVS(X = X, num_dummies = p) ``` ``` -------------------------------- ### TRexSelector Helper Functions (v0.0.0.9000) Source: https://cran.r-project.org/web/packages/TRexSelector/news/news.html Non-exported helper functions included in the initial pre-release version. ```R fdp_hat(); Phi_prime_fun(); and select_var_fun(). ``` -------------------------------- ### add_dummies Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Appends a specified number of dummy predictors, sampled from a univariate standard normal distribution, to the predictor matrix X. This is a utility function for preparing data for certain selectors. ```APIDOC ## Add dummy predictors to the original predictor matrix ### Description Sample num_dummies dummy predictors from the univariate standard normal distribution and append them to the predictor matrix X. ### Usage ```R add_dummies(X, num_dummies) ``` ### Arguments `X` | Real valued predictor matrix. `num_dummies` | Number of dummies that are appended to the predictor matrix. ### Value Enlarged predictor matrix. ### Examples ```R set.seed(123) n <- 50 p <- 100 X <- matrix(stats::rnorm(n * p), nrow = n, ncol = p) add_dummies(X = X, num_dummies = p) ``` ``` -------------------------------- ### Cite TRexSelector Package Source: https://cran.r-project.org/web/packages/TRexSelector/readme/README.html Generates the citation information for the 'TRexSelector' package, which should be used when citing the package in publications. ```R citation("TRexSelector") ``` -------------------------------- ### TRexSelector Core Functions (v0.0.0.9000) Source: https://cran.r-project.org/web/packages/TRexSelector/news/news.html These are the primary functions for executing the T-Rex selector and its components in the initial release. ```R trex(); random_experiments(); lm_dummy(); add_dummies(); and add_dummies_GVS(). ``` -------------------------------- ### R Simulation Loop for TRexSelector Source: https://cran.r-project.org/web/packages/TRexSelector/vignettes/TRexSelector_usage_and_simulations.html Iterates through target FDR levels and Monte Carlo runs to generate data, run the TREX selector, and record False Discovery Proportion (FDP) and True Positive Proportion (TPP). ```R for (t in seq_along(tFDR_vec)) { for (mc in seq(MC)) { # Generate Gaussian data X <- matrix(stats::rnorm(n * p), nrow = n, ncol = p) y <- X %*% beta + stats::rnorm(n) # Run T-Rex selector res <- trex(X = X, y = y, tFDR = tFDR_vec[t], verbose = FALSE) selected_var <- which(res$selected_var > eps) # Results FDP[mc, t] <- length(setdiff(selected_var, true_actives)) / max(1, length(selected_var)) TPP[mc, t] <- length(intersect(selected_var, true_actives)) / max(1, length(true_actives)) } } ``` -------------------------------- ### BibTeX Entry for TRexSelector R Package Source: https://cran.r-project.org/web/packages/TRexSelector/citation.html BibTeX entry for citing the TRexSelector R package. This is useful for LaTeX documents. ```bibtex @Manual{ title = {{TRexSelector: T-Rex Selector: High-Dimensional Variable Selection & FDR Control}}, author = {Jasin Machkour and Simon Tien and Daniel P. Palomar and Michael Muma}, note = {R package version 1.0.0}, year = {2024}, url = {https://CRAN.R-project.org/package=TRexSelector}, } ``` -------------------------------- ### Add Dummy Variables for T-Rex+GVS Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Appends dummy predictors to a matrix for the T-Rex+GVS selector. Ensure the number of dummies is a multiple of the original variables. ```R set.seed(123) n <- 50 p <- 100 X <- matrix(stats::rnorm(n * p), nrow = n, ncol = p) add_dummies_GVS(X = X, num_dummies = p) ``` -------------------------------- ### Screen-T-Rex Selector Usage Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html This snippet shows the default usage of the `screen_trex` function for variable selection. It outlines the function's parameters, including the predictor matrix X, response vector y, number of random experiments K, and bootstrap resamples R. ```R screen_trex( X, y, K = 20, R = 1000, method = "trex", bootstrap = FALSE, conf_level_grid = seq(0, 1, by = 0.001), cor_coef = NA, type = "lar", corr_max = 0.5, lambda_2_lars = NULL, rho_thr_DA = 0.02, parallel_process = FALSE, parallel_max_cores = min(K, max(1, parallel::detectCores(logical = FALSE))), seed = NULL, eps = .Machine$double.eps, verbose = TRUE ) ``` -------------------------------- ### Generate Toy Gaussian Linear Model Data Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Generates a synthetic dataset for a Gaussian linear model, including a predictor matrix X, response vector y, parameter vector beta, and support vector. This data is useful for testing variable selection methods. ```R set.seed(789) n <- 50 p <- 100 X <- matrix(stats::rnorm(n * p), nrow = n, ncol = p) beta <- c(rep(5, times = 3), rep(0, times = 97)) support <- beta > 0 y <- X %*% beta + stats::rnorm(n) Gauss_data <- list( X = X, y = y, beta = beta, support = support ) ``` -------------------------------- ### Run the T-Rex selector Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html The T-Rex selector performs fast variable selection in high-dimensional settings while controlling the false discovery rate (FDR) at a user-defined target level. ```APIDOC ## trex ### Description The T-Rex selector (doi:10.48550/arXiv.2110.06048) performs fast variable selection in high-dimensional settings while controlling the false discovery rate (FDR) at a user-defined target level. ### Usage ``` trex( X, y, tFDR = 0.2, K = 20, max_num_dummies = 10, max_T_stop = TRUE, method = "trex", GVS_type = "IEN", cor_coef = NA, type = "lar", corr_max = 0.5, lambda_2_lars = NULL, rho_thr_DA = 0.02, hc_dist = "single", hc_grid_length = min(20, ncol(X)), parallel_process = FALSE, parallel_max_cores = min(K, max(1, parallel::detectCores(logical = FALSE))), seed = NULL, eps = .Machine$double.eps, verbose = TRUE ) ``` ### Arguments * `X` (matrix) - Input data matrix. * `y` (vector) - Response vector. * `tFDR` (numeric, optional) - Target FDR level (default: 0.2). * `K` (numeric, optional) - Number of random experiments (default: 20). * `max_num_dummies` (numeric, optional) - Maximum number of dummies to include (default: 10). * `max_T_stop` (logical, optional) - Whether to stop at the maximum number of dummies (default: TRUE). * `method` (character, optional) - Method to use for selection (default: "trex"). * `GVS_type` (character, optional) - Type of Generalized Variable Selection (default: "IEN"). * `cor_coef` (numeric, optional) - Correlation coefficient threshold (default: NA). * `type` (character, optional) - Type of regularization path (default: "lar"). * `corr_max` (numeric, optional) - Maximum correlation allowed between variables (default: 0.5). * `lambda_2_lars` (numeric, optional) - Lambda parameter for LARS (default: NULL). * `rho_thr_DA` (numeric, optional) - Threshold for DA (default: 0.02). * `hc_dist` (character, optional) - Distance metric for hierarchical clustering (default: "single"). * `hc_grid_length` (numeric, optional) - Length of the hierarchical clustering grid (default: min(20, ncol(X))). * `parallel_process` (logical, optional) - Whether to use parallel processing (default: FALSE). * `parallel_max_cores` (numeric, optional) - Maximum number of cores to use for parallel processing (default: min(K, max(1, parallel::detectCores(logical = FALSE)))). * `seed` (numeric, optional) - Random seed for reproducibility (default: NULL). * `eps` (numeric, optional) - Small value for numerical stability (default: .Machine$double.eps). * `verbose` (logical, optional) - Whether to print verbose output (default: TRUE). ### Value A list containing the estimated support vector, the automatically selected false discovery rate (FDR), and additional information. ``` -------------------------------- ### Compute Selected Variables (T-Rex+DA+BT) Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Function to compute the set of selected variables using the T-Rex+DA+BT selector. It requires additional parameters for the BT method, including FDP estimates, occurrences, voting levels, and dendrogram grid. ```R select_var_fun_DA_BT( p, tFDR, T_stop, FDP_hat_array_BT, Phi_array_BT, V, rho_grid ) ``` -------------------------------- ### random_experiments Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Runs multiple early terminated T-Rex random experiments and computes the matrix of relative occurrences. This function is designed for comprehensive simulation studies and performance evaluation. ```APIDOC ## random_experiments ### Description Run K early terminated T-Rex random experiments and compute the matrix of relative occurrences for all variables and all numbers of included variables before stopping. ### Usage ```R random_experiments( X, y, K = 20, T_stop = 1, num_dummies = ncol(X), method = "trex", GVS_type = "EN", type = "lar", corr_max = 0.5, lambda_2_lars = NULL, early_stop = TRUE, lars_state_list, verbose = TRUE, intercept = FALSE, standardize = TRUE, dummy_coef = FALSE, parallel_process = FALSE, parallel_max_cores = min(K, max(1, parallel::detectCores(logical = FALSE))), seed = NULL, eps = .Machine$double.eps ) ``` ### Arguments * `X` (matrix) - Real valued predictor matrix. * `y` (numeric) - Response vector. * `K` (numeric) - Number of random experiments to run. * `T_stop` (numeric) - Number of included dummies after which the random experiments are stopped. * `num_dummies` (numeric) - Number of dummies that are appended to the predictor matrix. * `method` (character) - Selection method: 'trex', 'trex+GVS', 'trex+DA+AR1', 'trex+DA+equi', 'trex+DA+BT', 'trex+DA+NN'. * `GVS_type` (character) - Type of GVS: 'IEN' or 'EN'. * `type` (character) - Type of algorithm: 'lar' or 'lasso'. * `corr_max` (numeric) - Maximum allowed correlation between any two predictors from different clusters. * `lambda_2_lars` (numeric) - lambda_2-value for LARS-based Elastic Net. * `early_stop` (logical) - If TRUE, forward selection stops after T_stop dummies. Otherwise, the entire solution path is computed. * `lars_state_list` (list) - List of T-LARS states for warm-starts. * `verbose` (logical) - If TRUE, progress is shown. * `intercept` (logical) - If TRUE, an intercept is included. * `standardize` (logical) - If TRUE, predictors are standardized and response is centered. * `dummy_coef` (logical) - If TRUE, dummy coefficients are returned. * `parallel_process` (logical) - If TRUE, computations are parallelized. * `parallel_max_cores` (numeric) - Maximum number of cores to use for parallel processing. * `seed` (numeric) - Seed for random number generation. * `eps` (numeric) - Numerical zero. ``` -------------------------------- ### Run T-Rex Selector Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html The main function to run the T-Rex selector for variable selection in high-dimensional settings. It offers various parameters to control the selection process, including FDR level, number of dummies, and methods. ```R trex( X, y, tFDR = 0.2, K = 20, max_num_dummies = 10, max_T_stop = TRUE, method = "trex", GVS_type = "IEN", cor_coef = NA, type = "lar", corr_max = 0.5, lambda_2_lars = NULL, rho_thr_DA = 0.02, hc_dist = "single", hc_grid_length = min(20, ncol(X)), parallel_process = FALSE, parallel_max_cores = min(K, max(1, parallel::detectCores(logical = FALSE))), seed = NULL, eps = .Machine$double.eps, verbose = TRUE ) ``` -------------------------------- ### Gauss_data Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html A toy dataset generated from a Gaussian linear model, containing a predictor matrix X, response vector y, and parameter vector beta. This dataset is useful for testing and demonstrating variable selection algorithms. ```APIDOC ## Toy data generated from a Gaussian linear model ### Description A data set containing a predictor matrix X with n = 50 observations and p = 100 variables (predictors), and a sparse parameter vector beta with associated support vector. ### Usage ```R Gauss_data ``` ### Format A list containing a matrix X and vectors y, beta, and support: X Predictor matrix, n = 50, p = 100. y Response vector. beta Parameter vector. support Support vector. ### Examples ```R # Generated as follows: set.seed(789) n <- 50 p <- 100 X <- matrix(stats::rnorm(n * p), nrow = n, ncol = p) beta <- c(rep(5, times = 3), rep(0, times = 97)) support <- beta > 0 y <- X %*% beta + stats::rnorm(n) Gauss_data <- list( X = X, y = y, beta = beta, support = support ) ``` ``` -------------------------------- ### Compute set of selected variables for the T-Rex+DA+BT selector Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Computes the set of selected variables and returns the estimated support vector for the T-Rex+DA+BT selector. This function is used internally by the `trex` function. ```APIDOC ## select_var_fun_DA_BT ### Description Computes the set of selected variables and returns the estimated support vector for the T-Rex+DA+BT selector (doi:10.48550/arXiv.2401.15796). ### Usage ``` select_var_fun_DA_BT( p, tFDR, T_stop, FDP_hat_array_BT, Phi_array_BT, V, rho_grid ) ``` ### Arguments * `p` (numeric) - Number of candidate variables. * `tFDR` (numeric) - Target FDR level (between 0 and 1, i.e., 0% and 100%). * `T_stop` (numeric) - Number of included dummies after which the random experiments (i.e., forward selection processes) are stopped. * `FDP_hat_array_BT` (array) - Array containing the conservative FDP estimates for all variables (dimension 1), values of the voting level grid (dimension 2), and values of the dendrogram grid (dimension 3). * `Phi_array_BT` (array) - Array of relative occurrences as determined by the T-Rex calibration algorithm. * `V` (numeric) - Voting level grid. * `rho_grid` (numeric) - Dendrogram grid. ### Value List containing the estimated support vector, etc. ``` -------------------------------- ### Calculate False Discovery Proportion (FDP) Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Computes the FDP using estimated and true regression coefficient vectors. Requires the 'Gauss_data' dataset and the 'trex' function for initial results. ```R data("Gauss_data") X <- Gauss_data$X y <- c(Gauss_data$y) beta <- Gauss_data$beta set.seed(1234) res <- trex(X, y) beta_hat <- res$selected_var FDP(beta_hat = beta_hat, beta = beta) ``` -------------------------------- ### TRexSelector FDP/TPP Functions (v0.0.0.9000) Source: https://cran.r-project.org/web/packages/TRexSelector/news/news.html Functions for computing the False Discovery Proportion (FDP) and True Positive Proportion (TPP) in the initial release. ```R FDP(); and TPP(). ``` -------------------------------- ### TRexSelector Preprint Citation Source: https://cran.r-project.org/web/packages/TRexSelector/citation.html Use this format when citing the TRexSelector research paper published on arXiv. Ensure the year and URL are current. ```text Machkour J, Muma M, Palomar DP (2022). “The Terminating-Random Experiments Selector: Fast High-Dimensional Variable Selection with False Discovery Rate Control.” _arXiv preprint arXiv:2110.06048_. https://arxiv.org/abs/2110.06048. ``` -------------------------------- ### Calculate True Positive Proportion (TPP) Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Computes the TPP using estimated and true regression coefficient vectors. Similar to FDP calculation, it requires the 'Gauss_data' dataset and the 'trex' function. ```R data("Gauss_data") X <- Gauss_data$X y <- c(Gauss_data$y) beta <- Gauss_data$beta set.seed(1234) res <- trex(X, y) beta_hat <- res$selected_var TPP(beta_hat = beta_hat, beta = beta) ``` -------------------------------- ### Compute Selected Variables (T-Rex) Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Function to compute the set of selected variables using the T-Rex selector. It requires parameters related to FDR, stopping criteria, FDP estimates, occurrences, and voting levels. ```R select_var_fun( p, tFDR, T_stop, FDP_hat_mat, Phi_mat, V ) ``` -------------------------------- ### TRexSelector R Package Citation Source: https://cran.r-project.org/web/packages/TRexSelector/citation.html Use this format when citing the TRexSelector R package in publications. Ensure the version and URL are current. ```text Machkour J, Tien S, Palomar DP, Muma M (2024). _TRexSelector: T-Rex Selector: High-Dimensional Variable Selection & FDR Control_. R package version 1.0.0, https://CRAN.R-project.org/package=TRexSelector. ``` -------------------------------- ### TPP Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Computes the True Positive Proportion (TPP) based on the estimated and true regression coefficient vectors. This metric is used to evaluate the accuracy of selected variables. ```APIDOC ## True positive proportion (TPP) ### Description Computes the TPP based on the estimated and the true regression coefficient vectors. ### Usage ```R TPP(beta_hat, beta, eps = .Machine$double.eps) ``` ### Arguments `beta_hat` | Estimated regression coefficient vector. `beta` | True regression coefficient vector. `eps` | Numerical zero. ### Value True positive proportion (TPP). ### Examples ```R data("Gauss_data") X <- Gauss_data$X y <- c(Gauss_data$y) beta <- Gauss_data$beta set.seed(1234) res <- trex(X, y) beta_hat <- res$selected_var TPP(beta_hat = beta_hat, beta = beta) ``` ``` -------------------------------- ### Perform FDR-Controlled Variable Selection with T-Rex Source: https://cran.r-project.org/web/packages/TRexSelector/vignettes/TRexSelector_usage_and_simulations.html Applies the T-Rex selector to perform variable selection on the generated data, aiming for a target False Discovery Rate (FDR) of 5%. It then compares the selected variables to the true active variables. ```R # Seed set.seed(1234) # Numerical zero olds <- .Machine$double.eps # Variable selection via T-Rex res <- trex(X = X, y = y, tFDR = 0.05, verbose = FALSE) selected_var <- which(res$selected_var > eps) paste0("True active variables: ", paste(as.character(true_actives), collapse = ", ")) #> [1] "True active variables: 1, 2, 3" paste0("Selected variables: ", paste(as.character(selected_var), collapse = ", ")) #> [1] "Selected variables: 1, 2, 3" ``` -------------------------------- ### fdp_hat Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Computes the conservative False Discovery Proportion (FDP) estimate for the T-Rex selector. This function is essential for evaluating the performance and reliability of the T-Rex selection method. ```APIDOC ## fdp_hat ### Description Computes the conservative FDP estimate of the T-Rex selector. ### Usage ```R fdp_hat(V, Phi, Phi_prime, eps = .Machine$double.eps) ``` ### Arguments * `V` (numeric) - Voting level grid. * `Phi` (numeric) - Vector of relative occurrences. * `Phi_prime` (numeric) - Vector of deflated relative occurrences. * `eps` (numeric) - Numerical zero. ### Value Vector of conservative FDP estimates for each value of the voting level grid. ``` -------------------------------- ### Compute set of selected variables Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Computes the set of selected variables and returns the estimated support vector for the T-Rex selector. This function is used internally by the `trex` function. ```APIDOC ## select_var_fun ### Description Computes the set of selected variables and returns the estimated support vector for the T-Rex selector (doi:10.48550/arXiv.2110.06048). ### Usage ``` select_var_fun(p, tFDR, T_stop, FDP_hat_mat, Phi_mat, V) ``` ### Arguments * `p` (numeric) - Number of candidate variables. * `tFDR` (numeric) - Target FDR level (between 0 and 1, i.e., 0% and 100%). * `T_stop` (numeric) - Number of included dummies after which the random experiments (i.e., forward selection processes) are stopped. * `FDP_hat_mat` (matrix) - Matrix whose rows are the vectors of conservative FDP estimates for each value of the voting level grid. * `Phi_mat` (matrix) - Matrix of relative occurrences as determined by the T-Rex calibration algorithm. * `V` (numeric) - Voting level grid. ### Value Estimated support vector. ``` -------------------------------- ### Compute Conservative FDP Estimate Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Calculates the conservative False Discovery Proportion (FDP) estimate for the T-Rex selector. Requires voting level grid, relative occurrences, and deflated relative occurrences. ```R fdp_hat(V, Phi, Phi_prime, eps = .Machine$double.eps) ``` -------------------------------- ### R Compute Average FDR and TPR Source: https://cran.r-project.org/web/packages/TRexSelector/vignettes/TRexSelector_usage_and_simulations.html Calculates the average False Discovery Rate (FDR) and True Positive Proportion (TPR) across all Monte Carlo runs for each target FDR level. ```R # Compute estimates of FDR and TPR by averaging FDP and TPP over MC Monte Carlo runs FDR <- colMeans(FDP) TPR <- colMeans(TPP) ``` -------------------------------- ### Screen-T-Rex Selector Function Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html The Screen-T-Rex selector performs fast variable selection in high-dimensional settings and informs about the automatically selected false discovery rate (FDR). ```APIDOC ## screen_trex ### Description The Screen-T-Rex selector performs very fast variable selection in high-dimensional settings while informing the user about the automatically selected false discovery rate (FDR). ### Usage ```R screen_trex( X, y, K = 20, R = 1000, method = "trex", bootstrap = FALSE, conf_level_grid = seq(0, 1, by = 0.001), cor_coef = NA, type = "lar", corr_max = 0.5, lambda_2_lars = NULL, rho_thr_DA = 0.02, parallel_process = FALSE, parallel_max_cores = min(K, max(1, parallel::detectCores(logical = FALSE))), seed = NULL, eps = .Machine$double.eps, verbose = TRUE ) ``` ### Arguments - **X** (matrix) - Real valued predictor matrix. - **y** (vector) - Response vector. - **K** (numeric) - Number of random experiments. - **R** (numeric) - Number of bootstrap resamples. - **method** (character) - Method to use. Options include 'trex', 'trex+GVS', 'trex+DA+AR1', 'trex+DA+equi'. - **bootstrap** (logical) - If TRUE, Screen-T-Rex is carried out with bootstrapping. - **conf_level_grid** (numeric) - Confidence level grid for the bootstrap confidence intervals. - **cor_coef** (numeric) - AR(1) autocorrelation coefficient or equicorrelation coefficient. - **type** (character) - Type of selection algorithm. Options are 'lar' (LARS) and 'lasso'. - **corr_max** (numeric) - Maximum allowed correlation between any two predictors from different clusters. - **lambda_2_lars** (numeric) - lambda_2-value for LARS-based Elastic Net. - **rho_thr_DA** (numeric) - Correlation threshold for 'trex+DA+AR1' and 'trex+DA+equi' methods. - **parallel_process** (logical) - If TRUE, random experiments are executed in parallel. - **parallel_max_cores** (numeric) - Maximum number of cores for parallel processing. - **seed** (numeric) - Seed for the random number generator. - **eps** (numeric) - Numerical zero. - **verbose** (logical) - If TRUE, shows progress in computations. ``` -------------------------------- ### Add Dummy Predictors to Predictor Matrix Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Appends a specified number of dummy predictors, sampled from a univariate standard normal distribution, to an existing predictor matrix. This is useful for methods that require augmented feature sets. ```R set.seed(123) n <- 50 p <- 100 X <- matrix(stats::rnorm(n * p), nrow = n, ncol = p) add_dummies(X = X, num_dummies = p) ``` -------------------------------- ### FDP Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Computes the False Discovery Proportion (FDP) based on the estimated and true regression coefficient vectors. This is useful for evaluating the performance of variable selection methods. ```APIDOC ## FDP ### Description Computes the FDP based on the estimated and the true regression coefficient vectors. ### Usage ```R FDP(beta_hat, beta, eps = .Machine$double.eps) ``` ### Arguments `beta_hat` | Estimated regression coefficient vector. `beta` | True regression coefficient vector. `eps` | Numerical zero. ### Value False discovery proportion (FDP). ### Examples ```R data("Gauss_data") X <- Gauss_data$X y <- c(Gauss_data$y) beta <- Gauss_data$beta set.seed(1234) res <- trex(X, y) beta_hat <- res$selected_var FDP(beta_hat = beta_hat, beta = beta) ``` ``` -------------------------------- ### TRex Selector Function Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html The TRex selector is used for variable selection. It takes a predictor matrix and a response vector as input and performs random experiments to identify relevant variables. ```APIDOC ## random_experiments ### Description Performs random experiments for variable selection using the T-Rex method. ### Arguments - **X** (matrix) - Real valued predictor matrix. - **y** (vector) - Response vector. - **K** (numeric) - Number of random experiments. - **T_stop** (numeric) - Number of included dummies after which the random experiments are stopped. - **num_dummies** (numeric) - Number of dummies that are appended to the predictor matrix. - **method** (character) - Method to use for selection. Options include 'trex', 'trex+GVS', 'trex+DA+AR1', 'trex+DA+equi', 'trex+DA+BT', 'trex+DA+NN'. - **GVS_type** (character) - Type of GVS to use. Options include 'IEN' and 'EN'. - **type** (character) - Type of selection algorithm. Options are 'lar' (LARS) and 'lasso'. - **corr_max** (numeric) - Maximum allowed correlation between any two predictors from different clusters (for method = 'trex+GVS'). - **lambda_2_lars** (numeric) - lambda_2-value for LARS-based Elastic Net. - **early_stop** (logical) - If TRUE, stops after T_stop dummies are included. Otherwise, computes the entire solution path. - **lars_state_list** (list) - List of state variables or objects for warm-starts in previous T-LARS steps. - **verbose** (logical) - If TRUE, shows progress in computations. - **intercept** (logical) - If TRUE, includes an intercept. - **standardize** (logical) - If TRUE, predictors are standardized and the response is centered. - **dummy_coef** (logical) - If TRUE, returns a matrix of terminal dummy coefficient vectors. - **parallel_process** (logical) - If TRUE, executes random experiments in parallel. - **parallel_max_cores** (numeric) - Maximum number of cores for parallel processing. - **seed** (numeric) - Seed for the random number generator. - **eps** (numeric) - Numerical zero. ### Value List containing the results of the K random experiments. ### Examples ```R set.seed(123) data("Gauss_data") X <- Gauss_data$X y <- c(Gauss_data$y) res <- random_experiments(X = X, y = y) relative_occurrences_matrix <- res$phi_T_mat relative_occurrences_matrix ``` ``` -------------------------------- ### Phi_prime_fun Source: https://cran.r-project.org/web/packages/TRexSelector/refman/TRexSelector.html Computes the vector of deflated relative occurrences for all variables up to a specified number of included dummies (T_stop). This function is part of the T-Rex+GVS selector. ```APIDOC ## Computes the Deflated Relative Occurrences ### Description Computes the vector of deflated relative occurrences for all variables (i.e., j = 1,..., p) and T = T_stop. ### Usage ```R Phi_prime_fun( p, T_stop, num_dummies, phi_T_mat, Phi, eps = .Machine$double.eps ) ``` ### Arguments `p` | Number of candidate variables. `T_stop` | Number of included dummies after which the random experiments (i.e., forward selection processes) are stopped. `num_dummies` | Number of dummies `phi_T_mat` | Matrix of relative occurrences for all variables (i.e., j = 1,..., p) and for T = 1, ..., T_stop. `Phi` | Vector of relative occurrences for all variables (i.e., j = 1,..., p) at T = T_stop. `eps` | Numerical zero. ### Value Vector of deflated relative occurrences for all variables (i.e., j = 1,..., p) and T = T_stop. ``` -------------------------------- ### Perform FDR-Controlled Variable Selection with TRex Source: https://cran.r-project.org/web/packages/TRexSelector/readme/README.html Performs variable selection using the T-Rex selector with a target False Discovery Rate (FDR) of 5%. It then extracts and displays the true and selected active variables. ```R # Seed set.seed(1234) # Numerical zero eps <- .Machine$double.eps # Variable selection via T-Rex res <- trex(X = X, y = y, tFDR = 0.05, verbose = FALSE) selected_var <- which(res$selected_var > eps) paste0("True active variables: ", paste(as.character(true_actives), collapse = ", ")) #> [1] "True active variables: 1, 2, 3" paste0("Selected variables: ", paste(as.character(selected_var), collapse = ", ")) #> [1] "Selected variables: 1, 2, 3" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.