## Abstract

The coefficient of determination *R*^{2} quantifies the proportion of variance explained by a statistical model and is an important summary statistic of biological interest. However, estimating *R*^{2} for (generalized) linear mixed models (GLMMs) remains challenging. We have previously introduced a version of *R*^{2} that we called *R*^{2}_{GLMM} for Poisson and binomial GLMMs, but not for other distributional families. Similarly, we earlier discussed how to estimate intra-class correlation coefficients ICC using Poisson and binomial GLMMs, but not for other distributional families. In this article, we expand our methods to all the other non-Gaussian distributions such as negative binomial and gamma GLMMs. While expanding our approach, we highlight two useful concepts, Jensen’s inequality and the delta method, both of which help us in understanding the properties of GLMMs. We illustrate the implementation of our extension by worked examples in the R environment although our method can be used regardless of statistical environments.

## Introduction

One of the main purposes of linear modelling is to understand the sources of variation in biological data. In this context, it is not surprising that the coefficient of determination *R*^{2} is a commonly reported statistic because it represents the proportion of variance explained by a linear model. The intra-class correlation coefficient ICC is a related statistic that quantifies the proportion of variance explained by a grouping (random) factor in multilevel/hierarchical data. In the field of ecology and evolution, a type of ICC is often referred to as repeatability R, where the grouping factor is often individuals that have been phenotyped repeatedly (Lessells and Boag 1987, Nakagawa and Schielzeth 2010). We have reviewed methods for estimating *R*^{2} and ICC in the past (Nakagawa & Schielzeth 2010, 2013), with a particular focus on non-Gaussian response variables, featuring generalized linear mixed-effects models (GLMMs) as the most versatile engine for estimating *R*^{2} and ICC (specifically *R*^{2}_{GLMM} and ICC_{GLMM}). Our descriptions were limited to random-intercept GLMMs, but Johnson (2014) has recently extended the methods to random-slope GLMMs, widening the applicability of these statistics (see also, LaHuis *et al.* 2014; Jaeger et al. 2016).

However, at least one important issue seems to remain. Currently these two statistics are only described for binomial and Poisson GLMMs. Although these two types of GLMMs are arguably the most popular (Bolker *et al.* 2009), there are other commonly used families for GLMMs, such as negative binomial and gamma distributions (Ver Hoef & Boveng 2007; Bolker 2008). In this article, we revisit and extend *R*^{2}_{GLMM} and ICC_{GLMM} to more distributional families, in particular to negative binomial and gamma distributions. In this context, we discuss Jensen’s inequality and two variants of the delta method, which are useful not only for extending our method, but also for interpreting the results of GLMMs in general. Furthermore, we refer to some special considerations when obtaining *R*^{2}_{GLMM} and ICC_{GLMM} from binomially GLMMs for binary and proportion data, which we did not discuss in the past (Nakagawa & Schielzeth 2010, 2013). We provide worked examples focusing on implementation in the R environment (R Core Team 2016) and finish by referring to two alternative approaches for obtaining *R*^{2} and ICC from GLMMs along with a cautionary note.

## Definitions of *R*^{2}_{GLMM}, ICC_{GLMM} and overdispersion

To start with, we present *R*^{2}_{GLMM} and ICC_{GLMM} for a simple case of Gaussian error distributions based on a linear mixed-effects model (LMM, hence also referred to as *R*^{2}_{LMM} and ICC_{LMM}). Imagine a two-level dataset where the first level corresponds to observations and the second level to some grouping factor (e.g. individuals) with *k* fixed effect covariates. The model can be written as (model 1):
where *y _{ij}* is the

*j*th observation of the

*i*th individual,

*X*is the

_{hij}*j*th value of the

*i*th individual for the

*h*th of

*k*fixed effects predictors,

*β*

_{0}is the (grand) intercept,

*β*is the regression coefficient for the

_{h}*h*th predictor,

*α*is an individual-specific effect, assumed to be normally distributed in the population with the mean and variance of 0 and

