Using an R2D2-style prior for the ICC (brms/Stan)?

In a frequentist framework, the ICC (the proportion of true-score variance) for test-retest or rater reliability comes can be estimated form a mixed model in lme4: fit y ~ 1 + (1 | subject) + (1 | rater) and take the subject variance over the total. A Bayesian version looks easy on the surface (same model in brms), but I’ve hit two things I can’t resolve.

1- it isn’t intuitive to put priors on the SDs of the group-level intercepts. The quantity I have direct beliefs about is the ICC; the group-level variances are more challenging to generate priors for.

2- weakly informative priors on those SDs, especially the same on each, imply a fairly pessimistic prior. For example, if the subject, rater, and residual SDs all get the same half-t(3) prior, I’m saying my prior belief is that the subject should account for about a third of the variance.

I’ve been thinking about the R2D2 parameterization as an analogous problem/solution. The ICC is a similar kind of quantity, so why not put the prior directly on it. However - this is pushing my stats comfort zone - and I’d greatly appreciate some input from folks smarter than me.

My thought is to sample the ICC (theta) with a Beta prior, then sample the rater’s share of whatever variance is left over (psi), with its own Beta prior, and build the variance components from the two. Two-step split of the total variance (ICC first, then rater vs. residual), and I think the likelihood is unchanged.

real<lower=0, upper=1> theta;   // ICC(A,1)
real<lower=0, upper=1> psi;     // rater share of the non-subject variance

sigma2_s = theta * sigma2_total;
sigma2_r = psi * (1 - theta) * sigma2_total;
sigma2_e = (1 - psi) * (1 - theta) * sigma2_total;

theta ~ beta(theta_a, theta_b);
psi   ~ beta(psi_a, psi_b);

Q1: Is this reasonable?

Q2: the two priors I’ve landed on so far from simulation so far are theta ~ Beta(4.2, 1.8) (mode 0.8, concentration 6, mean 0.70) and psi ~ Beta(1.1, 4) (mean about 0.2). The theta choice mattered less than I expected; a weaker Beta(1.8, 1.2) behaved almost the same. For psi I’d prefer a spike at zero, but a Beta with a < 1 made the sampler diverge badly when raters are few, > 1 was a compromise. The cost is that it pulls psi toward 0.2 and never really says “no rater effect.” Perhaps this is a reasonable prior, since the rater effect is probably never truly zero.

I assume you mean pessimistic in terms of how much variance they can explain? I don’t think that’s unusual if the mean itself is predictive. But the right thing to do in any case is think about the scale of your problem. suppose we use a student_t(nu, mu, sigma) prior. The degrees of freedom nu will determine just how wide the tails are, mu will determine the location we expect, and sigma will determine the scale of variation. If it’s an intercept plus item-level effect formulation, then mu has to be 0 (this is how we recommend coding models like this). Then think about how much variation in item-level effects would surprise you and make you check your model thoroughly to make sure it’s not wrong. Then use that as the bounds for the weakly informative prior. If the data push up against that prior, you’ll see it in extreme values.

One workflow would be to fit an intercept only model with no group-level effects and inspect the residuals. The higher those are, the more variance you need among groups. This may seem like cheating if you come from a frequentist or traditional “objective” Bayesian background, but it’s what we’ve been recommending since we started the Stan project and what you actually see many groups doing on the down low (i.e., not telling people they’re inspecting the data before deciding on a model).

For more peace of mind, you can then run prior sensitivity analyses. Change sigma and nu and see how it affects the posterior. Usually not much.

If you actually format the mixed effects model as in lme4, then you probably are thinking about hyperpriors. That is, we have something like mu + alpha[item[n]] * x[n] as the linear predictor for item n in a simple case. Then the prior is something like alpha[k] ~ normal(0, tau) and then you can probably use a normal rather than Student-t for the items unless you expect orders of magnitude swings among them, in which case you may need wider tails. You then have to find a prior for tau, which is usually not very sensitive.

You can think in terms of variance explained and use that for a prior, but I doubt if you have much data per group that it will make much of a difference.

