<!DOCTYPE html>
<html lang="" xml:lang="">
<head>

  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <title>3 Features | CRABS: Congruent Rate Analyses in Birth-death Scenarios</title>
  <meta name="description" content="3 Features | CRABS: Congruent Rate Analyses in Birth-death Scenarios" />
  <meta name="generator" content="bookdown 0.36 and GitBook 2.6.7" />

  <meta property="og:title" content="3 Features | CRABS: Congruent Rate Analyses in Birth-death Scenarios" />
  <meta property="og:type" content="book" />
  
  
  

  <meta name="twitter:card" content="summary" />
  <meta name="twitter:title" content="3 Features | CRABS: Congruent Rate Analyses in Birth-death Scenarios" />
  
  
  

<meta name="author" content="Sebastian Höhna" />
<meta name="author" content="Bjørn T. Kopperud" />
<meta name="author" content="Andrew F. Magee" />
<meta name="author" content="Jérémy Andréoletti" />


<meta name="date" content="2023-10-23" />

  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  
  
<link rel="prev" href="installation.html"/>
<link rel="next" href="creating-the-congruence-class.html"/>
<script src="lib/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/fuse.js@6.4.6/dist/fuse.min.js"></script>
<link href="lib/gitbook-2.6.7/css/style.css" rel="stylesheet" />
<link href="lib/gitbook-2.6.7/css/plugin-table.css" rel="stylesheet" />
<link href="lib/gitbook-2.6.7/css/plugin-bookdown.css" rel="stylesheet" />
<link href="lib/gitbook-2.6.7/css/plugin-highlight.css" rel="stylesheet" />
<link href="lib/gitbook-2.6.7/css/plugin-search.css" rel="stylesheet" />
<link href="lib/gitbook-2.6.7/css/plugin-fontsettings.css" rel="stylesheet" />
<link href="lib/gitbook-2.6.7/css/plugin-clipboard.css" rel="stylesheet" />








<link href="lib/anchor-sections-1.1.0/anchor-sections.css" rel="stylesheet" />
<link href="lib/anchor-sections-1.1.0/anchor-sections-hash.css" rel="stylesheet" />
<script src="lib/anchor-sections-1.1.0/anchor-sections.js"></script>


<style type="text/css">
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
  { counter-reset: source-line 0; }
pre.numberSource code > span
  { position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
  { content: counter(source-line);
    position: relative; left: -1em; text-align: right; vertical-align: baseline;
    border: none; display: inline-block;
    -webkit-touch-callout: none; -webkit-user-select: none;
    -khtml-user-select: none; -moz-user-select: none;
    -ms-user-select: none; user-select: none;
    padding: 0 4px; width: 4em;
    color: #aaaaaa;
  }
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa;  padding-left: 4px; }
div.sourceCode
  {   }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>

<style type="text/css">
  
  div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
</style>
<style type="text/css">
/* Used with Pandoc 2.11+ new --citeproc when CSL is used */
div.csl-bib-body { }
div.csl-entry {
  clear: both;
}
.hanging div.csl-entry {
  margin-left:2em;
  text-indent:-2em;
}
div.csl-left-margin {
  min-width:2em;
  float:left;
}
div.csl-right-inline {
  margin-left:2em;
  padding-left:1em;
}
div.csl-indent {
  margin-left: 2em;
}
</style>

</head>

<body>



  <div class="book without-animation with-summary font-size-2 font-family-1" data-basepath=".">

    <div class="book-summary">
      <nav role="navigation">