_{i}*σ*

_{α}^{2},

*ε*is an observation-specific residual, assumed to be normally distributed in the population with mean and variance of 0 and

_{ij}*σ*

_{ε}^{2}, respectively. For this model, we can define two types of

*R*

^{2}as: where

*R*

^{2}

_{LMM(m)}represents the marginal

*R*

^{2}, which is the variance accounted for by the fixed effects,

*R*

^{2}

_{LMM(c)}represents the conditional

*R*

^{2}, which is the variance explained by both fixed and random effects, and

*σ*

_{f}^{2}is the variance explained by fixed effects (Snijders & Bosker 1999, 2011). Since marginal and conditional

*R*

^{2}differ only in whether the random effect variance is included in the numerator, we avoid redundancy and present equations only for marginal

*R*

^{2}in the following. Similarly, there are two types of ICC:

If no fixed effects are included, the two versions are identical and represent unadjusted ICC, but if fixed effects are fitted, ICC_{LMM(adj)} represents adjusted ICC, while ICC_{LMM} represented unadjusted ICC (*sensu* Nakagawa and Schielzeth 2010). Since the two versions of ICC differ only in whether the fixed effect variance (calculated as in Equation 6) is included in the denominator, we avoid redundancy and present equations only for adjusted ICC in the following.

One of the main difficulties in extending *R*^{2} from LMMs to GLMMs is defining the residual variance *σ _{ε}*

^{2}. For binomial and Poisson GLMMs with an additive dispersion terms, we have previously stated that

*σ*

_{ε}^{2}is equivalent to

*σ*

_{e}^{2}+

*σ*

_{d}^{2}where

*σ*

_{e}^{2}is the variance for the additive overdispersion term, and

*σ*

_{d}^{2}is the distribution-specific variance (Nakagawa & Schielzeth 2010, 2013). Here overdispersion represents the excess variation relative to what is expected from a certain distribution and can be estimated by fitting an observation-level random effect (OLRE; see, Harrison 2014, 2015). Alternatively, overdispersion in GLMMs can be implemented using a multiplicative overdispersion term (Browne

*et al.*2005). In such an implementation, we stated that

*σ*

_{ε}^{2}is equivalent to

*ω*·

*σ*

_{d}^{2}where

*ω*is a multiplicative dispersion parameter estimated from the model (Nakagawa & Schielzeth 2010). But obtaining

*σ*

_{d}^{2}for specific distributions is not always possible, because in many families of GLMMs the parameters are less clearly separated into a parameter for the expectation of the mean and a parameter for the (over)dispersion. It turns out that binomial and Poisson distributions are special cases where

*σ*

_{d}^{2}can be usefully calculated, because either all overdispersion is modelled by an OLRE (additive overdispersion) or by a single multiplicative overdispersion parameter (multiplicative overdispersion). However, as we will show below, we can always obtain the GLMM version of

*σ*

_{ε}^{2}(on the latent scale) directly. We refer to this generalised version of

*σ*

_{ε}^{2}as ‘the observation-level variance’ here rather than the residual variance (but we keep the notation

*σ*

_{ε}^{2}).

## Extension of R^{2}_{GLMM} snd ICC_{GLMM}

We now define *R*^{2}_{GLMM} and ICC_{GLMM} for an overdispersed Poisson (also known as quasi-Poisson) GLMM, because the overdispersed Poisson distribution is similar to the negative binomial distribution at least in their uses (Gelman & Hill 2007; Ver Hoef & Boveng 2007). Imagine count data repeatedly measured from a number of individuals with associated data on *k* covariates. We fit an overdispersed Poisson (OP) GLMM with the log link function (model 2):
where *y _{ij}* is the

*j*th observation of the

*i*th individual and

*y*follows an overdispersed Poisson distribution with two parameters,

_{ij}*λ*and

_{ij}*ω*, ln(

*λ*) is the latent value for the

_{ij}*j*th observation of the

*i*th individual,

