1 Introduction

A metapopulation is an assemblage of local populations connected via migration. The first mathematical metapopulation model was introduced by Levins (1969, 1970). He described the dynamics of the fraction of occupied patches based on local population extinctions and recolonizations. Even though the Levins’ classical model ignored the local population dynamics, it provided the important conceptual base on the future progress of metapopulation theory. Now, as anthropogenic alteration accelerate around the world and increasing number of species suffer from habitat fragmentation, the metapopulation setting is receiving ever more attention (e.g., Hanski and Gilpin 1997; Hanski 1999; Hanski and Gaggiotti 2004; Bulman et al. 2007; Wilson et al. 2009; Hanski et al. 2011; Schippers et al. 2011; Seppänen et al. 2012).

Since Darwin, we have understood that evolution interweaves with ecology everywhere. The most intuitive evolutionary question concerning metapopulations is, what selects for and against dispersal. Dispersal is costly but has also benefits for the dispersing individuals (Hamilton and May 1977; Gandon and Michalakis 2001). On the other hand, it is the key feature for patch recolonization and metapopulation viability. Unsurprisingly, there exist numerous studies on evolution of dispersal in general (e.g., Hamilton and May 1977; Comins et al. 1980; Motro 1982a, b, 1983) and in metapopulations (e.g., Clobert et al. 2001; Gyllenberg et al. 2002; Cadet et al. 2003; Parvinen et al. 2003; Parvinen 2006). Obviously, as one may observe nature full of amazing adaptations, researchers have investigated evolutionary questions in metapopulations on many other traits, such as local adaptation (Kisdi 2002), specialization (Parvinen and Egas 2004; Nurmi et al. 2008; Nurmi and Parvinen 2008), reproductive effort (Ronce et al. 2000) or cooperation (Parvinen 2011) only to mention few.

To study evolutionary dynamics Metz et al. (1992) defined invasion fitness as the long-term exponential growth rate r of a rare mutant in an environment set by the resident. A positive invasion fitness implies that the mutant population is able to grow and possibly replace the resident. Adaptive dynamics (Metz et al. 1996; Geritz et al. 1997, 1998) now has grown to a wide set of tools to study evolution and has been applied broadly, also within interdisciplinary goals (Dieckmann et al. 2002; Ferrière et al. 2004, Dieckmann and Metz, in press).

In metapopulation models, calculating the invasion fitness can be difficult. Therefore, Metz and Gyllenberg (2001) and Gyllenberg and Metz (2001) defined the metapopulation reproduction ratio \(R_{m}\) as the expected number of mutant dispersers produced by a local mutant colony initiated by one mutant disperser. This concept is analogous to the basic reproduction ratio, widely used in epidemiological models, with the difference that it operates between dispersal generations instead of traditional reproductive generations. The logarithm of \(R_{m}\) is sign-equivalent with the invasion fitness r, so that \(r>0\) if and only if \(R_{m}>1\). Thus, \(R_{m}\) is a proxy for invasion fitness. This approach has been applied to various types of metapopulation models, including models with large local populations defined in continuous time (Gyllenberg and Metz 2001; Metz and Gyllenberg 2001; Gyllenberg et al. 2002; Parvinen 2002; Parvinen et al. 2003; Parvinen and Egas 2004) or in discrete time (Parvinen 2006, 2007; Nurmi et al. 2008; Nurmi and Parvinen 2008, 2011), as well as metapopulation models with small local populations with locally stochastic population dynamics defined in continuous time (Gyllenberg and Metz 2001; Metz and Gyllenberg 2001; Parvinen et al. 2003; Parvinen and Metz 2008; Parvinen 2011).

In some cases the population sharing the same heritable trait consists of several types of individuals, which we here call stages. For example, taking maturing or development into account results in juvenile and adult stages. Thus, dispersers can also be of different types. Parvinen and Metz (2008) generalized the definition of \(R_{m}\) to such a case. The idea is to calculate the expected numbers of dispersers of type j produced by a mutant clan initiated with a single mutant of type i, and then to collect these values into a matrix \(\mathbf {M}\). The metapopulation reproduction ratio is then the dominant eigenvalue of the matrix \(\mathbf {M}\). In specific, Parvinen and Metz (2008) showed how to calculate \(R_{m}\) in a locally stochastic metapopulation with a diploid population, in which the mutant population thus consists of two types, namely heterozygotes and mutant homozygotes. For such locally stochastic metapopulations, in which the local population dynamics is described by a continuous-time Markov chain, this generalization is straightforward for any number of disperser types, although the number of equations needed (and calculation time) will increase dramatically.

