I noticed that rstanarm::stan_lmer fails to correctly estimate the variance components of a one-way ANOVA model with a random factor when the ratio of the between variance over the within variance is high.
mu <- 10000 # grand mean
sigmaWithin <- 1e-3
ratio <- 100
sigmaBetween <- sigmaWithin * ratio
sigmaBetween^2
I <- 10L # number of groups
J <- 5L # sample size per group
set.seed(31415926L)
groupmeans <- rnorm(I, mu, sigmaBetween)
y <- c(
vapply(groupmeans, function(gmean) rnorm(J, gmean, sigmaWithin), numeric(J))
)
dat <- data.frame(
y = y,
group = gl(I, J)
)
stan <- stan_lmer(
y ~ (1|group), data = dat,
prior_aux = cauchy(0, 5)
)
posterior_interval(stan)
How would you deal in such a situation? I found that increasing the scale parameter in prior_covariance = decov(......) yields better results.
That scale parameter has a gamma prior that by default has a shape of 1 and a scale of 1 (i.e. is exponential). So, if you think values above a million are plausible, then you would need to adjust the shape and scale a bit.