<ul class="summary">
<li class="chapter" data-level="1" data-path="overview.html"><a href="overview.html"><i class="fa fa-check"></i><b>1</b> Overview</a></li>
<li class="chapter" data-level="2" data-path="installation.html"><a href="installation.html"><i class="fa fa-check"></i><b>2</b> Installation</a></li>
<li class="chapter" data-level="3" data-path="features.html"><a href="features.html"><i class="fa fa-check"></i><b>3</b> Features</a>
<ul>
<li class="chapter" data-level="3.1" data-path="features.html"><a href="features.html#overview-of-functions-in-crabs"><i class="fa fa-check"></i><b>3.1</b> Overview of functions in <code>CRABS</code></a></li>
<li class="chapter" data-level="3.2" data-path="features.html"><a href="features.html#samplebasic"><i class="fa fa-check"></i><b>3.2</b> <code>sample.basic.models</code></a></li>
<li class="chapter" data-level="3.3" data-path="features.html"><a href="features.html#samplejoint"><i class="fa fa-check"></i><b>3.3</b> <code>sample.basic.models.joint</code></a></li>
</ul></li>
<li class="chapter" data-level="4" data-path="creating-the-congruence-class.html"><a href="creating-the-congruence-class.html"><i class="fa fa-check"></i><b>4</b> Creating the congruence class</a>
<ul>
<li class="chapter" data-level="4.1" data-path="creating-the-congruence-class.html"><a href="creating-the-congruence-class.html#rate-transformations"><i class="fa fa-check"></i><b>4.1</b> Rate transformations</a></li>
<li class="chapter" data-level="4.2" data-path="creating-the-congruence-class.html"><a href="creating-the-congruence-class.html#slopes-and-delta-t"><i class="fa fa-check"></i><b>4.2</b> Slopes and <span class="math inline">\(\Delta t\)</span></a></li>
<li class="chapter" data-level="4.3" data-path="creating-the-congruence-class.html"><a href="creating-the-congruence-class.html#the-model-object"><i class="fa fa-check"></i><b>4.3</b> The model object</a></li>
</ul></li>
<li class="chapter" data-level="5" data-path="testing-alternative-hypotheses.html"><a href="testing-alternative-hypotheses.html"><i class="fa fa-check"></i><b>5</b> Testing alternative hypotheses</a>
<ul>
<li class="chapter" data-level="5.1" data-path="testing-alternative-hypotheses.html"><a href="testing-alternative-hypotheses.html#alt-ext"><i class="fa fa-check"></i><b>5.1</b> Testing alternative extinction rates</a>
<ul>
<li class="chapter" data-level="5.1.1" data-path="testing-alternative-hypotheses.html"><a href="testing-alternative-hypotheses.html#constant-extinction-rates"><i class="fa fa-check"></i><b>5.1.1</b> Constant extinction rates</a></li>
<li class="chapter" data-level="5.1.2" data-path="testing-alternative-hypotheses.html"><a href="testing-alternative-hypotheses.html#linearly-increasing-extinction-rates"><i class="fa fa-check"></i><b>5.1.2</b> Linearly increasing extinction rates</a></li>
<li class="chapter" data-level="5.1.3" data-path="testing-alternative-hypotheses.html"><a href="testing-alternative-hypotheses.html#exponential-increasing-extinction-rates"><i class="fa fa-check"></i><b>5.1.3</b> Exponential increasing extinction rates</a></li>
<li class="chapter" data-level="5.1.4" data-path="testing-alternative-hypotheses.html"><a href="testing-alternative-hypotheses.html#two-epoch-extinction-rates"><i class="fa fa-check"></i><b>5.1.4</b> Two-epoch extinction rates</a></li>
<li class="chapter" data-level="5.1.5" data-path="testing-alternative-hypotheses.html"><a href="testing-alternative-hypotheses.html#reversed-trend-extinction-rates"><i class="fa fa-check"></i><b>5.1.5</b> Reversed trend extinction rates</a></li>
</ul></li>
<li class="chapter" data-level="5.2" data-path="testing-alternative-hypotheses.html"><a href="testing-alternative-hypotheses.html#testing-alternative-speciation-rates"><i class="fa fa-check"></i><b>5.2</b> Testing alternative speciation rates</a>
<ul>
<li class="chapter" data-level="5.2.1" data-path="testing-alternative-hypotheses.html"><a href="testing-alternative-hypotheses.html#constant-speciation-rates"><i class="fa fa-check"></i><b>5.2.1</b> Constant speciation rates</a></li>
<li class="chapter" data-level="5.2.2" data-path="testing-alternative-hypotheses.html"><a href="testing-alternative-hypotheses.html#exponential-increasingdecreasing-speciation-rates"><i class="fa fa-check"></i><b>5.2.2</b> Exponential increasing/decreasing speciation rates</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="6" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html"><i class="fa fa-check"></i><b>6</b> Exploring the congruence class</a>
<ul>
<li class="chapter" data-level="6.1" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html#assumptions-on-rates"><i class="fa fa-check"></i><b>6.1</b> Assumptions on rates</a></li>
<li class="chapter" data-level="6.2" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html#independent-or-joint-rate-sampling"><i class="fa fa-check"></i><b>6.2</b> Independent or joint rate sampling</a></li>
<li class="chapter" data-level="6.3" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html#sample-alternative-extinction-rates"><i class="fa fa-check"></i><b>6.3</b> Sample alternative extinction rates</a>
<ul>
<li class="chapter" data-level="6.3.1" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html#temporally-autocorrelated"><i class="fa fa-check"></i><b>6.3.1</b> Temporally autocorrelated</a></li>
<li class="chapter" data-level="6.3.2" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html#exponentially-decreasing"><i class="fa fa-check"></i><b>6.3.2</b> Exponentially decreasing</a></li>
<li class="chapter" data-level="6.3.3" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html#linearly-increasing"><i class="fa fa-check"></i><b>6.3.3</b> Linearly increasing</a></li>
<li class="chapter" data-level="6.3.4" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html#episodic"><i class="fa fa-check"></i><b>6.3.4</b> Episodic</a></li>
<li class="chapter" data-level="6.3.5" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html#uniform-independent"><i class="fa fa-check"></i><b>6.3.5</b> Uniform independent</a></li>
<li class="chapter" data-level="6.3.6" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html#brownian-motion-with-a-trend"><i class="fa fa-check"></i><b>6.3.6</b> Brownian motion with a trend</a></li>
</ul></li>
<li class="chapter" data-level="6.4" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html#sample-alternative-speciation-rates"><i class="fa fa-check"></i><b>6.4</b> Sample alternative speciation rates</a>
<ul>
<li class="chapter" data-level="6.4.1" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html#temporally-autocorrelated-1"><i class="fa fa-check"></i><b>6.4.1</b> Temporally autocorrelated</a></li>
</ul></li>
<li class="chapter" data-level="6.5" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html#jointly-sample-alternative-speciation-and-extinction-rates"><i class="fa fa-check"></i><b>6.5</b> Jointly sample alternative speciation and extinction rates</a>
<ul>
<li class="chapter" data-level="6.5.1" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html#constant-joint-trajectory"><i class="fa fa-check"></i><b>6.5.1</b> Constant joint trajectory</a></li>
<li class="chapter" data-level="6.5.2" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html#hsmrf-joint-trajectory"><i class="fa fa-check"></i><b>6.5.2</b> HSMRF joint trajectory</a></li>
<li class="chapter" data-level="6.5.3" data-path="exploring-the-congruence-class.html"><a href="exploring-the-congruence-class.html#hsmrf-joint-trajectory-with-global-regularity-filter"><i class="fa fa-check"></i><b>6.5.3</b> HSMRF joint trajectory with global regularity filter</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="7" data-path="exploring-the-posterior.html"><a href="exploring-the-posterior.html"><i class="fa fa-check"></i><b>7</b> Exploring the posterior</a>
<ul>
<li class="chapter" data-level="7.1" data-path="exploring-the-posterior.html"><a href="exploring-the-posterior.html#reading-the-posterior"><i class="fa fa-check"></i><b>7.1</b> Reading the posterior</a></li>
<li class="chapter" data-level="7.2" data-path="exploring-the-posterior.html"><a href="exploring-the-posterior.html#sampling-congruent-models-in-the-posterior"><i class="fa fa-check"></i><b>7.2</b> Sampling congruent models in the posterior</a></li>
</ul></li>
<li class="chapter" data-level="8" data-path="estimating-birth-death-models.html"><a href="estimating-birth-death-models.html"><i class="fa fa-check"></i><b>8</b> Estimating birth-death models</a>
<ul>
<li class="chapter" data-level="8.1" data-path="estimating-birth-death-models.html"><a href="estimating-birth-death-models.html#reading-the-phylogenetic-tree"><i class="fa fa-check"></i><b>8.1</b> Reading the phylogenetic tree</a></li>
<li class="chapter" data-level="8.2" data-path="estimating-birth-death-models.html"><a href="estimating-birth-death-models.html#tess"><i class="fa fa-check"></i><b>8.2</b> TESS Analysis</a></li>
<li class="chapter" data-level="8.3" data-path="estimating-birth-death-models.html"><a href="estimating-birth-death-models.html#treepar"><i class="fa fa-check"></i><b>8.3</b> TreePar</a></li>
<li class="chapter" data-level="8.4" data-path="estimating-birth-death-models.html"><a href="estimating-birth-death-models.html#revbayes"><i class="fa fa-check"></i><b>8.4</b> The HSMRF model in RevBayes</a></li>
</ul></li>
<li class="chapter" data-level="9" data-path="references.html"><a href="references.html"><i class="fa fa-check"></i><b>9</b> References</a></li>
</ul>

      </nav>
    </div>

    <div class="book-body">
      <div class="body-inner">
        <div class="book-header" role="navigation">
          <h1>
            <i class="fa fa-circle-o-notch fa-spin"></i><a href="./">CRABS: Congruent Rate Analyses in Birth-death Scenarios</a>
          </h1>
        </div>

        <div class="page-wrapper" tabindex="-1" role="main">
          <div class="page-inner">

            <section class="normal" id="section-">
