In the vaccination game, if all of one's neighbours adopt one strategy, then it is advantageous to adopt the opposite strategy. We therefore always find persistent polymorphisms of vaccinated and unvaccinated individuals for intermediate values of

*c*. plots both the equilibrium frequency of (

*a*) vaccinated and (

*b*) infected individuals for different values of

*c* and

*β* in the well-mixed imitation dynamics. We find qualitative agreement between stochastic simulations and an analytical prediction that uses both the equation for infection risk (

2.1) and an infinite-population approximation of the imitation dynamics (described in the electronic supplementary material).

For weak selection (

*β* = 1 in ), the imitation dynamics approximate the rational equilibrium

*x** given in equation (

2.2). One can understand this observation analytically by noting that the strategy update equation (

2.3) is roughly linear for small

*β*. First-order approximation of the imitation dynamics closely approximates the replicator dynamics [

32–

34], which in this game converge to the unique evolutionarily stable strategy—the Nash equilibrium (see the electronic supplementary material). As vaccination falls with increasing

*c*, the final size of the epidemic grows. Above a high cost threshold

*c*_{H} ≈ 0.893, no one chooses vaccination and the epidemic reaches its maximum size.

Strong selection in the imitation dynamics (represented by *β* = 10 in ) can decrease vaccination uptake below the level predicted by the rational equilibrium. In other words, individuals who carefully attend to peers' health outcomes and reliably copy the behaviour of successful peers will end up attempting to free-ride more than they rationally ‘ought’ to. If, for example, infection is 12 times as costly as vaccination (*c* = 0.08, a reasonable assumption for influenza, see the electronic supplementary material), then strong selection in our model lowers vaccination coverage by 8 percentage points versus weak selection (*a*), which increases the epidemic size from 4 per cent of the population to 15 per cent of the population (*b*). With increasing cost of vaccination, the equilibrium vaccination coverage follows a rotated ‘S’ curve, dropping rapidly (slope ≈−(*β*/2)) from the herd immunity threshold at low values of *c*, reaching a plateau near 1 − (2 ln 2)/*R*_{0} for intermediate values of *c*, and then dropping rapidly to zero as *c* grows large. The threshold *c*_{H} increases with selection strength (*a*).

Results are qualitatively similar for any basic reproduction ratio *R*_{0}> 1 of the infection. Figures S5 and S6 in the electronic supplementary material compare the cases *R*_{0} = 2.5 and *R*_{0} = 6. The higher value increases infection risk, making the population respond with increased vaccination uptake. Increasing *R*_{0} also raises the threshold *c*_{H}.

Restricting interaction to local neighbourhoods partly ameliorates the free-riding problem, but introduces greater sensitivity to the cost parameter *c* (). We consider a population of individuals arranged on a square lattice where each individual has four immediately adjacent neighbours. While the vaccination coverage in well-mixed populations drops from herd immunity levels as soon as *c* increases above zero, restricted spatial interaction promotes near-universal coverage at a range of positive *c*, preventing the epidemic. To give a simple operational definition, we say that vaccination ‘prevents the epidemic’ in a structured population if the average final epidemic size is less than twice the size of the initial inoculum. Define as *c*_{L} the critical vaccination cost below which the epidemic is prevented. For weak selection on the lattice (*β* = 1 in ), we get *c*_{L} ≈ 0.022. Above this threshold, the vaccination level drops precipitously, causing an epidemic that is even larger than in the well-mixed case.

At higher selection strength, the threshold *c*_{L} is lower, and vaccination coverage is even more sensitive to costs rising above *c*_{L} (*a*). The high-cost threshold *c*_{H} rises with selection strength, meaning that the transitional region between *c*_{L} and *c*_{H}, where vaccinated and unvaccinated individuals coexist, widens with larger *β*. Holding *c* constant at a value above *c*_{L}, increasing the strength of selection leads to more free-riding attempts, breaking apart clusters of vaccinators, thus allowing a larger epidemic to occur (*c* versus *d*).

Most actual populations are heterogeneous in the sense that different individuals may have different numbers of neighbours (i.e. degree; [

31]). To account for this feature, we consider vaccination dynamics on Erdős–Rényi random graphs, which have moderate degree heterogeneity; on scale-free networks, which have an even more variable degree distribution, our results are similar (see the electronic supplementary material).

Higher vaccination coverage is typically required to achieve herd immunity in populations with greater degree heterogeneity ([

35]; see also figures S2–S4 in the electronic supplementary material). This increased vulnerability to epidemic attacks reduces the temptation to free-ride, actually making it easier for a population of selfish imitators to achieve the high-vaccination threshold required for herd immunity. The threshold cost

*c*_{L} therefore increases versus the lattice case. Vaccination coverage drops after cost exceeds this threshold, although the effect is not quite as extreme as in lattice populations (

*a*,

*b*). Similarly to lattice populations, increased selection strength increases the size of the intermediate region between

*c*_{L} and

*c*_{H}.

Degree heterogeneity triggers a broad spectrum of individual vaccinating behaviour. Specifically, an individual's vaccination strategy is now influenced by her role in the population, and ‘hubs’ who have many neighbours are most likely to choose to be vaccinated, as they are at greatest risk of infection (*c*,*d*). Hubs that do manage to free-ride successfully become victims of their own success, as their vaccinated neighbours of smaller degree are likely to imitate them and switch strategies, potentially infecting the hubs in the following season.