39  Lab

In this lab you extend the open-population model from the Epidemic Models with Demography tutorial, varying the demographic rates and the network structure and reading the consequences off the diagnostics. The tutorial used a low, homogeneous mortality rate (0.001) and held the population stable. Here you push on that.

Learning objectives:

Note

A worked solution is in the course repository as mod7-demog-Lab.R. Please work through the lab yourself before you consult it. You will get much more out of the questions if you have already formed your own answer.

39.1 Lab Steps

These steps build directly on the model you fit in the demography tutorial, so keep that R session open. Each step changes just one thing (a rate, or a piece of the network structure) and re-runs, reusing the objects you already created there: nw, formation, target.stats, init, control, and the fitted est1. If you did close the session, the mod7-demog.R script rebuilds the heterogeneous-groups model in a few lines.

NoteStep 1: a growing population

Keep the departure rates at 0.001, but raise the arrival rate to a.rate = 0.0015, so the population grows. Re-run the epidemic simulation.

  • Before you run it: does the d.rate argument in dissolution_coefs need to change? Arrivals and departures are both demographic churn, but only one of them ends an existing partnership.
  • After you run it: plot the population size (num), the edge count (edges), and the mean degree (meandeg). Which of the three tracks the growing population, and which holds flat?
NoteStep 2: disease-specific mortality

Return the arrival rate to 0.001, and set higher departure rates with disease-related mortality: ds.rate = 0.0012 and di.rate = 0.0025. Now the d.rate death correction has to be re-tuned.

  • Start with the simple average of the two departure rates as your first guess for d.rate.
  • Estimate, simulate, and plot the mean degree against its target of 0.5. Adjust d.rate up or down and repeat until the mean degree holds flat.
NoteStep 3: a 2×2 of activity and mixing

The tutorial’s heterogeneous-groups model combined two features: risk group 1 has a higher mean degree (activity heterogeneity, the nodefactor term) and ties form preferentially within risk group (assortative mixing, the nodematch term). To ask whether their effects add up, you need all four combinations of the two features, on and off, not just three. Fit each of these four network models on the same 500-node, two-group network, holding the overall mean degree at 0.5 (edges target 125) throughout:

Model Activity Mixing Formation formula target.stats
Neither homogeneous proportional ~edges 125
Activity only heterogeneous proportional ~edges + nodefactor("risk") c(125, 187.5)
Mixing only homogeneous assortative ~edges + nodematch("risk") c(125, 112.5)
Both heterogeneous assortative ~edges + nodefactor("risk") + nodematch("risk") c(125, 187.5, 112.5)

Leaving a term out is how you turn its feature off: no nodefactor term means both groups share the overall mean degree of 0.5 (homogeneous activity), and no nodematch term means ties mix at random given the activity levels (proportional mixing). The “Both” row is exactly the tutorial’s heterogeneous-groups model. The Feedback tutorial raised this same question, comparing a both-features model against a neither-features model; here you fill in the two intermediate cells that let you actually answer it. Give every model the same dissolution model, epidemic parameters (param), initial conditions (init), and control settings (control) you already built, so the only thing changing across the four runs is the network structure.

Then pick one outcome, measured the same way in all four models, and compare them on it. A simple choice is the overall prevalence, the mean of i.num across simulations, which you can read from as.data.frame(sim, out = "mean"). Record it for each of the four models at the final step, and then again at an earlier step (say step 100), while the epidemic is still climbing. The two time points need not tell the same story.

NoteLab questions
  1. In Step 1, did you change d.rate? The death correction adjusts for the competing risk that a partner departs. Does an arrival remove a partner from any existing edge? As the population grows, which single quantity is the network-size correction holding fixed, the edge count or the mean degree?
  2. In Step 2, the simple average of ds.rate and di.rate was your starting guess. Did it hold the mean degree on 0.5, or did it miss, and in which direction? Why is the simple average not automatically the right value once mortality depends on disease status?
  3. Step 3 gives you four prevalences at each time point: \(P_\text{neither}\), \(P_\text{activity}\), \(P_\text{mixing}\), and \(P_\text{both}\). The effect of activity heterogeneity alone is \(P_\text{activity} - P_\text{neither}\), and the effect of assortative mixing alone is \(P_\text{mixing} - P_\text{neither}\). Which is larger, and does the sign of either one change between your early and final time points? If the two effects were exactly additive, the combined model would land at \(P_\text{neither} + (P_\text{activity} - P_\text{neither}) + (P_\text{mixing} - P_\text{neither})\). Compute the interaction, \(P_\text{both} - P_\text{activity} - P_\text{mixing} + P_\text{neither}\): near zero means the effects add up; a negative value means the combined model has lower prevalence than the two separate effects predict, and a positive value higher. Every one of these answers is specific to the outcome, time point, and scale you chose (a count of prevalence, at a particular step, on the additive scale). A different outcome such as cumulative incidence, or a different scale such as the log of prevalence (a multiplicative comparison), can move the numbers and even the signs, so state those choices whenever you report the result.