Environment Magazine

Need to Predict Population Trends, but Can’t Code? No Problem

Posted on the 02 December 2020 by Bradshaw @conservbytes

Yes, yes. I know. Another R Shiny app.

However, this time I’ve strayed from my recent bibliometric musings and developed something that’s more compatible with the core of my main research and interests.

Need to predict population trends, but can’t code? No problem

Welcome to LeslieMatrixShiny!

Over the years I’ve taught many students the basics of population modelling, with the cohort-based approaches dominating the curriculum. Of these, the simpler ‘Leslie’ (age-classified) matrix models are both the easiest to understand and for which data can often be obtained without too many dramas.

Need to predict population trends, but can’t code? No problem
a fictions life-cycle graph

But unless you’re willing to sit down and learn the code, they can be daunting to the novice.

Sure, there are plenty of software alternatives out there, such as Bob Lacy‘s Vortex (a free individual-based model available for PCs only), Resit Akçakaya & co’s RAMAS Metapop ($; PC only), Stéphane Legendre‘s Unified Life Models (ULM; open-source; all platforms), and Charles Todd‘s Essential (open-source; PC only) to name a few. If you’re already an avid R user and already into population modelling, you might be familiar with the population-modelling packages popdemo, OptiPopd, or sPop. I’m sure there are still other good resources out there of which I’m not aware.

But, even to install the relevant software or invoke particular packages in R takes a bit of time and learning. It’s probably safe to assume that many people find the prospect daunting.

It’s for this reason that I turned my newly acquired R Shiny skills to matrix population models so that even complete coding novices can run their own stochastic population models.

I call the app LeslieMatrixShiny.

But unlike some other Shiny matrix-modelling apps I’ve seen, LeslieMatrixShiny is not just for teaching or demonstration purposes. I’ve designed it so that it is customisable and can provide useful results for real research outputs. Like the name implies, it only implements Leslie (age-structured) models for now.

Need to predict population trends, but can’t code? No problem

This web-based app not only allows you to customise the demographic details of your chosen species/population, it also includes a customisable density-feedback function on survival, as well as full stochastic resampling features (including generationally scaled catastrophes) to estimate confidence intervals and extinction probabilities. You can also choose to project your population forward in time based on a set number of years or species-specific generations.

Finally, I’ve added functionality to examine two types of disturbances: (i) single-pulse and (ii) press disturbances.

A pulse disturbance is an acute perturbation that happens abruptly. I implemented this function to test the effect of one-off disturbance events like a harvest or known catastrophe (in addition or independent of the ‘normal’ probability of a generic catastrophes mentioned above). The user also has the choice to set a specific timing for the pulse disturbance, or to let it happen at any time randomly during the projection window. The user can also choose to set the perturbation as a percentage of the current population size, or as a fixed number of individuals.

A press disturbance is a perturbation that happens over a longer time frame than a pulse disturbance. I implemented this function to test the effect of a sustained disturbance event like an annual harvest. The user has the choice to set a specific interval for the press disturbance, or to let it happen throughout the entire projection window. Like in the pulse function, the user can choose to set the perturbation as a percentage of the current population size, or as a fixed number of individuals.

And like any good software, I have included a rather detailed instructions page to explain each step along the way. I’ve also provided all the underlying Shiny code and functions in Github.

This is a work in progress, of course, and I’m sure users and I will find bugs along the way. That said, I’m pretty satisfied with how it’s working now, and I’m keen for people to start using it. As time marches on, I plan to add more features, such as a minimum-viable population size calculator, download and upload facilities, time-variant carrying capacity, and perhaps more complex density-feedback functions.

CJA Bradshaw


Back to Featured Articles on Logo Paperblog