In this article we investigate continuous-time metapopulation models, in which the local populations are large  (Gyllenberg and Metz 2001; Metz and Gyllenberg 2001; Gyllenberg et al. 2002; Parvinen 2002). The local population dynamics are thus described by (a system of) ordinary differential equations. Conceptually, the generalization of the metapopulation reproduction ratio \(R_{m}\) to the case with several types of individuals is straightforward (Parvinen and Metz 2008). Nevertheless, the actual calculation method (Metz and Gyllenberg 2001, Appendix D), explained in detail by Parvinen (2002), does not generalize as such.

One aim of this article is to provide a novel method to compute the invasion fitness (proxy) in this class of metapopulation models, when there are several types of individuals, i.e., the metapopulation model is both size- and stage-structured. We find the method applicable for a very wide spectrum of evolutionary questions and ecological settings. Especially, the cases where evolutionary dynamics might depend on individual development have not been tractable in large-patch metapopulation models by adaptive dynamics before. Another aim of this article is to prove that this metapopulation reproduction ratio is well-defined. More precisely, we prove that

$$\begin{aligned} R_{m}(s_i,E_\mathrm{res})=1\quad \text { for all }\,\, i=1,\ldots ,n, \end{aligned}$$
(1)

i.e., the metapopulation reproduction ratio of a mutant with strategy \(s_i\) is equal to 1, when \(E_\mathrm{res}\) corresponds to an environment set by residents with strategies \(s_{i}\), \(i=1,\ldots ,n\) in a stable metapopulation-dynamical equilibrium. Such a consistency condition must naturally hold for any proxy of invasion fitness. However, such a proof has not been previously published even for the case with only one type of individuals (Gyllenberg and Metz 2001; Metz and Gyllenberg 2001).

2 Model and method

2.1 Local population model

Our ecological setting is a metapopulation with an infinite number of patches. In each patch there is a local population, which consists of individuals of different types, e.g. developmental stages, denoted by \(j=1,\dots ,m\). Each individual has a heritable trait s, which is under natural selection. Let n denote the number of different strategies, \(s_i\), where \(i=1,\dots ,n\), present in the metapopulation. Let \(X_{ji}\) denote the population density of individuals of type j with strategy \(s_{i}\) in a patch. We collect these values into a \(m\times n\) matrix

$$\begin{aligned} \mathbf {X} =(\mathbf {X}_{1},\ldots , \mathbf {X}_{n}),\quad \,\mathrm {where}\,\,\, \mathbf {X}_{i}=\left( \begin{array}{c} X_{1i}\\ \vdots \\ X_{mi} \end{array}\right) . \end{aligned}$$
(2)

In each patch, local population growth is described by a per capita growth function \(\mathbf {A}(\mathbf {X},s_{i})\). This function takes into account events like birth, death, and development to different stages. In addition, individuals disperse via a global dispersal pool. Emigration and immigration occur at per capita rates, \(\rho _{j}(\mathbf {X}, s_i)\) and \(\alpha \), respectively. Since dispersal has costs, we assume individuals experiencing death rate \(\nu \) in the dispersal pool. Thus, the probability to survive the dispersal event is \(\pi =\frac{\alpha }{\alpha +\nu }\). It is straightforward to generalize to a case where \(\alpha \) depends on the stage and the strategy, \(\alpha =\alpha _{j}(s_i)\), but for simplicity we assume \(\alpha \) to be a constant here.

The dynamics for the local population with the trait \(s_i\) is

$$\begin{aligned} \frac{d}{dt}\mathbf {X}_{i}= & {} \mathbf {A}(\mathbf {X},s_{i})\mathbf {X}_{i}-\varvec{\rho }(\mathbf {X},s_i)\mathbf {X}_{i}+\alpha \mathbf {D}_{i}\nonumber \\= & {} \mathbf {A}(\mathbf {X},s_{i})\mathbf {X}_{i}-\varvec{\rho }(\mathbf {X},s_i)\mathbf {X}_{i}+\mathbf {I}_{i}, \end{aligned}$$
(3)

where the ith row of the coefficient matrix A contains the growth for each type j including type changes from another types, the diagonal matrix \(\varvec{\rho }(\mathbf {X},s_i)=\mathrm {diag}(\rho _{1}(\mathbf {X},s_i),\ldots ,\rho _{m}(\mathbf {X},s_i))\) contains the emigration rates for each stage, and the vector \(\mathbf {D}_{i}=(D_{1i},\dots ,D_{mi})^{T}\) denotes the density of dispersers of types \(1, \ldots , m\) with strategy \(s_{i}\). For convenience we use the notation \(\mathbf {I}_{i}=\alpha \mathbf {D}_{i}\) for the vector of immigration rates observed in local patches corresponding to strategy \(s_i\). Furthermore, we collect these vectors for all present strategies into a \(m\times n\) matrix \(\mathbf {I} =(\mathbf {I}_{1},\ldots , \mathbf {I}_{n})\).

