Strong influence of behavioral dynamics on the ability of testing and treating HIV to stop transmission

Choosing between strategies to control HIV transmission with antivirals requires understanding both the dynamics affecting those strategies' effectiveness and what causes those dynamics. Alternating episodes of high and low contact rates (episodic risk) interact with increased transmission probabilities during early infection to strongly influence HIV transmission dynamics. To elucidate the mechanics of this interaction and how these alter the effectiveness of universal test and treat (UT8T) strategies, we formulated a model of UT8T effects. Analysis of this model shows how and why changing the dynamics of episodic risk changes the fraction of early transmissions (FET) and the basic reproduction number (R0) and consequently causes UT8T to vary from easily eliminating transmission to having little effect. As the length of risk episodes varies from days to lifetimes, FET first increases, then falls. Endemic prevalence varies similarly. R0, in contrast, increases monotonically and is the major determinant of UT8T effects. At some levels of episodic risk, FET can be high, but eradication is easy because R0 is low. At others FET is lower, but a high R0 makes eradication impossible and control ineffective. Thus changes in individual risk over time must be measured and analyzed to plan effective control strategies with antivirals.

T he ultimate goal of Treatment as Prevention (TasP), the complete elimination of HIV transmission, will be achieved if the number of transmissions made by a ''typical'' infected individual over the course of his infection can be reduced to less than one 1 . There are three major factors that affect how difficult it is to achieve this goal through Universal Test and Treat (UT&T): (1) The series of steps that must be traversed from diagnosis to viral suppression (the treatment cascade), (2) the fraction of transmissions that occur early in the transmitter's infected period (which is determined by both biological and social factors), and (3) the basic reproduction number of the virus within the population of interest (which is also affected by both biological and social factors). The basic reproduction number (R 0 ) and the fraction of early transmissions relate to two dimensions of difficulty in achieving elimination through UT&T: The basic reproduction number is closely related to the fraction of transmissions that must be prevented through diagnosis and treatment in order to achieve elimination (which is 1{ 1 R 0 ), and early transmissions are more difficult to prevent with UT&T than later ones. The importance of the treatment cascade and the fraction of transmissions from early infection have been extensively discussed, but the importance of the basic reproduction number (R 0 ), although touched on in some articles 2,3 , has received significantly less attention. We show that behavioral dynamics can result in a wide range of R 0 s even at a fixed endemic prevalence and a fixed fraction of transmissions from early infection. These variable R 0 s, in turn, cause elimination through UT&T to range from easy to realistically impossible. In particular, we explore conditions where, even though a relatively high fraction of transmissions come from early HIV infection (EHI), transmission can still be stopped with a relatively low effective treatment rate, because only a small fraction of transmissions must be interrupted in order to get the system below the endemic threshold of R 0 5 1. This accords with and extends existing modeling work that found that the relative transmissibility during EHI has little effect on the expected reduction in incidence thirty years after the initiation of an antiretroviral therapy (ART) intervention 4,5 .
In this paper we seek to make the complex phenomena behind these relationships more understandable, so they can better inform policy decisions. This paper seeks to generate qualitative understandings that will ultimately advance quantitative assessments. Toward this end, we use deterministic compartmental models (DCMs) to model population dynamics. Such models do not account for stochastic features of real-world population dynamics, but they allow for a simpler analysis. Although a DCM does not directly model individuals, it can be understood as the limiting case of an individual-based model of an arbitrarily large population, and flows between compartments can therefore be conceptualized in terms of changes in the states of (large numbers of) individuals. We will make frequent use of this abstraction throughout this paper.
We make our points by examining and explaining the behavior of a model for HIV transmission among men who have sex with men (MSM) closely based on the model developed by Zhang et al. 6 This model greatly simplifies the treatment cascade and the natural history of infection, while at the same time adding details about temporal patterns of behavior that other models often omit. In order to focus on the effects of these dynamics, we simplify the natural history of infection to a relatively brief early phase (early HIV infection, EHI) followed by a longer chronic phase. In 14.4 of the Supplementary Results, we show that our qualitative results continue to hold if this simplified natural history is replaced with a more realistic one, based on results from a study of HIV transmission in Lilongwe, Malawi 7 .
Similarly, we collapse the treatment cascade into a single parameter measuring the rate at which infected individuals are tested, treated, and rendered permanently non-transmitting, which we refer to as the effective treatment rate. Each individual is therefore classified as effectively treated or untreated. The untreated category includes undiagnosed; diagnosed, but untreated; and treated, but not virally suppressed individuals. In addition, all sexual partnerships are treated as instantaneous symmetrical contacts. Although all of these simplifications will affect some of the quantitative results that we obtain, we do not believe that any of them affect our qualitative conclusions. For more details about the model used, see 13.1 of the Supplementary Methods.
The purpose of these simplifications is to highlight the effect that different patterns of contact rates over time can have on the response of transmission systems to universal test-and-treat interventions, even when other aspects of those systems are identical. Our takehome message is that populations can differ with regard to patterns of contact rates in ways that drastically affect the effort required to achieve elimination of ongoing transmission through UT&T. We illustrate this with a simplified model of HIV transmission among MSM that is designed to highlight certain aspects of behavioral complexity. From this model we gain insights that suggest other aspects of real-world transmission systems that could generate similar effects.

