# Interpretation of mixed model output in lme4 and stan

here's my model in lme4

library(nlme)   # for the data
data("Machines")  # the data

fit2 <- lmer(score ~  -1 + Machine + (1|Worker), data=Machines)
summary(fit2)

Linear mixed model fit by REML ['lmerMod']
Formula: score ~ -1 + Machine + (1 | Worker)
Data: Machines

REML criterion at convergence: 286.9

Scaled residuals:
Min      1Q  Median      3Q     Max
-2.7249 -0.5233  0.1328  0.6513  1.7559

Random effects:
Groups   Name        Variance Std.Dev.
Worker   (Intercept) 26.487   5.147
Residual              9.996   3.162
Number of obs: 54, groups:  Worker, 6

Fixed effects:
Estimate Std. Error t value
MachineA   52.356      2.229   23.48
MachineB   60.322      2.229   27.06
MachineC   66.272      2.229   29.73

Correlation of Fixed Effects:
MachnA MachnB
MachineB 0.888
MachineC 0.888  0.888


when I model this in STAN using rstanarm, I get a totally different output:

library(rstanarm)
fit2a <- stan_glmer(score ~  -1 + Machine + (1|Worker), data=Machines)
fit2a

stan_glmer(formula = score ~ -1 + Machine + (1 | Worker), data = Machines)

Estimates:
MachineA -6.3   24.4
MachineB  1.6   24.3
MachineC  7.5   24.4
sigma     3.6    0.4

Error terms:
Groups   Name        Std.Dev.
Worker   (Intercept) 38.2
Residual              3.6
Num. levels: Worker 6

Sample avg. posterior predictive
distribution of y (X = xbar):
mean_PPD 59.6    0.7


my interpretation is this: I get the fixed effects by adding mean_PPD to the estimates, e.g. 59.6-6.3 = 53.3 ~ 52.3 as in lme.

Are the error terms in the stan output the random effects? And why does it use the median for the estimates or is this a rstanarm specific thing?

• The print method in the rstanarm package reports posterior medians because they always exist (whereas the mean may not, although that is unlikely for the models currently in rstanarm) and perhaps are better estimated than is the mean in cases where the Markov chain has issues sampling from the tails of the posterior distribution. Jan 18 '16 at 3:29
• The output under Error terms in rstanarm is comparable to the output under Random effects in lme4. But since rstanarm is largely Bayesian, the phrases "fixed effects" and "random effects" are avoided, although there are fixef and ranef extractor functions for compatibility with lme4. Either way, you can think of the (1|Worker) term as an error in the sense that the Machine predictor is unable to explain some variation in score. Jan 18 '16 at 3:35
• To your main question, I think you have encountered a bug in rstanarm. See github.com/stan-dev/rstanarm/issues/49 . Jan 18 '16 at 3:36

However, in general, we do not recommend rstanarm models that exclude the intercept. A better alternative is to place a tight prior with mean zero on the intercept. In this case, including the intercept yields a better fit and similar results between lme4::lmer and rstanarm::stan_lmer.