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

stan_lm gives estimates for only two of the three levels below (‘A’ and ‘B’), and ignores ‘C’. Any clues why?


df <- tribble(
  ~nm, ~ft,
  "A", 122.0,
  "A", 121.0,
  "B", 120.0,
  "B", 119.0,
  "C", 116.0,
  "C", 118.0

lm(ft ~ 0 + nm, data = df) %>% summary() # gives estimates for A, B and C  

stan_lm(ft ~ 0 + nm, prior = NULL, data = df) %>% summary() # gives estimates for A and B only. Why not C?

If possible, add also code to simulate data or attach a (subset of) the dataset you work with.

  • Operating System: R version 4.0.4 (2021-02-15)
    Platform: x86_64-apple-darwin17.0 (64-bit)
    Running under: macOS Big Sur 10.16
  • rstanarm Version: rstanarm_2.21.1

I’m not sure, but @bgoodri probably knows. As an alternative you can use stan_glm with family=gaussian and that should give you estimates of all three levels when you drop the intercept.

Yeah, I saw that it works with stan_glm.
But (to me) the stan_lm result is not what I expected, and so I’d love to know why it does that, or even if it is documented somewhere.