MyNixOS website logo
Description

Bayesian Dynamic Energy Budget Modelling.

Provides a Bayesian framework for Dynamic Energy Budget (DEB) modelling via 'Stan'. Implements the standard DEB model of Kooijman (2010, <doi:10.1017/CBO9780511805400>) as a state-space model with Hamiltonian Monte Carlo inference (Carpenter et al., 2017, <doi:10.18637/jss.v076.i01>). Includes individual-level growth models, growth-reproduction models, hierarchical multi-individual models with partial pooling, and toxicokinetic-toxicodynamic (TKTD) models for ecotoxicology following the DEBtox framework (Jager et al., 2006, <doi:10.1007/s10646-006-0060-x>). Supports prior specification from biological knowledge, convergence diagnostics (Vehtari et al., 2021, <doi:10.1214/20-BA1221>), posterior predictive checks, derived quantity estimation, and visualisation via 'ggplot2'.

BayesianDEB

DOI

BayesianDEB provides a Bayesian framework for Dynamic Energy Budget (DEB) modelling in R, using Stan as the computational backend via cmdstanr.

The package implements the standard DEB model (Kooijman, 2010) as a Bayesian state-space model. Parameters are estimated via Hamiltonian Monte Carlo (NUTS; Hoffman & Gelman, 2014), with full posterior uncertainty propagation to derived biological quantities such as ultimate length, von Bertalanffy growth rate, EC50, and NEC.

Overview

Four model types cover the most common DEB applications:

TypeStatesStan modelUse case
"individual"E, Vbdeb_individual_growthSingle organism growth
"growth_repro"E, V, Rbdeb_growth_reproGrowth + reproduction
"hierarchical"E, V + REbdeb_hierarchical_growthMulti-individual, partial pooling
"debtox"E, V, R, Dbdeb_debtoxEcotoxicology (TKTD)

Each model is bundled as a pre-written Stan program; the R layer handles data preparation, prior specification, fitting, diagnostics, and visualisation.

Note on model maturity. The "individual" and "growth_repro" models have the most complete downstream tooling (L_hat trajectories, posterior predictive checks, log_lik for LOO-CV). The "hierarchical" and "debtox" models use reduce_sum for within-chain parallelism, which means PPC and L_hat are not stored in Stan; trajectory plots are instead produced via R-side forward simulation from the posterior. All four model types support full diagnostics, summary, derived quantities, and trace/posterior/pairs plots.

Feature status

FeatureStatusNotes
Individual growth modelstable2-state DEB, full PPC
Growth + reproduction modelstable3-state DEB, NegBin/Poisson offspring
Hierarchical growth modelstableNon-centred param., reduce_sum threading
DEBtox (TKTD) modelbetaGroup-level (1 ODE/conc.); hierarchical DEBtox planned
Observation models (normal, lognormal, student-t)stableSwitchable per model via obs_*()
Arrhenius temperature correctionstableGlobal correction on rate parameters
Prior specificationstable6 families, weakly informative defaults
Species-specific priors (prior_species())stableBuilt-in for E. fetida, E. andrei, F. candida, D. magna, L. rubellus
Derived quantities (L_m, L_inf, k_M, g, r_B)stableKooijman (2010) formulas, dimensional tests
EC50 / NEC extractionstableAnalytical, full posterior
Within-chain parallelism (reduce_sum)stableHierarchical + DEBtox models
Trajectory plots for hierarchical/debtoxstableR-side LSODA simulation from posterior
PPC for hierarchical/debtoxnot availableUse trajectory plots and bdeb_diagnose()
Survival endpointplannedNot in current API; will be added in future version
Per-observation temperature (time-varying T)plannedCurrently global only
Multiple stress modes (maintenance, growth cost)plannedAssimilation stress implemented
Prior-posterior comparison plotstableplot(fit, type = "prior_posterior")
Prior predictive checksstablebdeb_prior_predictive() with plot method
Standalone simulatorsstabledeb_simulate(), debtox_simulate()
Maturity dynamics (wider)plannedCurrently post-puberty only
Hierarchical DEBtox (individual-level TKTD)plannedCurrently group-level only
Weight endpointplannedRequires shape coefficient in model
Shape coefficient ($\delta_M$) estimationplannedCurrently user-supplied conversion
Real-data benchmark datasetplannedSimulated data validated against AmP

Current limitations

  • "individual" and "growth_repro" support exactly one individual; multi-individual data require "hierarchical".
  • "debtox" fits one ODE per concentration group, not per individual. Multi-individual data within a group are aggregated to means (with warning). Hierarchical individual-level DEBtox is planned.
  • "hierarchical" models random effects on p_Am only; other parameters are shared across individuals.
  • Survival endpoint is not implemented (not in API).
  • Temperature correction is global (single T for the entire experiment); time-varying temperature is planned.
  • Food level (f_food) is constant; time-varying food is not supported.
  • All lengths are structural ($L = V^{1/3}$); the shape coefficient $\delta_M$ is not estimated (user must convert physical lengths).
  • R-side simulators (deb_simulate, trajectory plots, prior predictive) use the LSODA solver from deSolve, matching Stan's BDF solver.

Installation

BayesianDEB requires cmdstanr and a working CmdStan installation.

# 1. Install cmdstanr from r-universe
install.packages("cmdstanr",
  repos = c("https://stan-dev.r-universe.dev", getOption("repos")))

# 2. Install CmdStan (one-time)
cmdstanr::install_cmdstan()

# 3. Install BayesianDEB
# install.packages("BayesianDEB")
# or from source:
# remotes::install_github("sciom/BayesianDEB")

Quick start

library(BayesianDEB)

# Bundled example data: 21 Eisenia fetida individuals, 12 weeks
data(eisenia_growth)

# 1. Prepare data (single individual)
dat <- bdeb_data(growth = eisenia_growth[eisenia_growth$id == 1, ])

# 2. Specify model with custom priors
mod <- bdeb_model(dat, type = "individual",
  priors = list(
    p_Am  = prior_lognormal(mu = 1.5, sigma = 0.5),
    kappa = prior_beta(a = 3, b = 2)
  ))

# 3. Fit
fit <- bdeb_fit(mod, chains = 4, iter_sampling = 1000)

# 4. Inspect
bdeb_diagnose(fit)
plot(fit, type = "trajectory")

# 5. Posterior predictive check
ppc <- bdeb_ppc(fit)
plot(ppc)

# 6. Derived quantities
bdeb_derived(fit, quantities = c("L_inf", "growth_rate"))

Citation

If you use BayesianDEB in your work, please cite:

Hackenberger, B.K., Djerdj, T. and Hackenberger, D.K. (2026). BayesianDEB: Bayesian Dynamic Energy Budget Modelling. R package version 0.1.3. https://github.com/sciom/BayesianDEB

Key references

  • Kooijman, S.A.L.M. (2010). Dynamic Energy Budget Theory for Metabolic Organisation. 3rd ed. Cambridge University Press. doi:10.1017/CBO9780511805400
  • Jager, T., Heugens, E.H.W. and Kooijman, S.A.L.M. (2006). Making sense of ecotoxicological test results: towards application of process-based models. Ecotoxicology, 15(3), 305--314. doi:10.1007/s10646-006-0060-x
  • Carpenter, B. et al. (2017). Stan: A probabilistic programming language. Journal of Statistical Software, 76(1). doi:10.18637/jss.v076.i01

License

MIT.

Metadata

Version

0.1.4

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