Im interested in calculating the SE for a mix model. For that, first I have play around with one of the dataset that the package include, in a simpler model.
pigs$percent <- as.factor(pigs$percent)
Doc_lm_1 <- lm(conc~percent, pigs)
summary(Doc_lm_1)
emmeans(Doc_lm_1, pairwise~percent)$emmeans
The output:
percent emmean SE df lower.CL upper.CL
9 32.7 2.92 25 26.7 38.7
12 38.0 2.76 25 32.3 43.7
15 40.1 3.12 25 33.7 46.6
18 39.9 3.70 25 32.3 47.6
When I have try with balanced datasets, the SE is the same for all the groups and doesnt match a handmade SE. I guess that in that case is not ponderate it for any factor, but it still should match the handmade SE
Could be that SE is the SE of the parameter? As we can see in the table, the SE variate between groups when the data is unbalanced. I base my hypothesis in the fact that the cran project website of the package indicate (https://cran.r-project.org/web/packages/emmeans/vignettes/basics.html#backstory):
Estimated marginal means are based on a model – not directly on data"
So I was asking me, How are the SE calculated? and how will the addition of a random factor change this calculation? Thanks in advance.