Brms estimating group variances of normal responses

  • Operating System: Ubuntu 19.10
  • brms Version: 2.12.0

3.4e-mdl

data:

3.4e-data
Current stan code:

data {
int<lower=0> n;
real Y[n];
}

parameters {
real<lower=0> b;
real<lower=0> sigma[n];
}

model{
Y ~ normal(0, sigma);
sigma ~ inv_gamma(10,b);
b ~ gamma(1,1);
}

Current brms:
b3.4e <- brm(data = df,
family = gaussian,
formula = brms::bf(Y ~ 0 + (1|i), sigma ~ 0 + (1|i)),
prior = c(prior(normal(0, sigma), class = sd, group = i),
prior(inv_gamma(10,2), class = sd, dpar = sigma, group = i)),
iter = 4000, warmup = 500, chains = 4, cores = 12,
seed = 4
)

The goal is to estimate sigma[1:n] and b.

I feel confident about the Stan version which produces results close to RJAGS, but have been uncertain about how to model it appropriately with brms.

I’ve been looking at estimating distributional models, and using brms::get_prior to improve my likelihood formula and priors, but I still don’t know how to add the b prior correctly. Is this supposed to be an intercept-only model with group effects?

Is brms for non-regression models like this? Or does it just take a greater understanding of glm’s and brms’s syntax to get there?

You can check the Stan code produced by brms using the make_stancode and stancode function. Note that it is not possible (easily) to use InvGamma random effects but only normal (and student-t) ones.