Different Intercept Terms in Frequentist and Bayesian Regression

Hi @LucC. I have been taught that in these models the random intercepts for each individual are included implicitly in the model by the inclusion of their first score as a covariate. You get very similar estimates via a mixed-effects model

library(dplyr)
dfLong <- df %>% dplyr::select(id, group, pre, post) %>%
                 gather(key = time, value = score, pre, post) %>%
                 transform(time = factor(time, levels = c("pre", "post")))

summary(lmer(score ~ group*time + (1|id), data = dfLong))

### output
#                    Estimate Std. Error        df t value Pr(>|t|)    
# (Intercept)        39.91709    0.63939 155.95000  62.430  < 2e-16 ***
# groupnew            0.09049    0.90423 155.95000   0.100     0.92    
# timepost           -6.12193    0.89597  78.00000  -6.833 1.64e-09 ***
# groupnew:timepost  -6.19356    1.26709  78.00000  -4.888 5.34e-06 ***

It’s true that the standard errors are different in the non-mixed-effects model but there are different parameters.

summary(mod <- lm(post ~ group + preS, df))

### output
#             Estimate Std. Error t value Pr(>|t|)    
# (Intercept) 33.79590    0.60779  55.604  < 2e-16 ***
# groupnew    -6.10455    0.85957  -7.102 5.33e-10 ***
# preS         0.06948    0.43250   0.161    0.873   

How would I specify random effects in my Stan model? Via the inclusion of a subject term? Something like mu[i] = a + bGroup*group[i] + bPreS*preS[i] + bSubj[sIndex[i]]?