Results
Characteristics of interest. The primary characteristics of sexual contact patterns that we examine in this paper are risk heterogeneity and episodic risk. Risk in our model is only determined by contact rates, which are in turn determined by which of two risk groups an individual belongs to. Our key results still hold with more than two risk groups, but for the sake of simplicity, we focus on a model with only two, which we will refer to as the higher risk group and the lower risk group.
In models where individuals always remain in the same risk group, we say there is static risk heterogeneity. In models where individuals transition between risk groups, we say there is episodic risk.
We model episodic risk by selecting risk groups for individuals newly entering the sexually active population, and then reselecting their risk groups at intervals corresponding to a fixed rate of reselection (v). The probability of being selected to the higher or the lower risk group is always the same. Consequently, the fraction of the population that is in the higher risk group at the disease-free equilibrium is unaffected by whether there is static risk heterogeneity or episodic risk. The average length of an individual's stay in a risk group is therefore determined by both the re-selection rate and the probability of being assigned to that risk group at each point when they are re-randomized to risk groups. Thus, for example, if the probability of being assigned to the high risk group were 0.2, the average stay in the lower risk group would be four times the average stay in the higher risk group if no one left the sexually active population.
Note that this parameterization of the episodic risk formulation is the major way that this episodic risk model differs from the model in Zhang et al. 6 Instead of rates of transitioning between risk groups, we have this single re-selection rate parameter. This parameterization is chosen because it simplifies the mathematical analysis of the system and makes the origin of episodic risk effects clearer. It is not a causal model of what generates episodic risk, but an abstraction that allows us to make important qualitative observations. We parameterize differential transmissibility over the course of infection with a parameter (f) that gives the ratio of per-act transmissibility during early HIV infection (EHI) to per-act transmissibility during later/chronic infection. We will refer to this ratio as the relative transmissibility during EHI.
We focus most of our attention in this paper on these two parameters (v and f) in order to highlight the interaction of biological and behavioral factors in determining the difficulty of achieving elimination through UT&T, with a particular focus on an aspect of sexual behavior (episodic risk) that has received relatively little attention.
Homogeneous transmission potentials and episodic risk. To develop theory in a progressive fashion, we begin by considering a behaviorally homogeneous population, and we examine how the basic reproduction number changes when we add first static risk heterogeneity, and then episodic risk. In order to achieve maximum clarity, we first do this with a single-stage SI model, and then show how the results extend naturally to models with multiple stages of disease progression (such as the one used in this paper).
When the population is behaviorally homogeneous, and there is only one stage of infection, the basic reproduction number is simply the product of the (average) contact rate (x), the per-contact transmissibility (b), and the average duration of infection (D). We will refer to this basic reproduction number, calculated under conditions of behavioral homogeneity, as the (total) homogeneous transmission potential, and denote it by H: This behavioral homogeneity will be achieved if the ''higher'' and ''lower'' risk groups actually have the same contact rate (x) and there is only one transmission probability (b) over the entire duration of infection (D). We elaborate this model by introducing static risk heterogeneity, i. e. by allowing the two risk groups to have different contact rates, but requiring that the re-selection rate be 0, so that individuals stay in the same risk group for their entire sexually active lives. We assume here that risk groups mix proportionately 8 , except where otherwise noted. In 13.6 of the Supplementary Methods, we analyze a model of assortative mixing between risk groups and show that our major qualitative results still hold. Given static risk heterogeneity, the basic reproduction number increases in proportion to the square of the coefficient of variation of contact rates (equation adapted from May and Anderson 9 ): This occurs because members of the higher risk group will have both an elevated propensity to become infected and (once infected) an elevated propensity to transmit. This equation depends on the average contact rate (which determines H) and on the coefficient of variation of contact rates, but not on other features of the distribution of contact rates. Consequently, it still holds if the model is extended to have more than two risk groups, or to have a continuous distribution of contact rates.
We now further elaborate the model by introducing episodic risk, i.e. by allowing the re-selection rate to be greater than 0. In this formulation, an individual who is in the higher risk group at the time of infection will now have an elevated propensity to transmit only until their risk group is re-selected. Because the (multiplicative) increase to the basic reproduction number is a result of the same individuals who have an elevated propensity to become infected also having an elevated propensity to transmit, it will therefore only be applied to that fraction of the homogeneous transmission potential which represents transmissions occurring before we re-select the contact rate of the transmitter. This is simply the fraction of time infected that is, on average, spent prior to our re-selection of the infected individual's contact rate. We denote that fraction (which we call the (overall) fraction of heterogeneity effect) by y. This leads to the following generalization of equation 2: Now we go back to the situation without risk heterogeneity and examine the situation with multiple stages of infection, each with its own per-contact transmission rate. In this case the total homogeneous transmission potential (and therefore the basic reproduction number) will be the sum of the homogeneous transmission potentials from each stage (H i ): Note that in this case D i is the average duration of stage i for all infected individuals, including (for later stages) those who do not survive long enough to enter stage i (i.e., it incorporates the probability of not reaching stage i at all). Although the focus of this paper is on a model with only two stages of infection (and therefore the above summation is from i 5 1 to i 5 2), equation (4) does not depend on that fact, nor do any of the subsequent equations in this section. Consequently, they will still hold if a model with a more realistic natural history of infection is used, as is the case in 14.4 of the Supplementary Results. Given static risk heterogeneity, the contributions of each stage of infection to the basic reproduction number will be increased by the same multiplicative factor (relative to behavioral homogeneity), and so equation (2) still applies. But when we introduce episodic risk, this will no longer be the case: Because the stages of infection come in order, one after the other, the average fraction of an infected individual's time spent in the i-th stage of infection that occurs before his contact rate is re-selected (the fraction of heterogeneity effect for stage i, which we will denote y i ) will be smaller for larger i. In particular, the fraction of heterogeneity effect for chronic infection (y 2 ) will always be less than the fraction of heterogeneity effect for EHI (y 1 ). Therefore, the basic reproduction number will now be: Equation (3) still applies; however, the overall fraction of heterogeneity effect (y) is no longer simply the fraction of an individual's time infected that occurs prior to the re-selection of his contact rate, because one month of chronic infection and one month of EHI do not contribute equally to the total homogeneous transmission potential (H). Consequently, the overall fraction of heterogeneity effect is now a weighted average of the fractions of heterogeneity effect for each stage: Combining equation (6) with equation (3), we obtain two major implications: First, the more episodic that risk heterogeneity is (i.e. the higher the re-selection rate), the smaller y will be, and therefore the lower R 0 will be. Second, because the fraction of heterogeneity effect during EHI (y 1 ) will always be greater than the fraction of heterogeneity effect during chronic infection (y 2 ), episodic risk reduces transmissions from EHI less than it reduces transmissions from chronic infection. Consequently, episodic risk raises the fraction of transmissions from early infection while it lowers the basic reproduction number.
The above analysis relates to the potential for transmissions during exponential growth. Under these conditions, when the prevalence of infection is negligible in both risk groups, episodic risk has a strictly negative effect on transmissions. The effects of episodic risk on transmissions when the prevalence is not negligible (such as at the endemic equilibrium), are more complex, as seen in the next section.
Endemic prevalence and the basic reproduction number as functions of the relative transmissibility during EHI and the reselection rate. In Figure 1, we illustrate the effects of the relative transmissibility during EHI (f) and the re-selection rate (v) on the basic reproduction number (R 0 ) and the endemic prevalence (P), while fixing the total transmission potential across the course of infection, and keeping most other parameters the same (full details in 13.4 of the Supplementary Methods).
In Figure 1, both the basic reproduction number (R 0 ) and the endemic prevalence (P) are monotonically increasing with respect to the relative transmissibility during EHI, even though the overall transmission potential is fixed. This is a consequence of the fact, noted above, that episodic risk reduces the boost in transmissions caused by risk heterogeneity less for transmissions during EHI than for transmissions during chronic infection. Consequently, if the total transmission potential is fixed, increasing transmissions from EHI at the expense of transmissions from chronic infection results in an increase in transmissions, leading to an increase in both R 0 and P.
Unlike the relative transmissibility during EHI, the re-selection rate has a drastically different effect on the basic reproduction number and the endemic prevalence. As noted in the previous section, the basic reproduction number is monotonically decreasing with respect to the re-selection rate, because re-selection attenuates the increase in the average contact rate of infected individuals that results from risk heterogeneity. In contrast, the endemic prevalence has a non-monotonic dependence on the re-selection rate, peaking at a relatively high value of the latter. This is a product of the combined effects of the attenuation of the average contact rate of infected individuals (which works to reduce the endemic prevalence, just as it does the basic reproduction number) and the increased replenishment of higher risk susceptibles, which works to increase the endemic prevalence 6 . That episodic risk can increase endemic prevalence relative to the basic reproduction number at a given observed degree of (instantaneous) risk heterogeneity may explain the difficulty that modelers have experienced in reconciling estimates of the coefficient of variation in contact rate and the basic reproduction number with observed prevalence of HIV infection among MSM 10 .
System determinants of key epidemiological measures. We now introduce a third outcome of interest: the effective treatment rate required to achieve elimination (t E ). As noted in the introduction, we collapse the treatment cascade into a single parameter, which we refer to as the effective treatment rate and denote t. We then define the effective treatment rate required to achieve elimination (t E ) as the minimum value of the effective treatment rate (t) at which elimination is (deterministically) achieved, i.e. the minimum value that reduces the basic reproduction number (R 0 ) to or below the endemic threshold of R 0 5 1. In practice, achieving elimination in a reasonable timeframe may require that R 0 be brought significantly below 1. Consequently, if this model or one like it were to be used to set goals for a particular UT&T campaign, it would likely be desirable to target a lower basic reproduction number. Rather than fixing realistic targets, here we merely seek to provide qualitative insights. In Figure 2, we consider the effects on the basic reproduction number (R 0 ), fraction of transmissions from early infection (w), and effective treatment rate required to achieve elimination (t E ) of the same parameters examined in Figure 1, the relative transmissibility during early infection (f) and the re-selection rate (v). In this case, however, instead of fixing the total transmission potential over the course of infection, we fix the endemic prevalence, at 0.2. We vary the total transmission potential (by varying b 1 and b 2 , proportionally) in order to achieve this fixed endemic prevalence. This provides the common perspective in risk factor and prevention effects for HIV infection, where the prevalence is known, but what is determining that prevalence is unknown.
An important aspect of these relationships is that both factors have strong effects on the effective treatment rate required to achieve elimination as shown in panel (a) of Figure 2. Increasing the re-selection rate from 0.1 per year (relatively static risk groups) to 10.0 per year (strongly episodic risk) while holding the relative transmissibility during early infection constant at 9 results in a reduction of the required effective treatment rate from 1.47 to 0.101. This is over a 14-fold difference, without any change in the biological parameters, nor in any behavioral parameters that could be readily measured cross-sectionally. Likewise, reducing the relative transmissibility during early infection from 9 to 1 (while holding the re-selection rate constant at 0.1) results in a reduction of the necessary effective treatment rate to 0.442over a three-fold difference.
To understand what is generating these effects, it is useful to understand how the effective treatment rate required to achieve elimination (t E ) is affected by changes in the basic reproduction number (R 0 , shown as the outcome in panel (b) of Figure 2) and the fraction of transmissions from early infection (w, shown as the outcome in panel (c) of Figure 2). As can be seen in Figure 2, the effect on t E of the parameters v (the re-selection rate) and f (the relative transmissibility during EHI) is essentially a combination of their effects on R 0 and w. This combination of effects is attributable to the fact that, as mentioned in the introduction, R 0 and w each represent a different aspect of difficulty in eliminating transmissions through UT&T: The higher R 0 is, the larger the fraction   of transmissions that must be prevented, and the higher w is, the less effective UT&T is at preventing transmissions. A more detailed consideration of how R 0 and w affect t E can be found in 14.1 of the Supplementary Results.
In panel (c) of Figure 2, we can see that the fraction of transmissions from EHI (w) is, unsurprisingly, strongly positively dependent on the relative transmissibility during EHI (f). What is more striking is the strong, but non-monotonic, dependence on the rate of risk-group re-selection (v), peaking when v < 1/year. The explanation for this phenomenon is that the fraction of transmissions from EHI is maximized when the difference in average contact rates between EHI and chronic infection is maximized, and this happens at a moderate re-selection rate: At very low re-selection rates, there is little difference, because the vast majority of infected individuals still have the same contact rate as when they were infected, regardless of their stage of infection. At very high re-selection rates, there is again little difference, because the vast majority of infected individuals have had their contact rate re-selected since they were infected, again, regardless of their stage of infection. It is only at intermediate reselection rates that individuals in chronic infection are substantially more likely to have had their contact rates re-selected since being infected than individuals in EHI. Further details are included in 14.2 of the Supplementary Results.
Endemic Prevalence as a function of R 0 . In order to illustrate the importance of various aspects of the model in determining the basic reproduction number R 0 , we plotted curves relating R 0 to the endemic prevalence (P) for several related models. We derived a maximal model (parameter set given in Supplementary Table 1 in 12 of the Supplementary Information) from our primary model by adding assortative mixing (m 5 0.5), in which individuals in a particular risk group are more likely to form contacts with other individuals in that risk group 8,11 , to our primary model. We derived static risk heterogeneity sub-models from both the maximal model and our primary model by setting the re-selection rate (v) to 0. We further derived a behavioral homogeneity model by setting the ratio of the contact rates of the two risk groups (r HL ) to 1. Further details are included in 13.5 of the Supplementary Methods. The results are shown in Figure 3.
It is particularly instructive to consider what effect transitioning between these submodels has when the prevalence is fixed, as it is in Figures 2 and 4. Because Figure 3 depicts prevalence as a function of R 0 , this amounts to selecting a horizontal line (such as the black dashed line, indicating a prevalence of 0.2), and examining how transitioning between curves changes the value of R 0 at which the curve intersects that horizontal line. By doing so, we can see how drastically an estimated R 0 can vary at a single prevalence, depending   Consistent with the discussion in the section Endemic prevalence and the basic reproduction number as functions of the relative transmissibility during EHI and the re-selection rate, static risk heterogeneity dramatically increases R 0 at a given prevalence, but this increase is reduced (though not eliminated) when episodic risk is introduced. Assortative mixing increases the basic reproduction number at a given prevalence for both static risk heterogeneity and episodic risk, by causing the most frequently transmitting infected individuals (those in the higher risk group) to transmit preferentially to higher risk susceptibles.
It has previously been observed that static risk heterogeneity and assortative mixing both decrease prevalence at a given R 0 12,13 . To this we now add that episodic risk increases prevalence at given R 0 , relative to static risk heterogeneity. In fact, all three of these observations reflect different manifestations of the same basic phenomenon: Provided that the dynamics of behavior and disease are independent (e.g. there is neither serosorting nor faster disease progression among certain behavioral groups), static risk heterogeneity and assortative mixing will decrease prevalence at a given R 0 to the extent that they cause transmissions to disproportionately occur into a subgroup that saturates with infection more rapidly than the population as a whole. They do this by concentrating transmissions into the higher risk group, which consequently can become saturated with infection even when the prevalence in the population as a whole is still quite low. Episodic risk (partially) counteracts this effect (and thus increases prevalence at a given R 0 ) by causing a net replacement of higher risk infecteds by (formerly) lower risk susceptibles, thereby reducing the saturation of the higher risk group, and by moving infected individuals into the lower risk group, where assortative mixing will increase the fraction of their contacts that are with susceptible individuals.
Re-selection rate effects when the fraction of transmissions from EHI (w) is fixed. In Figure 4, we illustrate the dramatic effects that the re-selection rate can have on the ease of elimination, even when the fraction of transmissions from early infection is fixed. In order to obtain the results in Figure 4, we fixed the endemic prevalence at 0.2 and the fraction of transmissions from early infection (w) at 0.447, varying the per-contact transmission rate during chronic infection (b 2 ) and the relative transmissibility during EHI (f) in order to do so. This value for phi was chosen based on the results of a recent phylodynamic analysis 14 . In this figure, changing the re-selection rate can be seen to result in R 0 values that range from 1.27 to 3.28 and t E s that range from 0.0635/year to 0.891/year.
To get a sense of the magnitude of the latter difference, let us suppose (1) that time from infection to diagnosis, time from diagnosis to linkage to care, and time from linkage to care to viral suppression are all exponentially distributed, and (2) that the effective treatment rate is the rate of (also exponentially distributed) single-step diagnosis, treatment, and viral suppression that generates a distribution of times from infection to suppression that has the same mean as the actual distribution. Using published estimates for the time from diagnosis to linkage to care (77.2% initiating care with 3 months) 15 and the time from linkage to care to suppression (median of 1.03 years for all patients) 16 , we find that a t E of 0.0635/year corresponds to a diagnosis rate of only 0.0710/year. In contrast, a t E of 0.891/year would not be achievable at all with current times from linkage to care to viral suppression (median of 0.87 years even when  Table 1, and the meanings of symbols representing parameters (including derived parameters) are given in Table 2. Note that only re-selections resulting in transition to the other risk group are shown; loops depicting re-selections that place the individual in the same risk group (and therefore same compartment) they were in prior to re-selection are not included. restricted to patients with perfect retention in care) 16 , even if both diagnosis and linkage to care were instantaneous, and retention in care were perfect. Details of this calculation are presented in 14.3 of the Supplementary Results. From these results, we can see that inferences about the feasibility of achieving control or elimination through UT&T are extremely dependent on assumptions about if and how individuals' contact rates change over the course of their lives, even when the prevalence, fraction of transmissions from EHI, and (instantaneous) distribution of contact rates are all known.

