mapply_likelihoods: Use mapply on matrix exponentiations - post-byte-compiling

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

During the likelihood calculations from the tips to the root of a tree, the transition matrix Qmat needs to be exponentiated for each branch length in the tree. This is the slowest step of the likelihood calculation, especially for large matrices. This function performs this with mapply.

Usage

1
  mapply_likelihoods(Qmat, phy2, transpose_needed)

Arguments

Qmat

an input Q transition matrix.

phy2

A phylogenetic tree.

transpose_needed

If TRUE (default), matrix will be transposed (apparently EXPOKIT needs the input matrix to be transposed compared to normal).

Details

Byte-compiling is supposed to speed up functions; this is an attempt to do this on the rexpokit function expokit_dgpadm_Qmat. It is also possible to byte-compile everything during package installation (via ByteCompile: true in the DESCRIPTION file), which is implemented in BioGeoBEARS, so this may be redundant.

mapply_likelihoods_prebyte gets byte-compiled into mapply_likelihoods.

See http://dirk.eddelbuettel.com/blog/2011/04/12/ for discussion of the compile package.

Value

independent_likelihoods_on_each_branch The output matrix of the likelihoods for each state on each branch.

Note

Go BEARS!

Author(s)

Nicholas J. Matzke matzke@berkeley.edu

References

http://phylo.wikidot.com/matzke-2013-international-biogeography-society-poster

Matzke_2012_IBS

See Also

mapply, expokit_dgpadm_Qmat, expokit_dgpadm_Qmat2, compile, cmpfun

Examples

1
testval=1

Example output

Loading required package: rexpokit
Loading required package: cladoRcpp
Loading required package: ape
Loading required package: phylobase

Attaching package: 'phylobase'

The following object is masked from 'package:ape':

    edges

BioGeoBEARS documentation built on May 29, 2017, 8:36 p.m.