1 Introduction

Memory effects are an important part of disease modeling (Roddam 2001; Sofonea et al. 2021; Liao et al. 2022; Espinoza et al. 2022; Ali et al. 2022; Spitzer et al. 2022; Dönges et al. 2022). Non-pharmaceutical interventions and individuals adapting their behavior in response to the news both fall under this category, and the challenge when implementing these in models is the non-local interaction in time, i.e., that the information about number of infected is delayed.

In this paper, we apply kernel methods from animal population dynamics to epidemiological models as the susceptible-infected-recovered SIR - model and the susceptible-exposed-infected-recovered SEIR - model. These models allow analytical calculation of equilibrium points and their respective stability properties. We follow a modeling tradition which is common in theoretical ecology based on a dynamical systems approach with a distributed time delay incorporated, see Murray (2002), Murray (2001), Roos (2014) and Cushing (2013) and the references therein. A notable feature is that the distributed time delay has the significant advantage of being Markovian. Especially the criterion for an outbreak, local stability in time (i.e., for approximately constant number of susceptibles), and the attack rate are of interest. It is known that using non-pharmaceutical interventions such as lockdowns allows control of the system (Bisiacco and Pillonetto 2021), but we here show that stability comes automatically from adaptive behavior.

First, we investigate the properties of an SEIR-model with added feedback on the activity based on the recent history of the number of infected. Second, we discuss the physiological of these memory effects. Technical details can be found in the appendices.

2 SEIR-model with memory effects and its basic properties

Let us start with the standard stratified SEIR model (Ross 1916; Bastin 2012; Weiss 2013; Li 2018; Martcheva 2015; Arino et al. 2005) with n groups in full generality, where \(S,E,I,R: (0, \infty ) \rightarrow {\mathbb {R}}^n\). Here S denotes the number of susceptible, E the number of exposed, I the number of infectious and R denotes the number of recovered individuals. These functions depend on time \(t \in (0,\infty )\). The coordinates of SEIR counts the group members in the stratification, which may result from a segmentation of the population according to age, occupation, education and others. In addition we may include spatial segmentation into countries, provinces, regions, cities and towns of the population. This gives us the following model

$$\begin{aligned} \left. \begin{aligned} {\dot{S}}\ =&\ - \textrm{diag}(S)\beta I\\ {\dot{E}}\ =&\ \textrm{diag}(S) \beta I - \eta E\\ {\dot{I}}\ =&\ \eta E - \gamma I\\ {\dot{R}}\ =&\ \gamma I \end{aligned}\right. \ \end{aligned}$$
(1)

where \(\textrm{diag}(S)\) denotes a diagonal matrix with the elements of S on the diagonal and the dot denotes differentiation with respect to time t, see for instance Arino et al in Arino et al. (2005). The parameter \(\beta \) is the disease transmission rate and \(\gamma \) is the recovery rate. The SEIR model in (1) is scaled to fractions of the total initial population \(N_p\) such that

$$\begin{aligned} S + E + I + R= & {} \nu \end{aligned}$$
(2)
$$\begin{aligned} \sum _j^n \nu _j= & {} 1\, \end{aligned}$$
(3)

where \(\nu \in (0,1)^n\) is the fraction of the total population in group j. The population of susceptible at time t equals \(S_N(t)=N_p S(t)\), similarly for the exposed \(E_N(t)=N_p E(t)\), the infectious \(I_N(t)=N_p I(t)\), and for the recovered \(R_N(t)=N_p R(t)\). Subscript N in \(S_N, E_N, I_N\), and \(R_N\) refers to the actual number of susceptible, exposed, infected and recovered. We will later look at special cases to simplify certain calculations.

The contact matrix \(\beta \in (0,\infty )^{n\times n}\) holds the rate of interactions between different groups. Such stratification could be ages (interactions between young and old), physical location (different cities or countries), or species (such as mosquitoes and humans) (Bastin 2012; Li 2018; Martcheva 2015). To study the effects of adaptive behaviour, we promote the contact matrix \(\beta \) to be a function of time and infection numbers in the following way:

$$\begin{aligned} \beta _{jk}(t)= & {} (\beta _0)_{jk} - \sum _{m=1}^{n}\int \limits _{-\infty }^{t} \alpha _{jkm}(t-\tau ) I_m(\tau ) d\tau . \end{aligned}$$
(4)

That is, an integration kernel consisting of a linear series of the functions \(\alpha _k\), where \(\alpha _k\) is proportional to a product of \(u^{(k-1)} e^{-\sigma u}\) with \(u=t-\tau \) and an oscillating harmonic part. The first term is considered independent of time, and the second term is responsible for memory effects in the dynamics such as adaptive behavior. The 3-tensor kernel \(\alpha \) may in general be very complicated as long as it satisfies

$$\begin{aligned} \int \limits _{0}^{\infty }\vert (\alpha )_{jkm}(t)\vert dt < \infty ,\quad m=1,2,\ldots ,M. \end{aligned}$$
(5)

The kernel will typically decrease as u increases and otherwise the overall shape of \(\beta \) can be chosen to best represent the given data, e.g., whether it goes to 0 at the origin, which determines whether the feedback is immediate. In mathematical terms, we have a lot of freedom to choose a family of functions for the kernel.

We shall consider a kernel with an oscillating part for modelling e.g. seasonal variations or weekly variations due to shifts in behaviour between work and leisure time in the weekends. We use a kernel previously investigated by Ponosov et al. (2004) but now adding an oscillating term as follows

$$\begin{aligned} \alpha _{k}(u)= & {} c_{k} \frac{\sigma }{(k-1)!}u^{k-1}e^{-\sigma u}\left[ \frac{1}{2} + (\varepsilon _k + i\mu _k) e^{i \omega u} \right] + \text {cc} \quad \textrm{where} \quad u=t-s \;. \end{aligned}$$
(6)

The cc stands for complex conjugation of the preceding terms. We have here suppressed the matrix indices for readability, but all parameters can easily be given more indices if needed. We will also focus on a non-stratified model in this paper.

