I'm using the standard infection model on some data I am working with.

$ dS = -\beta SI $

$ dI = \beta SI - \gamma I $

$ dR = \gamma I $

Where $S$ is the number of susceptible subjects, $I$ is the infected, and $R$ is the recovered. I'm trying various methods for estimating the parameters $\beta$ and $\gamma$.

For any given discrete, fixed-width time period, I know the number of infected and the total population, which is fixed. One of the methods I have used to estimate the parameters is to feed the initial state into a differential equation solver in R and loop through several values for $\beta$ and $\gamma$ until they minimized the Mean Square Error.

To be thorough, I would like to do this using a least squares regression estimate of the parameters as well. Given that I know $I$, I can easily calculate $dI$ for each time period. However, I'm having trouble getting $S$ from my information.

One of my attempts assumed that all the infected from time $t-1$ moved to $R$ at time $t$ and that all infected at time $t$ had come from $S$. Therefore, $S$ was simply reduced by the number of infected each time period. I understood going into it that this was a risky assumption and the results were quite disappointing.

Any tips you have on how to find $S$ at each time period are greatly appreciated.

To be more clear, my goal is to do a regression on the equation

$$ dI = \beta (SI) + \gamma (-I) $$

to get the least squares estimates for $\beta$ and $\gamma$.

  • $\begingroup$ By the way, I wanted a tag such as "sir-model", "compartmental-model", "infection-model", or "epidemic-model", but don't have the reputation to create it. If one of you more reputable contributors could add whichever of those you think is best, that would be great. $\endgroup$ Sep 25, 2015 at 20:29
  • $\begingroup$ I know that stats.stackexchange.com/questions/174220/… is a similar question, so let me know if you think I should merge them into one question. $\endgroup$ Sep 25, 2015 at 21:18
  • $\begingroup$ I think you should merge them -- they are the same question, essentially. $\endgroup$
    – atiretoo
    Sep 25, 2015 at 21:32
  • $\begingroup$ They are two different methods that just happen to come from the same data, so I'm not so sure. Especially considering I'm assuming it will be difficult for anyone to answer both portions of the question (the least squares estimate and the maximum likelihood estimate), so I would prefer to keep them separate. Of course, if I get enough similar feedback I'll do it. $\endgroup$ Sep 25, 2015 at 21:36
  • 2
    $\begingroup$ There is some relevant discussion in the comments (but no answer) here: stats.stackexchange.com/q/130254/12258. The only way they differ is in possible assumptions for the error distribution; LS is essentially assuming a normal error distribution with a pure observation error model. ML is more flexible, including allowing for process error in addition to observation error. Is this experimental data, so that you have no error in the counts? $\endgroup$
    – atiretoo
    Sep 25, 2015 at 21:45

2 Answers 2


Based on your description, other appropriate forms for your model would include nonlinear growth or diffusion models. These are models like those used in the analysis of new products, tech innovations, movie ticket sales as well as the spread of diseases and contagions. The underlying process can range from simple, sigmoid-shaped Gompertz curves and loglets based on Fisher-Pry transformations to sophisticated Bose-Einstein processes. Good discussions of these issues can be found here:



Also and specifically with respect to the statistical issues and challenges involved in maximum likelihood estimation of the unknown parameters, Jack Weiss' Lecture Notes at UNC are an invaluable resource. He includes plenty of references to R modules as well:


  • 1
    $\begingroup$ Note: all of Jack Weiss's excellent lectures and class exercises/notes are linked in this post $\endgroup$ Jun 5, 2018 at 6:07

Since it was, as I feared, impossible to calculated $S_t$ directly, I will post my "best" solution to the problem.

Using my initial method of looping through values for $\beta$ and $\gamma$, I came upon an estimate that minimized the Mean Square Error (MSE) with respect to $I_t$. Using these estimates for $\beta$ and $\gamma$ and the model in the question, I as able to estimate $S_t$ for any $t$.

Now that we have $S_t$ for all $t$, we can perform regression on

$$I_{t+1}-I_t=\beta(S_tI_t)+\gamma(-I_t)$$ $$\text{or}$$ $$I_{t+1}=\beta(S_tI_t)+(1-\gamma)I_t.$$

The big difference here is that this is minimizing the MSE with respect to the difference $I_{t+1}-I_t$ instead of $I_t$ as in the first method. I should note that this did not result in a "better" model, but it allowed me to introduce some measure of the error in the estimates.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.