*ω*is the overdispersion parameter (when the multiplicative dispersion parameter

*ω*is 1, the model becomes a standard Poisson GLMM),

*α*is an individual-specific effect, assumed to be normally distributed in the population with the mean and variance of 0 and

_{i}*σ*

_{α}^{2}, respectively (as in model 1), and the other symbols are the same as above. For such a model, we can define R

^{2}

_{GLMM(m)}and (adjusted) ICC

_{GLMM}as: where the subscript of

*R*

^{2}and ICC denote the distributional family, here OP-ln for overdispersed Poisson distribution with log link, the term ln(1 +

*ω*/

*λ*) corresponds to the observation-level variance

*σ*

_{ε}^{2}(Table 1, for derivation see Appendix S1),

*ω*is the overdispersion parameter, and

*λ*is the mean value of

*λ*We discuss how to obtain

_{ij}.*λ*below.

The calculation is very similar for a negative binomial (NB) GLMM with the log link (model 3):
where *y _{ij}* is the

*j*th observation of the

*i*th individual and

*y*follows a negative binomial distribution with two parameters,

_{ij}*λ*and

_{ij}*θ*, where

*θ*is the shape parameter of the negative binomial distribution (given by the software often as the dispersion parameter), and the other symbols are the same as above. R

^{2}

_{GLMM(m)}and (adjusted) ICC

_{GLMM}for this model can be calculated as: Finally, for a gamma GLMM with the log link (model 4): where

*y*is the

_{ij}*j*th observation of the

*i*th individual and

*y*follows a gamma distribution with two parameters,

_{ij}*λ*and

_{ij}*v*, where

*v*is the shape parameter of the gamma distribution (sometimes statistical programs report 1/

*v*instead of

*v*; also note that the gamma distribution can be parameterized in alternative ways, Table 1),

*R*

^{2}

_{GLMM(m)}and (adjusted) ICC

_{GLMM}can be calculated as:

## Obtaining the observation-level variance by the ‘first’ delta method

For overdispersed Poisson, negative binomial and gamma GLMMs with log link, the observation-level variance *σ _{ε}*

^{2}can be obtained via the variance of the log-normal distribution, as described above (see Appendix S1). There are two more alternative methods to obtain the same target: the delta method and the trigamma function. The two alternatives have different advantages and will be discussed in some detail below.

The delta method for variance approximation uses a first order Taylor series expansion, which is often employed to approximate the standard error (error variance) for transformations (or functions) of a variable *x* when the (error) variance of *x* itself is known (see Ver Hoff 2012; for an accessible reference for biologists, Powell 2007). A simple case of the delta method for variance approximation can be written as:
where *x* is a random variable (typically represented by observations), *f* represents a function (e.g. log or square-root), var denotes variance, and *d/dx* is a (first) derivative with respect to variable *x*. Taking derivatives of any function can be easily done using the R environment (examples can be found in the Appendices). It is the delta method that Foulley *et al.* (1987) used to derive the distribution specific variance *σ _{d}*

^{2}for Poisson GLMMs as 1/

*λ*Given that var[

*λ*] =

_{ij}*λ*in Poisson distributions and

*d*ln(

*λ*) /

*dx =*1/

*λ*, it follows that var[ln(

*λ*).)] ≈

_{ij}*λ*(1 /

*λ*)

^{2}(note that for Poisson distributions without overdispersion,

*σ*

_{d}^{2}is equal to

*σ*

_{ε}^{2}because

*σ*

_{e}^{2}= 0). One clear advantage of the delta method is its flexibility, and we can easily obtain the observation-level variance

*σ*

_{ε}^{2}for all kinds of distributions/link functions. For example, by using the delta method, it is straightforward to obtain

*σ*

_{ε}^{2}for the Tweedie (compound Poisson-gamma) distribution, which has been used to model non-negative real numbers in ecology (e.g., Foster & Bravington 2013; Zhang 2013). For the Tweedie distribution, the variance on the observed scale has the relationship var[

*y*] =

