Effect Size Estimation in Linear Mixed Models
J\"urgen Gro{\ss}, Annette M\"oller

TL;DR
This paper revisits Cohen's effect size measure $f^2$ within linear mixed models, demonstrating its calculation using R's lme4 package on simulated data, simplifying effect size estimation without needing a coefficient of determination.
Contribution
It introduces a method to compute Cohen's $f^2$ effect size in linear mixed models using standard software, avoiding complex calculations.
Findings
$f^2$ can be effectively computed in linear mixed models using R.
The method simplifies effect size estimation without requiring a coefficient of determination.
Application demonstrated on artificially generated data.
Abstract
In this note, we reconsider Cohen's effect size measure under linear mixed models and demonstrate its application by employing an artificially generated data set. It is shown how can be computed with the statistical software environment R using lme4 without the need for specification and computation of a coefficient of determination.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAdvanced Statistical Methods and Models · Bayesian Modeling and Causal Inference · Statistical Methods and Inference
Effect Size Estimation in Linear Mixed Models
Jürgen Groß
Institute for Mathematics and Applied Informatics, University of Hildesheim, Germany
and
Annette Möller
Faculty of Business Administration and Economics, Bielefeld University, Germany
Abstract.
In this note, we reconsider Cohen’s effect size measure under linear mixed models and demonstrate its application by employing an artificially generated data set. It is shown how can be computed with the statistical software environment R using lme4 without the need for specification and computation of a coefficient of determination.
Key words and phrases:
Hypothesis testing, effect size, Cohen’s f2, linear regression, linear mixed model, multivariate normal distribution
2010 Mathematics Subject Classification:
62J05, 62J20, 62F03
Support of the second author by the Helmholtz Association’s pilot project ”Uncertainty Quantification” is gratefully acknowledged.
1. Introduction
In studies with a large number of observations, statistical testing procedures are prone to detect even minor departures from a null hypothesis yielding very small p-values. However, since significance does not automatically imply relevance, measures for the size of the effect associated with a possible rejection of the null hypothesis are often recommended as a useful tool, see e.g. Wilkinson (1999).
A well known effect size measure in a regression context when a quantitative variable depends on independent regressors (quantitative and/or qualitative) is Cohen’s , see Cohen (1988, Chapt. 9). Under multivariate normality this measure is strongly related to an test of a linear hypothesis that a subset of independent variables does not substantially contribute to the explanation of , given a set of independent regressors already included in the model. One may argue that even if the regression coefficients associated with variables significantly differ from zero, their contribution may be assessed as relevant when some meaningful size of their effect is measured.
In this light studies may additionally want to report values for each variable in a regression model given the others, see for example Tables 2 to 5 in Taylor et al. (2020). With regard to the procedure of calculating , the authors refer to Selya et al. (2012) who introduced a practical method in relation with SAS® software. This approach even carries over to linear mixed models, i.e. the case that some independent variables are associated with random effects rather than with fixed effects. Hence, the original approach by Cohen is generalized to a certain extent, involving the additional estimation of a variance-covariance matrix.
In the following we reconsider and discuss the generalization of to linear mixed models. We also point to an alternative computational procedure which turns out to be especially useful in context with the statistical software environment R (R Core Team, 2022) and well known package lme4, see Bates et al. (2015), for fitting linear mixed models. Our explanations are illustrated on the basis of an artificially generated data set.
2. Linear Mixed Model
Consider a linear mixed model (LMM) described by
[TABLE]
where is an observable random vector. It is assumed that the model matrix of full column rank can be partitioned as
[TABLE]
where denotes the vector of ones, while the and matrices and contain the values of regressors. The vector comprises unknown parameters addressed as fixed effects. The matrix contains the values of independent variables associated with an vector of unobservable random effects. It is assumed that has expectation (the vector of zeroes) and variance covariance matrix with unknown parameter and matrix , which may depend on further unknown parameters. For the vector of unobservable random errors it is assumed that and , where the positive definite matrix may also depend on unknown parameters. Moreover, the assumption (the matrix of zeroes) implies
[TABLE]
Then the above model may also be represented by the triplet and can be considered as a special case of the general Gauss-Markov model, see e.g. Groß (2004). As a matter of fact, formulas useful under model 1) carry over from a classical regression model with and , see Christensen (2020, Sect 2.7). Here denotes some nonsingular matrix satisfying . Let us assume for the moment that is completely known. Then
[TABLE]
is the best linear unbiased estimator for , and
[TABLE]
is the usual unbiased estimator for . Consider the linear hypothesis versus for a given matrix of full row rank and a given vector . The corresponding statistic in model (1) is
[TABLE]
where
[TABLE]
Under multivariate normality the statistic follows a distribution provided holds true.
2.1. Effect Size
Suppose that we are interested in the effect of the independent variables represented by the model matrix , given the variables represented by . The corresponding linear hypothesis reads with . Hence, by reasoning similar to Cohen (1988), an appropriate measure for the size of the effect based on the above statistic is provided by
[TABLE]
thereby removing the factor from the statistic. This generalizes Cohen’s in the sense that if , then the unobservable random vector equals with probability one, the LMM reduces to the usual linear model of fixed effects only, and becomes identical to the measure provided by formula (9.2.1) in Cohen (1988).
We note that it is also possible to compute as
[TABLE]
for appropriately defined coefficients of determination derived under the full model and derived under a reduced LMM assuming that variables represented by are not present at all. Such a formula is the basis for the widely applied computational procedure suggested by Selya et al. (2012).
2.2. Operational Effect Size
Formula (8) for is only operational when is completely known, a condition not met in practical applications. According to Harville (1977) a simple LMM is the ordinary mixed and random effects ANOVA model, also referred to as traditional variance components model, see Christensen (2019, Chapt. 5). Under this model, the variance-covariance matrix of depends on a total of variance components. The matrix is partitioned as , where each matrix is the design matrix corresponding to a qualitative variable with a certain number of levels. In such a case one may assume
[TABLE]
where and are unknown variance components. Then
[TABLE]
If for some , then the corresponding random effect vector equals with probability one. Such a model, and also more general ones, may be fitted in R with the package lme4, see Bates et al. (2015). From the fitting procedure its is possible to obtain an estimate for the variance-covariance matrix
[TABLE]
of the estimated fixed effects parameter vector . Then a corresponding estimate for is given as
[TABLE]
where the factor is required to compensate for the usage of in the estimated variance-covariance matrix (12). The application of this formula is illustrated in the following section. The merit of formula (13) lies in the fact that it can be applied whenever an estimate (12) is available. But then, of course, the actual outcome also depends on the estimation procedure, implying that different estimation methods for (12) may also lead to (slightly) different actual values of (13). This, however, is not the topic of our discussion. Also, when applying (13) there is no need for computing coefficients of determination. Nonetheless it is possible to define an operational version of (9) which corresponds to (13). This is demonstrated in Sect. 3.4, where the measure discussed in Edwards et al. (2008) is used with an operational version of the statistic obtained in the same light as (13) by employing the very same variance-covariance estimate (12). Again, employing alternative computational methods or alternative measures in linear mixed models, see also Nakagawa and Schielzeth (2013); Nakagawa et al. (2017), may result in different actual values of .
3. Example
In the following we discuss the performance of measure for an artificially generated data set of observations intended to further illustrate some computational aspects. For the sake of simplicity our model consists of two independent variables (categorical/binary) and (quantitative) associated with fixed effects and one variable (categorical) associated with random effects. However, the same principles apply when , , and are extended to possible sets of variables containing more than one element. Our setting corresponds to the above mentioned variance components model with and .
3.1. Variable of Interest
Figure 1 shows a discernible location difference with respect to the distribution of the response variable in the two groups indicated by the binary variable . The Welch two-sample statistic for the null hypothesis of no difference in group means reads implying a highly significant result. A corresponding effect size measure is Cohen’s which may be computed from R package effectsize, see Ben-Shachar et al. (2020), as . From Cohen, values , and indicate a small, medium and large effect, respectively.
3.2. Additional Fixed Effects
From Figure 2 one may conclude, however, that the difference in the two groups may to some extent be explained by the variable , since there is a tendency for larger values of to come along with larger values of and observations from group 1 of variable . Therefore one might be interested in the size of the effect of when is held constant. This can be achieved by considering a regression model with and as independent variables and deriving the measure as explained in (Cohen, 1988, Sect. 9). From package effectsize one gets . Here, values , and are supposed to indicate a small, medium and large effect, respectively.
Recently, Groß and Möller (2023) considered a generalized version of as an effect size measure for a binary variable given further variables. It may be computed from as
[TABLE]
where in our analysis is the number of additional independent variables incorporated in the model and is the variance of the regression coefficient for . For our data , yielding and thus confirming a less than small effect.
3.3. Additional Fixed and Random Effects
As a next step one may take the categorical variable , admitting 15 groups in our data set, into account. From Figure 3 it is seen that there is a tendency for groups with larger means of the response variable to contain less observations marked as 1 (referring to variable ) than groups with smaller means of . However, since observations from group 1 were earlier seen to reveal on average larger values than observations from group 0, holding constant is expected to contribute in favor of an effect of again.
As noted before, the variable is meant to be associated with a random effects vector . The corresponding design matrix has 15 columns where each row contains 0’s and a single 1, indicating the membership of the observations to the respective variable group. There are two variance components, the overall and the random effects variance denoted by here. The model may also be reparameterized via an unknown by setting . This gives variance-covariance matrix
[TABLE]
and the LMM reduces to the usual fixed effects regression model in case . For from (15) one may compute the effect size for as a function of from formula (8) when all variables , and are included in the LMM formulation. Figure 4 shows for different choices of . As expected, the effect size is larger when both, and are incorporated into the model compared to the case when only is employed, corresponding to the choice .
The operational version of from (13) can easily be computed from fitting the model by the function lmer from package lme4 as fit <- lmer(Y ~ 1 + X1 + X2 + (1|Z)). The estimated variance components are and giving as an estimation for , see the dashed vertical line in Figure 4. Then the vector is obtained from fixef(fit) and is obtained from vcov(fit). By using and , formula 13 yields indicating a small but not medium effect size of when and are held constant.
3.4. Coefficient of Determination
Finally, we confirm that may also be obtained from formula (9), although there is no actual need for this when formula (13) can be used instead. For this, we define
[TABLE]
which is the proposed for linear mixed models by Edwards et al. (2008, Eq. (19)). Here, is the statistic from (6) for testing the hypothesis with . The relationship between and from (16) may be established similar to Example 4.8 from Seber and Lee (2003). For our data , , and . The measure is defined in the same way, but for a reduced model with all variables present except for . For this reduced model we have , , , . This results in
[TABLE]
which is nearly the same as the value computed above. The displayed values were obtained from operational versions of and computed in the same light as formula (13) by employing the estimated variance covariance matrix of the fixed effects resulting from applying vcov() to the two models in question.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1Bates et al. (2015) D. Bates, M. Mächler, B. Bolker, and S. Walker. Fitting linear mixed-effects models using lme 4. Journal of Statistical Software , 67:1–48, 2015. URL https://doi.org/10.18637/jss.v 067.i 01 . · doi ↗
- 2Ben-Shachar et al. (2020) M. S. Ben-Shachar, D. Lüdecke, and D. Makowski. effectsize: Estimation of effect size indices and standardized parameters. Journal of Open Source Software , 5:2815, 2020. URL https://doi.org/10.21105/joss.02815 . · doi ↗
- 3Christensen (2019) R. Christensen. Advanced Linear Modeling: Statistical Learning and Dependent Data . Springer Nature, 2019.
- 4Christensen (2020) R. Christensen. Plane Answers to Complex Questions. Fifth Edition . Springer, 2020.
- 5Cohen (1988) J. Cohen. Statistical Power Analysis for the Behavioral Sciences. Second Edition . Lawrence Erlbaum Associates, 1988.
- 6Edwards et al. (2008) L. J. Edwards, K. E. Muller, R. D. Wolfinger, B. F. Qaqish, and O. Schabenberger. An R 2 statistic for fixed effects in the linear mixed model. Statistics in Medicine , 27:6137–6157, 2008.
- 7Groß (2004) J. Groß. The general Gauss-Markov model with possibly singular dispersion matrix. Statistical Papers , 45:311–336, 2004.
- 8Groß and Möller (2023) J. Groß and A. Möller. A note on Cohen’s d from a partitioned linear regression model. Journal of Statistical Theory and Practice , 17:22, 2023. URL https://doi.org/10.1007/s 42519-023-00323-w . · doi ↗
