Performs model selection to estimate the locations and magnitudes of evolutionary shifts in optimal trait values (mean) and diffusion variance under an Ornstein-Uhlenbeck (OU) process. This function searches across user-defined grids of shrinkage parameters for both types of shifts, uses cross-validation for selecting lambda1, and applies backward correction to refine top candidate models.
get_mean_var_shifts_model_selection(
Y,
tree,
alpha,
t = 0.01,
lambda1_list = NULL,
lambda2_list = exp(1:10 * 0.4 - 6),
criterion = "BIC",
max.steps = 300,
nfolds = 8,
top_k = 10,
measurement_error = FALSE,
lambda.type = "lambda.1se",
max.num.shifts = Inf,
verbose = TRUE
)A list containing:
The final selected OU model object, with estimated shifts and parameters.
A data frame summarizing the model selection results, including pre- and post-correction scores and shift locations.
A numeric vector of trait values for the species at the tips of the phylogenetic tree.
A phylogenetic tree of class phylo.
A non-negative numeric value representing the selection strength in the OU process.
Step size for iterative optimization. Default is 0.01.
A numeric vector of candidate \(\lambda_1\) values controlling shrinkage for shifts in optimal values.
A numeric vector of candidate \(\lambda_2\) values controlling shrinkage for shifts in variance. Default is exp(1:10*0.4-6)
Model selection criterion to optimize. Options include "BIC", "mBIC", or "pBIC". Default is "BIC".
Maximum number of optimization steps. Default is 300.
Number of cross-validation folds for tuning lambda1. Default is 8.
Number of top candidate models (ranked by criterion) to further refine using backward correction. Default is 10.
Logical. If TRUE, estimates a separate measurement error variance component. Default is FALSE.
A character string specifying the cross-validation rule used to select lambda1 from lambda1_list. Options are "lambda.min" (minimum CV error) and "lambda.1se" (1-SE rule, higher penalty). Default is "lambda.1se".
An integer specifying the maximum number of allowed shifts (combined across mean and variance). Default is Inf.
Logical. If TRUE, prints progress messages to the console. Default is TRUE.