BAMMlikelihood {BAMMtools} | R Documentation |
Calculate BAMM
likelihood
Description
Calculates the likelihood of a phylogeny exactly as is done
by BAMM
, given a set of events.
Usage
BAMMlikelihood(
phy,
eventdata,
gen = "last",
segLength = 0.02,
sf = 1,
return.intermediates = FALSE,
e_prob_condition = "if_different",
...
)
Arguments
phy |
Either an object of class |
eventdata |
A table of event data, as returned by |
gen |
The |
segLength |
The relative segment length, exactly as defined for
|
sf |
The sampling fraction. |
return.intermediates |
Debugging option, returns augmented
|
e_prob_condition |
Approach for how extinction probabilities are handled at nodes. |
... |
Additional arguments that will be passed to an internal
function |
Details
This function allows the user to check the likelihoods computed
by BAMM
using an independent R-based implementation. This is
designed to provide a check on potential software bugs that might be
introduced during future BAMM
development and which might
compromise the likelihood calculation. If you observe measurable
discrepancies between the likelihood computed by this function and the
corresponding likelihood returned by BAMM
, please inform the
BAMM
development team.
Value
If return.intermediates == TRUE
, then phylo
objects
are returned with the following components:
event_times |
A list of length (number of nodes), where
event_times[[k]] is the vector of absolute times, in order, of
events that happened on a focal branch. If no event, it is
|
event_id |
A list of length equal to number of nodes, as event_times, but holding the corresponding event id. |
events |
A dataframe giving parameters and associated nodes (and unique index values) of the event data. |
node_event |
The event governing the process realized at the node. This will be the first event encountered as one moves rootwards towards the tips from the focal node. |
Author(s)
Dan Rabosky, Pascal Title
Examples
# a global sampling fraction of 0.98 was used in generating the whales
# dataset.
data(whales, events.whales, mcmc.whales)
x <- BAMMlikelihood(whales, events.whales, gen = 'last', sf = 0.98)
# Does the likelihood generated by BAMM match the R implementation?
identical(round(x, 3), mcmc.whales[nrow(mcmc.whales), 'logLik'])
# an example with a constant-rate birth-death process:
pars <- c(0.5, 0.45)
names(pars) <- c("lambda", "mu")
BAMMlikelihood(whales, pars, sf = 0.98)