SimulateGeoHiSSE: Simulate under a GeoHiSSE model

View source: R/simulateGeoHiSSE.R

SimulateGeoHiSSER Documentation

Simulate under a GeoHiSSE model

Description

Simulation function for the GeoHiSSE model

Usage

SimulateGeoHiSSE(pars, hidden.traits=1, x0="0A", max.taxa=Inf,
max.time=Inf, add.jumps=FALSE, add.extinction=FALSE, 
include.extinct=FALSE, return.GeoHiSSE_pars=FALSE, 
override.safeties=FALSE)

Arguments

pars

an object of class "GeoHiSSE_pars" generated by SimulateGeoHiSSE. See 'Details'.

hidden.traits

number of hidden areas in the model. Default is 1.

x0

a character value for the starting state. Default is "01A".

max.taxa

have the simulation stop at max.taxa surviving taxa.

max.time

have the simulation stop at max.time height (including stem).

return.GeoHiSSE_pars

whether to (only) return a "GeoHiSSE_pars" object in the correct format to use in this function. See 'Details'.

add.jumps

whether to include jump dispersals in the model. Both for returning the parameters of the model and model estimation. Default is FALSE.

add.extinction

whether to separate extirpation and extinction of endemic lineages. Both for returning the parameters of the model and model estimation. Default is FALSE.

include.extinct

whether the simulation should keep extinct lineages. Default is FALSE.

override.safeties

simulate even if there is no limit on number of taxa or depth of tree.

Details

This function uses diversitree::tree.classe function to simulate the tree under the GeoSSE model with hidden states. The parameter pars is a list of class "GeoHiSSE_pars" that can be generated using this same function. The best way is to first run SimulateGeoHiSSE with empty parameters and return.GeoHiSSE_pars=TRUE and with hidden.areas equal to the number of desired hidden states in the model. This will return an object in list format with a set of four matrices. Each matrix controls a different set of parameters of the model. All parameters are set to 0 and parameters not used by the model are set to NA. To prepare the simulation, edit these matrices and change the desired parameter values. Leaving a parameter equal to 0 is the same as reducing the model by eliminating this parameter of the model.

Value

This returns a list, with the following elements:

$phy

a phylogeny of class phylo.

$data

a data matrix with the species names as the first column and the ranges (in 0, 1, and 2 format) as the second column.

$hidden.states

a named vector with the 'true' simulated ranges (include the hidden state information).

$sim.attempts

number of times that the simulation tried before reaching desired termination condition.

$pars

the parameters used for the simulation.

$classe.pars

the parameters in 'make.classe' format for the 'diversitree' package.

Author(s)

Daniel Caetano

Examples

## Not run: 
## Get the a list with the correct parameters to run the simulation:
pars <- SimulateGeoHiSSE(hidden.areas=1, return.GeoHiSSE_pars=TRUE)
## Edit the parameter values:
pars$model.pars[1:3,] <- 0.1
pars$model.pars[4:5,] <- 0.05
pars$model.pars[6:7,] <- 0.01
pars$q.01[1,2] <- pars$q.01[2,1] <- 0.01
pars$q.1[1,2] <- pars$q.1[2,1] <- 0.02
pars$q.2[1,2] <- pars$q.2[2,1] <- 0.02
## Run the simulation:
sim <- SimulateGeoHiSSE(pars=pars, hidden.areas=1, x0="01A", max.taxa=100)

## End(Not run)

hisse documentation built on Feb. 16, 2023, 10:26 p.m.