Estimated marginal means against raw mean when only one predictor I'm learning about estimated marginal means and I found this very interesting tutorial about it. I get almost all of it, especially the fact that with a multivariate analysis we can extract modelled means that are different from a raw mean (like they do when modelling Sepal.Width ~ Species * Petal.Width and looking at the means of Sepal.Width for each species).
But they also model a simple univariate model like so: Sepal.Width ~ Species, then look at the means of Sepal.Width for each species and say Note that the means computed here are not that different than the raw means we created above. But I don't see how a significant difference would be possible because if there was an "other variable" that could have offset the mean, we wouldn't be able to see it in the raw mean neither would we see it in the computed means, right?
I'm not quite sure about what tags I should be using. Feel free to correct me if I haven't used the right one.
 A: You are exactly right! The "raw means" of Y by group and the "marginal means" from regressing Y on group are the same.
library("tidyverse")

set.seed(1234)

# Raw means
iris %>%
  group_by(Species) %>%
  summarise(
    mean = mean(Sepal.Width)
  )
#> # A tibble: 3 × 2
#>   Species     mean
#>   <fct>      <dbl>
#> 1 setosa      3.43
#> 2 versicolor  2.77
#> 3 virginica   2.97

# Simple linear regression of Y = Sepal.Width on group = Species
model <- lm(Sepal.Width ~ Species, data = iris)

Since the only predictor is species, the marginal means are the same as the raw means but now we have a statistical model for sepal width, so we get standard errors and confidence intervals as well as means.
# Marginal means with two different packages.
modelbased::estimate_means(model)
#> We selected `at = c("Species")`.
#> Estimated Marginal Means
#> 
#> Species    | Mean |   SE |       95% CI
#> ---------------------------------------
#> setosa     | 3.43 | 0.05 | [3.33, 3.52]
#> versicolor | 2.77 | 0.05 | [2.68, 2.86]
#> virginica  | 2.97 | 0.05 | [2.88, 3.07]
#> 
#> Marginal means estimated at Species

# `emmeans` is a popular package to extract marginal means from various types of models.
emmeans::emmeans(model, ~Species)
#>  Species    emmean    SE  df lower.CL upper.CL
#>  setosa       3.43 0.048 147     3.33     3.52
#>  versicolor   2.77 0.048 147     2.68     2.86
#>  virginica    2.97 0.048 147     2.88     3.07
#> 
#> Confidence level used: 0.95