*φμ*where

^{p}*μ*is the mean on the observed scale and

*φ*is the dispersion parameter (comparable to

*λ*and

*ω*in Equation 9), and

*p*is a positive constant called an index parameter. Therefore, when used with the log-link function, an approximated

*σ*

_{ε}^{2}value can be obtained by

*φμ*

^{(p-2)}according to Equation 24. The log-normal approximation ln(1 +

*φμ*

^{(p-2)}) is also possible (see Appendix S1; cf. Table 1).

The use of the trigamma function *ψ*_{1} is limited to distributions with log link, but it should provide the most accurate estimate of the observation level variance *σ _{ε}*

^{2}. This is because the variance of a gamma-distributed variable on the log scale is equal to

*ψ*

_{1}(

*ν*) where

*v*is the shape parameter of the gamma distribution (Tempelman & Gianola 1999) and hence

*σ*

_{ε}^{2}is

*ψ*

_{1}(

*ν*). At the level of the statistical parameters (Table 1; on the ‘expected data’ scale;

*sensu*deVillemereuil

*et al.*2016; see their Figure 1), Poisson and negative binomial distributions can be both seen special cases of gamma distributions, and

*σ*

_{ε}^{2}can be obtained using the trigamma function (Table 1). For example,

*σ*

_{ε}^{2}for the Poisson distribution is

*ψ*

_{1}(

*λ*) with the speciality that in the case of Poisson distributions

*σ*

_{ε}^{2}=

*σ*

_{d}^{2}. As we show in Appendix S2, ln(1+1/

*λ*) (log-normal approximation), 1/

*λ*(delta method approximation) and

*ψ*

_{1}(

*λ*) (trigamma function) are similar if

*λ*is greater than 2. Nonetheless, our recommendation is to use the trigamma function for obtaining

*σ*

_{ε}^{2}whenever this is possible.

We note that in calculations of heritability (which can be seen as a type of ICC although in a strict sense, it is not; see de Villemereuil *et al.* 2016) using negative binomial GLMMs, the trigamma function has been previously used to obtain observation-level variance (Matos et al. 1997; Tempelman & Gianola 1999; cf. de Villemereuil *et al.* 2016). Table 1 summarises observation-level variance *σ _{ε}*

^{2}for overdispersed Poisson, negative binomial and gamma distributions for commonly used link functions.

## How to estimate *λ* from data

Imagine a Poisson GLMM with log link and additive overdispersion fitted as an observation-level random effect (model 5):
where *y _{ij}* is the

*j*th observation of the

*i*th individual, and follows a Poisson distribution with the parameter

*λ*,

_{ij}*e*is an additive overdispersion term for

_{ij}*j*th observation of the ith individual, and the other symbols are the same as above. Using the log-normal approximation

*R*

^{2}

_{GLMM(m)}and (adjusted) ICC

_{GLMM}can be calculated as: where, as mentioned above, the term ln(1+1/

*λ*) is

*σ*

_{ε}^{2}(or

*σ*

_{d}^{2}) for Poisson distributions with the log link (Table 1).

In our earlier papers, we proposed to use the exponential of the intercept (from the intercept-only model or models with centred fixed factors) exp(*β*_{0}) as an estimator of *λ* ((Nakagawa & Schielzeth 2010, 2013)). We also suggested that it is possible to use the mean of observed values *y _{ij}*. Unfortunately, these two recommendations are often inconsistent with each other. This is because, given the model 5 (and all the models in the previous section), the following relationships hold:
where E represents the expected value (i.e., mean) on the observed scale,

*β*

_{0}is the mean value on the latent scale (i.e.

*β*

_{0}from the intercept-only model),

*σ*

_{τ}^{2}is the total variance on the latent scale (e.g.,

*σ*

_{α}^{2}+

*σ*

_{e}^{2}in the models 1and 5, and

*σ*

_{α}^{2}in models 2-4; (Nakagawa & Schielzeth 2010); see also Carrasco 2010). In fact, exp(

*β*

_{0}) gives the median value of

