1 Introduction

The principles of mathematical epidemiology (ME) were established more than one century ago with the milestone work by Sir Ronald Ross in 1916 and by Kermack and McKendrick [1, 2].

The Kermack and McKendrick’s lied in the description of infection transmission by means of the mass action law of Chemistry and Statistical Mechanics. In their formulation, the individuals’ social contact patterns relevant for transmission are represented as collisions between particles of a perfect gas, while transmission is modeled as a chemical reaction occurring with a certain probability upon a random encounter between two individuals of different types, namely a susceptible subject and an infective one [3]:

\begin{aligned} \mathrm{Susceptible} + \mathrm{Infectious} {\mathop {\rightarrow }\limits ^{\beta }} \mathrm{Infectious} + \mathrm{Infectious}. \end{aligned}

As a consequence, in their approaches, the social contact rate per individual and the transmission rate $$\beta$$ per social contact were taken essentially as natural constants valid for appropriate combinations of spatial settings, human activities, cultural habits, institutions, etc. However, it was acknowledged the possible dependence of these constants on the seasonality of social phenomena, e.g., the school calendar, or on climatic phenomena [4].

In the last four decades, mathematical models of infectious diseases have become key supporting tools for public health decisions [5,6,7]. This development was made possible by the increasing awareness of the need for better data and statistical tools allowing a finer and finer description of the transmission process. Further dimensions were incorporated in the models: individual-level characteristics, as age and sex; meso-level fundamental structures, such as the community composition by household type, by space, by social activity, etc. [5].

The impulse impressed by the fear for avian influenza and the 2009 H1N1 flu pandemic induced the development of highly sophisticated mathematical and computational models, which better integrate models with data [6, 8], and which were used to describe and predict the worldwide dynamics of influenza pandemics. Of course, the current COVID-19 pandemic, and related mitigation measures, are bringing further astonishing momentum to the discipline, with an endless list of contributions (more than 9000 modeling papers and PhD theses on COVID-19 are reported by Google Scholar at February 2, 2022).

However, in essentially all public health models, the individuals’ social, transmission and vaccination behavior remain unaffected regardless of the trends in the risks of acquiring the infection they might perceive from available information.

Clearly, this is an unrealistic abstraction, increasingly less applicable in contemporary scenarios. This became even more true during the current COVID-19 pandemic, which represented a huge open-sky laboratory of humans’ behaviors [9]. Indeed, individuals are frantic information seekers and therefore hardly unaffected by the state of the disease and related information.

Attempts to remove this abstraction have led, in the last 20 years, to the birth of a new branch of ME that was termed the behavioral epidemiology (BE) of infectious diseases [7, 10,11,12].

The pioneering work in BE was due to Capasso and Serio [13, 14], who first assumed that the transmission intensity might also depend on the level of infection spread by modeling the contact rate $$\beta$$ as a decreasing function of infection prevalence. This was the first instance of an epidemiological model incorporating individuals’ spontaneous social-distancing behavior by a prevalence-dependent contact rate [7, 10,11,12]. A key postulate of BE is that infection spread is not anymore an independent process, but it is instead the outcome of the interplay of an infection-spread layer with a number of other layers, first of all a behavior layer, in turn modulated by an information layer. In simple words, human behavior relevant for infection spread may be critically affected by the information about the spread and severity of the considered infection. And any change in human behavior will possibly affect infection trends that might eventually feedback on behavior itself. This means that the spread of information is a critical component of infection transmission modeling and therefore requires careful modeling per se. All this led some of us to develop new classes of epidemiological models by using new variables, that we termed information indexes, in order to include not only individual perceptions about the current state of infection, but also the memory of past spread [7, 15, 16] and eventually also spatio-temporal memories. In particular, in [17] the Capasso–Serio model was extended by considering a deterministic SIR model for an endemic infection disease with a general information-dependent transmission rate allowing to also include past available information on infection spread.

In this article, we depart from the previously cited works [13, 17] along two main directions.

The first one deals with the interpretation side: we will cast the aforementioned behavior implicit models including the effects of delayed information [17]) in the framework of the theory of nonlinear feedback control systems [18,19,20,21]. The underlying idea is that the individuals’ behavioral responses considered in the BE literature, whereby, e.g., agents reduce their daily number of social contacts depending on the information they have on disease severity. This is nothing other than a (nonlinear) feedback control. In particular, unlike many feedback systems studied in mathematical biology [19, 22, 23], the one considered here is a genuine feedback. Indeed, it is the outcome of voluntary—though uncoordinated—actions of agents.

The second main departure point is that most BE studies are based on deterministic models and as such they are suitable to describe epidemic or endemic scenarios for large populations only.

More in detail, we aim at studying the impact of human behavior during the spread of an epidemic outbreak in small-medium size populations, by taking into account that human decisions might also depend on past information. This has a number of implications. First, the involved nonlinear feedback control systems are stochastic and therefore depart from the classical asymptotic deterministic description based on the qualitative theory of differential equations [18,19,20,21]. Moreover, as we are dealing here with a system having a finite life span, it is necessary to assess the impact of the control action on a mainly transient phenomenon.

In particular, we depart from classical stochastic models of mathematical epidemiology, generically belonging (as the models of chemical kinetics, of which they can be considered as a subcase [7]) to the class of nonlinear birth and death Markov processes [24, 25]. The latter processes can be simulated by means of the well-known Gillespie algorithm [26, 27]. However, the presence of the information memory index (denoted as M(t) in this paper) makes, from the theoretical viewpoint, the resulting model a hybrid stochastic system [28,29,30], where a birth–death model of epidemic spread is coupled with a piecewise deterministic model for the information index M(t). The main implications are the following: (i) the state variables of the stochastic epidemic sub-system impact on the—otherwise deterministic—dynamics of the memory; (ii) in its turn, the model of the memory impacts on the birth–death epidemic component by making the key occurrence probabilities, namely the transmission rate $$\beta$$, heterogeneous in time. From the computational viewpoint, the latter issue requires to modify Gillespie’s algorithm following the lines of [28,29,30,31].

Based on this background, we then use selected simulation experiments to analyze and classify the effects of different individuals’ delayed behavioral responses during the course of a stochastic SIR-type epidemic in a fully susceptible population. In particular, the agents’ responses to the epidemic threat are modulated by: (i) the structure of the behavioral response function, (ii) the form and amplitude of the response function temporal kernels. Consistently, for each hypothesis on the behavioral response function, the resulting system is simulated to adequately reconstruct a number of key features of the stochastic epidemic, namely the simulated distributions of (i) the final attack rate, (ii) the epidemic extinction time, (iii) the epidemic maximum prevalence, etc.

Finally, we explicitly stress that our work did not intend to refer to COVID-19, which is an infection with a more complex dynamical structure than the one considered here [32,33,34]. Instead, our work had a quite general purpose, namely to develop a general stochastic behavioral epidemiology framework including delayed responses by individuals. However, we will insert—only where appropriate—observations that could be related to (or of interest for) investigations on the current pandemics.

The manuscript is structured as follows. Section 2 (i) presents the behavioral deterministic models and the related information indices that motivated this study, (ii) it plugs them in the formalism of nonlinear control theory, and (iii) it presents the models main features. Section 3 introduces the stochastic counterparts of the given models with special focus on the simulation issues that arise when lagged behavioral components are considered, thereby leading to hybrid stochastic systems. Section 4 explains the experiments. The subsequent sections illustrate the results for different forms of the information index. Concluding remarks follow.

2 Deterministic epidemic models with implicit behavior

In this section we present the deterministic counterparts of the stochastic behavioral models used in this paper. We depart from two basic, behavior implicit, models with a prevalence-dependent response. Then, we discuss the structure of the information index M and present some main instances of delaying kernels tuning the behavioral response, namely, the exponentially fading kernel and a generalization that we term the acquisition fading kernel. Then we set the proposed systems in the framework of nonlinear control theory. Finally, we discuss the main qualitative features of the proposed class of models with special focus on the interplay between the strength of the behavioral response and the related time delay.

2.1 Prologue: the Capasso–Serio deterministic SIR epidemic model with social distancing