Local populations suffer from extinctions by environmental stochasticity. These events occur at rate \(\delta (\mathbf {X})\), which may depend on the local population size. When a catastrophic event occurs, the local population is wiped out, but the patch remains habitable to be then recolonized by immigrants from the dispersal pool.

2.2 Metapopulation dynamics

On the metapopulation level the state of the metapopulation is described by the distribution \(n(\mathbf {X})\) of local population sizes in patches, where \(\mathbf {X}\in \mathbb {R}^{nm}\). The dynamics of this distribution follows from straightforward book-keeping of local population dynamics (3), although its calculation can be tedious in practice. Here we focus on metapopulation-dynamical equilibria, and thus do not give a more detailed expression of the dynamics of \(n(\mathbf {X})\).

The dynamics of the dispersal pool size \(\mathbf {D}_{i}\) corresponding the metapopulation with the trait \(s_i\) incorporates emigration and immigration

$$\begin{aligned} \frac{d}{dt}D_{ji}=-(\alpha +\nu )D_{ji}+\int \rho _{j}(\mathbf {X},s_i) X_{ji}n(t,d\mathbf {X}). \end{aligned}$$
(4)

Next, we will show how to calculate the resident equilibrium and then we will derive the method to compute the proxy for the invasion fitness for the mutant.

3 Results

3.1 Metapopulation-dynamical equilibria

At a metapopulation-dynamical equilibrium the dispersal pool sizes (and thus immigration rates) and the local population size distributions are constant. Therefore, we first assume that we know the immigration vectors \(\mathbf {I}_{i}\), and then calculate the resulting local population size distributions. Using these distributions we obtain conditions that the immigration vectors \(\mathbf {I}_{i}\) need to satisfy at an equilibrium (each local population must be replaced exactly by itself or another local population). This is rather straightforward generalization of earlier results (e.g. Parvinen 2002), and is demonstrated in details below.

Consider now what happens in a patch after a catastrophe has occurred. Let \(\tau \) denote the patch age, which is the time since the last local extinction. Immediately after the catastrophe (at \(\tau =0)\), the patch is empty, and thus the local population size vectors \(\mathbf {X}_{i}(0,\mathbf {I})=0\). The local population sizes \(\mathbf {X}_{i}(\tau ,\mathbf {I})\) start to grow according to the system of ordinary differential equations (3) until another catastrophe occurs. This means that at a metapopulation-dynamical equilibrium, all patches of age \(\tau \) have precisely the same local population sizes \(\mathbf {X}_{i}(\tau ,\mathbf {I})\).

Let \(\mathcal {F}(\tau ,\mathbf {I})\) denote the probability that a population is still extant at age \(\tau \). That is, there has occurred no catastrophic event before age \(\tau \). Therefore, \(\mathcal {F}(\tau ,\mathbf {I})\) has to satisfy the differential equation

$$\begin{aligned} \frac{d}{d\tau }\mathcal {F}(\tau ,\mathbf {I})=-\delta (\mathbf {X}(\tau ,\mathbf {I}))\mathcal {F}(\tau ,\mathbf {I})\qquad \mathrm{with}\quad \mathcal {F}(0,\mathbf {I})=1. \end{aligned}$$
(5)

The solution of this linear differential equation can be written as

$$\begin{aligned} \mathcal {F}(\tau ,\mathbf {I})=\exp \left[ -\int _{0}^{\tau }\delta (\mathbf {X}(t,\mathbf {I}))dt\right] . \end{aligned}$$
(6)

The expected life-time of a local population is

$$\begin{aligned} L(\mathbf {I})=\int _{0}^{\infty }\tau \delta (\mathbf {X}(t,\mathbf {I}))\mathcal {F}(\tau ,\mathbf {I})d\tau =\int _{0}^{\infty }\mathcal {F}(\tau ,\mathbf {I})d\tau , \end{aligned}$$
(7)

where integration by parts is used in the second equality.

A patch of age \(\tau \) sends emigrants with strategy \(s_i\) with the rate \(\varvec{\rho }(\mathbf {X}(\tau ),s_i)\mathbf {X}(\tau )\). Therefore, during the patch lifetime, the expected production of emigrants with strategy \(s_{i}\) is

$$\begin{aligned} \mathbf {E}_{i}(\mathbf {I})=\int _{0}^{\infty }\varvec{\rho }(\mathbf {X}(\tau ,\mathbf {I}),s_i)\mathbf {X}_{i}(\tau ,\mathbf {I})\mathcal {F}(\tau ,\mathbf {I})d\tau , \end{aligned}$$
(8)

and thus the expected production of surviving emigrants is \(\pi \mathbf {E}_{i}(\mathbf {I})\). The corresponding expected number of immigrants arriving into a patch during its entire life is \(\mathbf {I}_{i}L(\mathbf {I})\). At a metapopulation-dynamical equilibrium these two vectors have to be equal, and therefore we obtain the condition

