Hi all,

I’m currently using `rstanarm::stan_lmer`

to fit a model, and I’m abiding by the the guidance to state the priors explicitly, even if I’m going to use the default priors. Somehow I’m not getting `prior_intercept correct`

, though. If I leave it implicit, then it gets centered where it should be. If I use ` prior_intercept = normal(location = 0, scale= 2.5, autoscale=TRUE) ,`

then the prior_intercept remains centered at 0. Is there something wrong with the way I’m specifying the prior_intercept in the code?

Thanks

Operating system: Windows 10

R version: 4.0.3

rstanarm version: 2.21.1

```
# Operating system: Windows 10
# R version: 4.0.3
# rstanarm version: 2.21.1
library(rstanarm) # 2.21.1
# create dataset
set.seed(123)
s_levels <- 1:5
m_levels <- c("A", "B", "C") # three years
v_levels <- c("L2", "L3", "L4") # three fields per year
reps <- 1:3
df <- expand.grid(s=s_levels, m=m_levels, v=v_levels, rep=reps)
df$y <- 10 + as.numeric(as.factor(df$v))*0.5 + rnorm(nrow(df), mean=0, sd=0.1)
df$subunit <- as.factor(paste(df$v,"-",df$m,"-",df$s, sep=""))
# default priors
mod_stanlmer_implicit_priors <- stan_lmer(
formula = y ~ 1 + v + m + s + m:s + (1|subunit),
data=df)
# the default priors stated explicitly, except for prior_covariance
mod_stanlmer <- stan_lmer(
formula = y ~ 1 + v + m + s + m:s + (1|subunit) ,
prior_intercept = normal(location = 0, scale= 2.5, autoscale=TRUE) ,
prior = normal(location = 0, scale= 2.5, autoscale=TRUE) ,
prior_aux = exponential(rate=1, autoscale=TRUE) ,
data=df)
posterior_vs_prior(
object = mod_stanlmer_implicit_priors ,
pars=c("(Intercept)", "s", "v", "m")
)
posterior_vs_prior(
object = mod_stanlmer ,
pars=c("(Intercept)", "s", "v", "m")
)
prior_summary(mod_stanlmer_implicit_priors) # adjusted prior location = 11
prior_summary(mod_stanlmer) # adjusted prior location = 0
# how do I extract just the prior samples from the fits?
# Plotting the model, though getting a warning:
# "Note: uncertainty of error terms are not taken into account. You may want to
# use `rstantools::posterior_predict()`."
library(ggplot2)
library(sjPlot)
ggplot(data = df ,
aes(x = s, y = y)) +
geom_point () +
facet_wrap( ~ v + m)
plot_model(
model = mod_stanlmer_implicit_priors ,
type="pred" ,
terms=c("s", "m", "v") ,
ci.lvl = 0.95
)
```

The issue shows up in both `prior_summary()`

and `posterior_vs_prior()`