What exactly are the posterior summaries reported for the random effect variances in the print method for stan_glmer
fits? When I manually compute point estimates from the draws, I get something pretty different than the output of the print method.
For example, using data from the Pilots dataset from chapter 13 of the ARM examples in the dataframe df
, I run
rstan_fit <- stan_glmer(y ~ 1 + (1 | group_id) + (1 | scenario_id), df)
print(rstan_fit)
This displays (in part):
Error terms:
Groups Name Std.Dev.
scenario_id (Intercept) 0.348
group_id (Intercept) 0.067
Residual 0.224
In contrast, we can look directly at the draws:
rstan_draws <- as.matrix(rstan_fit)
group_id_col <- "Sigma[group_id:(Intercept),(Intercept)]"
scenario_id_col <- "Sigma[scenario_id:(Intercept),(Intercept)]"
median(sqrt(rstan_draws[, scenario_id_col]))
mean(sqrt(rstan_draws[, scenario_id_col]))
median(sqrt(rstan_draws[, group_id_col]))
mean(sqrt(rstan_draws[, group_id_col]))
The output of which is:
> median(sqrt(rstan_draws[, scenario_id_col]))
[1] 0.3168345
> mean(sqrt(rstan_draws[, scenario_id_col]))
[1] 0.3335378
> median(sqrt(rstan_draws[, group_id_col]))
[1] 0.03530919
> mean(sqrt(rstan_draws[, group_id_col]))
[1] 0.04839807
None of these manually computed posterior summaries match the printed output. The group id standard deviation is particularly different.
I wondered if the parameters are being transformed? If so, what was the transformation? Or is a different posterior summary reported? Or something else?