*y*rather than the mean of

_{ij}*y*, assuming a Poisson distribution. Thus, the use of exp(

_{ij}*β*

_{0}) will often overestimate

*σ*

_{d}^{2}, providing conservative (smaller) estimates of

*R*

^{2}and ICC, compared to when using averaged

*y*, which is a better estimate of E[

_{ij}*y*]. Quantitative differences between the two approaches may often be negligible, but when

_{ij}*λ*is small, the difference can be substantial so the choice of the method needs to be reported for reproducibility (Appendix S2). Our new recommendation is to obtain

*λ*via Equation 32. When sampling is balanced (i.e. observations are equally distributed across individuals and covariates), Equation 32 and the mean of the observed values will give similar values, but when unbalanced, method Equation 32 is preferable. This recommendation for obtaining

*λ*also applies to negative binomial GLMMs (see Table 1).

## Jensen’s inequality and the ‘second’ delta method

A general form of Equation 31 is known as Jensen’s inequality, where *g* is a convex function. Hence, the transformation of the mean value is equal to or larger than the mean of transformed values (the opposite is true for a concave function; that is, ; Rao 2002). In fact, whenever the function is not strictly linear, simple application of the inverse link function (or back-transformation) cannot be used to translate the mean on the latent scale into the mean value on the observed scale. This inequality has important implications for the interpretation of results from GLMMs, and also generalized linear models GLMs and linear models with transformed response variables.

Although log-link GLMMs (e.g., model 5) have an analytical formula (Equation 32), this is not usually the case. Therefore, converting the latent scale values into observation-scale values requires simulation using the inverse link function. However, the delta method for bias correction can be used as a general approximation to account for Jensen’s inequality when using link functions or transformations. This application of the delta method uses a second order Taylor series expansion (Oehlert 1992; Ver Hoef 2012). A simple case of the delta method for bias correction can be written as:
)
where *d*^{2}*/dx*^{2} is a second derivative with respect to the variable x and the other symbols are as in Equations 24 and 32. By employing this bias correction delta method (with *d*^{2} exp(*x*)/ *dx*^{2} = exp(*x*)), we can approximate Equation 32 using the same symbols as in Equations 31-33:

The comparison between Equation 32 (exact) and Equation 35 (approximate) is shown in Appendix S3. The approximation is most useful when the exact formula is not available as in the case of a binomial GLMM with logit link (model 6):
Where *y _{ij}* is the number of ‘success’ in

*n*trials by the

_{ij}*i*th individual at the

*j*th occasion (for binary data,

*n*is always 1),

_{ij}*p*is the underlying probability of success, and the other symbols are the same as above.

_{ij}To obtain corresponding values between the latent scale and data (observation) scale, we need to account for Jensen’s inequality (note the logit function combines of concave and convex sections). For example, the overall intercept, *β*_{0} on the latent scale could be transformed not just with the inverse (anti) logit function (logit^{-1}(*x*) = exp(*x*)/(1 + exp(*x*))) but also the bias corrected approximation. For the case of the binomial GLMM, we can use this approximation below given that *d*^{2}logit^{−1} (*x*)/ *dx ^{2}* = exp(

*x*) (1 – exp(

*x*)) / (1 + exp(

*x*))

^{3}:

We can replace *β*_{0} with any value obtained from the fixed part of the model (i.e. *β*_{0}*+*Σ*β _{h}x_{hij}*). Another approximation proposed by Zeger et al. (1988) produces similar (but slightly better) estimates than Equation 40. Using our notation, this approximation can be written as:

A comparison between Equations 40 and 41 is also shown in Appendix S3. This approximation uses the exact solution for the inverse probit function, which can be written for a model like model 6 but using the probit link (i.e., *probit* in place of Equation 37):