Note that we can consider a kernel with explicit time dependence \(\alpha _{T}(t, t-\tau )\) as long as it is of the form \(\alpha _T(t, t-\tau ) = c(t) {\tilde{\alpha }}_T(t-\tau )\). This will allow c(t) to be pulled outside the integral and handled as a part of the rest of the differential equations. This is useful, either when looking at seasonal changes (Chowell et al. 2015; Viboud et al. 2016; Chowell et al. 2016) or sub-exponential growth (Brauer 2019). It makes sense to do this in conjunction with a time-dependent \(\beta _0\). To include oscillations in the kernel, depending on the delay time u=t-s, may seem less obvious. But the oscillations in the kernel depending on u could arise from people, who adjust their behavior today on their experience same time last year or same day last week. An example could be risky behavior due to gathering last weekend and in the current weekend people wish to behave less risky by staying home. From a mathematical point of view it is of interest that the linear chain trick can be extended to the case of an oscillating kernel as in Eq. (6). Furthermore, such oscillating kernels appear in physics and here we can mention the delayed Raman response in nonlinear optical fibers (Dudley and Taylor 2010).

The parameters \(\sigma \in ({\mathbb {R}}_+)^{n\times n}\) are positive real numbers, and the positive integers k takes the values \(k=1, 2, \ldots \, N\) with \(N \in {\mathbb {N}}_+\). Furthermore, \(c_k, \omega , \varepsilon _k, \mu _k \in {\mathbb {R}}^{n\times n}\) and \(n \in {\mathbb {N}}\).

2.1 Rewriting the integral kernel as a set of ODEs

In order to solve Eq. (1) numerically using Eq. (6) we apply the linear chain trick transforming the integro-differential equation into a set of ordinary differential equations. This transformation implies two advantages. First, the system of integro-differential equations in (1) can be solved numerically using ordinary differential equation solvers without invoking numerical methods for finding the integral parts. Secondly, stability analysis of equilibrium points for (1) can be conducted using methods from ordinary differential equations. We start by writing

$$\begin{aligned} \alpha _{k}(u) = G_0^k(u) + G_1^k(u) + G_2^k(u) \;, \end{aligned}$$
(7)

where we have introduced

$$\begin{aligned}&G_0^k(u) = \frac{c_k \sigma }{(k-1)!}u^{k-1}e^{-\sigma u}\nonumber \\&G_1^k(u) = \frac{c_k (\varepsilon _k + i\mu _k) \sigma }{(k-1)!}u^{k-1} e^{\left( -\sigma + i\omega \right) u}\nonumber \\&G_2^k = \left( \overline{G_1^k}\right) = \frac{c_k (\varepsilon _k - i\mu _k) \sigma }{(k-1)!}u^{k-1} e^{\left( -\sigma - i\omega \right) u} \end{aligned}$$
(8)

From the Eq. (4) we observe that we need to calculate integrals of the form

$$\begin{aligned} z_k(t) = \int \limits _{-\infty }^{t} \alpha _k(t-s) I(s) ds = z_{k}^{(0)}(t) + z_{k}^{(1)}(t) + z_{k}^{(2)}(t) \;, \end{aligned}$$
(9)

where

$$\begin{aligned}{} & {} z_{k}^{(0)}(t) = \int \limits _{-\infty }^{t} G_0^k(t-s) I(s) ds \;, \quad z_{k}^{(1)}(t) = \int \limits _{-\infty }^{t} G_1^k(t-s) I(s) ds \;,\nonumber \\{} & {} \quad z_{k}^{(2)}(t) = \overline{z_{k}^{(2)}}(t)\;, \end{aligned}$$
(10)

and the bar indicates the complex conjugate.

Applying the linear chain trick as presented in Ponosov et al. (2004) we can find differential equations for \(z_{k}^{(j)}(t)\), \(j=0,1,2\), by differentiating the integrals in (10). The integrals in the delay differential Eq. (4) can thus be replaced by a set of differential equations for \(z_{k}^{(j)}(t)\), using the particular form for \(\alpha _k\) in (6). Differentiating \(z_{k}^{(0)}(t)\) we get

$$\begin{aligned} \frac{dz_{k}^{(0)}(t)}{dt} = G_0^k(0) I(t) + \int \limits _{-\infty }^{t} \frac{d G_0^k(t-s)}{dt} I(s) ds \;. \end{aligned}$$
(11)

For \(k=1\) we have from Eq. (8) that \(G_0^1(u) = c_1 \sigma e^{-\sigma u}\) and accordingly \(G_0^1(0) = c_1 \sigma \) and \(G_0^1(u) \rightarrow 0 \) for \(u \rightarrow \infty \). For \(k=2, 3, \ldots , N\) we have that \(G_0^k(0) = 0\) and \(G_0^k(u) \rightarrow 0 \) for \(u \rightarrow \infty \). We can easily differentiate \(G_0^k\) in (8) with respect to t and use the definition of \(z_{k}^{(0)}(t)\) in (10) to obtain the differential equations for \(z_{1}^{(0)}(t)\) and \(z_{k}^{(0)}(t)\), for \(k=2, 3,\ldots , N\)

$$\begin{aligned} \left. \begin{aligned}&\frac{d z_{1}^{(0)}(t) }{dt} = c_1 \sigma I(t) - \sigma z_{1}^{(0)}(t)\\&\frac{d z_{k}^{(0)}(t) }{dt} = \frac{c_{k}}{c_{k-1}} z_{k-1}^{(0)}(t) - \sigma z_{k}^{(0)}(t) \quad \textrm{for} \quad k=2,3,\ldots , N \;. \end{aligned} \right. \end{aligned}$$
(12)

We now continue by deriving a differential equation for \(z_{k}^{(1)}(t)\) following the procedure for \(z_{k}^{(0)}(t)\). We have

$$\begin{aligned} \frac{d z_{k}^{(1)}(t) }{dt} = G_1^k(0) I(t) + \int \limits _{-\infty }^{t} \frac{d G_1^k(t-s)}{dt} I(s) ds \;. \end{aligned}$$
(13)

