Provides functions to correct biased transition and fertility
estimates in population projection matrices caused by small sample sizes.
Small or short-term studies frequently produce structural zeros
(biologically possible transitions never observed) and structural ones
(transitions estimated at 100% survival, stasis, or mortality that are
biologically implausible). Both distort matrix structure and bias
estimates of population growth. Implements a multinomial-Dirichlet
Bayesian prior for transition probabilities and a Gamma-Poisson prior
for reproduction, allowing analysts to incorporate prior biological
knowledge and regularise estimates from rare or unobserved events.
Includes functions to compute marginal posterior credible intervals for
all transition probabilities (transition_CrI()), visualise those
intervals as point-range plots (plot_transition_CrI()), and display
the full posterior beta density for each matrix entry
(plot_transition_density()). Methods are described in Tremblay et al.
(2021)
Functions to create matrix population models from a combination of data on stage/age transitions and Bayesian prior information. This compensates for structural problems caused by missing observations of rare transitions (“holey matrices”).
Based on methods described in:
Tremblay, R. L., Tyre, A. J., Pérez, M.-E., & Ackerman, J. D. (2021). Population projections from holey matrices: Using prior information to estimate rare transition events. Ecological Modelling, 447, 109526. https://doi.org/10.1016/j.ecolmodel.2021.109526
ggplot2, rlangtidyverse, popbio, huxtable, popdemo,
googledriveNote: The core functions work on any R >= 4.1.0. Vignettes require R >= 4.1.0 due to dependencies in
popdemo,dplyr, andpurrr. If you are on an older version of R, install without vignettes (see below) and read them online at https://atiretoo.github.io/raretrans/.
Install the stable release from CRAN:
install.packages("raretrans")
Or install the development version from GitHub:
# install.packages("remotes") # if needed
remotes::install_github("atiretoo/raretrans")
The code and data used to produce the published paper are tagged
v1.0.0:
remotes::install_github("atiretoo/[email protected]")
The main functions in this package are:
| Function | Purpose |
|---|---|
fill_transitions() |
Fill a transition matrix using a Dirichlet-multinomial prior |
fill_fertility() |
Fill a fertility matrix using a Gamma prior |
sim_transitions() |
Simulate posterior transition matrices |
transition_CrI() |
Compute credible intervals for all transition probabilities |
plot_transition_CrI() |
Visualise posterior means and credible intervals |
plot_transition_density() |
Visualise full posterior beta densities as a matrix plot |
All functions take a TF list of two matrices as their first argument:
a transition matrix T and a fertility matrix F. These can be
constructed by hand or created with
popbio::projection.matrix(..., TF = TRUE) from individual-level
transition data.
raretrans includes an interactive Shiny application to explore the
effects of different Bayesian priors on transition matrices dynamically.
raretrans::run_app()
library(raretrans)
# Example with *Lepanthes eltoroensis* data included in the package
data(L_elto)
# Build a TF list from individual transition data
TF <- popbio::projection.matrix(L_elto, TF = TRUE)
# Fill structural zeros and perfect (1.0) survival,
# transitions, stasis and fertilities using uninformative priors
fill_transitions(TF)
fill_fertility(TF)
| # | Vignette | Topic |
|---|---|---|
| 01 | Quick start | Minimal worked example with Lepanthes eltoroensis |
| 02 | Introduction | Full workflow walkthrough |
| 03 | Single population | Working with one population and transition period |
| 04 | Credible intervals | transition_CrI() and plotting with Cypripedium calceolus |
| 05 | Prior information | Effect of priors on transitions and fertility |
| 06 | Animal matrices | Examples with animal population data |
Browse all vignettes at https://atiretoo.github.io/raretrans/.
Caswell, H. (2001). Matrix Population Models: Construction, Analysis, and Interpretation (2nd ed.). Sinauer Associates.
Please note that the raretrans project is released with a Contributor
Code of
Conduct.
By contributing to this project, you agree to abide by its terms.