Computes the log-likelihood using a coalescent (or structured coalescent) genealogical model based on a user-supplied demographic process.
Usage
colik(
tree,
theta,
demographic.process.model,
x0,
t0,
res = 1000,
integrationMethod = "lsoda",
timeOfOriginBoundaryCondition = TRUE,
maxHeight = Inf,
forgiveAgtY = 1,
AgtY_penalty = 0,
returnTree = FALSE,
step_size_res = 10,
likelihood = "PL2"
)
Arguments
- tree
A DatedTree object
- theta
A named numeric vector or named list of parameter values used by the demographic model
- demographic.process.model
- x0
A named vector of initial conditions required by the model. This includes demes and any other dynamic variables.
- t0
The time of origin of the process. Should predate the root of the tree.
- res
Integer number of time steps to use when simulating model.
- integrationMethod
If simulating an ODE (ordinary differential equation) model, this provides the integration routine corresponding to options in deSolve.
- timeOfOriginBoundaryCondition
If TRUE, will return -Inf if the root of the tree precedes the time of origin.
- maxHeight
It will only count internode intervals in the likelihood that occur after maxHeight years before present. Useful for large trees and when you do not want to model the entire demographic history.
- forgiveAgtY
If number of extant lineages exceeds simulated population size, return -Inf if this value is one, or forgive the discrepancy if zero. If between zero and one, only forgive the discrepancy if this proportion of lineages is less than the given value.
- AgtY_penalty
If number of extant lineages exceeds simulated population size, penalize likelihood with value L*AgtY_penalty where L is the cumulative coalescent rate within the given internode interval. 0<= AgtY_penalty <= Inf.
- returnTree
If TRUE, a copy of the tree is also returned, which includes the inferred states of lineages and likelihood terms at each internal node.
- step_size_res
Parameter for the ODE solver; it is the default number of timesteps to use when solving coalescent equations in each internode interval
- likelihood
Toggle likelihood approximation to be used (QL fast/approximate, PL1 faster better approximation, PL2 slow/good approximation. See Volz & Siveroni 2018 for details. Default is set to PL2.
Examples
# A simple exponential growth model with birth rates beta and death rates gamma:
dm <- build.demographic.process(births = c(I = 'parms$beta * I'),
deaths = c(I = 'parms$gamma * I'),
parameterNames = c('beta', 'gamma'),
rcpp = FALSE,
sde = FALSE)
# simulate a tree based on the model:
tre <- sim.co.tree(list(beta = 1.5, gamma = 1),
dm,
x0 = c(I = 1),
t0 = 0,
sampleTimes = seq(10, 15, length.out=50),
res = 1000)
# Compute a likelihood
colik(tre,
list(beta = 1.5, gamma = 1),
dm,
x0 = c(I = 1),
t0 = -1,
res = 1e3)
#> [1] -216.1359