From Eq. (8) using \(k=1\) we have \(G_1^1(u) = \sigma c_1 (\varepsilon _1 + i\mu _1) e^{\left( -\sigma + i\omega \right) u}\) and thus \(G_1^1(0) = \sigma c_1 (\varepsilon _1 + i\mu _1)\) and \(G_1^1(u) \rightarrow 0 \) for \(u \rightarrow \infty \). Furthermore, for \(k=2, 3,\ldots , N\) we have \(G_1^k(0) = 0\) and \(G_1^k(u) \rightarrow 0 \) for \(u \rightarrow \infty \). We differentiate \(G_1^k\) in (8) with respect to t and use the definition of \(z_{k}^{(1)}(t)\) in (10) to obtain the differential equations governing \(z_{k}^{(1)}(t)\), for \(k=1, 2, 3, \ldots , N\)

$$\begin{aligned} \left. \begin{aligned}&\frac{d z_{1}^{(1)}(t) }{dt} = \sigma c_1 (\varepsilon _1 + i\mu _1) I(t) + \left( -\sigma + i\omega \right) z_{1}^{(1)}(t)\\&\frac{d z_{k}^{(1)}(t) }{dt} = \sigma \frac{c_k(\varepsilon _k + i\mu _k)}{c_{k-1}(\varepsilon _{k-1} + i\mu _{k-1})} z_{k-1}^{(1)}(t) + \left( -\sigma + i\omega \right) z_{k}^{(1)}(t) \\&\quad \textrm{for} \quad k=2,3,\ldots , N \;. \end{aligned} \right. \end{aligned}$$
(14)

Differential equations for \(z_{k}^{(2)}(t)\), \(k=1,2, \dots , N\), are easily obtained from noting that \(z_{k}^{(2)}(t) = \overline{z_{k}^{(1)}}(t)\) and accordingly we obtain

$$\begin{aligned} \left. \begin{aligned}&\frac{d z_{1}^{(2)}(t) }{dt} = \sigma c_1 (\varepsilon _1 - i\mu _1) I(t) + \left( -\sigma - i\omega \right) z_{13}(t)\\&\frac{d z_{k}^{(2)}(t) }{dt} = \sigma z_{k-1}^{(2)}(t) + \left( -\sigma - i\omega \right) z_{k}^{(2)}(t) \quad \textrm{for} \quad k=2,3,\ldots , N \;. \end{aligned} \right. \end{aligned}$$
(15)

Collecting the above, our aim is to solve the system of differential equations in (12), (14) and (15). Initial conditions are specified for S, I and R. The initial conditions for \(z_{kj}\), \(k=1,2,\ldots ,N\), and \(j=1,2,3\), must also be specified. We have

$$\begin{aligned} \left. \begin{aligned} z_{k}^{(0)}(0) \ =&\ \int \limits _{-\infty }^{0} G_0^k(-s) I(s) ds \\ z_{k}^{(1)}(0) \ =&\ \int \limits _{-\infty }^{0} G_{1}^k(-s) I(s) ds \\ z_{k}^{(2)}(0) \ =&\ \int \limits _{-\infty }^{0} G_{2}^k(-s) I(s) ds \end{aligned}\right. \end{aligned}$$
(16)

