stan-dev / rstanarm

rstanarm R package for Bayesian applied regression modeling
https://mc-stan.org/rstanarm
GNU General Public License v3.0
389 stars 134 forks source link

Name of the covariance matrix in stan_glmer() output #374

Closed jsocolar closed 5 years ago

jsocolar commented 5 years ago

Summary:

When fitting models using stan_glmer(), summary(stan_glmer()) names the elements of the covariance matrix using terms like Sigma[group:(Intercept),(Intercept)]. Especially in the (quite common) case where the covariance matrix is 1x1, it would be very easy for users to see Sigma, think "sigma", and assume that this is the standard deviation of the random effect, rather than the variance. I suggest changing the name from "Sigma" to "Var" in the case of a 1x1 matrix, and possibly also for the diagonal elements of higher-dimensionality covariance matrices. Alternatively, I suggest documenting this output both in the stan_glmer() documentation and in the rstanarm group-specific terms vignette.

Reproducible Steps:

probs <- boot::inv.logit(rnorm(500, 0,10))
trials <- ceiling(runif(500,0,100))
successes <- rbinom(500, trials, probs)
df <- data.frame(s_f = NA, group = as.factor(1:500))
df$s_f <- cbind(successes, trials-successes)
testmodel <- rstanarm::stan_glmer(s_f ~ (1|group), data = df, family = 'binomial', cores = 4, iter = 100)
a <- summary(testmodel)["Sigma[group:(Intercept),(Intercept)]",]

RStanARM Version:

2.18.2

R Version:

3.6.0

bgoodri commented 5 years ago

I don't think we should change the output because someone's R scripts may be relying on the current (not great) behavior. But I am about to commit an improvement to the documentation.