Mostrando entradas con la etiqueta simecol. Mostrar todas las entradas
Mostrando entradas con la etiqueta simecol. Mostrar todas las entradas

jueves, 22 de septiembre de 2016

Population Growth Models using R/simecol, Part 1 : The world population

In this entry, as part of the series on dynamic systems modeling with R and simecol, we'll take a look at population growth models, our main focus being on human population growth models and how they tie into other theoretical frameworks such as demographic transition theory and carrying capacity. These different models are then fitted to data on world population spanning a period between 10000 BC up to 2015, using R and simecol. In this latter part we will finally introduce the FME R package.

Malthus model of population growth

In 1798 the Reverend Thomas Malthus published An Essay on the Principle of Population, sparking a debate about population size and its effects on the wealth of nations. His Essay is framed within the wider context of considerations about the perfectibility of the human condition and it was Malthus' response to the likes of Condorcet and others who argued, in the typical positivist style of the era, that human reason would eventually surmount all obstacles in the way of mankind's progress.

At the core of the Malthusian argument was the observation that populations grow exponentially but the means of physical sustenance can only increase in arithmetic progression at best, and since population growth is commensurate to the availability of means of sustenance, any momentary improvement in the living condition of the human masses that would lift the restrictions on human population growth would inevitably result in long term famine and aggravation of man's plight. In modern day system dynamics terminology, we would say that population growth has a negative feedback mechanism that prevents further population growth and this idea in itself is not without justification. I mean, the planet cannot sustain exponential human population growth indefinitely, can it?

Malthus was in fact aware of negative feedback mechanisms and cyclical behavior in population growth. To paraphrase Malthus: the increase in population meant a decrease in wages and at the same time, an increase in food prices (less food for more population). During this time, the difficulties in rearing a family are so great that population growth is at a stand. But at the same time, a decrease in the price of labor meant that farmers could employ more laborers to work the land and increase food production thus loosening population growth restraints. The same retrograde and progressive movements in human well-being ocurred again and again- a cycle of human misery and suffering1. Being a clergyman, this situation was seen by Malthus as "divinely imposed to teach virtuous behavior"2.


At any rate, what is known today as the Malthus model for population growth, given in (1), only considers the exponential aspect of growth, as given by the rate parameter \(r\). No doubt the Malthus model is the simplest population growth model. It characterizes the growth of a population as dependent only upon the reproductive rate \(r\) and the population level at any given time (\(N\)). Note that the negative feedback controls we spoke of earlier are conspicuously missing in this model. In this model, there is only positive feedback: higher population levels beget even higher population levels, and so on to infinity.

\[\frac{dN}{dt}=rN\qquad\qquad(1)\]

Verhulst or Logistic Model of Population Growth

Considering the ideas on population growth that Malthus expounded in his Essay, Adolphe Quetelet judged that Malthus failed to provide a mathematical explanation as to how population levels, whose growth was by nature exponential, would top off at some point and not continue to rise to infinity3. Quetelet himself and his pupil, Pierre Verhulst, would assume this task in their effort to apply the methods of physics, which had seen a huge success with Newton's work, to the social sciences, as was characteristic of Positivist thought in the nineteenth century4.

Making an analogy with physics, Quetelet argued that in addition to the principle of geometric growth of the population, there was another principle at work according to which "the resistance or the sum of the obstacles encountered in the growth of a population is proportional to the square of the speed at which the population level is increasing"5. This premise bears semblance to the mathematical description of an object falling through a dense fluid: the deeper the object descends into this fluid, the greater the density, and hence the resistance to its downward trajectory, until the object reaches a depth beyond which it can't descend further6. By applying this analogy to demographic growth, we can infer that there is a maximum population level. As a result, a population finds the cause of its eventual equilibrium in its own growth7. In modern literature, this model of population growth is given by the following differential equation:

\[\frac{dN}{dt}=r_{max}N\left(1-\frac{N}{K}\right)\qquad\qquad(2)\]
Let us examine this equation in more detail to understand its behavior. For small population levels, when \(N\) is much smaller than \(K\), \(N\) exhibits exponential like growth, as dictated by the \(r_{max}\) parameter, also known as the intrinsic growth rate. This is because the \(\left(1-N/K\right)\) term is still relatively close to 1. However, as \(N\) becomes larger, this last term starts to matter because it approaches zero. As \(N(t)\) attains this point, the growth given by the \(dN/dt\) differential peters out and the population levels top off asymptotically at \(K\). This assymptotical level \(K\) is known as the saturation point or the carrying capacity of the population. We can integrate equation (2) to obtain \(N(t)\), whose graph is as follows:

KK/2N₀t
Functions whose curve has this characteristic S-shape like the Verhulst model of population growth are called sigmoid functions8. We encounter sigmoid functions in many contexts: as the cumulative probability distribution function of the normal and T-Student distributions, as the hyperbolic tangent function and as the activation function of neurons in mathematical neural network models. Then of course there's also the logistic family of functions, which occur in statistics and machine learning contexts as well as in chemistry, physics, linguistics and sociology (in the latter two contexts the logistic function is used to model language or social innovation/adoption processes). Hence the alternate denomination for the Verhulst model of population growth as the logistic model of population growth. Another feature of this model is that it has an inflection point - after the \(N\) reaches \(K/2\), the rate of population growth starts to decelerate until it eventually levels off to zero. At this halfway inflection point, the differential rate of growth is highest and curve has its "steepest" tangent line. Notice the symmetry of the curve around this inflection point.

The beauty of the logistic model of population growth lies in its simplicity (only two parameters) and the interpretability of its parameters. The intrinsic growth rate (parameter \(r_{max}\)) is the rate of exponential growth when the population is small and the carrying capacity parameter \(K\) is simply the maximum population level attainable. One important disadvantage of the logistic model is the fact that its inflection point is exactly half the carrying capacity \(K\), which severly limits the applicability of this model. Nonetheless, Verhulst himself used this model to fit census data in France (1817-1831), Belgium (1815-1833), Essex County (1811-1831) and Russia (1796-1827), all with relative success9.

Variants of the logistic population growth model

In seeking to improve the applicability of the basic logistic model for population growth, many authors have since proposed models with more parameters that still retain the basic sigmoid features of the logistic model and include one inflection point. Given the inflexibility of the basic logistic growth model about the inflection point, Blumberg introduced what he called the hyperlogistic function whose derivative is given by (3), which we will in turn call the Bloomberg model of population growth:

\[\frac{dN}{dt}=r_{max}N^\alpha\left(1-\frac{N}{K}\right)^\gamma\qquad\qquad(3)\]
The Blumberg model introduced two additional parameters to surmount problems raised by treating the intrinsic growth rate as a time-dependent polynomial10, while at the same time contributing some measure of pliancy to the inflection point, given by (4). I would add that equation (3) cannot always be integrated - Blumberg cataloged the various conditions on \(\alpha\) and \(\gamma\) that result in analytic solutions to (3) when explicit integration can be carried out.

