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

Simulates a birth-death tree (starting with one lineage) with speciation and/or extinction rate that varies as a function of an input environmental curve. Notations follow Morlon et al. PNAS 2011 and Condamine et al. ELE 2013.

1 2 | ```
sim_env_bd(env_data, f.lamb, f.mu, lamb_par, mu_par, df=NULL, time.stop=0,
return.all.extinct=TRUE, prune.extinct=TRUE)
``` |

`env_data` |
environmental data, given as a data frame with two columns. The first column is time, the second column is the environmental data (temperature for instance). |

`time.stop` |
the age of the phylogeny. |

`f.lamb` |
a function specifying the hypothesized functional form of the variation of the speciation rate |

`f.mu` |
a function specifying the hypothesized functional form of the variation of the extinction rate |

`lamb_par` |
a numeric vector of initial values for the parameters of f.lamb to be estimated (these values are used by the optimization algorithm). The length of this vector is used to compute the total number of parameters in the model, so to fit a model with constant speciation rate (for example), lamb_par should be a vector of length 1. Otherwise aic values will be wrong. |

`mu_par` |
a numeric vector of initial values for the parameters of f.mu to be estimated (these values are used by the optimization algorithm). The length of this vector is used to compute the total number of parameters in the model, so to fit a model without extinction (for example), mu_par should be empty (vector of length 0). Otherwise aic values will be wrong. |

`df` |
the degree of freedom to use to define the spline. As a default, smooth.spline(env_data[,1], env_data[,2])$df is used. See |

`return.all.extinct` |
return all extinction lineages in simulated tree. |

`prune.extinct` |
prune extinct lineages in simulated tree. |

In the f.lamb and f.mu functions, time runs from the present to the past.

a list with the following components

`tree` |
the simulated tree with number tips |

`times` |
the times of speciation events starting from the past |

`nblineages` |
the labels of surviving lineages and total number of surviving lineages |

The speed of convergence of the fit might depend on the degree of freedom chosen to define the spline.

E Lewitus and H Morlon

Morlon, H., Parsons, T.L. and Plotkin, J.B. (2011) Reconciling molecular phylogenies with the fossil record *Proc Nat Acad Sci* 108: 16327-16332

Condamine, F.L., Rolland, J., and Morlon, H. (2013) Macroevolutionary perspectives to environmental change, Eco Lett 16: 72-85

1 2 3 4 5 6 7 8 9 | ```
data(InfTemp)
dof<-smooth.spline(InfTemp[,1], InfTemp[,2])$df
# Simulates a tree with lambda varying as an exponential function of temperature
# and mu fixed to 0 (no extinction). Here t stands for time and x for temperature.
f.lamb <-function(t,x,y){y[1] * exp(y[2] * x)}
f.mu<-function(t,x,y){0}
lamb_par<-c(0.10, 0.01)
mu_par<-c()
#result_exp <- sim_env_bd(InfTemp,f.lamb,f.mu,lamb_par,mu_par,time.stop=10)
``` |

hmorlon/PANDA documentation built on Nov. 8, 2018, 12:32 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.