Daphnia-ms

Mechanistic Models for Panel Data: Analysis of Ecological Experiments with Four Interacting Species

View the Project on GitHub Megumi-ybb/Daphnia-ms

Mechanistic Models for Panel Data

Analysis of Ecological Experiments with Four Interacting Species

Bo Yang, Jesse Wheeler, Meghan A. Duffy, Aaron A. King, Edward L. Ionides

Preprint: arXiv:2506.04508 Archive: DOI

Overview

This repository contains the code and data to reproduce all analyses in Mechanistic models for panel data: Analysis of ecological experiments with four interacting species. We develop Panel Iterated Filtering (PIF) and Marginalized PIF (MPIF) methods for maximum likelihood inference on PanelPOMP models, and apply them to mesocosm experiments involving two Daphnia species, an algal food resource (Ankistrodesmus falcatus), and a fungal parasite (Metschnikowia bicuspidata).


Paper & Supplementary Material

Document Source Compiled
Main manuscript ms.Rnw ms.pdf
Supplementary material si.Rnw si.pdf

The manuscript is self-contained and can be generated by knitting ./daphnia-article/ms.Rnw. The supplement in ./daphnia-article/si/si.Rnw is independent of the main manuscript.

Compile the manuscript:

cd ./daphnia-article && Rscript -e "library(knitr); knit2pdf('./ms.Rnw')"

Compile the supplement:

cd ./daphnia-article/si && Rscript -e "library(knitr); knit2pdf('./si.Rnw')"

Note: The majority of expensive computations are done in separate R scripts, but there are a few calculations (including simulation and pomp object creation) that occur within ms.Rnw.


Data

The file Mesocosmdata.xls contains three sheets:

Sheet Contents
1 D. dentifera dynamics with/without parasite
2 D. lumholtzi dynamics with/without parasite
3 Mixed D. dentifera and D. lumholtzi dynamics with/without parasite

Processed data files used by model fitting scripts are in data/. See Section 2 of the manuscript for the full experimental design (6 treatment conditions × 8–10 replicates, 10 time points over 52 days).


Model Fitting Code

All models are fit under the panelPOMP framework using Panel Iterated Filtering. The run_level parameter in each script controls computational intensity:

Level Purpose Approximate Resources
1 Debug Minutes, any machine
2 Local computation ~1 hour on 36 cores, ~50 GB memory
3 Full estimation ~40 hours on 36 cores, ~50 GB memory

Mixed-species treatments (two Daphnia species)

Model Treatment Code Description
SIRJPF2 Two species + parasite Mixed-species/SIRJPF2/ Flagship model (8 latent states, 26 parameters)
SRJF2 Two species, no parasite Mixed-species/SRJF2/ Competition through shared food only

The SIRJPF2 directory contains:

Subfolder Contents
model/ Parameter estimation scripts (PIF/MPIF)
profile/ Profile likelihood scripts (MCAP algorithm)
specific_model/ Unit-specific parameter estimation (mif2)
specific_model_block/ Blocked unit-specific estimation (mif2)

Other model directories follow the same subfolder structure.

Single-species treatments

Model Species Treatment Code
SIRJPF D. dentifera With parasite Single-species/Dent/SIRJPF/
SIRJPF D. lumholtzi With parasite Single-species/Lum/SIRJPF/
SRJF D. dentifera No parasite Single-species/Dent/SRJF/
SRJF D. lumholtzi No parasite Single-species/Lum/SRJF/

Model hierarchy

SIRJPF2  (2 species + Parasite + Food + Juveniles)  ← Flagship
├── SIRJPF   (1 species + Parasite + Food + Juveniles)
├── SRJF2    (2 species + Food + Juveniles, no parasite)
└── SRJF     (1 species + Food + Juveniles, no parasite)

Utility Scripts

The util/ directory contains scripts for generating:


Tutorial

For a step-by-step guide on implementing PanelPOMP models and the methods used in this article, see the companion tutorial:

megumi-ybb.github.io/Daphnia-tutorial (GitHub repository)

The tutorial (Supplement 2) covers:

  1. PanelPOMP model specification
  2. Panel Iterated Filtering (PIF) for likelihood maximization
  3. Multi-stage optimization with tempering
  4. Profile likelihood confidence intervals (MCAP)
  5. Model diagnostics and simulation studies

Reproducing the Analysis

  1. Clone this repository:
    git clone https://github.com/Megumi-ybb/Daphnia-ms.git
    cd Daphnia-ms
    
  2. Install R dependencies:
    install.packages(c("pomp", "panelPomp", "tidyverse"))
    
  3. Fit models (example for the flagship SIRJPF2):
    cd Mixed-species/SIRJPF2/model/
    # Set run_level in the script (1 = debug, 2 = local, 3 = full)
    Rscript <script_name>.R
    
  4. Run profiling:
    cd Mixed-species/SIRJPF2/profile/
    Rscript <profile_script>.R
    
  5. Generate figures and tables using scripts in util/.

  6. Compile the manuscript and supplement (see commands above).

Citation

If you use this code or data, please cite:

Yang, B., Wheeler, J., Duffy, M. A., King, A. A., & Ionides, E. L. Mechanistic models for panel data: Analysis of ecological experiments with four interacting species. arXiv:2506.04508

BibTeX:

@article{yang2025mechanistic,
  title={Mechanistic models for panel data: Analysis of ecological
         experiments with four interacting species},
  author={Yang, Bo and Wheeler, Jesse and Duffy, Meghan A. and
          King, Aaron A. and Ionides, Edward L.},
  journal={arXiv preprint arXiv:2506.04508},
  year={2025}
}

Software


License & Acknowledgements

Archived version available on Zenodo: doi:10.5281/zenodo.15595669