The model by Capasso and Serio [13] extended the classical SIR deterministic epidemic model by Kermack and McKendrick [2] to include a prevalence-dependent contact (or transmission) rate, taken as a decreasing function of infective prevalence to mimic individual behavior change as a response to the epidemic threat. The model reads as follows:

\begin{aligned} S^{\prime }&=-\beta (I)\frac{I}{N} S \end{aligned}
(1)
\begin{aligned} I^{\prime }&=\beta (I)\frac{I}{N} S - \gamma I \end{aligned}
(2)

where $$S=S(t)$$, $$I=I(t)$$ represent the number of susceptible and infective individuals at time t, $$\gamma >0$$ is the recovery rate, and $$\beta (I)$$ is the prevalence-dependent transmission rate which was assumed to obey

\begin{aligned}&\beta ^{\prime }(I)<0 \\&\beta (0)=\beta _0 \end{aligned}

where $$\beta _0$$ represents the transmission rate in the epidemic early phase where no individuals’ responses are in place yet. The key hypothesis is that the larger the infective prevalence, the stronger will be the agents’ response to the epidemic threat by correspondingly reducing their transmission—or contact—rates, that is by expanding their social distancing.

Among the main properties of model (1)–(2) we mention that: (i) an epidemic outbreak will occur only if $$\beta (0)\left( S(0)/N\right) >\gamma$$, i.e., if the basic reproduction number (BRN) relevant for this model exceeds one; (ii) for $$t \rightarrow \infty$$ it is $$I(t) \rightarrow 0$$, that is, due to the deterministic continuous nature of the model the outbreak only ends for infinitely times. Moreover, the total number of infected subjects obeys the biologically meaningful relationship

\begin{aligned} T = \int _0^{+\infty }\beta (I(t))\frac{I(t)}{N}S(t)\mathrm{d}t = S(+\infty )-S(0) \end{aligned}

. In substantive terms, the working of the model is rather simple: the inclusion of a simple agents’ response increasing with prevalence has a protective role on the community. Compared to the baseline Kermack–McKendrick model, this response can mitigate the epidemic in the event of an outbreak and can—if very intense—even prevent the outbreak occurrence. This simplicity will obviously disappear in presence of more articulated behavioral response.

2.2 A deterministic endemic SIR model with social distancing

In [17], the notion of prevalence-dependent social distancing first formulated by Capasso and Serio was extended in a fairly general manner by taking the transmission rate $$\beta$$ as a decreasing function of a general information index denoted by M(t), i.e., $$\beta = \beta (M)$$, $$\beta ^{\prime }(M) < 0$$. The concept of information index was first introduced in [15], to summarize the entire amount of—current and past—available information about infection spread that agents can use to inform their response to the infection threat. In [17] the idea of social distancing was cast within a basic behavior implicit information-dependent SIR model for an endemic—rather than epidemic—infection (therefore also including the vital dynamics of the population). The model read as follows:

\begin{aligned} S^{\prime }&=\mu (N-S)-\beta (M(t))\frac{I}{N} S \end{aligned}
(3)
\begin{aligned} I^{\prime }&=\beta (M(t))\frac{I}{N} S - \gamma I - \mu I, \end{aligned}
(4)

where $$\mu$$ represent both the birth and death rates and kept equal to ensure population stationarity over time. The corresponding epidemic variant is obtained by just setting $$\mu =0$$.

A model using the M index in a behavior-explicit setting was proposed by [35] within their outbreak model with normal vs altered behavior.

As argued in [17], the information index is a flexible summary of the infection state and can therefore take a wide range of forms. A general form adequate for our present purposes is the following prevalence-dependent form

\begin{aligned} M(t)=\int _{0}^{+\infty }g(I(t-q))K(q)\mathrm{d}q \end{aligned}
(5)

where g(I) is an increasing function of the prevalence, and K(q) is a delaying kernel (or ‘memory function’), that is a probability density function that weighting the levels of past prevalence. For the sake of the simplicity, in our subsequent analyses we will use $$g(I)= kI$$.

In [17] it was shown that in the endemic case (i.e., for $$\mu >0$$), model (3)–(4)–(5) has two equilibria: (i) the disease-free equilibrium point $$DFE=(N,0)$$, which is Locally Asymptotically Stable (LAS) and Globally Asymptotically Stable (GAS) provided that the model BRN is lower or at most equal to one, where

\begin{aligned} \mathrm{BRN} = \frac{\beta (0)}{\mu +\nu } \end{aligned}

and a unique endemic equilibrium

\begin{aligned} EE=(S_e,I_e) \end{aligned}

where $$(S_e,I_e)$$ is the unique solution of the following system

\begin{aligned} S_e&= N-\left( 1+\frac{\nu }{\mu }\right) I_e \\ S_e&= N\frac{\mu +\nu }{\beta (I_e)}. \end{aligned}

The stability of the endemic state depends on the specific model of information index (5). For example, if the kernel K obeys $$K(q)=\delta (q)$$ where $$\delta (.)$$ is the Dirac function then $$M(t)=I(t)$$ (i.e., the model is unlagged), and EE is GAS (see [17, 36] and Appendix A).

2.3 Plugging social distancing within the framework of nonlinear control theory

Even on an intuitive ground, the information index M(t) can be read as a feedback control variable (traditionally denoted as u(t) in nonlinear control theory), since it represents a decision variable that—at the individual level—agents may tune to reduce their hazard of infection. By setting $$\beta _0=\beta (0)$$ and defining

\begin{aligned} \psi (M)=1-\frac{\beta (M)}{\beta _0} \end{aligned}

one can rewrite system (3)–(4)–(5) in the classical form of nonlinear control theory [18]

\begin{aligned} x^{\prime }= f(x) + \psi (M)g(x) \end{aligned}
(6)

where

\begin{aligned}&x=(x_1,x_2)=(S,I) \\&f(x)= \left( \mu (N-x_1) -\beta _0 \frac{x_2}{N}x_1, \beta _0 \frac{x_2}{N}x_1 - (\nu +\mu )x_2 \right) \\&g(x)= \left( \beta _0 \frac{x_2}{N}x_1, -\beta _0 \frac{x_2}{N}x_1 \right) . \end{aligned}

In particular, the case where the information index is assumed to be simply given by the infection prevalence, $$M=I=x_2$$, has a nice control-theory interpretation: it is the deviation of the state $$x_2(t)$$ (i.e., I) with respect to the ideal reference case of absence of disease, i.e., $$x_2^{ref}(t)=0$$: $$M=x_2-x_2^{ref}(t)$$.

2.4 Modeling the information index and its temporal kernels

In this section, we state our main assumptions on the transmission rate and the delaying kernel, and provide some relevant control-theoretic interpretations.

As regards the functional form of the transmission rate resulting from the above definition (2.3), i.e., $$\beta = \beta _0(1-\psi (M))$$, this could allow to design the control by applying techniques of differential geometry [18, 20, 21]. However, this approach would not keep under control the key constraint on function $$\psi (M)$$, namely:

\begin{aligned}&0< \psi (M) <1 \\&\psi (0)=0 \\&\psi ^{\prime }(M)>0. \end{aligned}

Therefore, in our numerical simulations we will use the following phenomenological family of functions for the information-dependent transmission rate $$\beta (M)$$:

\begin{aligned} \beta (M)= \beta _0 \frac{M_{50}^p }{M_{50}^p +M^p} \end{aligned}
(7)

where p is an integer such that $$p \ge 1$$, and $$M_{50}$$ is such that $$\beta (M_{50}) =0.5 \beta (0)$$

Note that, in the particular case where the information index only includes current information (that is, $$M(t)=I(t)$$) and for $$p=1$$, the corresponding force of infection (FOI) $$h(I) = \beta (I)I/N$$ (the instantaneous hazard of infection faced by a susceptible individual per time unit) is increasing, whereas for $$p\ge 2$$ the FOI is nonmonotone with a maximum at $$I=M_{50}$$.