Discussion
We have shown that episodic risk can have a dramatic effect on the effort required to achieve elimination through treatment, even when both the prevalence and the fraction of transmissions from early infection are fixed. Moreover, we have shown that episodic risk can have a major effect on the fraction of transmissions from early infection itself, independent of biological factors that increase transmission during EHI. We have also shown how differences in the extent to which risk heterogeneity is episodic can make the difference between a transmission system that is extremely vulnerable to universal test and treat, and one for which no level of testing and treating can ever be sufficient, by itself, to eliminate ongoing HIV transmission. Others have illustrated how transmission during early infection can affect the relationship between prevalence and the basic reproduction number, and thus alter the population effects of early diagnosis and treatment, sometimes in unexpected ways 4,5 . We have illustrated here how episodic risk is likely to considerably amplify those effects. Consequently, collecting more data on risk heterogeneity and episodic risk (or its continuous generalization, risk volatility 17 ) is highly important in order to make the best possible decisions about how to allocate finite HIV control resources. Our models do not attempt to reproduce real-world transmission dynamics. They dichotomize what are actually continuous phenomena: transmissibility over the course of untreated infection, contact rates, change in contact rates, and treatment success or failure. They are kept simple in order to focus on the basic concepts of how changes in contact rates over the course of individuals' lives alter the fraction of transmissions from early infection, R 0 , and the effectiveness of UT&T. This understanding should affect how control decisions are pursued in the face of ignorance about how individuals change their contact rates over the course of their lives. It should also affect both field studies and modeling studies designed to reduce our ignorance. The simplicity of our models, however, mean that any attempt to predict the effectiveness of UT&T in a particular population based on our results is invalid in the absence of an assessment of how realistic relaxation of our simplifying assumptions affects our results. However, we have identified important qualitative phenomena which will be highly relevant even in more realistic models.
In this paper, we have presented episodic risk abstractly, without considering its determinants. As noted in a previous paper 6 , there are numerous causal phenomena that can result in periods of more frequent or riskier sexual activity than characterizes an individual's sexually active life as a whole, such as periods of recreational drug use or alternation between a partnered state (with a low or zero rate of outside sexual contacts) and an unpartnered state (with a higher rate of casual sex). Higher rates of sexual activity at certain ages can also produce similar phenomena, particularly when sexual activity shows assortative mixing by age, as is generally the case. Some of these effects have been captured in previous model analyses that have explored the role of EHI on transmission in populations 18,19 . But empirical work on these factors has not progressed. We hope that our simple way of abstracting risk behavior fluctuations with our episodic risk formulation helps to show why risk fluctuations are so important. But we are not advocating that the episodic risk abstraction should be the way that histories are obtained. How risk fluctuation histories are taken should depend on what questions are easiest to comprehend and validly answer and how well the answers to those questions allow researchers to measure changes in risk behavior over the course of an individual's life.
One consistent pattern that we have observed across various parameters that we have examined is that changes to parameters tend to make elimination through UT&T harder when they create or strengthen the phenomenon of a distinct core group that transmits heavily to itself. That this phenomenon is consistent across various ways of strengthening such a group (increasing contact rate heterogeneity, decreasing episodic risk, and increasing assortativity) suggests that it is likely to be robust to realistic relaxation of simplifying assumptions. Under these conditions, UT&T becomes less effective. These conditions, however, form a core group with persistent higher risk behavior where Pre-Exposure Prophylaxis is more practicable and effective.
One possible direction for further research is extending the various dichotomized aspects of the model to polychotomous or continuous measures. For example, dichotomized episodic risk can be replaced by continuous risk volatility 17,20 . Another is incorporating important aspects of sexual behavior that are not included in the present model, such as long-term monogamous or semi-monogamous partnerships, temporal changes in insertive or receptive behavior 21 or temporal changes in condom use with different types of partners.
Episodic risk behavior/risk volatility has been understudied. Two studies have found both between and within-individual volatility 22,23 . However, due to limitations in the datasets that were available, these were based on an analysis of data from the early 1990s, and therefore may not be reflective of current behavioral dynamics.
There are three fundamental messages that we hope that other researchers will take from this paper. First, we have presented a new methodology for calculating the basic reproduction number in the presence of episodic risk, which generalizes naturally to continuous risk volatility, and which helps in creating understanding not only of the reasons for the effects of episodic risk itself, but for its interactions with other behavioral or biological phenomena. We hope that this approach will be of service to other modelers. Second, we have shown how episodic risk can increase prevalence at the same time as it reduces the basic reproduction number and the difficulty of eradication. Third, we have shown how strong these effects can be. Consequently, they should be taken into account, and the necessary data gathered in order to determine their magnitude and better plan control activities using models that incorporate the strong effects we have illustrated.

