Skip to content
Prev 1470 / 5636 Next

[R-meta] variance explained by fixed & random effects

Dear Wolfgang,

Thank-you for the fast reply! 

So the code is easy enough, but I am struggling to understand some of the nuance/ how to properly think about the different numbers. I have added some questions, between the dashed lines, below your answers. If they are within the scope of the mailing list and not to cumbersome, I would be curious for some explanations to help clear up my confusion. 

Thanks!

Theresa



One way of estimating an R^2-type measure for the fixed effects is to fit the reduced model without the predictor and then compute the proportional reduction in the variance components:

res0 <- rma.mv(yi, vi, random = ~ 1 | district/school, data=dat) 
pmax(0, (res0$sigma2 - res$sigma2) / res0$sigma2) * 100
max(0, (sum(res0$sigma2) - sum(res$sigma2)) / sum(res0$sigma2)) * 100

One can compute this per component or overall. There is no guarantee that the value is >= 0, so I use pmax()/max() to set negative values to 0. One could debate whether it even makes sense here to estimate how much of the school-level heterogeneity is accounted for by 'year'(since this is a district-level predictor), but that's another issue.

-----------------------------------------------------------------------------------------------------------------------------------------
***
So we have: 

sigma^2 for res0 .... heterogeneity in district & school:
0.06506194 0.03273652
sigma^2 for res1 .... heterogeneity in district & school, accounting for year:
0.11482670 0.03208976

(res0$sigma2 - res$sigma2) / res0$sigma2
-0.76488265  0.01975659

So it looks like accounting for year increases the heterogeneity in district.

Acknowledging and moving on from the fact that year is not the best fixed effect... What does it mean if the value is negative/zero? 
There is more variance in the random intercepts when you include the fixed effect? 
Adding this particular fixed effect does not improve the model? 
If I was writing this up, could I say: "Accounting for year does not explain any additional variation in the estimated variance of the random intercepts."
More specifically: 
"The heterogeneity accounted for by year is 0% for district level variance, and 1.98% for school level variance."
"The overall heterogeneity accounted for by year is 0%." ???

Thinking about marginal and conditional R^2 for mixed-effects models, there is a separation of fixed and random effects: fixed effects account for X% of the variation
and random effects accounting for Y% of the variation and Z% residual variance. But here the fixed effect is somehow included 
in the sigma^2 (estimated variance of the random intercepts)?  This just confuses me a bit/ I missed the thought process. 

***
-----------------------------------------------------------------------------------------------------------------------------------------

I am not sure how to think of the question how much variance is explained by a random effect here. One could ask how much of the total heterogeneity 
is due to district- and school-level variance, which would be:

res0$sigma2 / sum(res0$sigma2) * 100

Or one could ask how much of the unaccounted for heterogeneity (so heterogeneity not accounted for by 'year') is due to district- and school-level variance, which would be:

res$sigma2 / sum(res$sigma2) * 100

-----------------------------------------------------------------------------------------------------------------------------------------
***
So, to double check, the heterogeneity accounted for by year is, what you showed above: 

max(0, (sum(res0$sigma2) - sum(res$sigma2)) / sum(res0$sigma2)) * 100

We also know that: 

res0$sigma2 / sum(res0$sigma2) * 100  = 66.52655; 33.47345

max(0, (sum(res0$sigma2) - sum(res$sigma2)) / sum(res0$sigma2)) * 100 = 0

Since these have the same denominator... is it true that: 
[max(0, (sum(res0$sigma2) - sum(res$sigma2)) / sum(res0$sigma2)) * 100] + sum(res0$sigma2 / sum(res0$sigma2) * 100) = 100
(I check on my data and the answer seems to be no...)
***
-----------------------------------------------------------------------------------------------------------------------------------------

Or one could ask how much of the total variance (so heterogeneity + sampling variance) is due to district- and school-level variance, which would be:

k <- res$k
wi <- 1/dat$vi
s2 <- (k-1) * sum(wi) / (sum(wi)^2 - sum(wi^2))

res0$sigma2 / (sum(res0$sigma2) + s2) * 100

(here I am using the Higgins & Thompson, 2002, definition of a 'typical' sampling variance).

Or one could ask how much of the unaccounted for variance (so unaccounted for heterogeneity [heterogeneity not accounted for by 'year'] + sampling variance)
is due to district- and school-level variance, which would be:

res1$sigma2 / (sum(res1$sigma2) + s2) * 100

-----------------------------------------------------------------------------------------------------------------------------------------
***
Can one ask here how much of the total variance (estimate of variance in true effects + sample variation) is accounted for by year? This is really what I want. 
***
-----------------------------------------------------------------------------------------------------------------------------------------