Note moreover that, the fact that the DFE is LAS (GAS, actually) only if $$\mathrm{BRN}<1$$ independently of the memory kernel , i.e., only if in absence of the behavioral effect the disease cannot remain endemic, implies that one cannot design a $$\psi (M)$$ such that the DFE is stabilized.

As regards the memory kernel, we will consider three main cases:

• The memoryless case $$K(q)=\delta (q)$$. In this case the information index M only includes current information.

• The exponentially fading memory kernel (EFK):

\begin{aligned} K(q) = a \mathrm{Exp}(-a q). \end{aligned}

This represents the often realistic case where past information receives a decreasing weight. In this case, the integro-differential system can be reduced to ordinary differential equation (ODEs) by adding the further ODE:

\begin{aligned} M^{\prime }(t)=a(g(I)-M) \end{aligned}
(8)
• The acquisition-fading memory kernel (AFK):

\begin{aligned} K(q) = \frac{a_1 a_2}{a_2-a_1} \left( \mathrm{Exp}(-a_1 q) - \mathrm{Exp}(-a_2 q) \right) . \end{aligned}

This represents another possibly realistic scenario where no information (about the infection state) is available at current time; then, it is gradually acquired up to a maximum before starting fading out exponentially, as in the EFK case.

Even in this case integro-differential model (3)–(4)–(5) can be reduced to ODEs by the additional equations

\begin{aligned}&Z^{\prime }(t)=a_1(g(I)-Z) \end{aligned}
(9)
\begin{aligned}&M^{\prime }(t)=a_2(Z-M) \end{aligned}
(10)

Note that if the two sub-processes of information acquisition and memory fading occur at the same relative speed $$a_1=a_2 =a$$, then our 2-dimensional acquisition-fading kernel reduces (via the limit $$a_2 \rightarrow a_1$$) to the so-called $$Erlang(2,a)= a t \mathrm{e}^{-a t}$$ kernel [37].

It is immediate to verify that:

• In the case of the exponentially fading kernel, the memory index/control variable M(t) can be read as the output of a low-pass filter with characteristic cutoff frequency a that is applied to the ‘signal’ g(I(t)). Under our work assumption $$g(I)=k I$$ the transfer function $$H(\lambda )$$ between the input I and the output M reads as follows

\begin{aligned} H(\lambda )=\frac{{\widehat{M}}(\lambda )}{{\widehat{I}}(\lambda )}= \frac{k \lambda }{a+\lambda }={\widehat{K}}(\lambda ), \end{aligned}

where $$\lambda \in {\mathbb {C}}$$ and $${\widehat{M}}(\lambda )$$, $${\widehat{M}}(\lambda )$$ and $${\widehat{K}}(\lambda )$$ are the Laplace transforms of, respectively, M(t), I(t) and K(q);

• In the case of the acquisition-fading kernel, the memory index M(t) can be read as the output of the application of two low-pass filters in series (with characteristic frequencies $$a_1$$ and $$a_2$$) that is applied to the ‘signal’ g(I(t)). In particular, in the case $$g(I)=k I$$, the transfer function between the input I and the output M reads as follows

\begin{aligned} H(\lambda )=\frac{{\widehat{M}}(\lambda )}{{\widehat{I}}(\lambda )}= \frac{k a_1 a_2}{(a_1+\lambda )(a_2+\lambda )}={\widehat{K}}(\lambda ). \end{aligned}
(11)

Therefore, in our problems, the processes of fading and (if it is the case) acquisition of the memory are analogous to the error with memory connected to the measure of a feedback signal by means of a mechanic or electronic device [19]. This is a typical scenario in control theory, where the controller often acquires the information on the variables to be controlled by means of measure devices. The latter can have their own internal dynamics and, moreover, are also aimed at reducing extrinsic noises that are characterized by large frequencies.

Adopting again the control-theory formalism, the final structure of the considered family of models (6) is as follows:

• In case of EFK:

\begin{aligned} x= & {} (x_1,x_2,x_3)=(S,I,M) \\ f(x)= & {} \left( \mu (N-x_1) -\beta _0 \frac{x_2}{N}x_1, \beta _0\right. \\&\left. \frac{x_2}{N}x_1 - (\nu +\mu )x_2, a ( g(x_2) -x_3 ) \right) \\ g(x)= & {} \left( +\beta _0 \frac{x_2}{N}x_1, -\beta _0 \frac{x_2}{N}x_1 \right) ,0 \end{aligned}
• In case of AFK:

\begin{aligned} x= & {} (x_1,x_2,x_3,x_4)=(S,I,Z,M) \\ f(x)= & {} \left( \mu (N-x_1) -\beta _0 \frac{x_2}{N}x_1, \beta _0 \frac{x_2}{N}x_1\right. \\&\left. - (\nu +\mu )x_2, a_1(g(x_2) -x_3), a_2 ( x_3 -x_4 ) \right) \\ g(x)= & {} \left( +\beta _0 \frac{x_2}{N}x_1, -\beta _0 \frac{x_2}{N}x_1 \right) ,0 \end{aligned}

2.5 Properties of the previous general deterministic endemic model with social distancing

We discuss here the main stability properties of the endemic state of model (6) under the different hypotheses considered on the form of the delaying kernel.

First, in the case of EFK, it was proven in [17] that the endemic equilibrium is LAS. Moreover, in [38] by means of an appropriate Lyapunov function it was shown that under the additional condition $$\left( M \beta (M) \right) ^{\prime }>0$$ the endemic equilibrium is globally stable. Additionally, in [17], the case of an $$Erlang_{2}$$-type memory was considered. As already pointed out, this memory represents a special case of the acquisition-fading kernel where the two sub-processes of acquisition and fading occur at the same rate $$a_{1} = a_{2}=a$$. The corresponding transfer function reads as follows

\begin{aligned} \frac{{\widehat{M}}(\lambda )}{{\widehat{I}}(\lambda )}=\frac{k a^2}{(a+\lambda )^2}, \end{aligned}

In this case, the EE can be either LAS or can be destabilized by a Hopf bifurcation (see [17]).

Let us now consider model (6) for a general delaying kernel $$K(\tau )$$. Denoting as $${\widehat{K}}(\lambda )$$ the corresponding Laplace transform and linearizing at EE one gets:

\begin{aligned} \lambda ^2 + c_1 \lambda + c_0 + d (\lambda +\mu ) ={\widehat{K}}(\lambda )=0, \end{aligned}

where

\begin{aligned} c_1= & {} \mu +\beta (I_e) I_e>0 \\ c_0= & {} \beta ^2(I_e) I_e S_e>0 \\ d= & {} - \beta ^{\prime }(I_e) I_e S_e >0 \end{aligned}

Under an AFK, $${\widehat{K}}(\lambda )$$ is given by formula (11) and it can easily be rewritten as follows:

\begin{aligned} K(\lambda )= \frac{a_1a_2}{(\lambda +a_1)(\lambda +a_2)}=\frac{p}{\lambda ^2 +\sigma \lambda + p} \end{aligned}

where $$\sigma = a_1+a_2$$ and $$p=a_1 a_2$$.

This finally yields the following characteristic polynomial:

\begin{aligned} \lambda ^4 + q_1 \lambda ^3 + q_2 \lambda ^2 + q_3 \lambda +q_4 =0 \end{aligned}

where

\begin{aligned} q_3= & {} \sigma + c_1>0 \\ q_2= & {} c_1 \sigma + p + c_0>0 \\ q_1= & {} c_0 \sigma + (c_1+d) p>0 \\ q_0= & {} (\mathrm{d}\mu + c_0) p >0 \end{aligned}

Since all the coefficients are positive, applying the Routh–Hurwitz criterion we get the following local stability conditions of the EE:

\begin{aligned} H(p,\sigma )= q_1 q_2 q_3 - q_1^2 - q_3^2 q_0 >0 , \end{aligned}
(12)

In particular, if

\begin{aligned} H(p,\sigma )<0, \end{aligned}
(13)

then EE becomes unstable through Hopf a bifurcation at the locus

\begin{aligned} H(p,\sigma )=0. \end{aligned}