Methods
Throughout this paper, all sexual behavior is modeled as instantaneous, symmetric contacts. All sexual contacts between an infected individual and a susceptible individual are assumed to have a potential for HIV transmission that depends only on the stage and treatment status of the infected individual. Per-contact transmissibility is in general higher during EHI than during chronic infection, with the ratio between the two transmissibilities being a parameter whose effects we explore.
The flow diagram for our primary model is depicted in Figure 5. More details, parameter definitions and ranges, and a system of coupled differential equations are presented in 13.1 of the Supplementary Methods.
All simulations were performed and numerical results obtained using the Anaconda distribution (Continuum Analytics, version 2.1.0, 64-bit) of Python (version 3.4.1). Apart from the standard library, we made use of the NumPy (version 1.9.0) and SciPy (version 0.14.0) packages for simulation and computation, and the matplotlib (1.4.0) package for visualization and graphics production. All integration of systems of ordinary differential equations (ODEs) was done using the scipy. integrate.odeint function, with default solver and stepsize. Further details may be found in the source code, which is attached at the end of the Supplementary Information.
In general, we have three outcomes of interest: the basic reproduction number (R 0 ), the fraction of transmissions from EHI (w), and the effective treatment rate that is necessary to completely eliminate ongoing transmission (t E ). For the purposes of this paper, we use the next-generation matrix (NGM) definition of R 0 developed by Diekmann et al. 1 We define w as the fraction of transmissions from EHI made by all individuals in a generation during exponential growth (under the same assumptions used to define the next-generation matrix), and solve for it using a modification of the methods for finding R 0 1 , discussed in 13.6 of the Supplementary Methods. Using these definitions, we obtain an algebraic equation giving t E in terms of R 0 and w for submodels without episodic risk. This equation is presented, along with its implications, in 13.6 of the Supplementary Methods.
Except where otherwise noted, the endemic prevalence in the absence of treatment was set to equal 0.2, and for each parameter set, a value of b 2 that generated that endemic prevalence was obtained numerically. All of the software listed above is free to use. Source code is included as 15 of the Supplementary Information.