$$\begin{aligned} \mathbf {I}_{i}=\pi \frac{\mathbf {E}_{i}(\mathbf {I})}{L(\mathbf {I})}\quad \text { for all }\quad i=1,\ldots ,n. \end{aligned}$$
(9)

In case of no stage-structure (\(m=1\), and each \(I_{i}\) is a number), we can write the conditions (9) using the metapopulation reproduction ratio (see, e.g., equation (8) of Parvinen 2002)

$$\begin{aligned} R_{i}(I)=\pi \frac{E_{i}(I)}{I_{i}L(I)}=1\quad \text { for all }\,\,i=1,\ldots ,n. \end{aligned}$$
(10)

We can reach the condition (9) also by noting that at a metapopulation-dynamical equilibrium the patch-age distribution has density

$$\begin{aligned} m(\tau ,\mathbf {I})=\frac{\mathcal {F}(\tau ,\mathbf {I})}{L(\mathbf {I})}. \end{aligned}$$
(11)

Therefore, all patches through the whole metapopulation send surviving emigrants with strategy \(s_i\) with a rate \(\pi \int _{0}^{\infty }\varvec{\rho }(\mathbf {X}(\tau ,\mathbf {I}),s_i)\mathbf {X}_{i}(\tau ,\mathbf {I})m(\tau ,\mathbf {I})d\tau \). By requiring this quantity to be equal to \(\mathbf {I}_{i},\) condition (9) follows.

To obtain the factors required for finding the equilibrium can be challenging, especially in models derived from real life systems. Similarly as in Parvinen (2002) we compute the integrals numerically following the system:

