Skip to contents

‘hmde’ which stands for hierarchical methods for differential equations is a package built for biologists with repeat size measurement data who want to fit a specific set of growth functions.

Installation

‘hmde’ is under active development, you can install the stable, development version of ‘hmde’ from GitHub with:

# install.packages("remotes")
remotes::install_github("traitecoevo/hmde")

Overview

We treat growth as the continuous rate of change for size, and fit size-dependent growth functions. The repeat survey data requires multiple measurements from the same individuals over time that can be connected up as size(tj+1)=size(tj)+growth(from tj to tj+1).\begin{equation}\tag{1}\label{eqn_1} size(t_{j+1}) = size(t_{j}) + growth(\text{from }t_j\text{ to }t_{j+1}). \end{equation}

We assume that different individuals will have variation in the specifics of their growth function governed by the function parameters, but that individuals from the same population will have the same function description.

Notation

For notation we will express the true size for individual ii at time tjt_j as Yi(tj)Y_i(t_j), the growth function as ff, and a parameter of individual ii as βi\beta_i. So Equation can be expressed as Yi(tj+1)=Yi(tj)+tjtj+1f(Y(t),βi)dt\begin{equation}\tag{2}\label{eqn_2_longitudinal} Y_i(t_{j+1}) = Y_i(t_j) + \int_{t_j}^{t_{j+1}} f(Y(t), \beta_i)\,dt \end{equation} where the integral adds up all the growth over the intervening time. Each model we use will comes with its specific growth parameters that we will describe. Some are more biologically interpretable than others. We don’t assume that we see the true sizes, and instead have observed size yij=Yi(tj)+ error.y_{ij} = Y_i(t_j) + \text{ error}. We have assumed normally distributed error in hmde,this has proven reasonably robust in simulation for a more general size-dependent error model. For details see .

Due to the hierarchical structure of the statistical model, we have distributions that govern the behaviour of growth parameters. If we are modelling only a single individual, we don’t worry about the underlying distribution so much. If we have multiple individuals then we have a distribution with hyper-parameters that acts as a population-level feature, so βilog𝒩(μ,σ)\beta_i \sim \log\mathcal{N}(\mu, \sigma) for example, and we can examine the behaviour of the mean and standard deviation as population-level features.

{hmde} supported growth functions

  • Constant growth
  • Von Bertalanffy
  • Canham

For each growth function, we have implementation to model the growth of a single or for multiple individuals.

Workflow

Broadly, the workflow for hdme is to:

  1. Wrangle the data into the required format for a chosen model,
  2. Pass the data and the model to a function that runs the sampling with Stan’s MCMC algorithms.
  3. Inspect and anaysis the returned Stan fit object.

We will demonstrate this workflow using case studies that uses the three growth functions that are supported in hmde. You can find these on our website or you can view these in R using:

vignettes("constant-growth")
vignettes("von-bertalanffy")
vignettes("canham")

For each case study, we will discuss why that growth function was chosen in the context of the survey process as data availability is a key factor in determining which functions can be used. We will not discuss the mathematical and statistical theory in depth, if that is of interest, check out the vignette ‘hmde for Mathematicians’ or check out the methodology paper: .