<div id="features" class="section level1 hasAnchor" number="3">
<h1><span class="header-section-number">3</span> Features<a href="features.html#features" class="anchor-section" aria-label="Anchor link to header"></a></h1>
<div id="overview-of-functions-in-crabs" class="section level2 hasAnchor" number="3.1">
<h2><span class="header-section-number">3.1</span> Overview of functions in <code>CRABS</code><a href="features.html#overview-of-functions-in-crabs" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>Here we give you an overview of the main functions available in <code>CRABS</code>.</p>
<table>
<colgroup>
<col width="44%" />
<col width="55%" />
</colgroup>
<thead>
<tr class="header">
<th align="left">Function</th>
<th align="left">Description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left"><code>create.model</code></td>
<td align="left">Creates a diversification model object, which consists of the so-called reference speciation and extinction rates.</td>
</tr>
<tr class="even">
<td align="left"><code>congruent.models</code></td>
<td align="left">Generates alternative models that are congruent with a provided reference model(s). The user needs to explicitly supply a list of alternative extinction and/or speciation rate functions.</td>
</tr>
<tr class="odd">
<td align="left"><code>sample.basic.model</code></td>
<td align="left">Samples a rate function under specified assumptions. More information in section <a href="features.html#samplebasic">3.2</a></td>
</tr>
<tr class="even">
<td align="left"><code>sample.basic.models.joint</code></td>
<td align="left">Jointly samples speciation and extinction trajectories. More information in section <a href="features.html#samplejoint">3.3</a></td>
</tr>
<tr class="odd">
<td align="left"><code>sample.rates</code></td>
<td align="left">Helps you to randomly sample either a new speciation or extinction rate function given some constraints and/or expected behavior (e.g., autocorrelated vs independent rates)</td>
</tr>
<tr class="even">
<td align="left"><code>sample.congruence.class</code></td>
<td align="left">Randomly draws a set of samples from the congruence class. The user provides a function that draws extinction rates, and/or a function that draws speciation rates.</td>
</tr>
<tr class="odd">
<td align="left"><code>sample.congruence.class.posterior</code></td>
<td align="left">Uses <code>sample.basic.models</code> to samples a set of congruent models for each sample in the posterior distribution</td>
</tr>
<tr class="even">
<td align="left"><code>summarize.trends</code></td>
<td align="left">Calculates the slope in the rate function, and plots a summary of whether the rate was increasing, decreasing or flat for each episode</td>
</tr>
<tr class="odd">
<td align="left"><code>summarize.posterior</code></td>
<td align="left">Similar to <code>summarize.trends</code>, but instead iterating over all congruent samples for each posterior sample. This plot is sorted</td>
</tr>
<tr class="even">
<td align="left"><code>full.plot.regularity.thresholds</code></td>
<td align="left">Plots the rate functions after filtering them to only retain the most regular (smooth) trajectories.</td>
</tr>
</tbody>
</table>
<p>You can consult the R documentation for each of these by placing a question mark in front of the name. For example, try calling <code>?create.model</code> or <code>?sample.basic.models</code> or <code>?sample.basic.models.joint</code> in R.
We use these functions throughout the sections in the vignette.
For <code>sample.basic.models</code> and <code>sample.basic.models.joint</code>, we have separate sections explaining the most important flags and use cases because they might represent more complex but important functions of <code>CRABS</code>.</p>
</div>
<div id="samplebasic" class="section level2 hasAnchor" number="3.2">
<h2><span class="header-section-number">3.2</span> <code>sample.basic.models</code><a href="features.html#samplebasic" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>This function is designed to enable easy generation of commonly employed diversification-rate scenarios, for either speciation or extinction rates. For sampling these rates jointly, see the following section <a href="features.html#samplejoint">3.3</a>.</p>
<p>The basic models are specified by the argument <code>model</code>: exponentially increasing/decreasing rates, linearly decreasing rates, episodic (or piecewise constant rates), and Markov random field (MRF) models (constant rates are also possible).
The direction of change (increase or decrease) is controlled by the argument <code>direction</code>.
The function will fit a piecewise linear rate function, using the argument <code>times</code> to represent a vector for the discrete time steps.
The number of episodes is equal to the length of the <code>times</code> vector.
So, for example, the code <code>sample.basic.models()</code>, which uses all defaults, samples exponentially decreasing rates.</p>
<p>By default, the exponential, linear, and episodic models are sampled with an additional random component given by a MRF.
This can be stopped by setting <code>noisy=FALSE</code>.
The argument <code>MRF.type</code> allows you to control the type of Markov random field model, the default is “HSMRF” for Horseshoe Markov random fields <span class="citation">(Magee et al., 2020)</span>, which produces jumpier changes.
The alternative, “GMRF” for Gaussian Markov random field, produces smoother changes.
This MRF noise allows rates to go up or down, such that <code>direction</code> gives the overall trend across many sampled rates rather than a guarantee for any one rate.
To change this, and force rates to go one direction while allowing stochastic noise from an MRF, set <code>monotonic=TRUE</code>.</p>
<p>To have no trends, and pure MRF models, specify <code>model="MRF"</code>.
Note that this means that setting <code>model="MRF"</code> and <code>noisy=FALSE</code> amounts to a constant-rate model (by disabling both trends and stochastic variability).</p>
<p>The argument <code>fc.mean</code> dictates (more or less) the average amount of change from first to last rate as a fold change.
Specifically, <code>fc.mean</code> must be a value greater than 1 (1.00…01 is allowed), and <code>direction</code> determines the direction of change.
If <code>direction="increasing"</code>, then <code>fc.mean</code> defines first/last, while if <code>direction="decreasing"</code>, <code>fc.mean</code> defines last/first.
The default is 3, which is biologically plausible but not the universally best option.
Fold changes are drawn from a Gamma distribution with rate 1.25, offset 1, and a shape parameter that gives the desired mean.
This means, that every drawn single rate function has it’s own fold change.</p>
<p>All rate curves are sampled by rejection sampling to guarantee that the rates are all between <code>min.rate</code> and <code>max.rate</code>.
By default, rates are assumed to be in [0,10] which on a million-year time scale is probably the extreme end of plausible variation.
This rejection sampling means that the actual average change may not quite be what it is set to be.
For example if one sets the model to be a decrease through time, sets the rate at present to be 0.5, and the maximum rate to be 0.75, clearly the average fold change could not be a larger than 1.5x increase.
Be aware, setting rejection limits that make it difficult to sample trajectories can make this function (which is normally quite fast) take a very long time!</p>
<p>The initial rate is drawn from a lognormal distribution with median <code>rate0.median</code> and log(sigma) = <code>rate0.logsd</code>, which is to say a Lognormal(log(<code>rate0.median</code>),<code>rate0.logsd</code>) distribution.
The default is rates with median 0.1 and a 95% range covering [0.01,1].
Note that the argument <code>rate0</code> overrides drawing random starting values if it is set.
This allows sampling speciation rates, as the initial speciation rate must be the same in all replicates.</p>
</div>
<div id="samplejoint" class="section level2 hasAnchor" number="3.3">
<h2><span class="header-section-number">3.3</span> <code>sample.basic.models.joint</code><a href="features.html#samplejoint" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>This function is designed to jointly generate speciation and extinction rates that are congruent with the original diversification scenario, while inherently preventing negative extinction rates.</p>
<p><code>sample.basic.models.joint</code> primarily relies on generating a trajectory for a parameter <span class="math inline">\(p\)</span>, which serves as a reference for balancing the speciation and extinction rates. When <span class="math inline">\(p=0\)</span>, the speciation rate is constant (barring negative extinction rates) and the time-varying pattern is wholly reflected in the extinction rate. Conversely, when <span class="math inline">\(p=1\)</span>, the extinction rate is constant, and the time-varying pattern is reflected in the speciation rate. Each unique <span class="math inline">\(p\)</span>-trajectory is tied to a distinct pair of speciation and extinction rate trajectories, given a starting extinction rate at present.</p>
<p>Like in the <code>sample.basic.models</code> function, the <code>MRF.type</code> argument (“HSMRF” or “GMRF”) controls the type of Markov random field used for adding stochastic noise to the trajectories, although here it corresponds to the <span class="math inline">\(p\)</span>-trajectory rather than the speciation or extinction trajectories themselves. The scale of the stochastic noise can be adjusted using <code>mrf.sd.scale</code>, which defaults to 1.0 and can be set to 0.0 for constant <span class="math inline">\(p\)</span>-trajectories.</p>
<p>The congruence class in which to sample is specified through the pulled diversification rate function (<code>p.delta</code>), together with the speciation rate at the present. The extinction rate at present can either be specified or drawn randomly from a lognormal distribution, similarly to <code>sample.basic.models</code>.</p>
<p>Bounds for the rates can also be imposed using <code>min.lambda</code>, <code>max.lambda</code>, <code>min.mu</code>, and <code>max.mu</code> (which is usually unnecessary with this approach). Similarly, <code>min.p</code> and <code>max.p</code> can be used to set the lower and upper bounds of the p trajectory, allowing for finer control over the balance between speciation and extinction rates in the generated scenarios.</p>
</div>
</div>
            </section>

          </div>
        </div>
      </div>