\[N_{inf}=\frac{\alpha}{\alpha+\gamma}K\qquad\qquad(4)\]
The Richards growth model, originally developed to fit empirical plant mass data, is given by:

\[\frac{dN}{dt}=r_{max}N\left(1-\left(\frac{N}{K}\right)^\beta\right)\qquad\qquad(5)\]
\[N_{inf}=\left(\frac{1}{1+\beta}\right)^{\tfrac{1}{\beta}}K\qquad\qquad(6)\]
The inflection point in the Richards model is given by (6). Note that for \(\beta=1\), the Richards model is the original logistic growth model with the same inflection point. For extreme cases of \(\beta\), we have \(N_{inf}=e^{-1}K\) when \(\beta\rightarrow 0\) and \(N_{inf}=K\) when \(\beta\rightarrow \infty\).

A further (and logical) generalization of the Blumberg and Richards models leads us to the so-called generalized logistic growth function with five parameters11 (equation 7), where \(\alpha\), \(\beta\) and \(\gamma\) are all real positive numbers. The inflection point for this model is given by (8), which makes sense as long as \(N_0 < N_{inf}\). If \(N_0 > N_{inf}\), then \(N_{inf}\) will never be attained, because the intrinsic growth rate is assumed to be positive.

\[\frac{dN}{dt}=r_{max}N^\alpha\left(1-\left(\frac{N}{K}\right)^\beta\right)^\gamma\qquad\qquad(7)\]
\[N_{inf}=\left(1+\frac{\beta\gamma}{\alpha}\right)^{-\tfrac{1}{\beta}}K\qquad\qquad(8)\]
Yet another growth model similar to the logistic growth model is the Gompertz growth model12. The Gompertz model has been used to describe exponential decay in mortality rates, the return on financial investments13 and tumor growth. It's equation takes the following form:

\[\frac{dN}{dt}=r_{max}N\,\log\left(\frac{N}{K}\right)\qquad\qquad(9)\]
An interesting variant for this model's representation is to use two stock variables, one representing the mass or population that's growing (\(N\)) and the other representing the diminish rate or growth (\(r\)). So, we would have two differential equations14:

\(\frac{dr}{dt}=-kr\)(10)
\(\frac{dN}{dt}=rN\)
It must be noted that all the models above imply exponential growth from the first time instant, where in fact, the effective exponential rate of growth is highest, as the population or mass levels are still far from attaining the carrying capacity. In some situations, it would seem that some populations begin in a "dormant" stage, where they are not exhibiting this sort of exponential growth. Such may be the case, for example, in societies before the industrial revolution or even before the agricultural revolution, when scarcity was the order of the day and high birth rates were decompensated with high mortality rates, resulting in population numbers that grew ever so slowly.

While going over the literature in writing this post, I found an interesting two-stage population growth model in Petzoldt (2008). He describes the situation in which a microorganism culture is dormant while it is adapting to its environment, after which it begins to reproduce and increase in numbers according to the logistic growth mechanism outlined above. In other words, in this model, growth is delayed or lagged. Petzoldt's two stage model for population growth is in fact a two-compartment model (see my entry on epidemological models, where I discuss compartment models), with one compartment representing the part of the population in the "dormant" stage and the other representing the "active" population:

\[\frac{dN_d}{dt}=-r_1N_d\](11)
\[\frac{dN_a}{dt}=r_1N_d+r_2N_a\left(1-\frac{N_a}{K}\right)\]

Hyperbolic models of population growth

Some authors have pointed out that logistic population growth models, although fairly accurate for short-term growth of populations on a scale of centuries, fail to accurately describe the long-term population growth of the entire human race on a scale of thousands of years. Namely, the logistic models do not account for the fact that the world's population has grown from 2 billion to 7 billion in the last 50 years alone, in comparison to which the population growth curve seems almost flat for time periods in the remote past. In a seminal work by Von Foerster, Mora and Amiot15, they proposed that according to the available data by 1960, the world's population growth could be described by the the following model:

\[\frac{dN}{dt}=\frac{C}{(T_c-t)^2}\qquad\qquad(12)\]
This model has one essential flaw: as \(t\) approaches \(T_c\), the denominator approaches zero and the population shoots up towards infinity. Even when modeling the world's population, this model predicts an ever increasing population rate when in fact, in 1962, the world population growth rate \(N\cdot dN/dt\) peaked at 2.1% and has since been decreasing16. To avoid the singularity predicted by Von Foerster et al's model, the Russian physicist S.P. Kapitsa suggested the following approach:

\[\frac{dN}{dt}=\frac{C}{(T_c-t)^2 + \tau^2}\qquad\qquad(13)\]
The differential equation in (13) can be easily integrated, resulting in:

\[N(t)=\frac{C}{\tau}arccot\left(\frac{T_c-t}{\tau}\right)\qquad\qquad(14)\]
With (14), Kapitsa fitted his model to the world population data available at that time and found that \(C=(186\pm 1)\cdot 10^9\), \(T_c=2007\pm 1\), and \(\tau=42\pm1\). The parameter \(\tau\) represents, according to Kapitsa, the average lifespan of a human generation.

Models with variable carrying capacity

The logistic models covered so far implicitly assume that the carrying capacity is a constant, presumably dependent on the environment's capacity to sustain a species population. While this might be plausible with different populations of plants and animal species, the human species sets itself apart from the others in one important aspect: its unprecedented and unmatched capacity to significantly alter the environment (and indeed the planet) to suit its purposes.

As a first approach, we could consider that the carrying capacity of the earth is gradually expanded by a growing human population, an idea grounded on the observation that a greater number of people imply greater food productivity and eventually, a greater number of inventions to amplify the productivity of one individual. We would have the following model for population growth:

\[\frac{dN}{dt}=rN\left(1-\frac{N}{K}\right)\](15)
\[\frac{dK}{dt}=\gamma K N\]
In the first equation of (15) we can easily spot our old friend, the Verhulst logistic model. This time however, as the second equation of (15) implies a growing capacity always one step ahead of the population, it doesn't take much to convince ourselves that this model implies a runaway an unbounded population. In fact, it can be shown that prior to the critical time point \(t_c\), this model behaves very much like the hyperbolic model described by equation (12)17. Still, we intuitively know that there must be some physical limits for the earth's population and that human technological innovation cannot push the carrying capacity indefinitely towards infinity. For example, we have already pointed out that since 1962, the relative population growth rate \(1/N\cdot dN/dt\) has started to gradually to decrease. This occurred in the same time as the so-called Green Revolution, which brought about significant increases in food productivity and crop yields18. However, the Green Revolution did not bring about a surge in the relative population growth rate and quite the opposite occurred - the world population's growth seems to be slowing down.

