# 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

### How to predict unknown time series in using Facebook Prophet?

0  Asked on November 20, 2021

### Choosing the right model for prediction

1  Asked on November 18, 2021

### Relation between P-value in a randomness test, number of samples, and entropy

1  Asked on November 18, 2021

### Is there a way to use cor function with factor variables without creating dummy variables? (R)

1  Asked on November 18, 2021 by charles-orlando

### What’s the intuition behind contrastive learning or approach?

2  Asked on November 18, 2021

### What is the difference between econometrics and statistics?

6  Asked on November 18, 2021

### Central limit theorem – num random variables vs. sample size?

1  Asked on November 18, 2021 by imagineerthat

### How to smooth an existing PDF?

1  Asked on November 18, 2021 by crimson_idiot

### Finding variance and mean of an expression?

0  Asked on November 18, 2021

### One-sample t-test on count data

0  Asked on November 16, 2021 by zarya

### Book recommendation for ANOVA and linear models

2  Asked on November 16, 2021 by shial-de

### Can you run intraclass-correlations with different raters, and different numbers of raters per participant?

2  Asked on November 16, 2021 by bruce-rawlings

### How to calculate estimated log-sum coefficient in the context of nested logit model in R?

1  Asked on November 16, 2021

### Classification Problem With Estimated and Dependent Covariates

0  Asked on November 16, 2021 by dimitriy

### Variable of importance and Q2Y in PLSR

0  Asked on November 16, 2021

### Measurement error in one indep variable in OLS with multiple regression

3  Asked on November 16, 2021

### How is sklearn’s Logistic Regression’s Score Calculated?

0  Asked on November 16, 2021 by user291976

### Data Visualization – how to display error of a color scale?

1  Asked on November 16, 2021 by ben-s

### Acceptance sampling

1  Asked on November 16, 2021