As well known, the Hopf theorem only provides local information in the parametric space. In other words, it only states that in a parametric neighborhood of the bifurcation point the solution of the system is a periodic solution of small amplitude. Therefore, in our case this will hold for values of $$(p,\sigma )$$ in the region $$H(p,\sigma )<0$$ that are sufficiently close to points where $$H(p,\sigma )=0$$. In order to draw more general information about points in the interior of the region $$H(p,\sigma )<0$$ one can take advantage of the Yakubovitch–Efimov–Fradkov theorem [39].

To apply the theorem, note preliminarily that the system is bounded and has two unstable equilibrium points, and the DFE has as stable manifold the segment $$l=(x_1,0,0,0)$$ with $$x_1 \in [0,N]$$ that corresponds to the trivial case of absence of disease in the target population. The biological and geometrical nature of the stable manifold of DFE implies that there are not heteroclinic orbits connecting EE to DFE.

As a consequence, from the Yakubovitch–Efimov–Fradkov theorem (see corollary 1 of [39]) if $$H(p,\sigma )<0$$ then system undergoes self-sustained oscillations, not necessarily periodic, called Yakubovitch oscillations or Y-oscillations [40]. We report below two useful remarks.

Remark

The above results can easily be extended to delays in the form of $$n\ge 3$$ first-order low-pass filters in series.

Remark

Note that, in our case (and in the generalization) the Y-oscillations are fully induced by the behavior, i.e., by the control. In control language, this is the consequence of the fact that the control is based on a ‘measure’ coming from a double filtering of the prevalence, i.e., from the indirect nature of the control. Note however that the choice of the weight K(q) is primarily based on behavioral arguments.

As regards the analytical form of condition (12), this is cumbersome and gives no particular hints, so that also (13) becomes of scarce practical relevance. Therefore, we numerically computed the Jacobian and its 4 associated eigenvalues at the endemic equilibrium. This allowed us to plot (see Fig. 1) the stability and instability regions in function of the two key parameters: (i) $$T_1=1/a_1$$ which is the average acquisition time of information; and $$T_2=1/a_2$$ which is the average fading time. In particular, Fig. 1 reports the contour plot of the following function:

\begin{aligned} z(T_1,T_2) =Max\left( 0, Max_{k\in \{1,2,3,4\} }\left( Re(\lambda _k(T_1,T_2 ) \right) \right) \end{aligned}

2.6 Deterministic modeling of the epidemic case ($$\mu =0$$)

In the rest of the present work we will mostly focus on the purely epidemic case ($$\mu =0$$). This case was not previously analyzed with the exception of the case $$M=I$$, i.e., the Capasso–Serio model.

For the general model with a generic information-dependent M index it is easy to see that it exists a disease-free equilibrium $$x_2=0$$ and that $$x_1(t)$$ tends to an equilibrium value that depends on the function $$\psi (M(t))$$ and on the dynamics of M(t), which is in turn determined by the delay kernel. A fact not previously pointed out in the literature is that under appropriate behavioral responses multiple behavior-induced epidemic waves can arise even in the course of a single epidemic. We will numerically illustrate these deterministic results in “Appendix.”

3 Stochastic modeling of social distancing under generic M-indices

In this section we introduce the stochastic counterparts of the previous deterministic models with social distancing and discuss the simulation issues that arise when the behavioral component is involved. We start from the simpler case where no memory effects are considered, and then extend to the case of hybrid systems arising under memory effects.

3.1 No memory effects: stochastic version of the Capasso–Serio model

As is well known, the deterministic models of infectious diseases can be considered as a good approximation of the true underlying stochastic systems only if the population size is large enough so that stochastic oscillations around the mean pattern become negligible. In the absence of behavioral effects, if the population is small then the system is modeled by a birth–death Markov process [24].

In the absence of memory effects, i.e., when considering the stochastic version of the Capasso–Serio model, the resulting stochastic model remains a birth–death stochastic processes [24, 26, 27, 41].

In this case, the model is simply the outcome of two transition processes and related events, namely:

1. (i)

transmission: a susceptible subject becomes infectious due to adequate social contacts with infectious subjects. The probability of a transmission event during the infinitesimal interval $$(t,t+\mathrm{d}t)$$ is:

\begin{aligned}&\mathrm{Prob}\left( (S(t+\mathrm{d}t),I(t+\mathrm{d}t))=(S(t)-1,I(t)+1)\right) \nonumber \\&\quad =\beta (I)\frac{I}{N} S \mathrm{d}t \end{aligned}
(14)

However, unlike the basic stochastic SIR model, the probability in formula (14) is not bilinear.

2. (ii)

removal: an infectious individuals are removed from the infectious compartment due to recovery and immunity acquisition. The probability of a removal event during $$(t,t+\mathrm{d}t)$$ is:

\begin{aligned} \mathrm{Prob}\left( (S(t+\mathrm{d}t),I(t+\mathrm{d}t))=(S(t),I(t)-1)\right) =\gamma I \mathrm{d}t\nonumber \\ \end{aligned}
(15)

The stochastic simulation of birth and death Markov processes is elegantly done by the Gillespie algorithm [26, 27, 41] which in our case works as follows. Let us suppose that the nth event occurred at time $$t_n$$ so that the system after the event has state values

\begin{aligned} (S,I)=(S_n,I_n). \end{aligned}

Therefore, denoting the time of the next event as

\begin{aligned} t_{n+1}=t_n + \tau \end{aligned}

then $$\tau$$ is such that

\begin{aligned} \gamma I_n \tau + \beta (I_n)\frac{I_n}{N} S_n \tau = r_n \end{aligned}

where $$r_n$$ is exponentially distributed. This yields:

\begin{aligned} \tau =\frac{r_n}{\gamma I_n+ \beta (I_n)\frac{I_n}{N} S_n} \end{aligned}
(16)

The type of the next event, which will either be the contagion of a susceptible or the removal of an infectious subject), is determined by randomization through a Bernoulli experiment based on the two complementary probabilities

\begin{aligned} \rho _\mathrm{rec}= & {} \frac{\gamma I_n}{\gamma I_n+\beta (I_n)\frac{I_n}{N} S_n} \\ \rho _\mathrm{cont}= & {} 1- \rho _\mathrm{rec} \end{aligned}

3.2 Memory effects and simulation of hybrid stochastic systems

In the presence of a general memory effects the behavior of the system becomes more complicated. Indeed, the stochastic evolution of the discrete state variables (SI) has to be coupled with an integral equation describing the dynamics of M(t), which is a continuous one during each inter-events intervals $$(t_n,t_{n+1})$$. In particular, under our hypotheses on the memory kernels, the dynamics of M is given by a system of ordinary differential equations depending on $$I_n$$.

As a consequence, the system is no longer a classical birth and death process, but it belongs to the class of the so-called hybrid models [28] where stochastic automata are coupled with deterministic processes by means of time-varying propensities. Note however that in our case the coupling is mutual. Indeed, a stochastic birth–death model (for infection spread) is coupled with an ODE (or a system of ODEs) model for the memory, yielding for M a continuous piecewise deterministic model that depends on the stochastic epidemic model. Indeed, in between two stochastic events, the dynamics of M(t) is fully deterministic, i.e., M(t) is a piecewise deterministic process.

Overall, the above-described model can be formalized similarly to the class of stochastic hybrid automata defined in [31].

Operatively, the infinitesimal probability of a contagion event in $$(t,t+\mathrm{d}t)$$, given by:

\begin{aligned}&\mathrm{Prob}\left( (S(t+\mathrm{d}t),I(t+\mathrm{d}t))=(S(t)-1,I(t)+1)\right) \nonumber \\&\quad =\beta (M(t))\frac{I}{N} S \mathrm{d}t \end{aligned}
(17)

is time-dependent. This requires to resort to a version of the Gillespie algorithm with time-varying propensities, as in [28].

Namely, the time to the $$(n+1)$$-th event is determined by the following equation:

\begin{aligned} \gamma I_n \tau + \frac{I_n}{N} S_n \int _{t_n}^{t_n+\tau }\beta (M(t)) \mathrm{d}t = r_n \end{aligned}
(18)

