This is an example of interfacing R and shiny to allow users to explore
a biological model often encountered in an introductory ecology class.
We are interested the growth of a population that is composed of multiple,
discrete stages or age classes. Patrick H. Leslie provides an in-depth
derivation of the model in his 1945 paper
“ /joseph/Leslie_1945.pdf">On the use of matrices in certain population mathematics”.
The population at time is represented by a vector ,
where each element of the vector represents the number of individulas
in each age class (e.g. if a population has age classes, then
has elements). Time is considered discrete and we
assume that the population is censused prior to breeding. We assume
that individuals within each age class are identical, and that each
has some probability of maturing to the next age class, surviving
(staying in the same age class), and reproduction. Changes in the
population from one timestep to another are represented as:
where is an x Leslie matrix (or more generally, a
projection matrix) that describes the contribution of each age class to
the population at time .
Suppose we are tasked with modeling the annual dynamics of a population
with four age classes, and $t$ represents years. For simplicity, we
model only females and assume that plenty of males are available for
breeding. Individuals in the first age class survive to class 2 with
probability 0.1, class 2 individuals survive to class 3 with probability
0.5, class 3 individuals survive to class 4 with probability 0.9, and
class four individuals survive each year with probability 0.7. Only the
fourth age class is reproductive, with individuals producing 100 class
1 individuals per year. We can represent this population graphically as:
Equivalently, as a Leslie matrix:
The long term population growth rate is related to the dominant
eigenvalue of . If the population
eventually declines to extinction, and if , the
From a management perspective, it is often useful to know how limited
resources may be allocated to increase population growth or prevent
extinction. In other words, if an element such as fecundity or
survival could be manipulated by managers, how much would the long term
population growth rate change? To this end, one can calculate the
sensitivity of the dominant eigenvalue () to small
changes in :
where and are left and right
eigenvectors, respectively, associated with the dominant eigenvalue.
Because survival and fecundity are on different scales, sensitivity is
often scaled by a factor of for a measure
Building the R shiny app
Files are accessible in this repository. Please feel free to clone for your own use and/or contribute.
Here is the resulting graphical user interface for the model.