Simulation will give the most accurate conversions when no exact solutions are available. The use of the delta method for bias correction accounting for Jensen’s inequity is a very general and versatile approach that is applicable for any distribution with any link function (see Appendix S3) and can save computation time. We note that the accuracy of the delta method (both variance approximation and bias correction) depends on the form of the function *f*, the conditions for and limitation of the delta method are described in Oehlert (1992).

## Special considerations for binomial GLMMs

The observation-level variance *σ _{ε}*

^{2}can be thought of as being added to the latent scale on which other variance components are also estimated in a GLMM (Equations 10, 15, 20, 26, 37 for models 2-6). Since the proposed

*R*

^{2}

_{GLMM}and ICC

_{GLMM}are ratios between variance components and their additive combinations, we can show using the delta method that

*R*

^{2}

_{GLMM}and ICC

_{GLMM}calculated via

*σ*

_{ε}^{2}approximate to those of

*R*

^{2}and ICC on the observation (original) scale (shown in Appendix S4). In some cases, there exist specific formulas for ICC on the observation scale (Nakagawa & Schielzeth 2010). In the past, we distinguished between ICC on the latent scale and on the observation scale (Nakagawa & Schielzeth 2010). Such a distinction turns out to be strictly appropriate only for binomial distributions but not for Poisson distributions (and probably also not for other non-Gaussian distributions). This is because the property of what we have called the distribution-specific variance

*σ*

_{d}^{2}for binomial distributions (e.g.

*π*

^{2}/3 for binomial error distribution with the logit link function) is quite different from what we have discussed as the observation-level variance

*σ*

_{ε}^{2}although these two types of variance are related conceptually (i.e., both represents variance due to non-Gaussian distributions with specific link functions). Let us explain this further.

