I’ve been comparing outputs between `brms`

and `stan_gamm4`

. What I’ve found is that when I try and specify the same priors for both (as both use different default priors) but I’m getting different intercept estimates…

The stan_gamm4 version appears to match that found in gamm4 but the brms estimate (~15.5 vs 11.82) is much lower (see below for a MWE).

```
library(rstanarm)
library(mgcv)
library(brms)
library(gamm4)
# SIMULATE EXAMPLE
set.seed(1234)
## simulate 4 term additive truth
dat <- gamSim(6,n=400,scale=2)
## GAMM4
mod1 <- gamm4(y ~ s(x0)+s(x1), random = ~(1|fac),data=dat)
#Estimated intercept:
fixed.effects(g4$mer)[[1]]
#[1] 15.6657
# RSTANARM
mod2 <- rstanarm::stan_gamm4(y ~ s(x0)+s(x1), random = ~(1|fac),
data=dat,
prior_intercept = normal(0,5),
prior_smooth = normal(0,1),
prior_aux = normal(0,5))
#Estimated intercept
mod2$coefficients[[1]]
#[1] 15.49564
# BRMS
mod3 <- brms::brm(y ~ s(x0)+s(x1) + (1|fac),
data=dat,
prior = c(prior(normal(0,5), class="Intercept"),
prior(normal(0,1), class="sds"),
prior(normal(0,5), class="sd")))
fixef(mod3)[[1]]
#[1] 11.82925
```

What’s stranger is when I fit the two models using default priors I get similar intercepts…

```
mod4 <- rstanarm::stan_gamm4(y ~ s(x0)+s(x1), random = ~(1|fac),
data=dat)
mod5 <- brms::brm(y ~ s(x0)+s(x1) + (1|fac),
data=dat)
> mod4$coefficients[[1]]
#[1] 15.70542
fixef(mod5)[[1]]
#[1] 15.49703
```

On another note the predictions of each model are very similar… they are basically 1:1… which makes me wonder whether I’m 1) misunderstanding the print output of brms and that they are actually the same or 2) I’ve done something wrong in model specification.

Looking at the median across intercepts in the brms output

- Operating System: OSX Catalina
- brms Version: ‘2.13.0’