symbolic_to_P_matrix: Convert symbolic matrix to relprob matrix

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

View source: R/BioGeoBEARS_basics_v1.R

Description

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

Usage

1
2
3
  symbolic_to_P_matrix(dedf, cellsplit = "\\+",
    mergesym = "+", diags_sum_to_1 = FALSE, d = 0.1,
    e = 0.01, ...)

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 "+".

diags_sum_to_1

Calculate the diagonals such that, when added to the sum of the off-diagonals in a row, the entire row sums to 1. This creates a transition probability matrix where each row sums to 1, i.e. each cell represents the conditional probability of the column state, given the ancestral row state. The diagonal values represent the probability of staying the same.

d

The dispersal/range expansion rate. Default d=0.1.

e

The extinction/range contraction rate. Default e=0.01.

...

Additional arguments to pass to symbolic_cell_to_relprob_cell via sapply, and thence to cellstrsplit.

Details

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

Value

dedf_vals The output data.frame, contains the numeric results of the formulas calculating the transition probability matrix.

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

areas_list_to_states_list_new, areas_list_to_states_list_old, make_relprob_matrix_de

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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

# Defaults
Pmat = symbolic_to_P_matrix(dedf, cellsplit="\\\\+", mergesym="+",
diags_sum_to_1=FALSE, d=0.1, e=0.01)
Pmat

# Calculate diagonal
Pmat = symbolic_to_P_matrix(dedf, cellsplit="\\\\+", mergesym="+",
diags_sum_to_1=TRUE, d=0.1, e=0.01)
Pmat

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

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