Website: Bayes Growth BDD
Demonstrating the use of behavior-driven development (BDD) for monophasic and biphasic Bayesian fisheries growth models on sharks.
The general idea behind this demonstration is to synthesise the behavior-driven development (BDD) testing approach that is more commonly used within agile software development with Bayesian statistical modelling. With a marine biology flavour. The overall aim is to demonstrate how BDD can enable and facilitate communication among different disciplines using a common human-readable language. This is particularly important within highly technical scientific domains where cross-disciplinary communication may be more challenging.
BDD was chosen as it (at least in theory) facilitates collaboration and communication within multidisciplinary projects. Namely, it encourages business analysts and developers to collaborate in specifying the behaviour of software, via the use of user stories. These user stories should be written to a formal document. For this demonstration, these documents are written in the popular Gherkin syntax.
Likewise, by using a Bayesian modelling approach, we can easily incorporate prior assumptions from domain experts (marine biologists in this case) into our models. These assumptions can be documented in Gherkin, and would be recorded by business analysts as user stories.
Python dependencies are specified in this requirements.txt file. It's recommended that you create a virtual environment before installing these dependencies.
The PyMC library was used to specify all Bayesian growth models. This demonstration specifically implements nonlinear, Bayesian multilevel models using PyMC.
Documentation for actually implementing nonlinear, Bayesian multilevel models with multiple factors using PyMC is pretty limited. I probably should have used Stan instead 😎
The behave package was used to implement all BDD tests. These tests have been written using Gherkin syntax. For more information on Gherkin, click here.
- Feature files containing human-readable Gherkin can be found here.
- The implementation of the scenario steps can be found here.
Publicly available age and growth data for the following species were included in this demonstration:
- Blacktip shark (Carcharhinus limbatus)
- Spot-tail shark (Carcharhinus sorrah)
- Australian blacktip shark (Carcharhinus tilstoni)
All data used in this demonstration were retrieved from the following sources:
With the respective citations:
- Harry, A. V., Butcher, P. A., Macbeth, W. G., Morgan, J. A., Taylor, S. M., & Geraghty, P. T. (2019). Life history of the common blacktip shark, Carcharhinus limbatus, from central eastern Australia and comparative demography of a cryptic shark complex. Marine and Freshwater Research, 70(6), 834-848.
- Harry, A. V., Tobin, A. J., & Simpfendorfer, C. A. (2013). Age, growth and reproductive biology of the spot-tail shark, Carcharhinus sorrah, and the Australian blacktip shark, C. tilstoni, from the Great Barrier Reef World Heritage Area, north-eastern Australia. Marine and freshwater research, 64(4), 277-293.
- The unprocessed data can be found by here.
- The processed data can be found by here.
- This DVC pipeline can be executed to reproduce the data processing steps.
- The Hydra configuration files for the DVC pipeline can be found here.
- The behave.sh script will run the BDD tests.
- The BDD test results can be found here.
- An optional Docker configuration has been provided to facilitate experiment tracking.
- See the .env file for Docker environment variables.
- The docker_up.sh script can be executed to launch the Docker services.
- MLFlow is available for experiment tracking.
- Also, MinIO is available for storing experiment artifacts.
Experiment tracking is currently not being heavily used within the demonstration, but the option is definitely there...
The Gherkin documents here describe a statistical modelling exercise applied to 3 species of shark to evaluate and compare monophasic and biphasic Bayesian growth models. From statistical evidence provided by previous works on the subject, there is some reason to believe that biphasic models typically offer a superior statistical fit. For initial reading, refer to:
- Araya, M., & Cubillos, L. A. (2006). Evidence of two-phase growth in elasmobranchs. Environmental Biology of Fishes, 77, 293-300.
- Wilson, K. L., Honsey, A. E., Moe, B., & Venturelli, P. (2018). Growing the biphasic framework: Techniques and recommendations for fitting emerging growth models. Methods in Ecology and Evolution, 9(4), 822-833.
Notably, the results of the modelling exercise were fairly mixed - meaning that the biphasic growth models did not consistently outperform the monophasic growth models in terms of statistical fit.
Also, note that we are using priors gleaned from the data itself. Specifically, our priors were taken from Harry et al. (2013) and Harry et al. (2019). In other words, we are using Empirical Bayes, rather than a fully Bayesian treatment.
The growth function most commonly used within fisheries science to model growth patterns and length-at-age relationships is the von Bertalanffy growth model (VBGM) [1]. The VBGM provides informative parameter estimates including growth rates and maximum lengths [1]. The familiar Beverton-Holt parameterisation [2] of the VBGM is as follows:
where
Though the VBGM is highly popular, the assumption that a monophasic curve can model the entire lifetime growth of chondrichthyans has received criticism. For instance, a single curve may fail to account for changes in energy reallocation and growth that occur at the onset of maturity, resulting in models that fit poorly to the smallest or largest of individuals [3]. Therefore, a biphasic growth model may better characterise growth patterns for both the juvenile and mature life stages of chondrichthyans [4], potentially leading to more robust parameter estimates of growth. More accurate parameter estimates typically lead to more accurate stock assessments, and help to inform both conservation and fisheries management [5]. Hence, robust length-at-age models are key to the effective management and sustainability of fisheries.
One contributing factor to changes in the growth rate of chondrichthyans following sexual maturity is energy reallocation away from somatic growth and towards reproductive investment [4]. In contrast to teleostei, reproductive investment is relatively high for most chondrichthyans, so any changes in somatic growth rates following the age-at-maturity are more likely to be identified from growth and age data alone [6].
Soriano et al.'s [7] biphasic modifications to the common VBGM, hereafter referred to as the biphasic VBGM (BVBGM), have been applied to a number of chondrichthyes within several age and growth studies. For instance, Acuna et al. [8] made use of the BVBGM to model the growth of three pelagic sharks: Lamna nasus, Isurus oxyrinchus, Prionace glauca.
Soriano et al. [7] proposed two continuous modifications to the common VBGM. For each, a new factor
where
where
[1] Ricker, W. E. (1975). Computation and interpretation of biological statistics of fish populations. Fish. Res. Board Can. Bull., 191, 1-382.
[2] Beverton, R. J. H., & Holt, S. J. (1957). On the dynamics of exploited fish populations.
[3] Quince, C., Shuter, B. J., Abrams, P. A., & Lester, N. P. (2008). Biphasic growth in fish II: empirical assessment. Journal of Theoretical Biology, 254(2), 207-214.
[4] Araya, M., & Cubillos, L. A. (2006). Evidence of two-phase growth in elasmobranchs. Environmental Biology of Fishes, 77, 293-300.
[5] Pardo, S. A., Cooper, A. B., & Dulvy, N. K. (2013). Avoiding fishy growth curves. Methods in Ecology and Evolution, 4(4), 353-360.
[6] Frisk, M. G., Miller, T. J., & Fogarty, M. J. (2001). Estimation and analysis of biological parameters in elasmobranch fishes: a comparative life history study. Canadian Journal of Fisheries and Aquatic Sciences, 58(5), 969-981.
[7] Soriano, M., Moreau, J., Hoenig, J. M., & Pauly, D. (1992). New functions for the analysis of two-phase growth of juvenile and adult fishes, with application to Nile perch. Transactions of the American Fisheries Society, 121(4), 486-493.
[8] Acuña, E., Cid, L., Pérez, E., Kong, I., Araya, M., Lamilla, J., ... & Barraza, O. (2001). Estudio biológico de tiburones (marrajo dentudo, azulejo y tiburón sardinero) en la zona norte y central de Chile. Informe final, Proyecto FIP, (2000-23), 112.