bm_ase: Bayesian Ancestral State Estimation with Points

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

View source: R/rase_source.r

Description

Performs a bayesian two-dimensional ancestral state estimation with single values as input (contrast with rase) according to a Brownian Motion model of trait evolution (or dispersal for phylogeography). It uses Gibbs sampling to approximate the posterior distribution.

Usage

1
2
bm_ase(tree, values, niter = 1e3, logevery = 10, 
		sigma2_scale = 0.05, screenlog = TRUE, params0 = NA)

Arguments

tree

phylogenetic tree of class "phylo".

values

2-dimensional trait values (e.g., coordinates for phylogeography). Should be a data.frame with two columns named x & y, or a list with two elements named x & y.

niter

number of MCMC iterations. By default niter = 1000.

logevery

iteration cycle to print current iteration. By default logevery = 10.

sigma2_scale

optional. Window proposal for sigma2x & sigma2y.

screenlog

if TRUE (default), prints current iteration every logevery to the screen.

params0

optional. A vector of initial parameter values in the following order: x ancestors, y ancestors, sigma2x and sigma2y. If params0 = NA (default), an initial Maximum Likelihood optimization using ace provides the starting parameter values.

Value

returns a matrix where every column represents one parameter. The first columns (i.e., nX_x) give the ancestral locations for trait x in the order of nodes in the tree (see the phylo class for details), followed by the ancestral locations of trait y (i.e., nX_y), and the rate parameter in x (sigma2x) and y (sigma2y).

Author(s)

Forrest Crawford, Ignacio Quintero

References

Quintero, I., Keil, P., Jetz, W., Crawford, F. W. 2015 Historical Biogeography Using Species Geographical Ranges. Systematic Biology. doi: 10.1093/sysbio/syv057

See Also

For the maximum likelihood version see point.like.bm; for the incorporation of polygon uncertainty see rase.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
  ### Create some data to be analyzed
  # Number of taxa
  ntaxa <- 10

  # Known parameters
  mean_x <- 0
  mean_y <- 0
  sigma_x <- 1 
  sigma_y <- 1

  # Create a random tree
  tree <- ape::rtree(n = ntaxa)

  # Create random data according to tree structure
  x_locs <- as.numeric(mvtnorm::rmvnorm(1, rep(mean_x,ntaxa), sigma=sigma_x*vcv(tree)))
  y_locs <- as.numeric(mvtnorm::rmvnorm(1, rep(mean_y,ntaxa), sigma=sigma_y*vcv(tree)))
  values = list(x = x_locs, y = y_locs)
  ## Not run: 
    # run bm_ase for 10 iterations
    bm_results = bm_ase(tree, values, niter = 10)
  
## End(Not run)

ignacioq/rase documentation built on Feb. 20, 2022, 3:16 p.m.