In the general case, the inequality

\begin{aligned} 0 \le \beta (M) \le \beta _0 , \end{aligned}

implies that

\begin{aligned} 0 \le \int _{t_n}^{t_n+\tau }\beta (M(t)) \mathrm{d}t \le \beta _0 \tau . \end{aligned}

As a consequence, from (18) and provided that $$I_n>0$$ (the case $$I_n=0$$ is trivial because $$I=0$$ is an adsorbing state for the system) we can infer that

\begin{aligned} \tau _L \le \tau \le \tau _R, \end{aligned}

where

\begin{aligned} \tau _L= & {} \frac{r_n}{\gamma I_n +\beta _0 \frac{I_n}{N} S_n} \\ \tau _R= & {} \frac{r_n}{\gamma I_n} \end{aligned}

which is an useful bound for the numerical simulations.

Remark

The bounds $$\tau _L$$ and $$\tau _R$$ are not constant: they change at each step of the simulation algorithm.

To compute $$\tau$$ it is necessary to know the model linking the continuous state variable M(t) to the discrete state variables (SI).

Once $$\tau$$ has been determined, the type of the next event is chosen (as in the classical Gillespie algorithm) by the following probabilities:

\begin{aligned}&{\bar{\rho }}_\mathrm{rec} = \frac{\gamma I_n}{\gamma I_n+\beta (M(t_n+\tau ))\frac{I_n}{N} S_n} \\&{\bar{\rho }}_\mathrm{cont}=1- {\bar{\rho }}_\mathrm{rec} \end{aligned}

3.2.1 Numerical determination of $$\tau$$

Let us define

\begin{aligned} \psi (\tau ) = \int _{t_n}^{t_n+\tau }\beta (M(t)) \mathrm{d}t \end{aligned}

Then one has to numerically solve the following equation

\begin{aligned} \gamma I_n \tau + \frac{I_n}{N} S_n \psi (\tau ) = r_n \end{aligned}
(19)

in the interval

\begin{aligned} \tau _L \le \tau \le \tau _R, \end{aligned}

by some numerical algorithms. We then have two main cases. The first one occurs when function $$\psi (\tau )$$ is available in closed form. In the case where $$\beta (M(t))$$ can be analytically integrated in $$(t_n,t_{n+1})$$, then Eq. (19) can be solved by means of well-known standard iterative algorithms, such as the Newton–Raphson and the bisection methods (see “Appendix”).

For the sake of notational simplicity we define

\begin{aligned} f(\tau )= \gamma I_n \tau + \frac{I_n}{N} S_n \psi (\tau ) - r_n \end{aligned}

thus to determine $$\tau$$ we must solve

\begin{aligned} f(\tau )=0 \end{aligned}

Note also that: $$f(\tau _L)<0$$ and $$f(\tau _R)>0$$.

Instead, if $$\psi (\tau )$$ is not analytically known, one has to numerically approximate the integral that appears in the time-varying Gillespie algorithm. For this case, we propose the algorithm described by the following steps:

• Split the interval $$[0,\tau _R]$$ in $$L>>1$$ points, and define

\begin{aligned} h=\frac{\tau _R}{V} \end{aligned}
\begin{aligned} \theta _k = k h \end{aligned}

where $$k =0,1,\dots ,V.$$ Note that:

\begin{aligned} f(\theta _0)=f(0)=-r_n \end{aligned}
\begin{aligned} \theta _V=\tau _R \end{aligned}
• Approximate $$\psi (\theta _{k+1})$$ by some standard strategy, such as:

\begin{aligned}&\psi (\theta _{k+1})\approx \psi (\theta _k) + \frac{h}{2}\left( \beta (M(t_n+\theta _{k}))\right. \\&\quad \left. +\beta (M(t_n+\theta _{k+1}))\right) . \end{aligned}

Note that this implies that

\begin{aligned}&f(\theta _{k+1})\approx f(\theta _k)+ \gamma I_n h + \frac{I_n}{N}S_n \frac{h}{2}\nonumber \\&\quad \left( \beta (M(t_n+\theta _{k}))+\beta (M(t_n+\theta _{k+1}))\right) \end{aligned}
(20)
• Since $$\tau > \tau _L$$, we have to iterate computations (without checking if we have found the solution $$\tau$$) $$f(\theta )$$ at least until the step

\begin{aligned} k_L = \Big [\frac{\tau _L}{h}\Big ] \end{aligned}

where [x] is the integer part of x, e.g., $$[3.99] =3$$.

• Suppose that the step $$q \ge k_L$$ had been reached and that

\begin{aligned} f(\theta _q)<0. \end{aligned}

Then go to the next step $$\theta _{q+1}$$ and compute $$f(\theta _{q+1})$$ by means of formula (20). The following three cases are possible: (i) $$|f(\theta _{q+1})|<Tol$$, where Tol is a sufficiently small tolerance, so you can stop; (ii) $$f(\theta _{q+1})<-Tol$$, thus one must continue; (iii) $$f(\theta _{q+1})>Tol$$, which implies that then the solution $$\tau$$ is such that

\begin{aligned} \tau \in (\theta _q,\theta _{q+1}) \end{aligned}

Since h is sufficiently small, one can use the approximation

\begin{aligned} \tau \approx \frac{\theta _q+\theta _{q+1}}{2}=\theta _q+ \frac{h}{2} \end{aligned}

Remark

The most sensitive point in the previous algorithm is therefore that of appropriately choosing V, which must be sufficiently large. In our simulations, we have chosen V in a way such that the time step h is always kept smaller than 0.1 days. Moreover, one must remember that since $$\tau _R$$ changes at each step of the Gillespie algorithm, the same holds for V Once determined $$\tau$$ the type of the next event is chosen by the following probability:

\begin{aligned}&{\bar{\rho }}_\mathrm{rec} = \frac{\gamma I_n}{\gamma I_n+\beta (M(t_n+\tau ))\frac{I_n}{N} S_n} \\&{\bar{\rho }}_\mathrm{cont}=1- {\bar{\rho }}_\mathrm{rec} \end{aligned}

3.3 The case of the exponentially fading memory

In the cases of EFK and of AFK kernels, the coupling between the discrete and the continuous parts of the hybrid model is relatively simpler than in the general case. Indeed, as we have seen, in our examples the model of M(t) reduces, respectively, to one or two linear ordinary differential equations.

In this section and in the following one, we will show how $$\beta (M(t))$$ can be analytically defined in all event intervals $$(t_n,t_{n+1})$$ for both the EFK and the AFK. For the exponentially fading memory kernel, we will also provide the analytical form of $$\psi (\tau )$$, which allows to significantly speed up the computations.

In the case of an exponentially fading memory, one has that in each interval $$(t_n,t_{n+1})$$ between two consecutive events, M(t) is given by the following linear differential equation

\begin{aligned} M^{\prime }(t)&=a(g(I_n)-M) \end{aligned}
(21)
\begin{aligned} M(t_n)&=M_n \end{aligned}
(22)
\begin{aligned} M_0&= 0. \end{aligned}
(23)

since we suppose that the epidemics starts at $$t=0$$. The solution of ODE problem (21)–(22) is:

\begin{aligned} M(t)=g(I_n) + (M_n-g(I_n)) \mathrm{Exp}(-a \theta ) \end{aligned}
(24)

where

\begin{aligned} \theta = t-t_n . \end{aligned}

The function $$\psi (\tau )$$ is given by the integral

\begin{aligned} \psi (\tau )=\beta _0 \int _0^{\tau } \frac{M_{50}^p }{M_{50}^p +\left( g(I_n) + (M_n-g(I_n)) \mathrm{Exp}(-a \theta )\right) ^p}\mathrm{d}\theta \end{aligned}

Defining

\begin{aligned} K= \frac{M_{50}}{|M_n-g(I_n)|}, B=\frac{g(I_n)}{|M_n-g(I_n)|},\\ \sigma = \mathrm{sign}\left( M_n-g(I_n)\right) \end{aligned}

yields

