This is probably very easy but I could not find a straightforward answer.

reproducible example

x1<-c(rep("a",5),rep("b",5), rep("c",5) )
mod1<-lm(y1 ~ x1, data = datap)

plot(y1~x1 ,data=datap)

da <- as.data.frame(summary(emmeans(mod1,spec="x1")))

enter image description here

I would expect the confidence intervals for the group "b" and "c" to be much smaller than group "a" but they are all the same size. Why? Is it possible to represent a more "realistic" variance?

Sorry for the silly question.

  • $\begingroup$ Dave's answer is great, but I just want to add that if you have data where higher mean values have greater variance, like in your MWE, then often a logarithmic transformation is appropriate. $\endgroup$ Dec 23, 2020 at 21:18

1 Answer 1


The lm function does its inferential work under a fairly standard assumption that the error term has constant variance. That appears to be a poor assumption for your data, but lm does not know that, so it just treats the groups as having equal variance and calculates the error term variance thinking it is the same for each group.

Weighted least squares is one approach to getting a different variance for each group.

  • 3
    $\begingroup$ See the FAQs vignette in the emmeans package. $\endgroup$
    – Russ Lenth
    Dec 23, 2020 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.