<a href="installation.html" class="navigation navigation-prev " aria-label="Previous page"><i class="fa fa-angle-left"></i></a>
<a href="creating-the-congruence-class.html" class="navigation navigation-next " aria-label="Next page"><i class="fa fa-angle-right"></i></a>
    </div>
  </div>
<script src="lib/gitbook-2.6.7/js/app.min.js"></script>
<script src="lib/gitbook-2.6.7/js/clipboard.min.js"></script>
<script src="lib/gitbook-2.6.7/js/plugin-search.js"></script>
<script src="lib/gitbook-2.6.7/js/plugin-sharing.js"></script>
<script src="lib/gitbook-2.6.7/js/plugin-fontsettings.js"></script>
<script src="lib/gitbook-2.6.7/js/plugin-bookdown.js"></script>
<script src="lib/gitbook-2.6.7/js/jquery.highlight.js"></script>
<script src="lib/gitbook-2.6.7/js/plugin-clipboard.js"></script>
<script>
gitbook.require(["gitbook"], function(gitbook) {
gitbook.start({
"sharing": {
"github": false,
"facebook": true,
"twitter": true,
"linkedin": false,
"weibo": false,
"instapaper": false,
"vk": false,
"whatsapp": false,
"all": ["facebook", "twitter", "linkedin", "weibo", "instapaper"]
},
"fontsettings": {
"theme": "white",
"family": "sans",
"size": 2
},
"edit": {
"link": null,
"text": null
},
"history": {
"link": null,
"text": null
},
"view": {
"link": null,
"text": null
},
"download": null,
"search": false,
"toc": {
"collapse": "subsection"
}
});
});
</script>

<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
  (function () {
    var script = document.createElement("script");
    script.type = "text/javascript";
    var src = "true";
    if (src === "" || src === "true") src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/latest.js?config=TeX-MML-AM_CHTML";
    if (location.protocol !== "file:")
      if (/^https?:/.test(src))
        src = src.replace(/^https?:/, '');
    script.src = src;
    document.getElementsByTagName("head")[0].appendChild(script);
  })();
</script>
</body>

</html>
