# R square in mixed model with random effects

For mixed models with random intercepts only, the statistic for R square is

My question is: How to estimate R square in mixed models with random effects? And estimate R square for each level? Let’s say it’s a 3-level model with random effects of time at level 2.

The R package MuMIn also now has a function for calculating Nakagawa and Schielzeth’s r-squared for mixed models. That is the function r.squaredGLMM() and you simply feed it a lmer object (from package lme4) to obtain the values.