At any rate, there is no reason to suppose that the carrying capacity remains constant throughout human history, and surely, there must be positive and negative influences on the carrying capacity. On the one hand, the idea that each person contributes to the growth in human carrying capacity is not to be discarded entirely. On the other hand, the contribution of each additional person depends on the resources available, and these resources must be shared among more people as the population increases. What is being described here can be summarized in the following population-growth model proposed by Cohen19, which he called the Condorcet-Mill model, after the British philosopher John Stuart Mill (1806-1873) who is cited as foreseeing that a stationary population is both inevitable and desirable.

\[\frac{dN}{dt}=rN\left(1-\frac{N}{K}\right)\](16)
\[\frac{dK}{dt}=\frac{L}{N}\frac{dN}{dt}\]

Introducing the FME package and some comments on the world population data we'll be using

We have finally come to the part of this blog post in which we will try to fit the world population data to the various population growth models covered. The data was obtained fro the ourworldindata.org site20 and cosists of a tabular csv file with two columns, which i have renamed "time" (the year) and "pop" (population). This data covers a wide time-span, from 10,000 BC until 2015 and to be perfectly honest, I cannot vouch for the validity of the population counts in the remote past nor do I have any idea as to how they obtained census data for this time period. I'll just assume that the population data for the pre-historic and ancient time periods is fairly accurate. At any rate, this large time-scale population data allows us to compare the family of models based on logistic population growth to the singular approach by Kapitsa.

For the model fitting process, we will use an R-package called FME (FME stands for Flexible Modelling Environment). FME introduces added functionalities over the simecol package to aid in the process of system dynamics model building:

  • FME's modFit incorporates additional non-linear optimization methods for parameter fitting over simecol's fitOdeModel: "Marq" for the Levenberg-Marquardt algorithm, which is a least squares method, "Pseudo" for the pseudo-random search algorithm, "Newton" for a Newton-type algorithm, and "bobyqua" for a derivative-free optimization using quadratic approximations.
  • Global sensitivity analysis, which consists of assessing the change of certain model output variables according to changes in parameters over a large area of the parameter space, is done in FME via the sensRange function.
  • The sensFunc function in the FME package provides a way to define sensitivity functions in order to perform a Local sensitivity analysis, which consists of studying the effects of one parameter when it varies over a very small neighboring region near its nominal value.
  • The sensitivity functions are also used by FME to estimate the collinearity index of all possible subsets of the parameters. This has to do with the identifiability of the parameters in the model, a concept well worth delving into.
The nonlinear optimization methods used to fit ODE models like the ones I have been dealing with in this series of posts are very different from methods like the ordinary least squares used in linear regression, for example. The ordinary least squares method, on account of being linear on the model parameters, will always come up with a unique estimation of these parameters. The least squares estimation in linear regression is unique because there's only one global minimum in the parameter search space. In the case of nonlinear optimization problems like the ones that we deal with in ODE models, however, the parameter search space is much more complex and there may be many many local minima. This situation substantially complicates ODE model fitting, particularly when the model has several parameters.

When one is fitting ODE models, different initial "guesses" for the parameter values will result in entirely different model parameters and indeed, in an entirely behavior of the model's variables. To determine just how much do small changes in the initial parameter values affect the model's variables is the reason why we perform sensitivity analysis on the models. It may occur that some parameters are linearly or almost linearly dependent on others, and just like in the linear regression case, this multicollinearity negatively affects the identifiability of the model's parameters. In particular, the colinearity index given by the FME collin function gives a measure of the parameter set's identifiability based on the data we use to fit the model.

The collin function provides the collinearity index for all possible subsets of a model's parameters. The larger the collinearity index for any given set of parameters, the less identifiable those parameters are. As a rule of thumb, a parameter set with a collinearity index less than 20 is identifiable21.

Like sands through the hourglass, so are the days of our lives

We now begin the process of fitting various population models to the world population data described above. We will begin with the classic (Verhulst) Logistic growth model with 2 parameters:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
library("simecol")
library("FME")
#Read census data
census <- read.table("world_pop.csv",header=TRUE,sep=",")
#Verhulst logistic growth model
verhulst_model <- new("odeModel",
        main=function(time,init,parms, ...) {
            x <- init
            p <- parms
            dpop <- x["pop"]*p["r"]*(1-(x["pop"]/p["K"]))
            list(dpop)},
        init=c(pop=2431214),
        parms=c(r=1e-02,K=1e10),
        times=seq(from=-10000,to=2015,by=1),
        solver="lsoda")

#cost function
fCost <- function(p) {
    parms(verhulst_model) <- p
    out <- out(sim(verhulst_model))
    return(modCost(out, census, weight="std"))
}

#model fitting
result <- modFit(fCost, parms(verhulst_model),
                 lower=c(r=0,K=2431214),upper=c(r=1,K=1e+12))
(parms(verhulst_model) <- result$par)
cat("SC : ",ssqOdeModel(NULL,verhulst_model,census$time,census[2]),"\n")
#identifiability analysis
sF <- sensFun(func = fCost, parms = parms(verhulst_model))
(colin <- collin(sF))
The model's output - parameter estimations, sum of squares measure of goodness of fit as calculated in line 28 of the above code, and the collinearity index of the parameter set (produced by lines 30-31 of the code) - is given below, along with the plot for the real population curve (in red) and the fitted model (in cyan). I have not included the source code for generating these plots, but could do so if any reader is interested.
           r            K 
6.065198e-04 9.999754e+11 
SC :  92.33517
  r K N collinearity
1 1 1 2          7.9


Let's interpret the results above. First of all, with a collinearity index of 7.9, the model's parameters are identifiable, so that's not an issue. An inspection of the r and K parameters reveal that the Verhulst Logistic growth model predicts a maximum world population of almost \(1\cdot 10^{12}\) or one trillion inhabitants. Considering we're currently only at 8 billion inhabitans, we would have a long way to go before we reach that saturation point. One look at the graph reveals that this model is simply not adequate. The model's curve seems to bulge too much above the real population curve, indicating that this model predicts too much population growth at remote times in the past when we know that the real growth was barely noticeable. All the while, the model predicts a population of 3-4 billion in 2015 when we know the real population level to be over 7.3 bilion this year. So we have two major flaws with this model: 1) it predicts the modern, explosive, population growth to begin much sooner than it really did and 2) in modern times (1800-present), the model's predicted growth is simply not fast enough compared to the real data. These flaws are confirmed by the model's high sum of squares value of 92.34.

One of the limitations of the classic logistic growth model is the inability to "tweak" the inflection point. In this case, with the model's K value estimated at 1 trillion, the inflection point would be half of that, or 500 billion - too far into the future. We know for a fact that the increase in the world population growth rate started to slow down during the 1960's, so what we would need is a logistic growth model in which the inflection point can be closer to the maximum population levels. We will next attempt to fit the generalized logistic growth model, which would, in theory, afford us the flexibility in tweaking with the inflection point.