You’ll never get a true zero posterior estimate from a Bayesian posterior as it’s an expectation over a positively-constrained quantity. You can get close, though. That’s where people bring in things like the horseshoe prior, the compound structure of which can lead to much stronger regularization.

Thanks for your thoughts - this is extremely helpful. I should have been clearer about “pessimistic.” I don’t mean low R² in the regression sense. In a reliability model, the subject-level intercept is the signal, and the rater and residual terms are noise, so the ICC is the signal’s share of the total variance: tau_subject² / (tau_subject² + tau_rater² + sigma²). For any instrument worth using, I expect tau_subject to be much larger than tau_rater and sigma. Giving all three the same prior says the opposite - the subject is expected to carry about a third of the variance, and the implied prior on the ICC has a median around 0.22 with roughly a 1-in-4 chance of being below 0.05. That’s what I mean by pessimistic: before seeing any data it says the measure is probably unreliable.

I agree about thinking in terms of scale, and I do scale the hyperpriors to sd(y). But that sets each scale on its own and doesn’t control the ratio. I could give tau_subject a wider scale than the other two and tune it with prior predictive checks on the ICC, but that’s a roundabout way of saying what I actually believe, which is something like “the ICC is likely between .5 to .9; it would be unlikely for it to be < 0.5, and somewhat unlikely to exceed > 0.9.” I could try to decompose this belief into the separate hyperpriors, but this is much less intuitive.

The ICC is often evaluated on whether it clears 0.75 (i.e., the probability it exceeds some minimal threshold of acceptable reliability), so I care how the prior behaves on that scale rather than on the individual taus. Typical designs are also lopsided: e.g., 50 subjects but 3 to 8 raters. For tau_subject I agree the hyperprior barely matters. But tau_rater the hyperprior can be important. (Also - the more standard version of this model (i.e., estimate the taus directly) funnels badly for me with fewer raters, so “changing sigma and nu usually doesn’t matter much” isn’t necessarily true here.)

Perhaps of use for your problem: an approach I used (successfully) to decompose variance in count data. My problem back then was that I did not want to assign priors to the different group-level variances / random intercepts because it completely blew up the prior expected total variance (the push-forward prior). To this end, I defined (1) a parameter as a measure of the total variance in the data, more specifically the coefficient of variation in my case (total variance might me sufficient for you as a measure); and (2) a simplex parameter as a measure of how much of the total variance was explained by each grouping level. The math of it is explained in another thread here on the forum:

EDITs: typo corrections

If you have two random effects (subject and rater) then the R2D2 prior framework should work nicely. R2D2 and random effect models have been detailed in Yanchenko et al. (2025) (I’m the first author on this paper) and Aguilar and Burkner (2025). The model would look something like this:

Y_i = \beta_0 + \alpha[c_i] + \gamma[k_i] + \epsilon_i

where \beta_0 is the intercept, \boldsymbol{\alpha} is the random effect for subject and \boldsymbol{\gamma} is the random effect for rater, and \epsilon_i\sim N(0,\sigma^2) is the residual. The R2D2 prior would then model the random effects as

\boldsymbol{\alpha}\sim N(0,\sigma^2\phi_1\omega{\bf I})\text{ and } \boldsymbol{\gamma}\sim N(0,\sigma^2\phi_2\omega{\bf I})

where \omega \sim BP(a,b) is the global variance of the linear predictor;

\boldsymbol{\phi}=(\phi_1,\phi_2)^\top\sim Dirichlet (\xi_1,\xi_2) are the local variance components apportioning the variance to the subject effect (\phi_1) and rater effect (\phi_2). The hyper-parameters (\xi_1,\xi_2) allow you to control your prior beliefs on these components. For example, if you expect much more variance from the subject effect then the rater effect, you should set \xi_1 to be much larger than \xi_2. If after fitting you find \phi_1 is much larger than \phi_2, then this corresponds to what you said that the variance of the subject is much larger than the variance from the rater. This is one advantage of the R2D2 framework that these \phi_j’s naturally are interpreted as the proportion of variance of each random effect. Lastly, \sigma and \beta_0 can have “vague” priors.