$$\begin{aligned} \left\{ \begin{array}{lll} \mathbf {X}'_{i} &{} =\mathbf {A}(\mathbf {X},s_{i})\mathbf {X}_{i}-\varvec{\rho }(\mathbf {X},s_i)\mathbf {X}_{i}+\mathbf {I}_{i}, &{}\quad \mathbf {X}_{i}(0)=0\\ \mathcal {F}' &{} =-\delta (\mathbf {X})\mathcal {F}, &{}\quad \mathcal {F}(0)=1\\ L' &{} =\mathcal {F}, &{}\quad L(0)=0\\ \mathbf {E}'_{i} &{} =\varvec{\rho }(\mathbf {X},s_i)\mathbf {X}_{i}\mathcal {F}, &{}\quad \mathbf {E}_i(0)=0. \end{array}\right. \end{aligned}$$
(12)

In practice, however, the integration until \(\tau =\infty \) would take too long. It is often the case, that the local population sizes converge to a local population dynamical equilibrium \(\mathbf {X}^{*}\), defined as a solution of \(\frac{d}{d\tau }\mathbf {X}(\tau )=0\). In such case, when \(\tau \) is large enough (\(\tau =T\)) so that \(\mathbf {X}(\tau )\) is sufficiently close to \(\mathbf {X}^{*}\), we shall stop numerical integration. Thus we assume

$$\begin{aligned} \mathbf {X}(\tau )=\mathbf {X}(T),\quad \tau \ge T. \end{aligned}$$
(13)

Using this approximation we obtain

$$\begin{aligned} \mathcal {F}(\tau )=\mathcal {F}(T)\exp (-(\tau -T)\delta (\mathbf {X}(T)))\quad \text { for }\,\,\tau \geqslant T. \end{aligned}$$
(14)

Then we approximate the tails of the integration analytically:

$$\begin{aligned} \mathbf {E}_{i}(\infty )= & {} \mathbf {E}_{i}(T)+\frac{\varvec{\rho }(\mathbf {X},s_i) \mathbf {X}_{i}(T)\mathcal {F}(T)}{\delta (\mathbf {X}(T))}\nonumber \\ L(\infty )= & {} L(T)+\frac{\mathcal {F}(T)}{\delta (\mathbf {X}(T))}. \end{aligned}$$
(15)

In case the residents’ population dynamics approach a limit cycle, see the “Appendix”.

As already noted above, at the equilibrium the condition (9) must hold for all resident traits \(s_i\) present in the metapopulation. In general, it is not guaranteed to find the equilibrium explicitly, but a numerical solution is still possible to find, for example, by using iterative methods which do not require the use of derivatives.

3.2 Invasion fitness

Now, assume the resident population is on its ecological attractor. That is, for all residents traits \(s_i\) present in the metapopulation, the immigration rate vectors \(\mathbf {I}_{i}\) are constant. A mutant, with a phenotypic trait different from all the residents, appears into the metapopulation. It immigrates to a random patch which is inhabited by the residents. The age of the patch is random, and follows the distribution \(m(\tau )\) (Eq. 11), which is determined by the residents.

Consider a mutant population of size \(\hat{\mathbf {Y}}\) immigrating into a patch of age \(t_{\mathrm{res}}\). In principle, dynamics for the mutant’s population density vector \(\mathbf {Y}\) follows the differential equation

$$\begin{aligned} \frac{d}{dt}\mathbf {Y}(t)=\mathbf {A}(\{ \mathbf {X}(t),\mathbf {Y}(t)\} ,s_\mathrm{mut})\mathbf {Y}(t)-\varvec{\rho }(\{ \mathbf {X}(t),\mathbf {Y}(t)\},s_\mathrm{mut})\mathbf {Y}(t). \end{aligned}$$
(16)

When dispersal is the evolving strategy, we can replace \(\{ \mathbf {X}(t),\mathbf {Y}(t)\}\) by \(\mathbf {Y}(t) + \sum _{i=1}^n \mathbf {X}_i(t)\). However, initially the mutant population is so small that it has no effect on resident’s dynamics, and the dynamics for \(\mathbf {Y}\) becomes linear with respect to \(\mathbf {Y}\):

$$\begin{aligned} \frac{d}{dt}\mathbf {Y}(t;t_{\mathrm{res}})=[\mathbf {A}(\mathbf {X}(t),s_\mathrm{mut})-\varvec{\rho }(\mathbf {X}(t),s_\mathrm{mut})]\mathbf {Y}(t;t_{\mathrm{res}}),\quad \mathbf {Y}(t_{\mathrm{res}};t_{\mathrm{res}})=\hat{\mathbf {Y}}. \end{aligned}$$
(17)

Note, that the matrix \(\mathbf {A}\) depends on the resident’s states \(\mathbf {X}(t)\), which is the solution of (3) with \(\mathbf {X}(0)=0\). We call the initial mutant population and all their descendants in this patch a mutant colony. When the patch experiences a catastrophic event, the colony will die. However, during its lifetime the mutant colony sends emigrants to the dispersal pool. The expected number of mutant emigrants of type j for such colony is

$$\begin{aligned} E_{j}^\mathrm{mut}(t_{\mathrm{res}},\hat{\mathbf {Y}})=\int _{t_{\mathrm{res}}}^{\infty }\rho _{j}(\mathbf {X}(\tau ),s_\mathrm{mut})Y_{j}(\tau ;t_{\mathrm{res}})\frac{\mathcal {F}(\tau )}{\mathcal {F}(t_{\mathrm{res}})}d\tau , \end{aligned}$$
(18)

where \(\rho _{j}(\mathbf {X}(\tau ),s_\mathrm{mut})\) is the emigration rate of the mutant type j. The production of surviving mutant dispersers through all metapopulation is

$$\begin{aligned} E_{j}^{\mathrm{prod}}(\hat{\mathbf {Y}})=\pi \int _{0}^{\infty }E_{j}^\mathrm{mut}(t_{\mathrm{res}},\hat{\mathbf {Y}})m(t_{\mathrm{res}})dt_{\mathrm{res}}. \end{aligned}$$
(19)

Let \(\tilde{\mathbf {Y}}(j)=(\tilde{Y}_1(j),\ldots ,\tilde{Y}_m(j))^T\) denote the unit vector,

$$\begin{aligned} \tilde{Y}_{k}(j)=\left\{ \begin{array}{ll} 1,&{}\quad \text {if }k=j,\\ 0, &{} \quad \text {otherwise}. \end{array}\right. \end{aligned}$$
(20)

We calculate the values of \(E_{j}^{\mathrm{prod}}(\hat{\mathbf {Y}})\) for all \(\hat{\mathbf {Y}}=\tilde{\mathbf {Y}}(k)\), \(k=1,\ldots ,m\), and collect these values into a matrix. Analogous to Parvinen and Metz (2008) the invasion fitness (proxy) for the mutant is the dominant eigenvalue of this matrix:

$$\begin{aligned} R^{\mathrm{mut}}(s_\mathrm{mut})=\lambda _{d}\left( \mathbf {M}\right) ,\quad \text { where }\quad M_{jk}=E_{j}^{\mathrm{prod}}(\tilde{\mathbf {Y}}(k)). \end{aligned}$$
(21)

3.2.1 A novel method for the numerical calculation of the invasion fitness

The calculation method for the scalar version of (19) in section 2.3.1 of Parvinen (2002) (adapted from Appendix D of Metz and Gyllenberg 2001) has to be modified to cope with the general case of several stages. Some of the equations therein would become meaningless, as they would include, e.g., division of vectors by vectors.

To calculate (19), we first use (11) and (18) to obtain

$$\begin{aligned} E_{j}^{\mathrm{prod}}(\hat{\mathbf {Y}})=\pi \int _{0}^{\infty }\int _{t_{\mathrm{res}}}^{\infty }\rho _{j}(\mathbf {X}(\tau ),s_\mathrm{mut})Y_{j}(\tau ;t_{\mathrm{res}})\frac{\mathcal {F}(\tau )}{\mathcal {F}(t_{\mathrm{res}})}d\tau \frac{\mathcal {F}(t_{\mathrm{res}})}{L}dt_{\mathrm{res}}. \end{aligned}$$
(22)

Notice that the factors \(\mathcal {F}(t_{\mathrm{res}})\) cancel each other, and then swap the integration order to obtain

$$\begin{aligned} E_{j}^{\mathrm{prod}}(\hat{\mathbf {Y}})=\frac{\pi }{L}\int _{0}^{\infty }\mathcal {F}(\tau )\rho _{j}(\mathbf {X}(\tau ),s_\mathrm{mut})\int _{0}^{\tau }\mathbf {Y}_{j}(\tau ;t_{\mathrm{res}})dt_{\mathrm{res}}d\tau \end{aligned}$$
(23)

We still have two integrals within each other. To ease the numerical calculation of the above integral, we now introduce an auxiliary variable, \(\mathbf {N}\),

$$\begin{aligned} \mathbf {N}(\tau )=\int _{0}^{\tau }\mathbf {Y}(\tau ;t_{\mathrm{res}})dt_{\mathrm{res}}. \end{aligned}$$
(24)

By differentiating we obtain by using (17)

$$\begin{aligned} \frac{d}{d\tau }\mathbf {N}(\tau )= & {} \mathbf {Y}(\tau ;\tau )+\int _{0}^{\tau }[\mathbf {A}(\mathbf {X}(\tau ),s_\mathrm{mut})-\varvec{\rho }(\mathbf {X}(\tau ),s_\mathrm{mut})]\mathbf {Y}(\tau ;t_{\mathrm{res}})dt_{\mathrm{res}}\nonumber \\= & {} \hat{\mathbf {Y}}+[\mathbf {A}(\mathbf {X}(\tau ),s_\mathrm{mut})-\varvec{\rho }(\mathbf {X}(\tau ),s_\mathrm{mut})]\int _{0}^{\tau }\mathbf {Y}(\tau ;t_{\mathrm{res}})dt_{\mathrm{res}}\nonumber \\= & {} \hat{\mathbf {Y}}+[\mathbf {A}(\mathbf {X}(\tau ),s_\mathrm{mut})-\varvec{\rho }(\mathbf {X}(\tau ),s_\mathrm{mut})]\mathbf {N}(\tau ). \end{aligned}$$
(25)

As above in the resident case we can with the help of (23) and (25) numerically compute the integrals needed for the invasion fitness:

$$\begin{aligned} \left\{ \begin{array}{lll} \mathbf {X}'_{i} &{} =\mathbf {A}(\mathbf {X},s_{i})\mathbf {X}_{i}-\varvec{\rho }(\mathbf {X},s_{i})\mathbf {X}_{i}+\mathbf {I}_{i}, &{}\quad \mathbf {X}_{i}(0)=0,\; i=1,\ldots ,n\\ \mathcal {F}' &{} =-\delta (X)\mathcal {F} &{}\quad \mathcal {F}(0)=1\\ L' &{} =\mathcal {F} &{}\quad L(0)=0\\ \mathbf {N}' &{} =\hat{\mathbf {Y}}+\left[ \mathbf {A}(\mathbf {X},s_\mathrm{mut})-\varvec{\rho }(\mathbf {X},s_\mathrm{mut})\right] \mathbf {N} &{}\quad \mathbf {N}(0)=0\\ Q'_{j} &{} =\mathcal {F}\rho _{j}(\mathbf {X},s_\mathrm{mut})N_{j} &{}\quad Q_j(0)=0\; j=1,\ldots ,m \end{array}\right. \end{aligned}$$
(26)

Similarly as in the resident case, we will not integrate until infinity. Instead, we again solve the system of differential equations numerically until time T large enough, such that resident population is close to a population-dynamical equilibrium \(\mathbf {X}^{*}\). Then we again use the approximation \(\mathbf {X}(\tau )=\mathbf {X}(T)\) for \(\tau \ge T\), and derive the tails needed analytically. As before we obtain \(\mathcal {F}(\tau )\) for \(\tau \ge T\) from (14). The tail for L is as in (15). For times large enough the matrix \(\mathbf {A}\) remains constant, and therefore also \(\mathbf {N}\) will approach an equilibrium. Analogous to (15), emigrant production of the type j is

$$\begin{aligned} E_{j}^{\mathrm{prod}}(\hat{\mathbf {Y}})= & {} \frac{\pi }{L}\int _{0}^{\infty }\mathcal {F}(\tau )\rho _{j}(\mathbf {X}(\tau ),s_\mathrm{mut})N_j(\tau )d\tau \nonumber \\= & {} \frac{\pi }{L(\infty )}\left( Q_{j}(T)+\frac{\rho _{j}(\mathbf {X}(T),s_\mathrm{mut})\mathcal {F}(T)N_{j}(T)}{\delta (\mathbf {X}(T))}\right) . \end{aligned}$$
(27)

In case the population dynamics approach a limit cycle we recommend the reader to look at “Appendix”.

We have now shown how to numerically compute the invasion fitness for a mutant in large patch metapopulations which are both size- and stage-structured and the local dynamics takes place in continuous time. The method itself is independent of the trait under selection. Thus, this method is applicable to a very wide spectrum of evolutionary questions.

3.2.2 Proof of consistent fitness

Theorem 1

\(R_\mathrm{mut}(s_{i},E_\mathrm{res})=1\) for all \(i=1,\ldots ,n\), where \(E_\mathrm{res}\) is an environment set by residents with strategies \(s_{i}\), \(i=1,\ldots ,n\) in a stable metapopulation-dynamical equilibrium.

Proof

Consider the metapopulation-dynamical equilibrium of strategies \(s_{i}\) with immigration vectors \(\mathbf {I}_{i}\) for \(i=1,\ldots ,n\). We can choose the strategy of a mutant to be the same as one of the resident strategies, \(s_{\mathrm{mut}}=s_{i}\). Now we want to calculate \(\mathbf {E}^{\mathrm{prod}}(\mathbf {I}_{i})\), defined in (19). When \(s_{\mathrm{mut}}=s_{i}\) and \(\hat{\mathbf {Y}}=\mathbf {I}_{i}\), according to (25) we have \(\mathbf {N}(\tau )=\mathbf {X}_{i}(\tau )\). Therefore,

$$\begin{aligned} \mathbf {E}^{\mathrm{prod}}(\mathbf {I}_{i})=\frac{\pi }{L}\mathbf {E}_{i}(\mathbf {I})=\mathbf {I}_{i}, \end{aligned}$$
(28)

where the second equality follows from (9). Because \(\mathbf {E}^{\mathrm{prod}}(\hat{\mathbf {Y}})\) is linear with respect to \(\hat{\mathbf {Y}}\), Eq. (28) means that

$$\begin{aligned} \mathbf {M}\mathbf {I}_{i}=\mathbf {I}_{i}, \end{aligned}$$
(29)

where \(M_{jk}=\mathbf {E}_{j}^{\mathrm{prod}}(\tilde{\mathbf {Y}}(k))\) with \(\tilde{\mathbf {Y}}(k)\) as in (20). According to (29), the vector \(\mathbf {I}_{i}\) is an eigenvector of the matrix \(\mathbf {M}\) and the corresponding eigenvalue \(\lambda =1\). The metapopulation reproduction ratio is the dominant eigenvalue of \(\mathbf {M}\). To finish the proof we only need to show that \(\lambda =1\) is the dominant eigenvalue: if the matrix \(\mathbf {M}\) would have an eigenvalue with \(\left| \lambda \right| >1\), the metapopulation-dynamical equilibrium would not be stable. \(\square \)

3.3 Examples

To provide a practical view to the question in what kind of ecological situations the generalized model (and thus the methods provided) can be applied, we describe two examples, an epidemiological model and a viral infection model. Our examples clearly show the demand for this generalized model type.

3.3.1 SIR model

Let us consider an epidemiological model in a metapopulation setting. Local dynamics follow a common SIR model (Diekmann and Heesterbeek 2000). Natural death events occur within each group of individuals, susceptibles S, infected I and recovered R with rates \(\mu _{S}\), \(\mu _{I}\) and \(\mu _{R}\), respectively. The host population can be polymorphic with several strategies \(s_k\) present. Local population sizes are then \(S_k\), \(I_k\) and \(R_k\) denoting individual types with the inheritable phenotypic trait \(s_k\). The trait or strategy s affects essential life-history parameters as described below. The per capita reproduction rate \(b(N,s_{i})\) is a function of the whole host population size \(N=\sum _k S_{k}+I_{k}+R_{k}\) and the phenotypic strategy \(s_{i}\) of the subpopulation. In this example we assume no vertical transmission, and thus all individuals are susceptibles at birth. However, the generalization to incorporate vertical transmission would be rather easy. Infection occurs according to the law of mass action, with a rate \(\beta (s_{i})\) corresponding to contacts between susceptibles with strategy \(s_i\) and infected individuals. Recovering occurs at the rate \(\gamma (s_{i})\). Patches may represent a cluster or some condensation of the host population, e.g. cities or schools in case of human host populations. All types of individuals, S, I and R, may disperse—move from a patch to another with emigration rate \(\rho \) and immigration rate \(\alpha \). A good and conceivable way to model this situation is obviously a metapopulation, which is structured by the population size and the stage of the individuals.

We write the local dynamics (3) as following

$$\begin{aligned} \frac{d}{dt}S_{i}= & {} b(N,s_{i})(S_{i}+I_{i}+R_{i})-\beta (s_{i})S_{i}\sum I_{k}-(\mu _{S}+\rho _{S})S_{i}+\alpha D_{S_{i}}\nonumber \\ \frac{d}{dt}I_{i}= & {} \beta (s_{i})S_{i}\sum I_{k}-(\mu _{I}+\gamma (s_{i})+\rho _{I})I_{i}+\alpha D_{I_{i}}\nonumber \\ \frac{d}{dt}R_{i}= & {} \gamma (s_{i})I_{i}-(\mu _{R}+\rho _{R})R_{i}+\alpha D_{R_{i}} . \end{aligned}$$
(30)

The evolution of traits in the host population can now be studied in a rather realistic model setting. We could, for example, study the evolution of host behaviour, affecting the transmission rate \(\beta (s_{i})\), the recovery rate \(\gamma (s_{i})\) and the reproductive rate \(b(N,s_{i})\) with different trade-off functions depending on the characteristics of the host population and the infectious disease. We can write (30) using the notation used elsewhere in this article by setting \(X_{1i}=S_{i}\), \(X_{2i}=I_{i}\) and \(X_{3i}=R_{i}\), after which all the methods presented here are applicable.

3.3.2 Viral infection model

Consider a hepatitis C infection in a (human) host. The hepatitis C virus particle contains positive-strand RNA in an envelope. In its replication, which occurs only inside the cells of the host, \(\hbox {RNA}^{+}\) strands are used in the production of \(\hbox {RNA}^{-}\) strands and vice versa. Furthermore, \(\hbox {RNA}^{+}\) strands are packed in envelopes to form virus particles, which can exit the cell to the blood stream, and enter new target cells. At least three stages (virus particles and the \(\hbox {RNA}^{+}\) and \(\hbox {RNA}^{-}\) strands) are thus involved. The within-cell viral dynamics can be described with a system of differential equations (e.g., Guedj and Neumann 2010). The viral dynamics within a host can be modeled using the general size- and stage-structured metapopulation model, in which the dispersal pool corresponds to the blood circulation, and cells are habitable patches.

4 Discussion

The Levins (1969, 1970) metapopulation model was inspiring for the research field, but nevertheless very simplistic, because it only described the dynamics of the fraction of occupied patches. Beyond patches being occupied or empty, the local population size was not taken into account in the model. This simplification has later been lifted in structured metapopulation models. The metapopulation reproduction ratio \(R_m(s_\mathrm{mut},E_\mathrm{res})\) introduced by Gyllenberg and Metz (2001) and Metz and Gyllenberg (2001) is a useful concept for studying adaptive dynamics in (structured) metapopulation models. It is the expected number of mutant dispersers (with strategy \(s_\mathrm{mut}\)) produced by a local mutant colony initiated by one mutant disperser in the environment \(E_\mathrm{res}\) set by the resident. It measures growth between dispersal generations, and is often easier to calculate than the invasion fitness \(r(s_\mathrm{mut},E_\mathrm{res})\) (Metz et al. 1992), which measures growth in real time. The definition of the metapopulation reproduction ratio suggests that it is a fitness proxy, i.e., it is greater than one, \(R_m(s_\mathrm{mut},E_\mathrm{res})\), if and only the invasion fitness is positive, \(r(s_\mathrm{mut},E_\mathrm{res})>0\).

Although structured metapopulation models are more realistic than the Levins metapopulation, they do not necessarily take individual development into account. Two individuals with the same strategy in the same habitat patch are typically assumed to be identical. More detailed models are structured not only with respect to the local population size, but also take into account differences of individuals (other than the strategy). Properties taking into account such differences can be continuous (such as the weight of an individual) or discrete (such as a juvenile or an adult). In the latter case the population is stage-structured.

In this article we have presented a metapopulation model that is both size- and stage-structured. Our contribution consists of two parts. First, since the previously published algorithm to calculate the metapopulation reproduction ratio is not applicable in the general case, we have modified the algorithm to cope with the stage structure. Second, we have presented a proof showing that the metapopulation reproduction ratio is well-defined. In other words, we have shown that \(R_{m}(s_i,E_\mathrm{res})=1\) for all such strategies \(s_i\) that are present in the stable metapopulation-dynamical equilibrium resulting in the resident environment \(E_\mathrm{res}\). To illustrate the variety of potential applications, we have presented two examples, an epidemiological (SIR) model, and a viral infection model. We hope that our methods will be found useful by a large number of applicants in the future.