fit_tree_model {castor} R Documentation

## Fit a cladogenic model to an existing tree.

### Description

Fit the parameters of a tree generation model to an existing phylogenetic tree; branch lengths are assumed to be in time units. The fitted model is a stochastic cladogenic process in which speciations (births) and extinctions (deaths) are Poisson processes, as simulated by the function generate_random_tree. The birth and death rates of tips can each be constant or power-law functions of the number of extant tips. For example,

B = I + F\cdot N^E,

where B is the birth rate, I is the intercept, F is the power-law factor, N is the current number of extant tips and E is the power-law exponent. Each of the parameters I, F, E can be fixed or fitted.

Fitting can be performed via maximum-likelihood estimation, based on the waiting times between subsequent speciation and/or extinction events represented in the tree. Alternatively, fitting can be performed using least-squares estimation, based on the number of lineages represented in the tree over time ("diversity-vs-time" curve, a.k.a. "lineages-through-time"" curve). Note that the birth and death rates are NOT per-capita rates, they are absolute rates of species appearance and disappearance per time.

### Usage

fit_tree_model( tree,
parameters          = list(),
first_guess         = list(),
min_age             = 0,
max_age             = 0,
age_centile         = NULL,
Ntrials             = 1,
coalescent          = FALSE,
discovery_fraction  = NULL,
fit_control         = list(),
min_R2              = -Inf,
min_wR2             = -Inf,
grid_size           = 100,
max_model_runtime   = NULL,
objective           = 'LL')


### Author(s)

Stilianos Louca

generate_random_tree, simulate_diversification_model reconstruct_past_diversification

### Examples

# Generate a tree using a simple speciation model
parameters = list(birth_rate_intercept  = 1,
birth_rate_factor     = 0,
birth_rate_exponent   = 0,
death_rate_intercept  = 0,
death_rate_factor     = 0,
death_rate_exponent   = 0,
resolution            = 0,
rarefaction           = 1)
tree = generate_random_tree(parameters, max_tips=100)

# Fit model to the tree
fitting_parameters = parameters
fitting_parameters$birth_rate_intercept = NULL # fit only this parameter fitting = fit_tree_model(tree,fitting_parameters) # compare fitted to true value T = parameters$birth_rate_intercept
F = fitting$parameters$birth_rate_intercept
cat(sprintf("birth_rate_intercept: true=%g, fitted=%g\n",T,F))


[Package castor version 1.6.8 Index]