Learn R Programming

ShiVa (version 1.0.1)

backward_correction: Backward Selection for OU Model Shift Correction

Description

Performs backward stepwise selection on a given set of candidate shifts in optimal trait values (mean) and evolutionary variance under an Ornstein-Uhlenbeck (OU) model. This function iteratively removes individual shifts to improve model fit based on a specified selection criterion.

Usage

backward_correction(
  tree,
  Y,
  alpha,
  shifts_mean,
  shifts_var,
  criterion = "BIC",
  original_model = NULL,
  measurement_error = FALSE,
  max.num.shifts = Inf
)

Value

A fitted OU model object (a list), as returned by fit_OU_mean_var, with a potentially reduced set of shifts that minimizes the specified criterion.

Arguments

tree

A phylogenetic tree of class phylo.

Y

A numeric vector of trait values corresponding to the tips of the tree.

alpha

A non-negative numeric value specifying the strength of selection in the OU process.

shifts_mean

A vector of branch indices with candidate shifts in optimal trait values.

shifts_var

A vector of branch indices with candidate shifts in evolutionary variance.

criterion

A model selection criterion to guide backward elimination. Options include "BIC", "mBIC", or "pBIC". Default is "BIC".

original_model

(Optional) A previously fitted OU model returned by fit_OU_mean_var. If NULL, the model is refit using the provided shifts.

measurement_error

Logical. If TRUE, the model accounts for measurement error by estimating an additional variance term. Default is FALSE.

max.num.shifts

An integer specifying the maximum number of total shifts (mean and variance combined) allowed in the model. Default is Inf.