The problem with the generalized logistic growth model is the large number of parameters (5) with just one differential equation. This results in a very complex parameter space with potential problems in parameter identifiability. To explore this situation, I decided to sample one hundred initial parameter guess values (N=100) using the uniform probability distribution with a given range for each parameter and storing these initial values in a data-frame (see code snippet below), from where I proceeded to use them as initial values for the model fitting procedure.

1
2
3
4
5
parameters <- data.frame(   r=runif(N,min=0,max=0.1),
                          K=runif(N,min=7349472099,max=1e+11),
                          alpha=runif(N,min=0.1,max=1.2),
                          beta=runif(N,min=0.1,max=2),
                          gamma=sample((1:10),size=N,replace=TRUE) )
I must comment on the reason why I sampled only integer values for the gamma (\(\gamma\)) parameter. Taking a look at model equation (7), we see that if the expression within parentheses on the right hand side that's raised to the gamma exponent ever becomes negative, this would raise numerical error issues because we'd be raising a negative base to a fractional exponent. While there are possibly ways around this issue, it was simpler for me to just use integer values for gamma. Now when fitting the generalized logitic model using these 100 different initial parameter sets, I obtained different parameter estimations with different sum of squares goodness of fit values, which I wrote to a csv file with the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
library("simecol")
library("FME")
#Read census data
census <- read.table("world_pop.csv",header=TRUE,sep=",")
#Generalized logistic growth model
generalized_model <- new("odeModel",
        main=function(time,init,parms, ...) {
            x <- init
            p <- parms
            dpop <- x^p["alpha"]*p["r"]*(1-(x/p["K"])^p["beta"])^p["gamma"]
            list(dpop)},
        init=c(pop=2431214),
        parms=c(r=1e-08,K=7349472099,alpha=1,beta=1,gamma=4),
        times=seq(from=-10000.0,to=2015.0,by=1),
        solver="lsoda")

#cost function
fCost <- function(p) {
    parms(generalized_model) <- p
    out <- out(sim(generalized_model))
    return(modCost(out, census, weight="std"))
}
parameters <- read.table("initial_parms.csv",sep="\t",header=TRUE)
parameters <- as.matrix(parameters)
for (i in 1:N) {
  #get initial parameter estimations and fit the model
  parms(generalized_model) <- parameters[i,]
  options(show.error.messages = FALSE)
  try(
    fitted_model <- modFit(fCost, parms(generalized_model) ,
      lower=c(r=0,K=7349472099,alpha=0.1,beta=0.1,gamma=1),
      upper=c(r=0.1,K=1e+11,alpha=1.2,beta=2,gamma=20) )
  )
  options(show.error.messages = TRUE)
  parms(generalized_model) <- fitted_model$par
  r <- as.numeric(fitted_model$par["r"])
  K <- as.numeric(fitted_model$par["K"])
  a <- as.numeric(fitted_model$par["alpha"])
  b <- as.numeric(fitted_model$par["beta"])
  g <- as.numeric(fitted_model$par["gamma"])
  Ninf <- as.numeric((1+b*g/a)^(-1/b)*K)
  output <- out(sim(generalized_model))
  SC <- ssqOdeModel(NULL,generalized_model,census$time,census[2])
  results <- rbind(results,
                      data.frame(   r=r,K=K,alpha=a,beta=b,gamma=g,
                                  Ninf=Ninf,SC=SC) )
  cat(i," ",SC,"\n")
} 
Choosing the parameter set with the least sum-of-squares (SC) value, I ran the simulation of the model and obtained the following graph and the following collinearity indexes:

           r           K   alpha     beta    gamma       N_inf       SC
1.836653e-05 99966063867 1.19538 1.996857 1.009536 60943709007 76.60192

   r K alpha beta gamma N collinearity
1  1 1     0    0     0 2          5.8
2  1 0     1    0     0 2        214.0
3  1 0     0    1     0 2          6.2
4  1 0     0    0     1 2          5.8
5  0 1     1    0     0 2          6.0
6  0 1     0    1     0 2         81.3
7  0 1     0    0     1 2       6442.9
8  0 0     1    1     0 2          6.3
9  0 0     1    0     1 2          5.9
10 0 0     0    1     1 2         81.0
11 1 1     1    0     0 3        403.1
12 1 1     0    1     0 3        131.9
13 1 1     0    0     1 3       9122.3
14 1 0     1    1     0 3        425.7
15 1 0     1    0     1 3        403.4
16 1 0     0    1     1 3        133.0
17 0 1     1    1     0 3        133.7
18 0 1     1    0     1 3       9018.9
19 0 1     0    1     1 3       6751.7
20 0 0     1    1     1 3        134.9
21 1 1     1    1     0 4        608.5
22 1 1     1    0     1 4      14594.6
23 1 1     0    1     1 4      11876.4
24 1 0     1    1     1 4        604.7
25 0 1     1    1     1 4      11704.0
26 1 1     1    1     1 5      14777.0


The fit of the generalized logistic model is slightly better, as can be seen from the sum-of-squares value of 76.6 in comparison to the Verhulst SC of 92.34. The models curve on the graph is bending down slightly closer to the data values. However, the asymptotic population level is still unrealistically high at 1 trillion inhabitants and so is the population at the inflection point (at about 610 billion souls). As in the previous model, the population levels at 2015 are underestimated and the modern-era type growth begins much sooner (according to the model), than it really did. Notice also that the collinearity indexes for any combination of more than 2 parameters indicate that this model was nowhere near adequate on account of poor parameter identifiability.

I then attempted to fit Petzoldt's two-compartment model to see if it would be capable of retarding the modern-era type hyperexponential growth while at the same time not underestimating population levels during the third millenium. The results were the following (code and graphics included):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
petzoldt_model <- new("odeModel",
  main=function(time,init,parms, ...) {
    with(as.list(c(init,parms)), {
      dy1 <- -a * y1                          # "inactive" part of population
      dy2 <-  a * y1 + r * y2 * (1 - y2 / K)  # growing population
      list(c(dy1, dy2), pop = y1 + y2)        # total pop = y1 + y2
    })
  },
  init=c(y1=2431214, y2=0),
  parms=c(r=1e-04,K=7349472099,a = 1e-05),
  times=seq(from=-10000.0,to=2015.0,by=1),
  solver="lsoda")

## cost function
fCost <- function(p) {
  parms(petzoldt_model) <- p
  out <- out(sim(petzoldt_model))
  return(modCost(out, census, weight="std"))
}

## fit model (all parameters)
result <- modFit(fCost, parms(petzoldt_model),
                 lower=c(r=0,K=7349472099,a=0),
                 upper=c(r=1,K=1e+12,a=1),
                 method="Port",
                 control=list(scale=c(r=1,K=1e-12,a=1)) )
                
(parms(petzoldt_model) <- result$par)
cat("SC : ",result$ssr,"\n")
#identifiability analysis
sF <- sensFun(func = fCost, parms = parms(petzoldt_model))
(colin <- collin(sF))
           r            K            a 