In these expressions we need to specify I(s) for \(s \in ( -\infty ; 0]\), which is typically very difficult in realistic systems. Though this is of course also a problem if one wants to determine the initial conditions for I in an SEIR-model without adaptive behaviour. In both cases, fitting infection data to a polynomial is tenable (https://covid19.ssi.dk/analyser-og-prognoser/modelberegninger). In our simulations, we assume that \(I(s)<0\) for \(s \in ( -\infty ; 0]\), simplifying this problem.

2.2 Numerics

For illustration, we restrict ourselves to the simpler form of the kernel

$$\begin{aligned} \alpha (u)= & {} \frac{c_0}{2} u e^{-\sigma t}\left( 1 + (\epsilon + i\mu ) e^{i \omega u} \right) + \text {cc}. \end{aligned}$$
(17)

That is, Eq. (8) for \(k=2\). For this specific kernel (17), the linear chain trick has the following form. We express it in the following real functions

$$\begin{aligned} \left. \begin{aligned} \beta ^0_R(t) = \frac{c_0}{2} e^{(-\sigma + i \omega ) t} + \text {cc},&\quad \quad \beta ^0_I(t) = i\frac{c_0}{2} e^{(-\sigma + i \omega ) t} + \text {cc}\,\\ \beta ^1_R(t) = \frac{c_0}{2} t e^{(-\sigma + i \omega ) t} + \text {cc},&\quad \quad \beta ^1_I(t) = i \frac{c_0}{2} t e^{(-\sigma + i \omega ) t} + \text {cc}\,\\ u^{(0)}(t) = \sum \limits _{m=1}^{M} \int \limits _{-\infty }^{t} \beta ^0_R(t-\tau ) I_m(\tau ) d\tau ,&\quad \quad v^{(0)}(t) = \sum \limits _{m=1}^{M} \int \limits _{-\infty }^{t} \beta ^0_I(t-\tau ) I_m(\tau ) d\tau \,\\ u^{(1)}(t) = \sum \limits _{m=1}^{M} \int \limits _{-\infty }^{t} \beta ^1_R(t-\tau ) I_m(\tau ) d\tau ,&\quad \quad v^{(1)}(t) = \sum \limits _{m=1}^{M} \int \limits _{-\infty }^{t} \beta ^1_I(t-\tau ) I_m(\tau ) d\tau \,\\ \beta _H(t) = c_0 e^{-\sigma t},&\quad \quad \widehat{\beta }(t) = \sum \limits _{m=1}^{M} \int \limits _{-\infty }^{t} \beta _H(t-\tau ) I_m(\tau ) d\tau . \end{aligned}\right. \end{aligned}$$
(18)

We will later set \(n=1\), but as some results are obtainable for general n, we keep it for now. The following differential equation for \(\beta \) in Eq. (4) is

$$\begin{aligned} {\dot{\beta }}_{jk}= & {} -\sum _{m=1}^n \left( \overbrace{\alpha (0)}^{=0}I_m(t) + \int \limits _{-\infty }^{t} \partial _t \alpha (t-\tau ) I_m(\tau ) d\tau \right) + \text {cc}\nonumber \\= & {} -\frac{c_0}{2} \sum _{m=1}^n \int \limits _{-\infty }^{t} e^{-\sigma (t-\tau )}\left[ \left( 1 + (\epsilon + i\mu ) e^{i \omega (t-\tau )} \right) \left( 1 -\sigma t \right) \right. \nonumber \\{} & {} \left. + i\omega t (\epsilon +i\mu ) e^{i\omega (t-\tau )} \right] I_m(\tau ) d\tau + \text {cc}\nonumber \\= & {} -\sigma \left( \beta _{jk} - (\beta _0)_{jk} \right) - \widehat{\beta } - \omega (\epsilon - \mu )u^{(1)} - \omega (\epsilon + \mu )v^{(1)} \end{aligned}$$
(19)

and similarly for the helper functions we get

$$\begin{aligned} \left. \begin{aligned} \dot{\widehat{\beta }}&= c_0 \left( 1+\epsilon \right) \sum \limits _{m=1}^{n}I_m - \sigma \widehat{\beta }\\ {\dot{u}}^{(1)}&= u^{(0)} - \sigma u^{(1)} + \omega v^{(1)}\\ {\dot{v}}^{(1)}&= v^{(0)} - \sigma v^{(1)} - \omega u^{(1)}\\ {\dot{u}}^{(0)}&= c_0 \left( 1+\epsilon \right) \sum \limits _{m=1}^{n}I_m - \sigma u^{(0)} + \omega v^{(0)}\\ {\dot{v}}^{(0)}&= c_0 \left( 1+\epsilon \right) \sum \limits _{m=1}^{n}I_m - \sigma v^{(0)} - \omega u^{(0)} \end{aligned}\right. \end{aligned}$$
(20)

This gives us a set of differential equations that describes our system

$$\begin{aligned} \left. \begin{aligned} {\dot{S}}\ =&\ - \textrm{diag}(S)\beta I\\ {\dot{E}}\ =&\ \textrm{diag}(S) \beta I - \eta E\\ {\dot{I}}\ =&\ \eta E - \gamma I\\ {\dot{R}}\ =&\ \gamma I\\ {\dot{\beta }}\ =&\ -\sigma \left( \beta - (\beta _0) \right) - \widehat{\beta } - \omega (\epsilon - \mu )u^{(1)} - \omega (\epsilon + \mu )v^{(1)}\\ \dot{\widehat{\beta }}\ =&\ c_0 \left( 1+\epsilon \right) \sum \limits _{m=1}^{n}I_m - \sigma \widehat{\beta }\\ {\dot{u}}^{(1)}\ =&\ u^{(0)} - \sigma u^{(1)} + \omega v^{(1)}\\ {\dot{v}}^{(1)}\ =&\ v^{(0)} - \sigma v^{(1)} - \omega u^{(1)}\\ {\dot{u}}^{(0)}\ =&\ c_0 \left( 1+\epsilon \right) \sum _{m=1}^{n} I_m - \sigma u^{(0)} + \omega v^{(0)}\\ {\dot{v}}^{(0)}\ =&\ c_0 \left( 1+\epsilon \right) \sum _{m=1}^{n} I_m - \sigma v^{(0)} - \omega u^{(0)} \end{aligned}\right. \end{aligned}$$
(21)

with the initial conditions \(\beta = \beta _0\) and \(\widehat{\beta } = u^{(1)} = v^{(1)} = u^{(0)} = v^{(0)} = 0\). That is, we assume there has been no infection before \(t=0\).

Numerical results illustrating the effect of the delay are shown in Fig. 1, using the parameter values in Table 1. We consider the scalar case of the dependent variables S, E, I and R corresponding to \(n=1\).

Fig. 1
figure 1

Plots of SEIR-model with adaptive behaviour. Parameter values are taken from Table 1 and using \(n=1\), that is we consider S, E, I and R to be scalars. Top left: The classical variables S, E, I, and R. Bottom left: The auxiliary variables from Eq. (18) that pertain to the contact rate. Note that \(\beta \) stays positive for all times. Top right: Plot of the integral kernel from Eq. (17) used in the simulation. Bottom right: Comparison of the I-state for an SEIR-model with the same time parameters, but with and without adaptive behaviour. (The one without adaptive behaviour simply has \(c_0=0\)

2.3 Equilibrium points and stability

The results for \(t\rightarrow \infty \) are of course still determined by depletion of susceptibles, but as long as the number of susceptibles is assumed to be roughly constant, the memory effects have interesting consequences, such as stability of the number of infections on short time scales. This explains why a contact number around 1 is observed more often in real-world systems than a traditional exponential model would suggest. We investigate these in detail with the example kernel in Eq. (17).

Leaving out the recovered state R through normalization and assuming approximately constant number of susceptibles S, the Jacobian is

$$\begin{aligned} J= & {} \left( \begin{array}{c|cccccccc} &{} \partial _{E_j} &{} \partial _{I_j} &{} \partial _{\beta _{jm}} &{} \partial _{\widehat{\beta }} &{} \partial _{u^{(1)}} &{} \partial _{v^{(1)}} &{} \partial _{u^{(0)}} &{} \partial _{v^{(0)}}\\ \hline {\dot{E}}_{k} &{} -\eta &{} S_k \beta _{kj} &{} S_j I_m &{} 0 &{} 0 &{} 0 &{} 0 &{} 0\\ {\dot{I}}_{k} &{} \eta &{} -\gamma &{} 0 &{} 0 &{} 0 &{} 0 &{} 0 &{} 0\\ {\dot{\beta }}_{kn} &{} 0 &{} 0 &{} -\sigma \delta _{jk} \delta _{mn} &{} -1 &{} -\omega (\epsilon - \mu ) &{} -\omega (\epsilon + \mu ) &{} 0 &{} 0\\ \dot{\widehat{\beta }} &{} 0 &{} c_0 \left( 1+\epsilon \right) &{} 0 &{} -\sigma &{} 0 &{} 0 &{} 0 &{} 0\\ {\dot{u}}^{(1)} &{} 0&{} 0 &{} 0 &{} 0 &{} -\sigma &{} \omega &{} 1 &{} 0\\ {\dot{v}}^{(1)} &{} 0 &{} 0 &{} 0 &{} 0 &{} -\omega &{} -\sigma &{} 0 &{} 1\\ {\dot{u}}^{(0)} &{} 0&{} c_0 \left( 1+\epsilon \right) &{} 0 &{} 0 &{} 0 &{} 0 &{} -\sigma &{} \omega \\ {\dot{v}}^{(0)} &{} 0 &{} c_0 \left( 1+\epsilon \right) &{} 0 &{} 0 &{} 0 &{} 0 &{} -\omega &{} -\sigma \end{array}\right) \end{aligned}$$
(22)

Note that u, v, and \(\widehat{\beta }\) do not need indices, but \(\beta \) and \(\beta _0\) do because we may want \(n>1\).

2.3.1 Disease free

Let us start with the trivial disease-free equilibrium point

$$\begin{aligned} \left. \begin{aligned} E^*_j = I^*_j = \widehat{\beta }^*_{jk}\ =\ (u^{(1)})^* = (v^{(1)})^*\ =&\ (u^{(0)})^* = (v^{(0)})^* = 0\\ \beta ^*\ =&\ \beta _0 \end{aligned}\right. \end{aligned}$$
(23)

The Jacobian (22) reduces to

$$\begin{aligned} J_{DF}= & {} \left( \begin{array}{cccccccc} -\eta &{} S_k (\beta _0)_{kj} &{} 0 &{} 0 &{} 0 &{} 0 &{} 0 &{} 0\\ \eta &{} -\gamma &{} 0 &{} 0 &{} 0 &{} 0 &{} 0 &{} 0\\ 0 &{} 0 &{} -\sigma \delta _{jk} \delta _{mn} &{} -1 &{} -\omega (\epsilon - \mu ) &{} -\omega (\epsilon + \mu ) &{} 0 &{} 0\\ 0 &{} c_0 \left( 1+\epsilon \right) &{} 0 &{} -\sigma &{} 0 &{} 0 &{} 0 &{} 0\\ 0 &{} 0 &{} 0 &{} 0 &{} -\sigma &{} \omega &{} 1 &{} 0\\ 0 &{} 0 &{} 0 &{} 0 &{} -\omega &{} -\sigma &{} 0 &{} 1\\ 0 &{} c_0 \left( 1+\epsilon \right) &{} 0 &{} 0 &{} 0 &{} 0 &{} -\sigma &{} \omega \\ 0 &{} c_0 \left( 1+\epsilon \right) &{} 0 &{} 0 &{} 0 &{} 0 &{} -\omega &{} -\sigma \end{array}\right) \nonumber \\ \end{aligned}$$
(24)

Note that all blocks but \(S_j (\beta _0)_{jk}\) are proportional to the identity matrix, so we may diagonalize that block on its own and relate the eigenvalues \(x_{S\beta _0}\) of \(\textrm{diag}(S)\beta _0\) to those of \(J_{DF}\). The largest eigenvalue (i.e. the one that potentially can be positive) is

$$\begin{aligned} EV_{\textrm{max}}= & {} \frac{-\eta - \gamma + \sqrt{\eta ^2 - 2 \eta \gamma + \gamma ^2 + 4\eta x_{S\beta _0}}}{2} \end{aligned}$$
(25)

So the condition is \(x_{S\beta _0} < \gamma \) for the disease-free equilibrium point to be stable. This corresponds to a reproduction number

$$\begin{aligned} R_{ND} = \frac{S\beta _0}{\gamma } \end{aligned}$$
(26)

above 1 in a normal SEIR-model. This is significant, because it shows that feedback of the kind (17) cannot change whether or not there will be an outbreak, only the severity of it.

Table 1 Parameter values used in Fig. 1

2.3.2 Equilibrium point during outbreak

It turns out that there is also an equilibrium point during an outbreak

$$\begin{aligned} \left. \begin{aligned} \widehat{\beta }^*\ =&\ \frac{c_0 \left( 1+\epsilon \right) }{\sigma } \sum _{m=1}^{M} I^*_m\\ (u^{(0)})^*\ =&\ \frac{c_0\left( \sigma + \omega \right) \left( 1+\epsilon \right) }{{\sigma }^2 + {\omega }^2} \left( \sum _{m=1}^{M} I^*_m\right) \\ (v^{(0)})^*\ =&\ \frac{c_0\left( \sigma - \omega \right) \left( 1+\epsilon \right) }{{\sigma }^2 + {\omega }^2} \left( \sum _{m=1}^{M} I^*_m\right) \\ (u^{(1)})^*\ =&\ \frac{\sigma (u^{(0)})^* + \omega (v^{(0)})^*}{{\sigma }^2 + {\omega }^2}\ =\ \frac{c_0 \left( 1+\epsilon \right) \left( {\sigma }^2 - {\omega }^2 + 2 \sigma \omega \right) }{\left( {\sigma }^2 + {\omega }^2\right) ^2} \left( \sum _{m=1}^{M} I^*_m\right) \\ (v^{(1)})^*\ =&\ \frac{\sigma (v^{(0)})^* - \omega (u^{(0)})^*}{{\sigma }^2 + {\omega }^2}\ =\ \frac{c_0 \left( 1+\epsilon \right) \left( {\sigma }^2 - {\omega }^2 - 2 \sigma \omega \right) }{\left( {\sigma }^2 + {\omega }^2\right) ^2} \left( \sum _{m=1}^{M} I^*_m\right) \\ \beta ^*\ =&\ \beta _0 - \frac{\widehat{\beta }^* + \omega (\epsilon - \mu )(u^{(1)}) + \omega (\epsilon + \mu )(v^{(1)}) }{\sigma }\\ E^*\ =&\ \frac{\gamma }{\eta }I^*\\ \beta _0 I^*\ =&\ \textrm{diag}\left( S\right) ^{-1}\gamma I^* + c_0 \left( 1+\epsilon \right) \left( \frac{1}{{\sigma }^2} + 2 \frac{\omega }{\sigma } \frac{\epsilon \left( {\sigma }^2 - {\omega }^2\right) - 2\sigma \omega \mu }{\left( {\sigma }^2 + {\omega }^2\right) ^2}\right) \\&\left( \sum _{m=1}^{M} I^*_m\right) I^* \end{aligned}\right. \end{aligned}$$
(27)

The last condition on I is very difficult to solve in general, especially because the quantity \(\sum \limits _{m=}^{n}I^*_m\) is not invariant under diagonalization of \(\beta _0\). We therefore continue with a single group (i.e., \(n=1\)) to see what properties can be divined in this case. This reduces the equilibrium point equations to

$$\begin{aligned} I^* \ =&\ \frac{\beta _0 - \gamma /S}{c_0 \left( 1+\epsilon \right) \left( \frac{1}{{\sigma }^2} + 2 \frac{\omega }{\sigma } \frac{\epsilon \left( {\sigma }^2 - {\omega }^2\right) - 2\sigma \omega \mu }{\left( {\sigma }^2 + {\omega }^2\right) ^2}\right) }\nonumber \\ \widehat{\beta }^*\ =&\ \frac{c_0 \left( 1+\epsilon \right) }{\sigma } I^*\nonumber \\ E^*\ =&\ \frac{\gamma }{\eta }I^*\nonumber \\ (u^{(0)})^*\ =&\ \frac{c_0 \left( 1+\epsilon \right) \left( \sigma + \omega \right) }{{\sigma }^2 + {\omega }^2} I^*\nonumber \\ (v^{(0)})^*\ =&\ \frac{c_0 \left( 1+\epsilon \right) \left( \sigma - \omega \right) }{{\sigma }^2 + {\omega }^2} I^*\nonumber \\ (u^{(1)})^*\ =&\ \frac{c_0\left( 1+\epsilon \right) \left( {\sigma }^2 - {\omega }^2 + 2 \sigma \omega \right) }{\left( {\sigma }^2 + {\omega }^2\right) ^2} I^*\nonumber \\ (v^{(1)})^*\ =&\ \frac{c_0\left( 1+\epsilon \right) \left( {\sigma }^2 - {\omega }^2 - 2 \sigma \omega \right) }{\left( {\sigma }^2 + {\omega }^2\right) ^2} I^*\nonumber \\ \beta ^*\ =&\ \frac{\gamma }{S} \end{aligned}$$
(28)

We require \(I>0\), which means that the non-damped reproduction number has to be larger than 1, corresponding to an ongoing epidemic. (By non-damped we mean \(c_0 = 0\) where there is no feedback.) It is clear that below this point, we transition to the disease-free equilibrium point. This assumes that the denominator in \(I^*\) is positive. Note that negative denominator does not make physical sense, as we then get more infected when the contact rate is lowered.

We also implicitly assume that \(I^*\ll S\). Otherwise the change in susceptibles will play a role in the dynamics.

For the sake of stability analysis, we start by looking at a simplified case where \(\omega =0\), and then treat the full version numerically. First we take the case \(\omega = 0\). As discussed above, this is a very physiologically relevant case. For simplicity, we also set \(\epsilon =\mu =0\) as these may otherwise simply be absorbed in \(c_0\). Here the equilibrium point for \(M=1\) is

$$\begin{aligned} \left. \begin{aligned} I^*\ =&\ \frac{{\sigma }^2}{c_0 S}\left( R_{ND}-1\right) \gamma \\ E^*\ =&\ \frac{\gamma }{\eta }I^*\\ \beta ^*\ =&\ \frac{\gamma }{S}\\ \widehat{\beta }^*\ =\ (u^{(0)})^*\ =\ (v^{(0)})^*\ =&\ \frac{\sigma }{S}\left( R_{ND} - 1 \right) \gamma \\ (u^{(1)})^*\ =&\ (u^{(0)})^*/\sigma \\ (v^{(1)})^*\ =&\ (v^{(0)})^*/\sigma \end{aligned}\right. \end{aligned}$$
(29)

Note an important, but perhaps unsurprising feature here. As \(c_0\sim \sigma ^2\) for a normalized version of the kernel in (17), the stable level of infection I depends only on the integral of the kernel. So epidemic non-pharmaceutical interventions may be spread out over a period of time, or they may be strict and fast. It gives the same level of infection.

The variables \(u^{(0)}\), \(v^{(0)}\), \(u^{(1)}\), and \(v^{(1)}\) drop out of the dynamics, and the relevant part of the Jacobian (22) therefore reduces to

$$\begin{aligned} J_{\omega =0}= & {} \left( \begin{array}{cccc} -\eta &{} \gamma &{} \frac{{\sigma }^2}{c_0} \left( R_{ND} - 1 \right) \gamma &{} 0\\ \eta &{} -\gamma &{} 0 &{} 0 \\ 0 &{} 0 &{} -\sigma &{} -1 \\ 0 &{} c_0 &{} 0 &{} -\sigma \end{array}\right) . \end{aligned}$$
(30)

We will use the Routh-Hurwitz theorem to determine the stability of the system, specifically the formulation from Nordbø et al. (2007). The characteristic polynomial for the Jacobian is

$$\begin{aligned} P^J_{\omega = 0}(x)= & {} x^4 + a_1 x^3 + a_2 x^2 + a_3 x + a_4. \end{aligned}$$
(31)

where

$$\begin{aligned} \left. \begin{aligned} a_1\ =&\ \eta + \gamma + 2 \sigma \\ a_2\ =&\ 2 \sigma (\eta + \gamma + \sigma )\\ a_3\ =&\ \sigma ^2(\eta + \gamma )\\ a_4\ =&\ \eta \sigma ^2 \left( R_{ND} - 1 \right) \gamma \end{aligned}\right. \end{aligned}$$
(32)

These are all positive, because \(R_{ND} = \beta _0 S / \gamma \ge 1\). Using the definitions from Nordbø et al. (2007)

$$\begin{aligned} \begin{aligned} \mathbf {D_1} = a_1\,\ \mathbf {D_2} = \left( \begin{matrix} a_1 &{}\quad a_3\\ 1 &{}\quad a_2 \end{matrix}\right) \,\ \mathbf {D_3}&= \left( \begin{matrix} a_1 &{}\quad a_3 &{}\quad 0\\ 1 &{}\quad a_2 &{}\quad a_4\\ 0 &{}\quad a_1 &{}\quad a_3 \end{matrix}\right) \,\ \mathbf {D_4} = \left( \begin{matrix} a_1 &{}\quad a_3 &{}\quad 0 &{}\quad 0\\ 1 &{}\quad a_2 &{}\quad a_4 &{}\quad 0\\ 0 &{}\quad a_1 &{}\quad a_3 &{}\quad 0\\ 0 &{}\quad 1 &{}\quad a_2 &{}\quad a_4 \end{matrix}\right) . \end{aligned}\nonumber \\ \end{aligned}$$
(33)

From the condition \(\det (\mathbf {D_4})>0\) we find

$$\begin{aligned} 1&< \frac{S(0) \beta _0}{\gamma } = R_{ND} \nonumber \\&< \frac{\eta \gamma (\eta + \gamma )^2 + 2 (\eta + \gamma ) (\eta ^2 + 4 \eta \gamma + \gamma ^2) \sigma + 4 (\eta ^2 + 3 \eta \gamma + \gamma ^2) \sigma ^2 + 2 (\eta + \gamma ) \sigma ^3}{\eta \gamma (\eta + \gamma + 2 \sigma )^2}. \end{aligned}$$
(34)

There is also a root of \(\det (\mathbf {D_3})\) at this point, but as \(\textrm{sign}(a_1) = \textrm{sign}(a_3)\), there is still a Hopf bifurcation when this criterion is not satisfied (Nordbø et al. 2007).

Note an interesting property of Eq. (34). The stability of the equilibrium point is independent of \(c_0\), and the interpretation seems to be the following: As long as the feedback is non-zero, it cannot change the stability of the equilibrium point, only the position. A sign change would give rise to an equilibrium point at negative I, which in turn would change the sign of the integral in Eq. (4). This is of course purely formal as \(I<0\) is unphysical. It is merely to explain the absence of \(c_0\) in the stability condition. Numerics shows that the transition is between a stable equilibrium point and a stable limit cycle, see Fig. 2, left column.

Fig. 2
figure 2

Phase space and stability for \(\omega \) and \(\beta _0\) using \(n=1\). We keep S constant to illustrate the local stability in time. We choose three set of parameters that are unstable, critical, and unstable for \(\omega =0\), using Eq. (34), and then vary \(\omega \) to analyse changes in stability. The parameters are \(\gamma = \eta = 1/3.5,\ c_0 = 5.5,\ \sigma = 0.5,\ S = 0.8,\ \epsilon =\mu =0.5\) for all the configurations and \(\beta _0 = 1.319,\ 1.519,\ 1.719\) for the stable, critical, and unstable configurations respectively (top, middle, and bottom row respectively), corresponding to non-damped generation numbers of 3.70, 4.25, and 4.81 respectively. The initial conditions are chosen according to the equilibrium point from Eq. (28), but with I varied to show convergence of different paths. We have omitted runs that exit the interval \(E+I\in [0,1]\) as they are unphysical. These typically display large oscillations. We also use \(\max (\beta ,0)\) instead of \(\beta \) in the RHS of Eq. 21. We see that \(\omega \) does indeed allow changes in stability, but mostly around the critical point

2.3.3 Numerical stability analysis of full model

We start by choosing parameters just above, below, and at the critical point in Eq. (34) for \(\omega =0\). This shows the transition is between a stable point and a stable limit cycle. When increasing \(\omega \), the limit cycles increase radius to the point where the I-state exits the physical interval [0, 1]. See Fig. 2.

We then investigate the effects of varying \(\epsilon \) and \(\mu \) for both the stable and unstable configurations. It turns out that the important transitions here happen at \(\mu =0\) and \(\epsilon =0\). See “Appendix A”.

Fig. 3
figure 3

Connection between the initial non-damped reproduction number \(R_{ND, 0}\) and the attack rate \(R(\infty )\) for the kernel (17) using \(n=1\). The black line indicates \(R_{ND, 0} = -\frac{\ln \left( 1 - R(\infty )\right) }{R(\infty )}\), which is the relation for no dampening. The red point are generated by uniformly sampling parameters in the intervals \(\eta ,\gamma \in [0.1,1]\), \(\beta _0 \in [\gamma , 2]\), and \(c_0 \in [0.1,5], \sigma \in [0.1,1], \omega \in [0,1], \mu , \epsilon \in [-0.4,0.4]\), so the kernel is always positive. We see that all points lie to the right of the black line, indicating a lower attack rate than one would expect from a non-damped system (\(c_0 = 0\))

2.4 Physiological bounds on the parameters

In order to make realistic examples, let us briefly take a look at physiological scope of each parameter. Since we assume vanishing change in S in the section, we must first and foremost require \(S+E+I\le 1\Rightarrow I^*(1+\frac{\gamma }{\eta })\le 1-S\). This gives conditions on the feedback parameters through

$$\begin{aligned} \frac{\beta _0 - \gamma /S}{c_0 \left( 1+\epsilon \right) \left( \frac{1}{{\sigma }^2} + 2 \frac{\omega }{\sigma } \frac{\epsilon \left( {\sigma }^2 - {\omega }^2\right) - 2\sigma \omega \mu }{\left( {\sigma }^2 + {\omega }^2\right) ^2}\right) } \le \frac{S}{1 + \gamma /\eta } \end{aligned}$$
(35)

for the general case and

$$\begin{aligned} \frac{{\sigma }^2\left( \beta _0 - \frac{\gamma }{S}\right) }{c_0} \le \frac{S}{1 + \gamma /\eta } \end{aligned}$$
(36)

for \(\epsilon =\mu =\omega =0\). These are necessary conditions, but unfortunately not sufficient ones if the trajectories of E and I go above \(1-S\) on their way to the equilibrium point. This may even be the case if \(I(0)<I^*\), see Fig. 2.

Note that \(\gamma \) and \(\eta \) are typically equilibrium by the nature of the disease, though \(\gamma \) can be artificially lowered by testing the population and putting positive cases in isolation. In terms of physical size, both \(\sigma \) and \(\omega \) have units of inverse time and it is unrealistic to have feedback that reacts faster than a day, unless the population have access to their own tests and report the results immediately (and accurately). We therefore consider \(\sigma ,\omega < 1\ { \mathrm days}^{-1}\).

We also require \(\beta \ge 0\) at all times. A rough estimate can be obtained through Eqs. (4) and (17), where we for simplicity assume \(\epsilon =\mu =\omega =0\).

$$\begin{aligned} \int \limits ^t_{-\infty } \alpha (t-\tau )I(\tau )d\tau \ {}\le & {} (1-S) \int \limits ^t_{-\infty } \alpha (t-\tau )d\tau \ \nonumber \\= & {} (1-S) \int \limits ^{\infty }_{0} \alpha (u)du\ =\ (1-S) \frac{c_0}{\sigma ^2}\ \le \ \beta _0 \end{aligned}$$
(37)

If the Eq. (21) are implemented as they stand, it is difficult to satisfy Eqs. (35) and (37) at the same time, because we only control \(c_0\) and \(\sigma \). However, as non-pharmaceutical interventions hardly are implemented to satisfy Eq. (37), we replace \(\beta \) by \(\max (0, \beta )\) by hand on the RHS of Eq. (21). The numerics show that the trajectory still converges to either a stable limit cycle or a stable equilibrium point, see Fig. 2.

2.5 Attack rate

A different interesting question to ask is the effects of the feedback on the attack rate, i.e. \(R(\infty )\). Note that at the end of the epidemic, the I-state is almost empty, and it is therefore tempting to think that the feedback does not affect the attack rate. This turns out not to be the case, as can be seen from the following. Start with the fraction of the S- and R-equations in the non-stratified model

$$\begin{aligned} \frac{dS}{dR}= & {} -\frac{S \beta }{\gamma }\ =\ -\frac{S \beta _0}{\gamma } + \frac{S}{\gamma } \int \limits _{-\infty }^{t} \alpha (t-\tau ) I(\tau ) d\tau \nonumber \\ \int \frac{dS}{S}= & {} - \int \frac{\beta _0}{\gamma }dR + \frac{1}{\gamma } \int \int \limits _{-\infty }^{t} \alpha (t-\tau ) I(\tau ) d\tau dR\nonumber \\ \ln \left( \frac{S(\infty )}{S(-\infty )}\right)= & {} -\frac{\beta _0}{\gamma }\left( R(\infty ) - R(-\infty )\right) - \frac{1}{\gamma } \int \int \limits _{-\infty }^{t} \alpha (t-\tau ) I(\tau ) d\tau dR \end{aligned}$$
(38)

If we assume \(S(-\infty ) \approx 1\) and \(R(-\infty ) \approx 0\), the first terms simplify. Reapplying \(dR = \gamma I dt\) and shifting the \(\tau \)-integral, we can rewrite the last term as

$$\begin{aligned} \ln \left( 1 - R(\infty )\right)= & {} -\frac{\beta _0}{\gamma }R(\infty ) - \int \limits _{-\infty }^{\infty } \int \limits _{-\infty }^{0} I(t) \alpha (-\tau ) I(\tau + t) d\tau dt\nonumber \\= & {} -R_{ND, 0}R(\infty ) - \int \limits _{-\infty }^{\infty } \int \limits _{0}^{\infty } I(t) \alpha (\tau ) I(t - \tau ) d\tau dt\, \end{aligned}$$
(39)

where \(R_{ND, 0}\) denotes the initial non-damped reproduction number. (As \(\beta (t = 0) = \beta _0\), we could also just call this the initial reproduction number.) While the second term is a complicated integral to handle in general, we can draw some conclusions from it. As long as \(\alpha (\tau )\ge 0\), which is the case for our kernel when \(\epsilon \cos \left( \arctan (\mu /\epsilon )\right) + \mu \sin \left( \arctan (\mu /\epsilon )\right) \ge -1\), we can be certain that the integrand is non-negative too. This means that attack rate for a given initial reproduction number will be lower than one would expect for a standard SEIR-model. See Fig. 3 for a numerical check of this. A more general, but less transparent calculation for a stratified model (\(n>1\)) can be found in “Appendix B”.

3 Physiological interpretation of memory effects

While it is clear that non-pharmaceutical interventions as well as a population reading about high rates of infection in the news and therefore changing their behavior are obvious examples of memory effects, we would like to briefly discuss the physiological interpretation in more details.

If we start with \(\omega =0\), we only have a dampening from the kernel in Eq. (17). So whenever the recent number of infectious has been high, the activity decreases. The behavioral part is not limited to individual choice. Governmental non-pharmaceutical interventions, such as local lockdowns or extra tests in areas with high rates of infection, of course restrict activity based on recent history of infection, but it may also come from increased focus in the media leading to more cautious behavior. It may also come naturally, i.e. without testing the population, from the acquired immunity. If the option of moving from S to R is included, a lingering but waning immunity would take the same kernel form, where infectiousness diminishes for some time. Note that self-isolation does not take this form as it is immediate in time, i.e. the individual isolates based on their own illness, not the previous illness of the population.

The interpretation of \(\omega >0\) should be seen more exclusively as behavioral. It allows for a momentary increase in activity based on a previous wave of infection. Unless the disease weakens individuals and makes secondary infection more likely, this will not happen naturally. However, after a period of either lockdown or self-isolation, humans may be inclined to compensate socially, and thus a wave of infection may be followed by first a period of lower activity and then one of higher. In other words, as we are more social than logical beings, an oscillatory kernel may be very relevant for description of adaptive behavior.

Transmission of a disease may also vary over one week due to different social behaviour in workdays as opposed to weekends. In this case the period of the oscillating disease transmission is 7 days.

4 Conclusion

We have implemented a feedback mechanism in epidemic models and illustrated its properties. This is useful for modelling adaptive behaviour and non-pharmaceutical interventions, which are both central in epidemic control.

The feedback dampening cannot prevent an outbreak from happening, as the stability of the disease-free equilibrium point does not depend on the kernel. Instead, the feedback can create equilibrium points locally in time as well as decrease the attack rate, so the severity of the outbreak can be contained.

The existence of a stable equilibrium point on short timescales is noteworthy, because it explains how the effective generation number of many countries during the COVID19-pandemic stayed consistently close to 1, which is impossible in normal SIR-type models without fine-tuning.

We have also shown that the feedback affects the attack rate \(R(\infty )\). This is important, because it shows that non-pharmaceutical interventions reduce the number of people that need to be infected on long time scales, instead of simply postponing the time of infection, which would otherwise be reasonable to assume.