stan-dev / rstanarm

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

Why does stan_lm ignore a factor level in a model with no intercept? #557

Open jgabry opened 2 years ago

jgabry commented 2 years ago

Originally pointed out on the forum in https://discourse.mc-stan.org/t/why-does-stan-lm-ignore-a-factor-level-in-a-model-with-no-intercept/24877.

@bgoodri stan_lm still drops a factor level even if the intercept is omitted, e.g. stan_lm(mpg ~ 0 + as.factor(cyl), data = mtcars, prior = R2(0.5, "mean")). This contradicts the behavior of lm and stan_glm. Is this intentional or a bug?