ShiVa {ShiVa}R Documentation

ShiVa: Automatic Shift Detection in Mean and Variance

Description

Performs automatic detection of evolutionary shifts in both optimal trait values (mean) and diffusion variance under an Ornstein-Uhlenbeck (OU) process. This function serves as a wrapper for get_mean_var_shifts_model_selection, with the added ability to automatically estimate the selection strength parameter alpha if not provided.

Usage

ShiVa(
  Y,
  tree,
  alpha = NULL,
  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
)

Arguments

Y

A numeric vector of trait values at the tips of the phylogenetic tree.

tree

A phylogenetic tree of class phylo.

alpha

(Optional) A non-negative numeric value specifying the OU selection strength. If NULL, it is estimated via maximum likelihood using phylolm().

t

Step size for optimization. Default is 0.01.

lambda1_list

A numeric vector of candidate \lambda_1 values for penalizing mean shifts.

lambda2_list

A numeric vector of candidate \lambda_2 values for penalizing variance shifts. Default is exp(1:10 * 0.4 - 6).

criterion

Model selection criterion to use. Options are "BIC", "mBIC", or "pBIC". Default is "BIC".

max.steps

Maximum number of optimization steps. Default is 300.

nfolds

Number of folds for cross-validation in tuning lambda1. Default is 8.

top_k

Number of top candidate models (based on criterion) to refine using backward correction. Default is 10.

measurement_error

Logical. If TRUE, estimates a measurement error variance term. Default is FALSE.

lambda.type

Cross-validation rule for selecting lambda1. Options are "lambda.min" or "lambda.1se". Default is "lambda.1se".

max.num.shifts

Maximum number of allowed shifts (in both mean and variance). Default is Inf.

Value

A list with the same structure as get_mean_var_shifts_model_selection:

best_model

The final selected OU model object.

score_summary

A data frame summarizing candidate models and backward-corrected scores.


[Package ShiVa version 1.0.1 Index]