\begin{aligned} \psi (\tau )=\beta _0 K^p \int _0^{\tau } \frac{1 }{K^p +\left( R + \sigma \mathrm{Exp}(-a \theta )\right) ^p}\mathrm{d}\theta \end{aligned}

Defining the new variable

\begin{aligned} y = R +\sigma \mathrm{Exp}(-a \theta ) \end{aligned}

yields

\begin{aligned} \psi (\tau )=\beta _0 K^p \int _{R+\sigma }^{R +\sigma \mathrm{Exp}(-a \tau )}\frac{-1}{a}\frac{1}{(K^p+y^p)}\frac{1}{y-R}\mathrm{d}y. \end{aligned}

As for the above integral note the following: (i) if $$\sigma =1$$ then we have that the upper integration limit is smaller than the lower integration limit (due to $$a>0$$), but since $$y=R + \mathrm{exp}(-a\theta )\Rightarrow y>R$$, thus the function to be integrated is negative and the integral is positive; (ii) if $$\sigma =-1$$, the upper integration limit is greater than the lower integration limit and since $$y=R - \mathrm{exp}(-a\theta )\Rightarrow y<R$$, the integrand function turns out to be positive, so that the integral will be positive as well (and, in principle, analytically solvable).

Further setting $$y = K z$$ one gets:

\begin{aligned} \psi (\tau )=\beta _0 \int _{r+\rho }^{r+\rho \mathrm{Exp}(-a \tau )}\frac{-1}{a}\frac{1}{(1+z^p)}\frac{1}{z-r}\mathrm{d}z \end{aligned}

where $$r=R/K$$ and $$\rho = \sigma /K$$.

Namely, for the case $$p=1$$ one has:

\begin{aligned} \psi (\tau )=\beta _0 \frac{-1}{a (1+r)} \Big |log(z-r) - log(1+z)\Big |_{r+\rho }^{r +\rho \mathrm{Exp}(-a \tau )} \end{aligned}

yielding

\begin{aligned} \psi (\tau )=\beta _0 \frac{-1}{a (1+r)} log\left( \frac{1+r+\rho }{\mathrm{Exp}(a\tau )(1+r)+\rho } \right) >0 \end{aligned}

or equivalently (the following version reduces numerical errors in the case $$\mathrm{exp}(-a\tau )<<1$$)

\begin{aligned} \psi (\tau )=\beta _0 \frac{-1}{a (1+r)}\left( - a\tau -log\left( \frac{1+r+\rho \mathrm{Exp}(-a\tau )}{1+r+\rho }\right) \right) \nonumber \\ \end{aligned}
(25)

For the case $$p=2$$ one has:

\begin{aligned}&\psi (\tau )=\beta _0 \frac{-1}{a} \frac{1}{1+r^2}\\&\quad \Big |log(z-r)-(1/2)log(1+z^2)-r Arctan(z)\Big |_{r+\rho }^{r+\rho \mathrm{Exp}(-a \tau )} \end{aligned}

For $$p\ge 3$$, the expression of $$\psi (\tau )$$ becomes untractable.

Of course, once $$\tau$$ has been computed, one must set

\begin{aligned} M_{n+1}= g(I_n) + (M_n-g(I_n)) \mathrm{Exp}(-a \tau ) \end{aligned}

3.4 The case of the acquisition-fading kernel

In the case of the acquisition-fading kernel, one has that in each interval $$(t_n,t_{n+1})$$ the solution (Z(t), M(t)) to the pair of addition differential equations can be computed as follows. First, Z(t) is defined as the solution of the following differential equation

\begin{aligned} Z^{\prime }(t)&=a_1(g(I_n)-Z) \end{aligned}
(26)
\begin{aligned} Z(t_n)&=Z_n \end{aligned}
(27)
\begin{aligned} Z_0&=0 \end{aligned}
(28)

The solution of the above ODE problem is:

\begin{aligned} Z(t)=g(I_n) + (Z_n-g(I_n)) \mathrm{Exp}(-a_1 \theta ) \end{aligned}
(29)

where

\begin{aligned} \theta = t-t_n. \end{aligned}

Next, M(t) is the solution of

\begin{aligned} M^{\prime }(t)&=a_2(Z(t)-M) \end{aligned}
(30)
\begin{aligned} M(t_n)&=M_n. \end{aligned}
(31)

implying:

\begin{aligned} M(t)= & {} g(I_n) + \Big ( \frac{a_2}{a_2-a_1} (Z_n-g(I_n)) \Big )\mathrm{Exp}(-a_1\tau ) \nonumber \\&+ \Big (M_n - \frac{a_2 Z_n}{a_2-a_1} + \frac{a_1 g(I_n)}{a_2-a_1}\Big ) \mathrm{Exp}(-a_2\tau ) \end{aligned}
(32)

Note that in this case the integral defining $$\psi (\tau )$$ cannot be analytically solved even in the case $$p=1$$.

Remark

In this case, once $$\tau$$ has been numerically computed, one must set

\begin{aligned} Z_{n+1}= & {} g(I_n) + (Z_n-g(I_n)) \mathrm{Exp}(-a_1 \tau ) \end{aligned}
(33)
\begin{aligned} M_{n+1}= & {} g(I_n) + \Big ( \frac{a_2}{a_2-a_1} (Z_n-g(I_n)) \Big )\mathrm{Exp}(-a_1\tau ) \nonumber \\&+ \Big (M_n - \frac{a_2Z_n}{a_2-a_1} + \frac{a_1g(I_n)}{a_2-a_1}\Big ) \mathrm{Exp}(-a_2\tau ) \end{aligned}
(34)

Simulations of scenarios where the memory kernel is the AFK are shown in appendix, for the sake of the readability.

3.5 Algorithm for the localization of multiple ‘process’ peaks in the simulated time series

In our work we used MATLAB 2019b for model simulation and the analysis of results. Given our focus on multiple-stochastic—epidemic waves, we briefly present the approach for the localization of (multiple) epidemic peaks. The purpose of the algorithm is that of allowing to separate true ‘process’ peaks, i.e., peaks induced by the behavioral response, from spurious oscillations due to the stochastic nature of the problem. The localization of the first peak was done by finding the maximum number of infectious individuals, because the first peak always resulted the higher one. The latter (purely due to susceptible depletion) is a somewhat straightforward consequence of the simplicity of the model. The localization of the second peak (and subsequent ones) was more complicated due to the noise of stochastic simulations. Firstly, we filtered the time courses and analyzed only cases with 3 and more points. Noise was filtered by the Gaussian-weighted moving average filter (we applied MATLAB function: smoothdata) with window size equal to 100 points. Then we accepted as true peaks, maxima arising in the smoothed data course according to the following criteria (i) minimum height of peak equal to 100 infectious, (ii) minimum time distance between subsequent peaks of 5 days (MATLAB function: findpeaks). As matter of fact, since the appearance of multiple peaks was much neater in the case $$\mathrm{BRN}=15$$ (compared to $$\mathrm{BRN}=2$$), later on we will mainly report our results on multiple peaks for this case.

4 Results: Stochastic epidemics and behavior—The memoryless case

In this section we report the main results of a range of stochastic simulation experiments, with special focus on the effects of different hypotheses on the shape of the social distancing response function $$\beta (M)$$ on the system behavior.

4.1 Simulation strategy, assignment of input parameters and main simulation outputs

In all our experiments we simulated epidemic outbreaks in a fully susceptible population, under the following assumptions on input parameters: (i) the population size is set to $$N =10{,}000$$; (ii) the infection average duration is set to one week, implying $$\gamma =1/7 \text {days}^{-1}$$; (iii) $$M_{50\%}$$ is allowed to take three possible values: $$M_{50\%} \in \{10,50,200\}$$. As regards the basic reproduction number, we considered two widely different cases: (1) $$\mathrm{BRN}=15$$ corresponding to a highly transmissible infection, such as measles; (2) $$\mathrm{BRN}=2$$, corresponding to a moderately transmissible infection as it may be the case, e.g., of seasonal influenza. The corresponding baseline transmission rates (in the absence of any behavioral response) are $$\beta _0=15/7 \text {days}^{(-1)}$$, and $$\beta _0=2/7 \text {days}^{(-1)}$$, respectively. In the deterministic SIR epidemic model in a wholly susceptible population, the considered figures of the $$\mathrm{BRN}$$ would yield a total proportion of people eventually infected, i.e., a final attack rate of the outbreak—well above 99percent for $$\mathrm{BRN}=2$$. As for the main outputs of stochastic simulation we primarily looked at the simulated probability density functions (PDF) of (i) the final attack rate, (ii) the epidemic extinction time, (iii) the maximum prevalence, and to the temporal realizations (or realized paths) of the prevalence function. In particular, in order to adequately reproduce the relevant probability density functions, the model simulation is replicated $$N_\mathrm{sim}=100{,}000$$ times.

