Variance as a life history outcome: Sensitivity analysis of the contributions of stochasticity and heterogeneity

Highlights • Individuals vary in traits or in luck; both cause variance in life history outcomes.• The variance components are calculated from a multistate group-stage cohort model.• Sensitivity analysis shows how variance components relate to demographic parameters.• Both mortality and fertility affect the variance components.• Effects depend on life history timing, and the nature and mixture of differences.

which we rewrite as the following to make life a bit easier for ourselves; The main steps of sensitivity analysis are to differentiate the expression, then apply the vec operator, and substitute and simplify where necessary. We will do this for both sides of the equation ( to extract B, in this case the term we are differentiating. We can do this by writing an identity matrix on the "empty" side of the target term (e.g. dŨ T ρ 1 = I dŨ T ρ 1 , so that The final step involves writing vec Ũ T in terms of vecŨ , which requires the vec-permutation matrix K, In this section we will use several vec-permutation matrices of different sizes, we list them here for reference; K = K g,s gs × gs (A-10) Differentiating the right-hand side of (A-2) gives Applying the vec operator (and Roth's theorem, and the vec-permutation matrix) yields The vec operator is applied to a Hadamard product using the following rule; Applying this rule to (A-14) yields As shown in equation (33),P is a block-structured matrix built fromŨ and d 1×gs (and some zeros and ones). More generally, the Markov chainP is written as According to Caswell & van Daalen (2016), the vec operator applied toP can be written as follows where α is the number of absorbing states. When α = 1, the mortality matrixM can be obtained fromŨ asM In this case, equation (A-18) further simplifies to Solving for dρ 1 and substituting I −Ũ T = Ñ T −1 gives (A-24) This is the general formula for the sensitivity of mean LRO to the underlying matrices. From here, one can decide which of the parameters in the matrices is of interest, which will be discussed in Section A.3. Let us first obtain the general derivative of the variance in LRO.

A.2 Tackling the beast: Variance in LRO
The variance in lifetime reproductive output is given bỹ v =ρ 2 − (ρ 1 •ρ 1 ) . (A-25) Differentiating this and applying the rule for veccing 1 Hadamard products as in (A-15) yields Simple enough. We know dρ 1 from the previous section. All that remains is to obtain the derivative of the second moment of LRO, where the second moment is given bỹ Using the same trick as in Section A.1, we write this as Differentiating term A follows the same steps as we performed in (A-3)-(A-9). The only difference is that the term we solve for here isρ 2 ; Differentiating term B follows the same steps we took earlier in (A-13)-(A-16), except term B in equation (A-28) contains the matrixR 2 instead ofR 1 ; Applying the vec operator (and Roth's theorem, the vec-permutation matrix, and the rule for veccing Hadamards) then yields Despite the fact that it will not be fun to look at, solving forρ 2 gives Fortunately, we can simplify as we get more specific.

A.3 Pick your side: Mortality or fertility
Now that we have formulas (A-24), (A-33), and (A-26), we can differentiate our way down to the parameters we are interested in. Although it is possible that a single (vector of) parameter[s] influences both mortality and fertility simultaneously, in our examples we investigate the effect of a change in these parameter sets separately.

A.3.1 Mortality
When our parameter set of interest is mortality, some of the terms in equations (A-24) and (A-33) will drop out since they do not depend on mortality. We know that dvecŨ , and by extension dvecP , depend on mortality through the transition rates between states. dvecR 1 and dvecR 2 , on the other hand, depend on the moments of reproduction, and therefore on fertility. By writing dvecP as in (A-22), the sensitivities ofρ 1 andρ 2 with respect to mortality are obtained from (A-24) and (A-33) as The only missing ingredient is the derivative ofŨ with respect to the mortality schedule for group i.
In the example for Lomatium bradshawii, the relationship betweenŨ and the mortality vector for a given group is given by the equations in (23), (21), and (60)-(62): Other than Roth's theorem, and the rule for veccing a Hadamard product, we need to know how to differentiate σ i = e −µ i , which is DifferentiatingŨ with respect to U, differentiating U with respect to U i , and differentiating U i with respect to µ i gives The derivative ofŨ with respect to µ i is obtained from the differential dvecŨ as (this is the First Identification Theorem of Magnus & Neudecker (1985)). Substituting (A-43) into (A-34) gives the sensitivity of mean lifetime reproductive output with respect to mortality.

Substituting (A-43) into the derivative of the first moment (A-34) and the second moment (A-35) of LRO, and then combining these into
yields the sensitivity of variance in LRO to mortality, as calculated from (42) and (43).

A.3.2 Fertility
When we want to know instead how mean or variance in LRO responds to a change in fertility, all the terms concerning the sensitivity of outcomes with respect to mortality drop out of equations (A-24) and (A-33). These become In order to reduce the number of matrices we need to differentiate, we can writeR 1 andR 2 in terms ofR 1 . Note that rewritingR 2 as a function ofR 1 is not always possible, for example, when the higher moments of fertility are directly obtained from data. In our example we only have information on the first moment, and we make the assumption that fertility is Poisson distributed to obtainR Differentiating (A-47) and applying the vec operator gives Applying the rule for differentiating Hadamard products, this becomes which can be written as R 1 isR 1 with the absorbing states removed; Differentiating (A-51), and applying the vec operator yields which, following Roth's theorem, gives Now we can write equations (A-45) and (A-46) in terms of the derivatives ofρ 1 ,ρ 2 , andR 1 ; The matrixR 1 is a function of f 1 through the following set of equations; The derivative ofR 1 with respect to f i is obtained through the usual steps; differentiation, applying the vec operator and then Roth's theorem if necessary; Invoking the First Identification Theorem gives Combining (A-59), (A-54), and (A-55) provides the sensitivity of mean and variance in LRO to fertility.
Presenting sensitivity analyses of matrix expressions with long chains of dependency ( Figure 1) confronts the researcher with a tricky decision. Whether we present it as a long chain rule for which we collect the individual parts (as we do in the main text), or just start somewhere and 'differentiate down' (as we did here), it is a challenge to keep track of all the parts of the equations. Did this matrix lose a transpose? Is this supposed to be K 1 or K 2 ? Are all the dimensions correct? Once you have the correct expression (and have successfully implemented it in MATLAB or your matrix language of choice), it is tempting to show that final equation you worked so hard to obtain. However, the final product, for example, sensitivity of variance in LRO to mortality for Lomatium, might look like this: This expression might be the final product, and it might be impressive, but it does not provide any insight (nor does it spark joy, even in us). It is a solution for the sensitivity of variance in LRO to mortality, but an attempt to code it as a single expression is likely to produce errors. Programming each piece of the chain of derivatives is a better solution. In addition, the parts of the calculation can be useful to other investigators performing sensitivity analysis even if their model differs in some components. By presenting the chain of consecutive sensitivities, it is easier for other investigators to identify where their analyses might differ. This expression, together with expressions for each of the derivatives, contains the same information as (A-60) with the advantage that it shows the steps required to get the solution. Some matrix calculus is required to get there, and although differentiating matrices with respect to vectors can seem daunting at first, it requires only a few main steps (just 6 according to Caswell (2019)). Matrix calculus is your friend, not just as a technique for sensitivity analysis, but also as a way to present it. If the main text of our paper did not convince you of this, maybe this little appendix has.