You’ll notice that this framework has the residual variance \sigma^2 as part of the random effects variance and also treats both subject and rater effects as “signal” whereas it seems that you would prefer to treat the rater as “noise.” I think this formulation is still fine however as it explicitly shows where the variance is coming from. This formulation yields

R^2=\frac{\omega}{1+\omega}\sim Beta(a,b) so you can also set (a,b) if you have information on the overall model fit (as quantified in R^2).

Hope this helps. I’ve authored multiple papers on the R2D2 prior and would be happy to discuss more if that would help. Feel free to reach out at eyanchenko@aiu.ac.jp

You can proceed as Eric said!

The R2D2 prior for multilevel models is already implemented within brms. If you are interested in inducing shrinkage, this can achieved by setting values below 0.5 for the corresponding Dirichlet vector parameters.

Below you can find a short script that illustrates how to use the R2D2 prior in brms. Let us know if you have any questions :) Hope this helps.

library(brms)
library(posterior)
library(bayesplot)
library(haven)
library(tidyverse)

# small script to show how to use the R2D2 prior with brms
# see ?R2D2 for details
# https://paul-buerkner.github.io/brms/reference/R2D2.html


# Read the data
# I am using the popularity dataset, which I found in this brms tutorial
# https://www.rensvandeschoot.com/tutorials/brms-started/
# Dataset is found here: 
#https://github.com/Rensvandeschoot/Tutorials/blob/master/R%20for%20beginners/popular_regr_1.sav

popular2data <- read_sav(file = "your directory")
popular2data <- dplyr::select(popular2data, pupil, class, extrav, sex, texp, popular)

# Specifiy the R2D2 prior 
bprior <- prior(R2D2(mean_R2= 0.5, prec_R2=1 ,cons_D2 = 2, main = TRUE), class = sd) + 
  prior(R2D2(), class = b)

# Model with varying slopes

fit1 <- brm(popular ~ 1 + sex + extrav + texp + (1 + extrav | class),  
              data = popular2data, 
              prior = bprior,
              warmup = 1000,
              iter = 2000, 
              cores = 4, 
              chains = 4, 
              seed = 123) 

summary(fit1)
plot(fit1)

#---- Additional plots 

# R2 and total variance

mcmc_dens_overlay(fit1, pars = c("R2D2_R2",
                                 "R2D2_tau2"),
                  facet_args = list(nrow = 2)) 

# Proportions of explained variance

drawsfit1 <- as_draws_df(fit1, 
                         variable = c("^R2D2_tau2", "^R2D2_R2", "^sdb_", "^sd"),
                         regex= TRUE) %>%
  mutate_variables( phi_sex = `sdb_sex`^2/ R2D2_tau2,
                    `phi_extrav` = `sdb_extrav`^2 / R2D2_tau2,
                    `phi_texp` =`sdb_texp`^2/R2D2_tau2,
                    `phi_class_Intercept` =`sd_class__Intercept`^2/R2D2_tau2,
                    `phi_class_extrav` =`sd_class__extrav`^2/R2D2_tau2
  ) %>% 
  rename_variables(
    "TotalVariance"= "R2D2_tau2", 
    "R2"="R2D2_R2", 
  ) %>% 
  dplyr::select(!starts_with("sd"))

mcmc_intervals(drawsfit1, regex_pars=c("^phi_"), prob = 0.8, prob_outer = 0.95) +
  ggtitle("Proportion of explained variance") +
  theme(plot.title = element_text(size = 16)) + 
  yaxis_text(size = 14) +
  xaxis_text(size = 14)


sm1 <- summarise_draws(drawsfit1, default_summary_measures())
knitr::kable(sm1, caption = "Summary Model 1", digits = 3)

Thanks all - so helpful and grateful for your responses! I’m going to run some simulations and see how this performs vs. the standard parameterization and a frequentist ICC. Will report back -