4.2 Results: behavioral responses without memory effects

4.2.1 Effects of $$M_{50\%}$$ in the stochastic case

In this subsection, we considered the memoryless case with $$p=1$$, in order to characterize the role of parameter $$M_{50\%}$$.

The stationary PDFs of the final attack rate and of the extinction time are shown in the upper and lower panels of Fig. 2 (left panels: $$\mathrm{BRN}=15$$, right panels: $$\mathrm{BRN}=2$$), respectively. Each panel reports three different histograms corresponding to the three values considered of $$M_{50\%}$$ and, for comparison purposes, also the one corresponding to the benchmark case of the classic stochastic SIR model without behavioral response.

Concerning the final attack rates (upper panels of 2), we note that for both $$\mathrm{BRN}=15$$ and $$\mathrm{BRN}=2$$, the simulated PDFs are always bimodal. The mode for low values of the infected subjects reflects stochastic extinction occurring soonafter infection introduction, when the behavioral effects are still negligible. Obviously stochastic extinction is rather unlikely for $$\mathrm{BRN}=15$$, whereas it occurs with a much higher probability percentages for the ‘classical SIR’; instead for $$\mathrm{BRN}=2$$ this lower mode is very large.

We may note that even for $$M_{50\%}=200$$ for both $$\mathrm{BRN}=15$$ and $$\mathrm{BRN}=2$$ the effect is remarkable. Qualitatively, both for $$\mathrm{BRN}=15$$ and for $$\mathrm{BRN}=2$$, the mean value of the total number of people that acquired the infection decreases if $$M_{50}$$ decreases, but the variance of the distributions increases. For $$\mathrm{BRN}=2$$, at $$M_{50}=10$$ the distribution is characterized by a large initial peak followed by exponential-like decrease.

As for the extinction time (lower panels of 2), the simulated PDFs are also bimodal, corresponding to “initial” and “final” (i.e., after the outbreak occurred) extinction. Interestingly, for $$\mathrm{BRN}=15$$ the mean values of the extinction time are increasing as $$M_{50}$$ decreases (i.e., when outbreaks occur, the stronger the behavioral response the longer is the epidemic), and also the variances become larger. Moreover, at $$M_{50}=10$$ the PDF is more markedly bimodal. For $$\mathrm{BRN}=2$$ and $$M_{50\%}=10$$ the PDF again shows an initial peak followed by exponential-like decrease.

Note that, for $$\mathrm{BRN}=15$$ the location of PDFs of the extinction time for $$M_{50\%}=50$$ and especially for $$M_{50\%}=10$$ is so rightward that the chosen approximation of neglecting vital dynamics could be questioned. The same holds for $$\mathrm{BRN}=2$$ and $$M_{50\%}=50$$. This suggests that behavioral responses could significantly delay the epidemic extinction time and, not paradoxically, sustain the endemicity of the infection. Both these effects have been observed during the current COVID-19 pandemic.

For the sake of completeness, the right panels of Figures 2 and 3 report analogous results for the case $$\mathrm{BRN}=2$$. Note in particular the much larger stochasticity arising compared to $$\mathrm{BRN}=15$$, a well-known fact.

The PDFs of the maximum reached prevalence and of the time of occurrence of such maximum are reported in the upper and the lower panels of Fig. 3, respectively. For both $$\mathrm{BRN}=15$$ and $$\mathrm{BRN}=2$$, the mean maximum epidemic size (upper panels of Fig. 3) and its variance are rapidly increasing as $$M_{50}$$ increases. For $$\mathrm{BRN}=15$$, the mean and the variance of the time of occurrence of such maximum (lower panels of Fig. 3) are increasing as $$M_{50}$$ decreases. Instead, for $$\mathrm{BRN}=2$$, the mean is nonmonotone with $$M_{50\%}$$, whereas the variance increases.

Summary statistics of the various PDFs of Figs. 2 and 3 are reported, respectively, in Tables 1 and 2.

4.2.2 The effects of the shape of the response function

The effects of the shape of the behavioral response function $$\beta (M)$$, in absence of delays, is summarized by parameter p. Of course, even the threshold $$M_{50\%}$$ plays a fundamental role. Figure 4 reports a sample of the simulated time series of the infectious prevalence with $$M_{50\%} = 200$$, for different values of p (we keep $$\mathrm{BRN}=15$$). This shows three main effects of increasing p. The first is related to the fact that, for $$p>1$$, the function $$\beta (I;p)$$ decreases slower with I, thereby increasing extinction time. This effect is better illustrated by the corresponding PDFs in Fig. 5. The second and the third are more interesting: (i) the maximum epidemic size decreases with p and (ii) the disease prevalence remains at large values for a larger time w.r.t. the case $$p=1$$. Particularly interesting is the case $$p=100$$, whose behavior can be better understood by resorting to the following approximation of function $$\beta (I)$$

