Learn R Programming

phybreak (version 0.2.0)

logLik.phybreak: Log-likelihood of a phybreak-object.

Description

The likelihood of a phybreak-object is calculated, with the option to include or exclude parts of the likelihood for genetic data, phylogenetic tree (within-host model), sampling times and generation times.

Usage

# S3 method for phybreak
logLik(object, genetic = TRUE, withinhost = TRUE,
  sampling = TRUE, generation = TRUE, ...)

Arguments

object

An object of class phybreak.

genetic

Whether to include the likelihood of the mutation model.

withinhost

Whether to include the likelihood of within-host (coalescent) model.

sampling

Whether to include the likelihood of the sampling model (sampling intervals).

generation

Whether to include the likelihood of the transmission model (generation intervals).

...

Some methods for this generic require additional arguments. None are used in this method.

Value

The log-likelihood as an object of class logLik.

Details

The sequence likelihood is calculated by Felsenstein's pruning algorithm, assuming a prior probability of 0.25 for each nucleotide. The within-host likelihood is the likelihood of coalescence times given the within-host model and slope. The generation interval and sampling interval likelihood are log-densities of the gamma distributions for these variables.

References

Klinkenberg et al. (2017) Simultaneous inference of phylogenetic and transmission trees in infectious disease outbreaks. PLoS Comput Biol, 13(5): e1005495.

Examples

Run this code
# NOT RUN {
#First build a phybreak-object containing samples.
simulation <- sim.phybreak(obsize = 5)
MCMCstate <- phybreak(data = simulation)
logLik(MCMCstate)

MCMCstate <- burnin.phybreak(MCMCstate, ncycles = 20)
logLik(MCMCstate)

tree0 <- get.phylo(MCMCstate)
seqdata <- get.seqdata(MCMCstate)
pml(tree0, seqdata, rate = 0.75*get.parameters(MCMCstate)["mu"]) 
logLik(MCMCstate, genetic = TRUE, withinhost = FALSE, 
       sampling = FALSE, generation = FALSE) #should give the same result as 'pml'
# }

Run the code above in your browser using DataLab