Learn R Programming

BioGeoBEARS (version 0.2.1)

symbolic_to_Q_matrix_exper: Experimental version of symbolic_to_Q_matrix_exper, including base frequencies

Description

Still experimental.

Usage

symbolic_to_Q_matrix_exper(dedf, cellsplit = "\\+", mergesym = "*", d = 0.1, e = 0.01, basefreqs = rep(1, nrow(dedf))/nrow(dedf), ...)

Arguments

dedf
The transition matrix or dispersal-extinction data.frame (dedf), contains the actual text of the formulas by which the transition probability matrix would be calculated.
cellsplit
The symbol to split the formulas on. Default "\\+" (plus symbol, with escape code).
mergesym
The symbol to merge the formulas with. Default "+".
d
The dispersal/range expansion rate. Default d=0.1.
e
The extinction/range contraction rate. Default e=0.01.
basefreqs
Base frequencies, i.e. the equilibrium probabilities of the different states; the meaning of such an idea is debatable in the context of a LAGRANGE-like model where the null range (extinct everywhere) is included in the matrix and is a nonreversible absorbing state. Default is rep(1,nrow(dedf))/nrow(dedf).
...
Additional arguments to pass to symbolic_cell_to_relprob_cell via sapply, and thence to cellstrsplit.

Value

dedf_vals The output data.frame, contains the Q matrix

Details

This function takes a transition probability matrix (in text form) and converts it to an instantaneous rate matrix (Q matrix), given values for d, e, or other parameters in the text formulas.

This is not particularly fast, but good for illustrative purposes.

References

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

Matzke_2012_IBS

FosterIdiots

See Also

areas_list_to_states_list_old, make_relprob_matrix_de areas_list_to_states_list_new

Examples

Run this code
testval=1

states_list = list("_", c("A"), c("B"), c("C"), c("A","B"),
c("B","C"), c("A","C"), c("A","B","C"))

states_list = areas_list_to_states_list_new(areas=c("A","B","C"),
include_null_range=TRUE, split_ABC=TRUE)
states_list

dedf = make_relprob_matrix_de(states_list=states_list, split_ABC=FALSE,
split="", remove_simultaneous_events=TRUE, add_multiple_Ds=TRUE,
dispersal_multiplier_matrix=make_dispersal_multiplier_matrix(states_list=states_list))
dedf

# Right
Qmat = symbolic_to_Q_matrix_exper(dedf, cellsplit="\\\\+", mergesym="+", d=0.1, e=0.01)
Qmat

# Wrong
Qmat = symbolic_to_Q_matrix_exper(dedf, cellsplit="\\\\+", mergesym="*", d=0.1, e=0.01)
Qmat

# You don't have to split, if the formulas are directly parsable
Qmat = symbolic_to_Q_matrix_exper(dedf, cellsplit="yadda", mergesym="", d=0.1, e=0.01)
Qmat

# Compare to symbolic_to_Q_matrix
Qmat = symbolic_to_Q_matrix(dedf, cellsplit="yadda", mergesym="", d=0.1, e=0.01)
Qmat

Run the code above in your browser using DataLab