MyNixOS website logo
Description

Simulate Temporally Autocorrelated Populations.

Temporally autocorrelated populations are correlated in their vital rates (growth, death, etc.) from year to year. It is very common for populations, whether they be bacteria, plants, or humans, to be temporally autocorrelated. This poses a challenge for stochastic population modeling, because a temporally correlated population will behave differently from an uncorrelated one. This package provides tools for simulating populations with white noise (no temporal autocorrelation), red noise (positive temporal autocorrelation), and blue noise (negative temporal autocorrelation). The algebraic formulation for autocorrelated noise comes from Ruokolainen et al. (2009) <doi:10.1016/j.tree.2009.04.009>. Models for unstructured populations and for structured populations (matrix models) are available.

colorednoise

CRAN_version CoverageStatus Download_count Paper_doi

Overview

Many populations that change over time are temporally autocorrelated, which means that the random noise in each timestep is correlated to that of the previous timestep. Instead of uncorrelated white noise, these populations are governed by blue noise (negatively autocorrelated) or red noise (positively autocorrelated.)

The colorednoise package allows you to simulate colored noise as well as populations whose behavior is governed by colored noise.

Installation

You can install the latest version of colorednoise from github with:

# install.packages("devtools")
devtools::install_github("japilo/colorednoise")

Example

Here are plots of blue- and red-noise populations generated by the matrix_model function.

library(colorednoise)
set.seed(7927)
pop_blue <- matrix_model(
  data = list(
    mean = matrix(c(0.6687097, 0.2480645, 0.6687097, 0.4335484), ncol=2),
    sd = matrix(c(0.34437133, 0.08251947, 0.34437133, 0.10898160), ncol=2),
    autocorrelation = matrix(rep(-0.4, 4), ncol=2)
  ), timesteps = 100, initialPop = c(100, 100)
)
pop_red <- matrix_model(
  data = list(
    mean = matrix(c(0.6687097, 0.2480645, 0.6687097, 0.4335484), ncol=2),
    sd = matrix(c(0.34437133, 0.08251947, 0.34437133, 0.10898160), ncol=2),
    autocorrelation = matrix(rep(0.4, 4), ncol=2)
  ), timesteps = 100, initialPop = c(100, 100)
)
ggplot(pop_blue, aes(x = timestep, y = total)) + geom_line(col="blue") + ylim(0, 6000)

ggplot(pop_red, aes(x = timestep, y = total)) + geom_line(col="red") + ylim(0, 6000)

Metadata

Version

1.1.2

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • 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-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
  • 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-windows