A binomial distribution with a mean of *p* (the proportion of successes) has a variance of *p*(1–*p*) and we find that the observation-level variance is 1/(*p*(1–*p*)) using the delta method on the logit-link function (see Table 2). This observation-level variance 1/(*p*(1–*p*)) is clearly different from the distribution-specific variance *π*^{2}/3. As with the observation-level variance for the log-Poisson model (which is 1/*λ* and changes with *λ*; note that we would have called 1/*λ* the distribution-specific variance; Nakagawa & Schielzeth 2010, 2013), the observation-level variance of the binomial distribution changes as *p* changes (see Appendix S5), suggesting these two observation-level variances (1/*λ* and 1/(*p*(1–*p*))) are analogous while the distribution-specific variance *π*^{2}/3 is not. Further, the minimum value of 1/(*p*(1-*p*)) is 4, which is larger than *π*^{2}/3 *≈* 3.29, meaning that the use of 1/*p*(1–*p*) in *R*^{2} and ICC will always produce larger values than those using *π*^{2}/3.

Consequently, Browne et al. (2005) showed that ICC values (or variance partition coefficients, VPCs) estimated using *π*^{2}/3 were higher than corresponding ICC values on the observation (original) scale using logistic-binomial GLMMs (see also Goldstein et al. 2002; Nakagawa & Schielzeth 2010). Then, what is *π*^{2}/3?

Three common link functions in binomial GLMMs (logit, probit and complementary log-log) all have corresponding distributions on the latent scale: the logistic distribution, standard normal distribution and Gumbel distribution, respectively. Each of these distributions has a theoretical variance, namely, *π*^{2}/3, 1 and *π*^{2}/6, respectively (Table 2). As far as we are aware, these theoretical variances only exist for binomial distributions. It is important to notice that, for example, the meaning of 1/(*p*(1–*p*)), which is the variance on the latent scale that approximates to the variance due to binomial distributions on the observation scale is distinct from the meaning of *π*^{2}/3, which is the variance of the latent distribution (i.e., the logistic distribution) according to which the original data are theoretically distributed on the logit scale. We need distinguishing these theoretical (distribution-specific) variances from the observation-level variance. Put another way, *R*^{2} and ICC values using the theoretical distribution-specific variance can rightly be called the latent (link) scale *(sensu* Nakagawa & Schielzeth 2010) while, as mentioned above, *R*^{2} and ICC values using the observation-level variance estimate the counterparts on the observation (original) scale (cf. de Villemereuil *et al.* 2016). The use of the theoretical distribution-specific variance will almost always provide different values of *R*^{2}_{GLMM} and ICC_{GLMM} from those using the observation-level obtained via the delta method (see Appendix S5). In any case, we should be aware that binomial GLMMS are special cases for obtaining R^{2}_{GLMM} and ICC_{GLMM} from binomial GLMMs.

## Worked examples: revisting the beetles

In the following, we present a worked example by expanding the beetle dataset that was generated for (Nakagawa & Schielzeth)((2013)). In brief, the dataset represents a hypothetical species of beetle that has the following life cycle: larvae hatch and grow in the soil until they pupate, and then adult beetles feed and mate on plants. Larvae are sampled from 12 different populations (‘Population’; see Fig. 1). Within each population, larvae are collected at two different microhabitats (‘Habitat’): dry and wet areas as determined by soil moisture. Larvae are exposed to two different dietary treatments (‘Treatment’): nutrient rich and control. The species is sexually dimorphic and can be easily sexed at the pupa stage (‘Sex’). Male beetles have two different color morphs: one dark and the other reddish brown (‘Morph’, labeled as A and B in Fig 1). Sexed pupae are housed in standard containers until they mature (‘Container’). Each container holds eight same-sex animals from a single population, but with a mix of individuals from the two habitats (N_{[container]} = 120; N_{[animal]} = 960).

We have data on the five phenotypes, two of them sex-limited: (i) the number of eggs laid by each female after random mating which we had generated previously using Poisson distributions (with additive dispersion) and we revisit here for analysis with quasi-Poisson models (i.e. multiplicative dispersion), (ii) the incidence of endo-parasitic infections that we generated as being negative binomial distributed, (iii) body length of adult beetles which we had generated previously using Gaussian distributions and that we revisit here for analysis with gamma distributions, (iv) time to visit five predefined sectors of an arena (employed as a measure of exploratory tendencies) that we generated as being gamma distributed, and (v) the two male morphs, which was again generated with binomial distributions. We will use this simulated dataset to estimate *R*^{2}_{GLMM} and ICC_{GLMM}.

All data generation and analyses were conducted in R 3.3.1 (R Development Core Team). We used functions to fit GLMMs from the three R packages: 1) the *glmmadmb* function from glmmADMB (Fournier et al. 2012), 2) the *glmmPQL* function from MASS (Venables & Ripley 2002) and 3) the *glmer* and *glmer.nb* functions from lme4 (Bates et al. 2015). In Table 1, we only report results from *glmmADMB* because this is the only function that can fit models with all relevant distributional families. All scripts and results are provided as an electronic supplement (Appendix S6). In addition, Appendix S6 includes an example of a model using the Tweedie distribution, which was fitted by the *cpglmm* function from the cplm package (Zhang 2013). Notably, our approach for *R*^{2}_{GLMM} is kindly being implemented in the *rsquared* function in the R package, piecewiseSEM (Lefcheck 2016). Another important note is that we often find less congruence in GLMM results from the different packages than those of linear mixed-effects models, LMM. Thus, it is recommended to run GLMMs in more than one package to check robustness of the results although this may not always be possible.

In all the models, estimated regression coefficients and variance components are very much in agreement with what is expected from our parameter settings (Table 1 and Appendix S6). When comparing the null and full models, which had ‘sex’ as a predictor, the magnitudes of the variance component for the container effect always decrease in the full models. This is because the variance due to sex is confounded with the container variance in the null model. As expected, (unadjusted) ICC values from the null models are usually smaller than adjusted ICC values from the full models because the observation-level variance (analogous to the residual variance) was smaller in the full models (implying that the denominator of Equation 10 shrinks). However, the numerator also becomes smaller for ICC values for the container effect from the parasite, size and exploration models so that adjusted ICC values are not necessarily larger than unadjusted ICC values. Accordingly, adjusted ICC_{[container]} is smaller in the parasite and size models but not in the exploration model. The last thing to note is that for the morph models (binomial mixed models), both *R*^{2} and ICC_{vaiues} are larger when using the distribution-specific variance rather than the observation-level variance, as discussed above (Table 3; also see Appendix S4).

## Alternatives and a cautonary note

Here we extended our simple methods for obtaining *R*^{2}_{GLMM} and ICC_{GLMM} for Poisson and binomial GLMMs to other types of GLMMs such as negative binomial and gamma. We have described three different ways of obtaining the observational-level variance and how to obtain the key rate parameter *λ* for Poisson and negative binomial distributions. We discussed important considerations which arise for estimating *R*^{2}_{GLMM} and ICC_{GLMM} with binomial GLMMs. As we have shown, the merit of our approach is not only its ease of implementation but also that our approach encourages researchers to pay more attention to variance components at different levels. Research papers in the field of ecology and evolution often report only regression coefficients but not variance components of GLMMs (Schielzeth & Nakagawa 2013).

We would like to highlight two recent studies that provide alternatives to our approach. First, Jaeger et al. (2016) have proposed *R*^{2} for fixed effects in GLMMs, which they referred to as *R*^{2}_{β*} (an extension of an R^{2} for fixed effects in linear mixed models or *R*^{2}_{β*} by Edwards et al. 2008). They show that *R*^{2}_{β*} is a general form of our marginal R^{2}_{GLMM;} in theory, *R*^{2}_{β*} can be used for any distribution (error structure) with any link function. Jaeger et al. (2016) highlight that in the framework of *R*^{2}_{β*}, they can easily obtain semi-partial *R*^{2}, which quantifies the relative importance of each predictor (fixed effect). As they demonstrate by simulation, their method potentially gives a very reliable tool for model selection. One current issue for this approach is that implementation does not seem as simple as our approach. We note that our *R*^{2}_{GLMM} framework could also provide semi-partial *R*^{2} via commonality analysis (see Ray-Mukherjee et al. 2014; note that unique variance for each predictor in commonality analysis corresponds to semi-partial R^{2;}; Nimon & Oswald 2013).

Second, de Villemereuil *et al.* (2016) provided a framework with which one can estimate exact heritability using GLMMs at different scales (e.g. data and latent scales). Their method can be extended to obtain exact ICC values on the data (observation) scale, which is analogous to, but not the same as, our ICC_{GLMM} using the observation-level variance, *σ _{ε}*

^{2}described above. Further, this method can, in theory, be extended to estimate

*R*

^{2}

_{GLMM}on the data (observation) scale. One potential difficulty is that the method of de Villemereuli et al. is exact but that a numerical method is used to solve relevant equations so one will require a software package (e.g., the QGglmm package; de Villemereuil

*et al.*2016).

Finally, we finish by repeating what we said at the end of our original *R*^{2} paper (Nakagawa & Schielzeth 2013). Both *R*^{2} and ICC are indices that are likely to reflect only one or a few aspects of a model fit to the data and should not be used for gauging the quality of a model. We encourage biologists use *R*^{2} and ICC in conjunctions with other indices like information criteria (e.g. AIC, BIC and DIC), and more importantly, with model diagnostics such as checking for model assumptions, heteroscedasticity and sensitivity to outliers.

## Acknowledgements

We thank Losia Lagisz for help in making Figure 1. This work has been benefited from discussion with Jarrod Hadfield, Pierre de Villemereuil, Alistair Senior, Joel Pick and Dan Noble. SN was supported by an Australian Research Council Future Fellowship (FT130100268). HS was supported by an Emmy Noether fellowship from the German Research Foundation (DFG; SCHI 1188/1-2).

## Footnotes

**Authorship Statement:**SN conceived ideas and conducted analysis. Both developed the ideas further, and contributed to writing and editing of the manuscript.