MyNixOS website logo
Description

Bayesian Priors for Matrix Population Models.

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) <doi:10.1016/j.ecolmodel.2021.109526>.

raretrans

Project Status:Active CRANstatus R-CMD-check

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

Requirements

  • R >= 4.1.0
  • Core package dependencies: ggplot2, rlang
  • Vignette dependencies: tidyverse, popbio, huxtable, popdemo, googledrive

Note: The core functions work on any R >= 4.1.0. Vignettes require R >= 4.1.0 due to dependencies in popdemo, dplyr, and purrr. If you are on an older version of R, install without vignettes (see below) and read them online at https://atiretoo.github.io/raretrans/.

Installation

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]")

Overview

The main functions in this package are:

FunctionPurpose
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.

Interactive Application

raretrans includes an interactive Shiny application to explore the effects of different Bayesian priors on transition matrices dynamically.

raretrans::run_app()

Quick Start

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)

Vignettes

#VignetteTopic
01Quick startMinimal worked example with Lepanthes eltoroensis
02IntroductionFull workflow walkthrough
03Single populationWorking with one population and transition period
04Credible intervalstransition_CrI() and plotting with Cypripedium calceolus
05Prior informationEffect of priors on transitions and fertility
06Animal matricesExamples with animal population data

Browse all vignettes at https://atiretoo.github.io/raretrans/.

Getting Help

Reference

Caswell, H. (2001). Matrix Population Models: Construction, Analysis, and Interpretation (2nd ed.). Sinauer Associates.

Code of Conduct

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.

Metadata

Version

1.0.5

License

Unknown

Platforms (80)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows