I am performing model selection in R with the anova() function, and my categorical variable was maintained in my final model, but when I did a post hoc analysis with the emmeans() function, it told me the levels did not differ. What does it mean?
I use R software, and I am studying how the body condition of a species of fish varies in 3 kinds of rivers: preserved, slightly urban and very urban. Each category has one replicate, so that means I have 2 preserved rivers, 2 slightly urbanized rivers and 2 very urbanized rivers, which means that "river" is a random factor, and "category of urbanization" is my fixed factor and predictor variable with 3 levels. While performing model selection in R with the anova() function, the categorical variable "category" is maintained:
`#it is a linear mixed model because condition is normally distributed
> lmm.1 <- lmer(condition ~ category.of.urbanization + (1|river), data = fish)
> lmm.null <- lmer(condition ~ 1 + (1|river), data = fish)
> anova(lmm.null, lmm.1)
refitting model(s) with ML (instead of REML)
Data: fish
Models:
lmm.null: condition ~ 1 + (1 | river)
lmm.1: condition ~ category.of.urbanization + (1 | river)
npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
lmm.null 3 -214.42 -205.37 110.21 -220.42
lmm.1 5 -219.80 -204.71 114.90 -229.80 9.3806 2 0.009184 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1`
`
My p-value is 0.009184, meaning category of urbanization is an important predictor, and I expected that at least one level of the categorical variable would be different from the others. However, when trying to do a post hoc analysis, I called the emmeans() function, and R says that none of the levels differ, because the p-values are all above 0.05:
`> emmeans(lmm.1, pairwise ~ category.of.urbanization)
Registered S3 methods overwritten by 'broom':
method from
tidy.glht jtools
tidy.summary.glht jtools
$emmeans
category.of.urbanization emmean SE df lower.CL upper.CL
preserved -0.1281 0.0441 3.42 -0.2592 0.00304
slightly urban 0.0316 0.0341 2.20 -0.1030 0.16632
very urban 0.0425 0.0350 2.43 -0.0852 0.17032
Degrees-of-freedom method: kenward-roger
Confidence level used: 0.95
$contrasts
contrast estimate SE df t.ratio p.value
preserved - slightly urban -0.1597 0.0558 2.83 -2.863 0.1324
preserved - very urban -0.1706 0.0563 2.95 -3.028 0.1123
slightly urban - very urban -0.0109 0.0489 2.32 -0.223 0.9733
Degrees-of-freedom method: kenward-roger
P value adjustment: tukey method for comparing a family of 3 estimates `
Please, what does this mean? How is the predictor variable significant, but with levels that aren't different? I have 151 fish, so my number of data and observations is not very low. I am sorry if I've made spelling mistakes, English is not my native language.