# Linear Mixed Regression Variance Decomposition

Cross Validated Asked by lstdnce on January 5, 2022

I’m pretty new to R and was hoping to get some advice on variance decomposition in mixed linear models. Similar to this question;
How to estimate variance components with lmer for models with random effects and compare them with lme results, I have a linear mixed model and would like to be able to estimate how much variability in the outcome variable is related to the random and fixed effect factors (something like R-squared). This appears to be relatively straight forward when there are only fixed factors (e.g. https://murraylax.org/rtutorials/regression_anovatable.html) but I cannot seem to find anything about how to calculate this when there are random effects involved as well.

Here is what I’ve tried so far. I am working with the Orthodont data set as an example. The linear model that I used was:

res <- lmer(distance ~ age*Sex + (1|Subject), data= Orthodont)
summary(res)
anova(res)


The summary was:

Linear mixed model fit by REML ['lmerMod']
Formula: distance ~ age * Sex + (1 | Subject)
Data: Orthodont

REML criterion at convergence: 433.8

Scaled residuals:
Min      1Q  Median      3Q     Max
-3.5980 -0.4546  0.0158  0.5024  3.6862

Random effects:
Groups   Name        Variance Std.Dev.
Subject  (Intercept) 3.299    1.816
Residual             1.922    1.386
Number of obs: 108, groups:  Subject, 27

Fixed effects:
Estimate Std. Error t value
(Intercept)    16.3406     0.9813  16.652
age             0.7844     0.0775  10.121
SexFemale       1.0321     1.5374   0.671
age:SexFemale  -0.3048     0.1214  -2.511

Correlation of Fixed Effects:
(Intr) age    SexFml
age         -0.869
SexFemale   -0.638  0.555
age:SexFeml  0.555 -0.638 -0.869


The anova was:

    Analysis of Variance Table
npar  Sum Sq Mean Sq  F value
age        1 235.356 235.356 122.4502
Sex        1  17.860  17.860   9.2921
age:Sex    1  12.114  12.114   6.3027


What I would like to determine, is how to calculated the % of variance related to the each parameter. To my understanding, Repeatability can be calculated by dividing the variance contribute of one factor by the total variance. To perform this calculation with this data for age, would it be correct to divide the mean squared error for age by the sum the mean squared error from the ANOVA table and the variances from the random-effects table:

i.e:
235.356/(235.356 + 17.860 + 12.114 + 3.299 + 1.922)

..and repeat something similar for the remaining factors? Something about this seems a bit odd to me. Any help would be appreciated.

## Related Questions

### Choice between static and dynamic panel regression

2  Asked on December 21, 2020 by uzbekistan

### Are there realistic/relevant use-cases for one way ANOVA?

2  Asked on December 20, 2020 by david-ernst

### Help with name of a regression

0  Asked on December 19, 2020 by user276835

### Forecasts combination via weights based on normal distribution

0  Asked on December 18, 2020 by oumayma-bounouh

### May Skilling’s Nested Sampling Estimate parameters in hierarchical model?

0  Asked on December 18, 2020 by germania

### How to test the influence of an external factor?

0  Asked on December 17, 2020 by pavel

### Nonparemetric tests: how to support the null hypothesis you claim to be testing

1  Asked on December 17, 2020

### Hazards in AFT with Weibull distribution

1  Asked on December 17, 2020 by user11130854

### Seeking authoritative references on weighted ANOVA

0  Asked on December 16, 2020 by whuber

### Lasso Regression – Finding multiple candidate models

1  Asked on December 16, 2020 by jlearner

### Are conditional mean in an AR(1)-GARCH(1,1) equal for different GARCH(1,1) processes of the same data?

1  Asked on December 16, 2020 by ber08

### Completly Randomized Trials versus Incomplete Cubic Lattice

0  Asked on December 16, 2020 by noumenal

### Unusual (to me) Phrasing of Power Analysis Objective; Interpretation Requested

1  Asked on December 15, 2020 by emmettcc

### Question about the right inverse method in a GLM of order 2

1  Asked on December 15, 2020 by suzee

### Different formulations of within-class scatter matrix

0  Asked on December 15, 2020

### Correct algorithm for string classification

1  Asked on December 14, 2020 by bandit_king28

### What is the best way to remember the difference between sensitivity, specificity, precision, accuracy, and recall?

9  Asked on December 13, 2020 by jessica

### Quantifying the uncertainty of aggregated model predictions

1  Asked on December 13, 2020 by kh_one

### Evaluate Bayesian SEM goodness of fit blavaan

1  Asked on December 13, 2020 by l-sicilis