Learn R Programming

ShiVa (version 1.0.1)

get_mean_var_shifts: Estimate Shifts in Optimal Trait Values and Variance

Description

Estimates shifts in both the optimal trait values (mean) and evolutionary variance along a phylogeny under an Ornstein-Uhlenbeck (OU) process, using an \(\ell_1\)-penalized optimization procedure. Optionally accounts for measurement error in the observed trait data.

Usage

get_mean_var_shifts(
  Y,
  tree,
  alpha,
  lambda1,
  lambda2,
  max.steps = 1000,
  t = 0.01,
  penalty = "L1",
  thres = 0.01,
  sigma2 = NULL,
  measurement_error = FALSE
)

Value

A list containing:

shifts_mean

Indices of branches with detected shifts in optimal trait values (\(\beta \neq 0\)).

shifts_var

Indices of branches with detected shifts in evolutionary variance (\(\gamma \neq 0\)).

beta

Estimated shift coefficients for optimal trait values.

gamma

Estimated shift coefficients for evolutionary variance.

sigma2

Estimated base variance (\(\sigma^2\)) of the OU process.

b0

Estimated intercept (root state).

sigma2_error

Estimated measurement error variance (only returned if measurement_error = TRUE).

Arguments

Y

A numeric vector of continuous trait values for the species at the tips of the tree.

tree

A phylogenetic tree of class phylo.

alpha

The selection strength parameter in the OU process.

lambda1

Non-negative penalty for \(\beta\) (shifts in optimal trait values).

lambda2

Non-negative penalty for \(\gamma\) (shifts in evolutionary variance).

max.steps

Maximum number of optimization steps. Default is 1000.

t

Step size for the gradient-based updates. Default is 0.01.

penalty

Type of penalty to apply. Options are "L1" (default) or "None".

thres

Convergence threshold for the change in loss between steps. Default is 0.01.

sigma2

Optional initial value for the base evolutionary variance. If NULL, it is initialized to 1.

measurement_error

Logical. If TRUE, the method estimates additional measurement error variance.