\begin{aligned} \beta (I) \approx {\left\{ \begin{array}{ll} \beta (0)\quad \text { if } I<M_{50\%}\\ 0.5\quad \text { if } I=M_{50\%}\\ 0\quad \text { if } I\ge M_{50\%} \end{array}\right. } \end{aligned}

Initially, since for $$I<M_{50\%}$$ it holds $$\beta (I)\approx \beta (0)$$, the epidemic grows free up to the level $$I=M_{50\%}$$. Sooner or later I switches to the value $$M_{50\%}$$ where $$\beta =0.5 \beta (0)$$. However, sooner or later the next contagion event will occur, so that prevalence I reaches the value $$M_{50\%}+1$$ and the transmission rate abruptly falls to $$\beta =0$$. This means that the contagion stops and prevalence will remain constant at the level $$I=M_{50\%}+1$$ until the next removal event occurs, so that the system now switches back and forth around $$M_{50\%}$$. In other words, I(t) will experience for a long time small stochastic oscillations around $$I=M_{50\%}$$ until when through a series of removal events disease extinction is reached.

By decreasing $$M_{50\%}$$ the minimal extinction time remarkably increases. This is better shown in Fig. 5. Figures 6 and 7 report the results for the case BRN $$=$$ 2. As for the total number of infected people, the corresponding simulated PDF gradually switches rightward as p increases (see supplementary figures).

5 Results: Exponentially fading kernels and multiple stochastic epidemic waves

In this section we investigate the effects of delayed social distancing response function $$\beta (M)$$ on the epidemic course. In particular, we will study the EFK case by considering two possible values for the parameter a tuning the delayed response: $$a=0.1$$/day and $$a=0.05$$/day, corresponding to an average response delay of 10 and 20 days, respectively.

We assessed the effects of a delayed behavioral response in both the stochastic and in the deterministic case (see “Appendix”), for $$\mathrm{BRN}=15$$ (Fig. 8) and $$\mathrm{BRN}=2$$ (Fig. 9) and for distinct values of p ($$p=1,2,10$$). Both deterministic and stochastic simulations show that multiple epidemic waves can actually occur, as a consequence of the behavioral response of individuals, when lagged information is used in the response process. The different cases reported in the figures clarify mechanisms and determinants of these waves. Notably, these waves cannot occur in the absence of the delay. In particular, the oscillatory pattern will be more marked the larger the amplitude of the time delay (i.e., the lower a), the sudden the behavioral response (i.e., the larger p), and the larger the response threshold $$M_{50\%}$$.

5.1 Statistical features of simulated epidemics

In what follows, we reports the main statistics of our simulative result where multiple waves occur. To do so, in the computation of the simulated PDFs we did not include those realizations where no second peak was clearly detectable. In the present experiments we keep $$M_{50\%}=50$$, whereas $$a \in \{ 0.05,0.1 \}$$, $$p=1,2,10$$, $$\mathrm{BRN} \in \{ 2,15 \}$$. Figure 10 shows the PDF of infectious prevalence at the first epidemic peak. We note that of course in all cases there is a peak at low prevalence levels, corresponding to a rapid extinction of the epidemic. A second peak occurs for larger values of prevalence. We note that for $$\mathrm{BRN}=2$$ (bottom part of the figure) the PDFs are located at low values of prevalence, they are overlapping and the average values are increasing with p. On the contrary, for $$\mathrm{BRN}=15$$ (top part of the Figure), the PDFs are located at large values of the prevalence, they are not overlapping and the average values are decreasing with p. Obviously, the larger the delay in the behavioral response, the larger the expected magnitude at the first peak.

Figure 11 reports the PDF of the infectious prevalence at the second epidemic peak. As detailed before, this is done only for the case of a large value of the $$\mathrm{BRN}$$ ($$\mathrm{BRN}=15$$), in order to magnify occurrence and detectability of the second wave. For $$a=0.1$$ the prevalence at the second time series peak decreases with p, whereas for $$\mathrm{BRN}=15$$ and $$a=0.05$$ the histograms overlap, but their location appears somewhat nonmonotone with p.

As for the simulated PDF of the time of occurrence of the first epidemic peak (Fig. 12 ), we note that (disregarding the initial peak due to stochastic extinction) for $$\mathrm{BRN}=15$$, the PDFs are well-separated with an average peak-time decreasing in p (from 4 to 8 days), while for $$\mathrm{BRN}=2$$, the PDFs largely overlap especially for longer behavioral response delays. In particular, the effects of the response delay are essentially negligible on the timing of the first peak.

Instead, the corresponding PDFs of the time at the second epidemic peak (still drawn for $$\mathrm{BRN}=15$$ only) reveal (Fig. 13) a marked effect of the time delay in the behavioral response.

We report in Table 3 the main summary statistics of the PDFs shown in the previous figures.

For the sake of completeness, we report also the PDFs of the time to epidemic extinction (Fig. 14). Still disregarding initial stochastic extinction, it can be noted that no relevant role was played by the delay in the behavioral response. However, the dependency on p and the $$\mathrm{BRN}$$ remains more complicated.

As for the epidemic final attack rate, the corresponding simulated PDFs (Fig. 15), suggest—as usual—a major role of the shape of the behavioral response (tuned by p) for $$\mathrm{BRN}=2$$. For $$\mathrm{BRN}=15$$ a counter-intuitive role of the delay emerges at high values of p: for $$p=10$$ and $$a=0.05$$, the PDF of the final attack rate has two nontrivial modes. One of these is the traditional one at high levels of the FAR. The second one occurs for levels of the FAR around value $$20\%$$. This second mode reflects the interesting fact by which a too delayed behavioral response cannot prevent the occurrence of the outbreak but, if the response is sufficiently intense, it can halt it and bringing it to extinction.

Finally, the PDF of the number of nontrivial peaks (Fig. 16) in the more interesting case ($$\mathrm{BRN}=15$$), reveals the number of (detectable) peaks increases with the delay of the behavioral response (that is, for $$a=0.05$$ compared to $$a=0.1$$).

5.2 The filtering effect

For $$\mathrm{BRN} =2$$, Fig. 17 compares, for a single realization of the stochastic process, the simulated time series of the information index M(t) and that of the infectious prevalence I(t). The figure well shows the analogy between the concept of an exponentially fading memory and the concept of ‘low-pass filter’ used in system control theory. Calling these quantities as the (original) ‘signal’ (I(t)) and the ‘filtered signal’ (M(t)), it happens that the signal is noisy and the filtered signal is smooth, for $$a=0.01$$ and for $$(a,p)=(0.1,1)$$, whereas in all the other cases also the filtered signal is noisy, especially for $$a=0.05$$. This is a natural consequence of the fact that the ‘low-pass frequencya is too close to the typical frequency of the stochastic events of I(t). Case $$\mathrm{BRN}=15$$ is shown in Appendix.

6 Concluding remarks

This article investigated the effects of agents’ behavioral responses on the dynamics of stochastic SIR models for epidemic outbreaks. The agents’ behavioral response was represented by means of an information-dependent transmission rate specified as a function of an appropriate information index, as first proposed in [15, 17]. In particular, agents were assumed to respond either to the current or past prevalence of infection, where the latter was specified according either to an exponentially fading memory or to an acquisition-fading memory. This resulted in a family of hybrid stochastic models. In order to numerically simulate specific models belonging to the family, we needed a suitable extension of classical Gillespie algorithm. In particular, we developed analytical formulas valid for two classes of models.

Our analysis provides a thorough classification of the possible outcomes of behaviorally modulated stochastic SIR epidemics depending, besides basic reproduction numbers, on: (i) the form and strength of the behavioral response, (ii) the information time lag with which this behavioral response is enacted by individuals.

This offers a range of theoretical results. For example, even in the absence of delays in the behavioral response (i.e., when the agents’ response is only based on current prevalence), the behavioral response may substantially increase the variance of the extinction time, thereby favoring infection persistence (especially for highly transmissible infections). This behavior-triggered persistence might link with other factors, such as demographics or the appearance of new variants of the pathogen, favoring endemicity, as might sadly be the case with COVID-19. These phenomena becomes richer when the behavioral response is also modulated by past information. In this case, we showed that multiple epidemic waves can result from delayed agents’ responses already in the underlying deterministic models and remain also in the stochastic formulation.

In general the topic of recurrent waves, especially in relation to endemic infectious diseases (e.g., for measles), has been a major topic of mathematical epidemiology over decades [6]. Instead, the issue of multiple waves during an epidemic outbreak has become popular during the pandemic preparedness in the early 2000s. This started from retrospective studies on the 1918–1919 Spanish flu pandemic and developed after the H1N1 2009 pandemic. A variety of explanations were proposed, ranging from exogenous changes in transmissibility [42], to policy intervention [43], to the presence of multiple strains [44], up to behavioral changes [45]. Recently, elegant analytical work has stressed the role of inter-regional commuting in inducing multiple (behavior-unrelated) epidemic waves [46]. The multiple waves observed during the COVID-19 pandemic in industrialized countries were primarily due to the activation and relaxation of social distancing measures during the first pandemic year and to the onset of new variants of concern during 2021 [47], but also behavioral explanations were proposed [48].

In relation to the previous debate, the main innovation of this work lies in the fact that it represents the first general theoretical assessment of the role of delayed behavioral responses in promoting multiple waves in the most basic stochastic setting. This in turn required to consider an innovative formal setting, namely that of Stochastic Hybrid Automata, whose continuous component mirrors (in our case) a distributed delay/memory.

Of course, the proposed model is minimalistic: many refinements can be considered. First, the model represents spontaneous individual behaviors in the simplest manner, i.e., implicitly by the information index approach [15, 17]. As such, the model might also represent a situation where a government uses the same information index to implement a policy of forced behavior change in individuals as, e.g., a lockdown. Modeling behavior in an explicit manner [7, 15, 16] can refine such scenarios.

Further improvements might include: (i) further epidemiological detail, e.g., the presence of a latency period; (ii) the effects of exogenous seasonal fluctuations in transmission; (iii) the combination of individuals’ behavior with governmental responses; (iv) the spatial dimension modeled as continuous or by a discrete metapopulation approach ( [46]): it is well-known that the metapopulation network topology can relevantly impact on disease spread [7, 49]; (v) the presence of multiple pathogen strains; (vi) the possibility that, besides the transmission rate, the behavioral response affects also the recovery rate. For COVID-19 this surely occurred, e.g., in the propensity to testing and self-isolating by pauci-symptomatic individuals; (vii) the modeling of the propagation of information through its articulated interpersonal and virtual networks [49,50,51].