6.459584e-04 7.349472e+09 1.685916e-03 

SC :  115.537 

  r K a N collinearity
1 1 1 0 2          6.0
2 1 0 1 2          6.7
3 0 1 1 2          3.6
4 1 1 1 3         12.2
I would like to comment briefly on the code for the two-compartment model. The observed variable is pop, y1 and y2 are not observed variables; they are compartment variables used for the purpose of modeling but have no existence as such (there aren't two species of human beings based on whether they belong to either compartment, on the contrary to the epidemic compartment models, where infected individuals were different from recovered or susceptible individuals, for example). However, their sum y1+y2 is the total population, which is the variable we're really interested in fitting, so we need a way to indicate that in the code. What should be done is to pass this total in the results list along with the differentials, as is done in line 6 in the above code. Note that the pop variable identifier in the list needs to be the same as the pop variable in the census data-frame (observed values).

Regarding the results, the delayed population growth caused by having inactive and active compartments that is the hallmark of this model did not do much to correct the flaws we saw with the previous two models. The sum-of-squares goodness of fit meassure did not improve and the growth is too fast for periods of time in the remote past while being too slow for the modern-era time period. We next attempt to fit the Condorcet-Mill model (code and results below).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#Condorcet-Mill population growth model
cm_model <- new("odeModel",
        main=function(time,init,parms, ...) {
            x <- init
            p <- parms
            dpop <- p["r"]*x["pop"]*(1-x["pop"]/x["K"])
            dK <- p["L"]/x["pop"]*dpop
            list(c(dpop,dK))},
        init=c(pop=2431214,K=2432000),
        parms=c(r=1.4e-03,L=3.7e+09,K0=2432000),
        times=seq(from=-10000.0,to=2015.0,by=1.0),
        solver="lsoda")

#cost function
fCost <- function(p) {
    parms(cm_model) <- p
    init(cm_model) <- c(pop=2431214,K=as.numeric(p["K0"]))
    out <- out(sim(cm_model))
    return(modCost(out, census, weight="none"))
}

#model fitting
result <- modFit(fCost, parms(cm_model),
                 lower=c(r=0,L=0,K0=2431214.1),
                 upper=c(r=1,L=Inf,K0=Inf))
(parms(cm_model) <- result$par)
cat("SC : ",ssqOdeModel(NULL,cm_model,census$time,census[2]),"\n")
#identifiability analysis
sF <- sensFun(func = fCost, parms = parms(cm_model))
(colin <- collin(sF))
           r            L           K0 
6.062496e-04 3.553315e+16 2.431214e+06 

SC :  92.28798 

  r L K0 N collinearity
1 1 1  0 2          1.4
2 1 0  1 2          9.0
3 0 1  1 2          1.5
4 1 1  1 3         11.0


The Condorcet-Mill population growth model has two parameters according to the equations in (16). However, when you try to implement the model in simecol, the question first comes up is : If K is a variable, what is its initial value? The carrying capacity is not an observable variable- it's just a theoretical construct, so we really have no way of knowing what the initial value of K is. Consequently, we should include the initial value of K as a parameter in the model to be estimated with the data at hand. That is the reason why a third parameter K0 is included but does not appear in the ODE model definition. However, if you inspect the model cost function, you'll see that before it runs a simulation of the model with the given parameters, it sets the initial value of K to K0 (this is what line 17 of the code does).

Redgarding the results of this model's fit, it is very similar to those of the other logistic growth variants. We now turn our attention to the Kapitsa model, which is really set apart from the other models thus discussed in that it is originally meant to model the human population growth over a large time scale, such as the one we're dealing with. Here is the code and the results:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#Kapitsa population growth model
kapitsa_model <- new("odeModel",
        main=function(time,init,parms, ...) {
            x <- init
            p <- parms
            dpop <- p["C"]/((p["Tc"]-time)^2 +p["tau"]^2)
            list(dpop)},
        init=c(pop=2431214),
        parms=c(C=1.86e+11,Tc=2007,tau=42),
        times=seq(from=-10000.0,to=2015.0,by=1.0),
        solver="lsoda")

#cost function
fCost <- function(p) {
    parms(kapitsa_model) <- p
    out <- out(sim(kapitsa_model))
    return(modCost(out, census, weight="none"))
}

#model fitting
result <- modFit(fCost, parms(kapitsa_model),
                 lower=c(C=0,Tc=-10000,tau=0),
                 upper=c(C=Inf,Tc=10000,tau=20000),
                 method="Marq")
(parms(kapitsa_model) <- result$par)
cat("SC : ",ssqOdeModel(NULL,kapitsa_model,census$time,census[2]),"\n")
#identifiability analysis
sF <- sensFun(func = fCost, parms = parms(kapitsa_model))
(colin <- collin(sF))
           C           Tc          tau 
1.718330e+11 2.002740e+03 4.271126e+01 

SC :  0.3774335 

  C Tc tau N collinearity
1 1  1   0 2          1.4
2 1  0   1 2          2.7
3 0  1   1 2          2.4
4 1  1   1 3          5.4


It shouldn't be hard to convince yourself that this model fits the data much better than all the previous models. According to the values of the fitted parameters and the function's equation in (14), the predicted asymptotic human population level is \(\pi C/\tau \approx 12.64\,billion\), which is a much more realistic and feasible value than that obtained by the other fitted models. The sum-of-squares is 0.377, which puts the Kapitsa model in the realm of decent fitting models. Also, note that the collinearity index for the three parameters tells us that this model's parameters are identifiable. It is interesting to note that with the data we have at hand, which is surely more than what was available to Kapitsa in the 1990's, we obtained a slightly different estimate for \(T_c\): Kapitsa's was 2007 and ours is roughly 2002. Since \(T_c\) is the time of the inflection point, it is interesting that more census data brought the estimate closer to the 1960-1970 range. My final comment on this model is a caveat: even though this model is by far the best fitting model, it would be hazzardous to mistake model predictions for categorical statements. For example, I cannot categorically state that the maximum human population on earth is 12.64 billion people. Still, this would at least be an informed estimate.

Demographic Transition Theory and some concluding remarks

All of the population growth models thus covered so far attempt to describe in mathematical terms, the human population dynamics in various time scales, but they don't address questions of a more qualitative nature, such as why must population growth slow down after a certain point? Demographic transition theory addresses some of these questions. Demographic transition theory essentially states that societies that go through the process of modernization experience four stages (now possibly five), as laid down by the works of Warren Thompson in 1929 and Frank Notestein in 194522.

The first stage is the pre-modern regime in which there is a high-mortality rate and a high fertility rate in almost mutual equilibrium, resulting in very slow population growth. In the second stage, the mortality rate begins to drop rapidly due to improvements in food supply and health, which cause a longer life span and reduced mortality due to diseases. In the third stage, the fertility rates begin to decline. Notestein elaborates on the reasons for this decline in fertility, attributing it mainly to socio-economic factors. For example, in an industrialized urban society longer periods of formal schooling are required, which bring about longer periods of economic dependency for children and consequently higher costs of raising children. Lower mortality rates, as another example, increased the size of the family and the number of economically dependent people to support, acting as another deterrent to have more births. The fertility rate eventually drops to replacement levels (estimated as 2.1 children per woman) as the society's population reaches an equilibrium level in the fourth stage. In some countries already well into the fourth stage such as Japan, fertility rates continue to drop bellow replacement levels, bringing about a critical economic issue for that nation: an aging population with a dwindling active work-force to support it.

While researching to write this blog post, I became aware of a very interesting (and frightening) phenomenon occurring today in Japan. It is the case of the so-called hikikomori, a sort of post-modern hermit who shuts himself up in his parent's house and shuns the idea of having a spouse, rearing a family and even having sex. As most of you are probably aware, Japan has been in economic recession for twenty years or more. The traditional prospect of getting a job with a large corporation and remaining loyal to it for the rest of your productive life entails an insanely competitive educational sysem with dwindling job oppotunities due to the economic recession and the automation of labor. Consequently, an increasing number of young people in Japan are opting out of this traditional salaryman system, secluding themselves in their parent's house. Then there's also the phenomenon of hervibore men, a term coined by Maki Fukasawa to describe men that are not interested in finding girlfriends, wives or pursuing romantic relationships of any sort. Hervibore men usually see themselves as not bound to the traditional Japanese manliness values and show no aptitude for hurting others or being hurt by others. Like the hikikomori, they are not salarymen and usually work part-time jobs, which allows them to spend more time on things like manicure, visits to the hairdresser, and tending to their poodle dogs but do not permit them to cover costs of housing and much less family rearing. Both of these social phenomenons probably have a significant impact on the dire demographical situation of Japan.

In the old debate between Condorcet and Malthus, it would seem to me that Malthus was wrong about the inconveniency of policies benefiting the poorer sectors of society. The Nobel Prize economist Amartya Sen has referred to Malthus' approach as the "override" approach, where government policies seek to limit or coerce individual freedom in matters such as famility planning (think of the Chinese "One-child per family" policy, for example). The alternative approach, which he calls the "collaborative" approach, relies less on legal or economic restrictions and more on the rational decisions of men and women based on their expanded choices. In this sense, Amartya Sen claims that only more development can effectively alleviate the problem of overpopulation, and that for example public welfare policies such as improving women's education, in particular, can bring about a decline in birth rates:

Central to reducing birth rates,then, is a close connection between women's well-being and their power to make their own decisions and bring about changes in the fertility pattern. Women in many third world countries are deprived by high birth frequency of the freedom to do other things in life, not to mention the medical dangers of repeated pregnancy and high maternal mortality, which are both characteristic of many developing countries. It is thus not surprising that reductions in birth rates have been typically associated with improvement of women's status and their ability to make their voices heard—often the result of expanded opportunities for schooling and political activity.23


Notes

  1. See MALTHUS, p. 9 (Chapter 2).
  2. See the Wikipedia entry on Thomas Malthus.
  3. See QUETELET, p. 276.
  4. This quote pretty much sums up the spirit of nineteenth century positivism: Il est à remarquer que plus les sciences physiques fait de progrès, plus ont elles ont tendu à rentrer dans le domaine des mathématiques, qui est une espèce de centre vers lequel elles viennent converger. On pourrait, même juger du degré de perfection auquel une science et parvenue, par la facilité plus ou moins grande avec laquelle elle se laisse aborder par le calcul. (QUETELET, p. 276). To me, this idea is still in full vigor. With the advent of big data methods, we can expect the social sciences to progress by leaps and bounds.
  5. See QUETELET, p. 277.
  6. See VERHULST, p. 114.
  7. See QUETELET, p. 278.
  8. See the Wikipedia entry on Sigmoid functions.
  9. See VERHULST (1838).
  10. See TSOULARIS, p. 29.
  11. There are other population growth models with this "generalized" denomination, but here we are following the terminology in TSOULARIS (2001), where this five-parameter model is called the generalized population growth model.
  12. The Gomperz model can be derived as a limiting case of the generalized logistic growth function. See TSOULARIS (2001), pp. 34-35.
  13. See PETZOLDT, p. 52.
  14. See PETZOLDT, pp. 52-52.
  15. Cited in GOLOSOVSKY, p. 2.
  16. GOLOSOVSKY, p. 2.
  17. GOLOSOVSKY, pp. 3-4.
  18. Very few people have heard of Norman Borlaug, an American agronomist considered the father of the Green Revolution. Borlaug received the Nobel Peace Prize in 1970 for his work on high-yield varieties of cereals and cultivation methods that is credited with saving billions of people from starvation. This makes Borlaug probably one of the most underrated individuals in history. For an interesting account of this, see Harold Kingsberg's answer to the question "What people in history are underrated?" on Quora (https://www.quora.com/What-people-in-history-are-underrated).
  19. See COHEN, p. 344.
  20. See ORTIZ-OSPINA and ROSNER.
  21. See SOETAERT (2012), p. 15.
  22. See KIRK, p. 361.
  23. See SEN, p. 13.

Bibliography



If you found this post interesting or useful, please share it on Google+, Facebook or Twitter so that others may find it too.

miércoles, 31 de agosto de 2016

Simulation models of epidemics using R and simecol

In this post we'll dip our toes into the waters of epidemological dynamics models, using R and simecol, as we have done in the previous two posts of this series. These models of epidemics are interesting in that they introduce us to a more general class of models called compartment models, commonly used in the study of biological systems. This "compartment point of view" will prove to be an useful tool in modeling, as we shall see in future posts. As usual, after a brief theoretic and mathematical rundown of the various types of epidemic models, we shall fit one of those models to some data using R's simecol package.



Infectious or Epidemic Processes

When studying the spread of infectious diseases, we must take into account the possible states of a host with respect to the disease:
  • Susceptible (S) These are the individuals susceptible to contracting the disease if they're exposed to it.
  • Exposed (E) These individuals have contracted the disease but are not yet infectious, thus still not able to pass the disease unto the susceptible (S) group.
  • Infectious (I) After having been exposed, these individuals are now abel to pass the disease unto other individuals in the S group. This group should not be confused with the infected group of individuals, which are those that are either exposed (E) or infectious (I).
  • Recovered (R) Having gone through the previous phases of the disease, individuals recover because they have developed an immunity to the disease (permanent or temporary). This group is neither susceptible to the disease nor infectious1.
Not all epidemological models will include all four of the above classes or groups, and some models with greater degree of sophistication may include more (Berec, 2010). For example, there may be diseases for which it is useful to consider a group of chronic carriers. Moreover, infected mothers may have been previously infected with a disease and, having developed antibodies, pass these to their newborn infants through the placenta. These newborn infants are temporarily immune to the disease, but later move into the susceptible (S) group after the maternal antibodies disappear. These newborn infants would then constitute a group of passively immune (M) individuals. On the other hand, it is posible that all these groups may not be as homogenous as one may think. Different social, cultural, demographic or geographical factors may affect or be related to the mode of transmission, rate of contact, infectious control, and overall genetic susceptibility and resistance.

Based on the selection or ommision of these classes or compartments, which in itself implies some assumptions about the characteristics of the specific disease we're trying to model, there are several accronyms used to name these models. For example, in an SI model, also known as a simple epidemic model, the host never recovers. An SIS model is one in which the susceptible population becomes infected and then after recovering from the disease and its symptoms, becomes susceptible again. The SIS model implies that the host population never becomes immune to the disease. An SEIR model is one in which there is an incubation period: susceptible individuals first become exposed (but not yet infectious), later enter the infectious group when the disease is incubated, and finally, they enter the R group when they cease to become infectious and develop immunity. An SIR model is basically the same as the SEIR model, but without an incubation period, etc.

Compartment models

We can see from the last paragraph on different epidemic models that these attempt to describe how the individuals in a population leave one group and enter another. This is characteristic of compartment, or "box" models, in which individuals in a population are classified at any given time into different compartments or boxes according to the state in which they find themselves. Compartment models are commonly used to study biological or chemical systems in which the main interest is the transport or change of state of materials or substances over time2.

In the process of dynamic model building, it is often useful to think of the state variables as boxes or compartments that "hold" a certain amount of substance at any given time, even though "substance" or "material" may refer to discrete entities such as individuals. In fact, because system dynamic models are governed by differential equations, modeling discrete entities through quantities that vary continously is inevitable. Notwithstanding, thinking in terms of compartments is useful because it forces us to reflect on the mechanisms that affect how individuals enter or leave a compartment. For example, in the Lanchester model of the Battle of Iwo Jima there were two compartments: American troops and Japanese troops. In that case, individuals would not leave one compartment to enter another, because we were not contemplating soldiers defecting from their original army to fight for the other side. In the epidemic models, however, we do contemplate individuals leaving one compartment and entering another as they progresss through the various stages of the disease. The utility of the "compartment point of view" in modeling lies in the principle that if there are group of entities whose dynamic behavior is different from other groups, even though they are apparently the same type of entity, they should each have their own compartment. We shall explore this idea in more detail when we cover population growth models in a future post in this blog.

SIS models

SIS models of epidemics comprise two compartments: S (susceptible) and I (infected). In what follows we will assume that:

  1. There is a finite population \(N\) that remains constant at all times.
  2. The epidemic cycle is sufficiently short to assume that births, deaths, immigration/emmigration or any other event that modifies the population do not occur.
  3. Individuals transition from being susceptible to the disease, then to being infected, and back again to being susceptible as they recover. The disease is such that no permanent or temporary immunity is developped, and there are no mortalities.
  4. The number of infections of susceptible individuals that occur is proportional to the number of contacts between infected and susceptible individuals.
  5. At each time unit, a certain percentage \(\kappa\) of infected individuals recover from the disease and become susceptible again. This amounts to stating that the mean duration of the infected/infectious period is \(1/\kappa\) time units.
This is a very simple model and some of the above assumptions may be unrealistic or inapplicable to all SIS epidemic processes but nevertheless, it is an useful model for illustrating the emmergent behavior of some systems. These assumptions are usually expressed in the literature in differential equation form as follows:

\[\frac{dS}{dt}=\kappa I - \alpha\gamma S\cdot I\] \[\frac{dI}{dt}=-\kappa I + \alpha\gamma S\cdot I\]
As already mentioned, the parameter \(\kappa\) represents the percentage of infected individuals that recover at each time unit and become susceptible again. Parameter \(\alpha\) represents the percentage of contacts that result in an infection and \(\gamma\) is the rate of contact between infected and susceptible people. Having these two last parameters in a model may render the model impossible to fit using simecol, since there are infinetly many combinations of \(\alpha\) and \(\gamma\) that result in the same value for their product \(\alpha\gamma\)3. Besides, in principle one should strive to have as few parameters as possible in a model - all the more so in this case since the two parameters can be considered as one: \(\beta=\alpha\gamma\), which could be taken to represent the percentage of cases from the overall susceptible and infected populations that effectively result in an infection. So the resulting model is:

\[\frac{dS}{dt}=\kappa I - \beta S\cdot I\] \[\frac{dI}{dt}=-\kappa I + \beta S\cdot I\]
At a glance, one thing becomes apparent in this model: the rate of flow into compartment S is the same as the rate of flow out of compartment I, so that at any two given time instants \(S_{t+a}+I_{t+a}=S_t+I_t\). The total number of individuals that are either in compartment S or in compartment I is invariable, in keeping with one of the assumptions laid down for this model.

Let's try to understand the implications of this assumption intuitively. At one instant, susceptible individuals are becoming infected, but at some later instant, these infected individuals are becoming susceptible again. There is a negative feedback mechanism in place here because each compartment relies on a greater quantity of individuals on the other compartment to grow in numbers. In other words, the lack of susceptible individuals ensures that the population of infected individuals will start to decrease, which can only mean that there will be more susceptible individuals in the future, as the overall population remains constant. Indeed, the SIS model represents a system that works its way towards equilibrium.

And precisely what is this equilibrium? Can we expect the disease to eventually extinguish itself or on the contrary, will everyone become infected? Or will the system perhaps work its way towards a certain fixed amount of infected and susceptible individuals? Answering questions of this type is one of the aims or dynamic system modeling. We usually want to determine the emmergent behavior of the system that results from the mathematical properties hidden deep within the differential equations.

In our case of this simple SIS model of epidemics, we don't have to dig too deep. A simple mathematical procedure will sufice to determine this equilibrium state analitically. In a state of equilibrium, the state variables do not change, so any of the above derivatives can be set to 0:

\[\kappa I - \beta S\cdot I=0\qquad\rightarrow\] \[\kappa (N-S) - \beta S(N-S)=0\qquad\rightarrow\] \[\beta S^2 - (\kappa+\beta N)S+\kappa N=0\]
The last equation is a simple cuadratic equation whose roots are \(S=\kappa/\beta\) and \(S=N\)- these are the equilibrium states for the number of susceptible individuals. If the equilibrium state for the susceptible population S is greater than or equal to N, everyone will eventually become susceptible and no one will be infected \(I=N-N=0\): the disease is extinguished. If on the contrary no one recovers from the infection (\(\kappa=0\)), then everyone will eventually be infected and there will be no susceptibles. Otherwise, \(0\leq\kappa/\beta\leq N\) and the number of steady-state susceptibles will be closer to N for large values of \(\kappa\) (high recovery rates) and low values of \(\beta\) (low rate of effective contagious contacts).

The following R/simecol simulation model, run for three different combinations of the \(\kappa\) and \(\beta\) parameters serve to validate our simple mathematical analysis. Each simulation run starts with \(I=5\) infected individuals and \(S=95\) susceptibles. But regardless of the initial values, we can see that the steady-state susceptible population reaches \(\kappa/\beta\) or \(N\), if \(\kappa/\beta\gt N\) in all simulation runs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
library(simecol)
N <- 100  #total population size
sis <- odeModel(
  main=function(t,y,parms){
    p <- parms
    dS <- p["k"]*y["I"]-p["b"]*y["S"]*y["I"]
    dI <- -p["k"]*y["I"]+p["b"]*y["S"]*y["I"]
    list(c(dS,dI))
  },
  times=c(from=0,to=20,by=0.01),
  init=c(S=N-5,I=5),
  parms=c(k=1,b=0.003),
  solver="lsoda"
)
simsis <- sim(sis)
plot(simsis)

We run the SIS model script using different values for the parameters \(\beta\) (b in the code) and \(\kappa\) (k in the code), to illustrate the steady state behavior of the system. Notice that the plot method in line 16, when called with an odeModel object, produces an individual plot for each state variable.

SIS model simulation run with k=1, b=0.003

SIS model with k=1, b=0.003

SIS model simulation run with k=1, b=0.0125

SIS model with k=1, b=0.0125

SIS model simulation run with k=1, b=0.05

SIS model with k=1, b=0.05

SIR models

The SIR model of disease was first proposed in 1927 by Kermack and McKendrick, hence the alternative denomination of Kermack-McKendrick epidemic model. With this model, researchers sought to answer questions as to why infectious diseases suddenly errupt and expire without leaving everyone infected. In this regard, the Kermack-McKendric model succeeded and was considered one of the early triumphs of mathematical epidemology4.

I should mention in passing that the basic SIR or Kermack-McKendric model asumes a disease transmission rate given by the \(\beta SI\) term, a form called mass-action incidence or density dependent transmission. When the disease transmission rate is \(\beta SI/N\) (\(N\) being the overall population), the disease transmission mechanism implicit in the model is known as standard incidence or frequency dependent transmission.

The use of one or another model of disease transmission between infected hosts and susceptibles and the circumstances under which either one is more appropriate for modeling the onslaught of a disease is a somewhat controversial issue. It has been generally suggested, however, that the mass-action incidence form is more appropriate for air-borne diseases for example, where doubling the population also doubles the rate at which the disease is transmitted. On the other hand, sexually transmitted diseases are best modeled by the frequency dependent transmission form, because the transmission depends on the mean frequency of sexual contacts per person, which is basically unrelated to the size of the susceptible population.

In view of these considerations, we could appropriately model short-lived and mass-action incidence diseases by the SIR model given below:

\[\frac{dS}{dt}=-\beta SI\] \[\frac{dI}{dt}=\beta SI - \kappa I\] \[\frac{dR}{dt}=\kappa I\]
We will apply this (mass-action incidence) SIR model to an epidemic event involving a case of influenza in an English boarding school for boys, as reported by anonymous authors to the British Medical Journal in 19785. This influenza outbreak apparently began by a single infected student in a population of 763 resident boys (including that student), spanning a period of 15 days. The data furnished refers only to the number of bedridden patients each day- these will be taken as the infected population numbers6.

Day 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
I 1 3 8 28 75 221 291 255 235 190 125 70 28 12 5

With this data, we're ready to code the R/simecol script for fitting the SIR model:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
library(simecol)
flu_data <- data.frame(
  time=0:14,
  S=c(762,rep(NA,14)),
  I=c(1,3,8,28,75,221,291,255,235,190,125,70,28,12,5),
  R=c(0,rep(NA,14))
)
flu_weights <- data.frame(
  S=c(1,rep(0,14)),
  I=rep(1,15),
  R=c(1,rep(0,14))
)
sir <- odeModel(
  main=function(t,y,parms) {
    p <- parms
    dS <- -p["b"]*y["S"]*y["I"]
    dI <- p["b"]*y["S"]*y["I"]-p["k"]*y["I"]
    dR <- p["k"]*y["I"]
    list(c(dS,dI,dR))
  },
  times = c(from=0,to=14,by=0.1),
  init=c(S=762,I=1,R=0),
  parms=c(k=0.5,b=0.002),
  solver="lsoda"
)
result_fit <- fitOdeModel(
  sir,
  obstime=flu_data$time,
  yobs=flu_data[2:4],
  fn=ssqOdeModel,
  weights=flu_weights,
  method="PORT",
  lower=c(k=0,b=0))
result_fit
parms(sir) <- result_fit$par
times(sir) <- c(from=0,to=20,by=0.1)
sir <- sim(sir)
matplot(
  x=sir@out,
  main="",
  xlab = "Day",
  ylab = "Population",
  type = "l", lty = c("solid", "solid","solid"), 
  col = c("blue","red","darkgreen"))
points(flu_data$time,flu_data$I,col="red",pch=19)

Influenza outbreak in an English boarding school (1978)

Influenza outbreak in an English boarding school
The results of the simulation of the influenza outbreak indicate that over 20 students remained susceptible and everyone else was infected. Epidemic diseases do not always affect the entire population- whether they do or not depends on the transmission and recovery rates. In fact, looking at the differential equation for the I compartment, we can easily see that the \(dI/dt\) is 0 only when \(I=0\), which is the trivial case when there are no longer infected individuals to infet anyone else and so the epidemic has died out or when \(S=\kappa/\beta\).

This special value \(\kappa/\beta\) is known as the threshold value of the disease because when \(S\) reaches this threshold value, the disease begins to recede (the infected population is decreasing). If at the outset of the epidemic, the susceptible population number is less than the threshold value, the disease will not invade. One can think of this intuitively as the point when the infectious disease "runs out of fuel" because the infected patients are recovering faster than the rate at which the susceptibles are contacting the disease.

If you play around with the value of \(\kappa\), you will see that if you increase this value, there will be less individuals infected and the contrary if you decrease \(\kappa\). This makes sense, as the larger the percentage of the infected population that recovers at each time period, the less the duration of the disease. What this means is that a fatal disease is much more dangerous if it kills slowly and those fatal diseases that kill (remove) their hosts quickly are likely to have a shorter life themselves7.

Notes

  1. There are indeed mortal diseases from which individuals do not recover. Still, recovered and deceased individuals should be dealt with differently in the model (and in real life), since the purpose of the model is to study the ocurrence of these two very different events.
  2. See BLOMHØJ et al.
  3. We hit upon the topic of parameter identifiability, which will be dealt with in a future post.
  4. See BEREC, p. 12.
  5. The data can be found in SULSKY.
  6. See CLARK.
  7. See "SIR Model of Epidemics" (TASSIER, pp. 5-6).

Bibliography



If you found this post interesting or useful, please share it on Google+, Facebook or Twitter so that others may find it too.