How can we use the knowledge we gained by simulating under different parameter values to estimate parameter values from real data?
Sometimes the question is simply: “If the world worked this way, what would happen?”
In this course, we want to fit models. To do so, we need to know about the relationship between the parameters and observable aspects of the data.
For instance, we need to know things like:
For simple models, it is possible to do out the math to find the answers to these questions.
In more complicated models, the only way to find out is to look at simulations across a range of parameter values.
Overall idea: have a population of individuals, they start out susceptible, potentially become infected, and then recover.
\[ S \longrightarrow I \longrightarrow R \]
\[ \beta = \text{transmission parameter}, \qquad \gamma = \text{recovery parameter}, \qquad R_0 = \frac{\beta}{\gamma} \]
\(R_0\): roughly, how many new infections one infectious person generates while population immunity is still negligible (not immediately obvious from the framing of the model).
Discrete time steps, two binomial draws per step:
\[ \Delta I_t \mid S_t, I_t \sim \operatorname{Binomial}\!\Big(S_t, 1-(1-\beta/N)^{I_t}\Big), \qquad \Delta R_t \mid I_t \sim \operatorname{Binomial}(I_t, \gamma). \]
\(\Delta I_t\) people move from S to I; \(\Delta R_t\) people move from I to R:
\[ S_{t+1} = S_t - \Delta I_t, \qquad I_{t+1} = I_t + \Delta I_t - \Delta R_t, \qquad R_{t+1} = R_t + \Delta R_t. \]
What actually happens inside simulate_sir, one time step
at a time:
R
Two different \((\beta, \gamma)\) pairs.
The shape of the trajectory clearly changes as the parameters change.
However: variability from run to run with the same parameters makes it difficult to investigate systematically over different parameter values.
Therefore: generally take some summary statistics that initial investigation suggests might be informative and look at how they vary with the parameters in a more systematic way.
Based on initial plots, we might use:
To make things simpler, we will fix \(\gamma\) (a story would be that it is known from clinical data on infectious duration).
We will try to investigate the behavior of the model as a function of \(R_0 = \beta / \gamma\).
We will:
Yes — centers move strongly, and distributions overlap relatively little. Early growth rate is a useful summary.
We have good evidence that our summaries distinguish different values of \(R_0\). Let’s use that.
Forward: choose a parameter, simulate, summarize. Inference reverses the question — we observe the summary and ask what parameter could have produced it.
\[ \theta \xrightarrow{\ \text{simulate}\ } Y \xrightarrow{\ s(\cdot)\ } s(Y) \qquad\qquad s(Y_{\text{obs}}) \xrightarrow{\ \text{estimate}\ } \theta \]
For SIR:
\[ R_0 \xrightarrow{\ \text{simulate}\ } \text{epidemic} \xrightarrow{\ s(\cdot)\ } \text{early-growth statistic} \qquad\qquad \text{observed early-growth statistic} \xrightarrow{\ \text{estimate}\ } R_0 \]
Choose a set \(\Theta\) of possible parameter values. For each \(\theta \in \Theta\):
Choose the value that is closest to the observed summary.
We need to pin this down precisely enough to implement.
The standard way to formalize this idea is Simulated Method of Moments (SMM):
\[ \hat\theta = \arg\min_\theta \; g(\theta)^\top W \, g(\theta), \qquad g(\theta) = s(Y_{\text{obs}}) - \overline{s(Y_\theta)}, \qquad \overline{s(Y_\theta)} = \frac1B\sum_{b=1}^B s(Y_\theta^{(b)}) \]
Note that for a single summary, \(W\) is a \(1 \times 1\) matrix (a single scalar) and the result doesn’t depend on the value it takes.
We’ll build these up one at a time, starting with the simplest case: one parameter, one summary.
With a single summary, \(g(\theta)\) and \(W\) are both scalars, and \(W\) drops out entirely:
\[ Q(\theta) = \big[s(Y_{\text{obs}}) - \overline{s(Y_\theta)}\big]^2, \qquad \hat\theta = \arg\min_\theta Q(\theta) \]
The algorithm is therefore: Pick the parameter whose simulations reproduce the observed summary most closely.
\(Q(R_0)\), across a grid of candidate \(R_0\)’s:
In the SIR example, we had two summaries: \[ s(Y) = \begin{pmatrix} s_1(Y) \\ s_2(Y) \end{pmatrix} = \begin{pmatrix} \text{growth rate} \\ \text{final size} \end{pmatrix}, \qquad g(\theta) = s(Y_{\text{obs}}) - \overline{s(Y_\theta)} \]
\(g(\theta)\) is now a vector.
SMM says that we should use \(W = \hat\Omega^{-1}\), where \(\hat \Omega\) is an estimate of \(\operatorname{Cov}(g(\theta_0))\).
Many problems here!
If our “estimate” of the covariance of the summary statistics is that they are independent and each have variance 1, that corresponds to \(W = I\).
Plugging that into the SMM objective function gives
\[ Q(\theta) = g_1(\theta)^2 + g_2(\theta)^2 \]
Why might this cause a problem?
The problem traces back to scale. Final size ranges over hundreds; growth rate ranges over tenths. A discrepancy of 10 is:
Treating both raw discrepancies as equally important — as \(W=I\) does — silently lets the noisier, larger-scale summary dominate.
For independent summaries, the fix is to divide each by its own variance:
\[ Q(\theta) = \frac{g_1(\theta)^2}{\sigma_1^2} + \frac{g_2(\theta)^2}{\sigma_2^2} \]
Estimating the covariance \(\hat\Omega\) is exactly how we do this in general, and how we account for the summaries not being independent.
Repeated-estimation results, SIR example (true \(R_0=6\), where growth rate is the good summary and final size is much weaker):
| RMSE of \(\hat R_0\) | |
|---|---|
| Growth rate alone | \(\approx 0.45\)–\(0.48\) |
| Final size alone | \(\approx 0.75\)–\(0.89\) |
| Unweighted (both) | \(\approx 0.75\)–\(0.89\) |
\(W=I\) looked natural, but it is not generally a good idea: combining the two summaries naively bought us nothing — it just looks like the weaker summary.
Here we cheat and use a covariance estimate based on the true R_0.
There are more sophisticated ways of estimating that don’t rely on knowing the truth.
| RMSE of \(\hat R_0\) | |
|---|---|
| Growth rate alone | \(\approx 0.45\)–\(0.48\) |
| Final size alone | \(\approx 0.75\)–\(0.89\) |
| Unweighted (both) | \(\approx 0.75\)–\(0.89\) |
| Weighted (\(\hat\Omega^{-1}\), both) | \(\approx 0.38\)–\(0.43\) — beats even the best single summary |
A weak/noisy summary can hurt if combined carelessly; weighting keeps it from having inappropriate influence — and here, legitimately combining two pieces of information beats using either alone.
Setting \(W = \operatorname{Cov}(g(\theta_0))^{-1}\) isn’t just a good heuristic we happened to verify empirically today.
Under standard conditions, it is the choice of \(W\) that minimizes the estimator’s variance among all valid weighting matrices — a classical result from generalized method of moments theory.
The derivation is beyond today’s scope. The takeaway: “weight by the inverse covariance” is the textbook default because it is provably the best you can do with these summaries, not an arbitrary convention.
\[ \boxed{ \theta \to \text{simulate many datasets} \to \text{calculate summaries} \to \text{estimate expected summaries} } \]
\[ \boxed{ \text{choose } \theta \text{ so simulated summaries resemble observed summaries} } \]
SMM turns a forward simulator into a parameter-estimation method.