given_a_starting_state_simulate_branch_end: Given the state at the start of a branch, simulate the state...

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

View source: R/BioGeoBEARS_simulate_v1.R

Description

This function simulates a biogeographical history, given a Q transition matrix, a starting state, and a branch length. All this involves is exponentiating the Q transition matrix, producing a P transition probability matrix, and then producing a random draw from this P matrix, conditional on the ancestor.

Usage

1
2
  given_a_starting_state_simulate_branch_end(index_Qmat_0based_of_starting_state = 1,
    Qmat, branchlength = 1, all_tips_living = TRUE)

Arguments

index_Qmat_0based_of_starting_state

An integer index value, between 0 and (numstates-1), which specifies what state is the starting point for the branch.

Qmat

A (square, dense) Q transition matrix. Using a sparse matrix would require writing another function.

branchlength

The length of the branch, or branch segment if you are dealing with a stratified phylogeny.

all_tips_living

Currently this is the only assumption. If, hypothetically, you had a phylogeny with extinct tips (representing the ends of the ranges of fossil taxa), you might want to treat them differently, IF you think that the time-invariant geographic range addition/subtraction process is the same one that made lineages go extinct (it could be something else, e.g. mass extinction). False attribution of extinctions to the range loss process will dramatically elevate the rate of range loss, and also range expansion to compensate, and the resulting high rates can substantially degrade inference (Matzke_Maguire_2011_SVP).

Details

This could be sped up in various ways, if needed.

Value

state_desc 0-based index of the descendant state (just before cladogenesis, if below a node).

Note

Go BEARS!

Author(s)

Nicholas J. Matzke matzke@berkeley.edu

References

http://phylo.wikidot.com/matzke-2013-international-biogeography-society-poster https://code.google.com/p/lagrange/

Matzke_2012_IBS

Matzke_Maguire_2011_SVP

See Also

rcpp_calc_anclikes_sp_COOweights_faster

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.