I am analyzing an ecological dataset in R and try to answer the following question: which environmental variables have an effect on the diversity of the community that we observed?
Diversity is measured via continuous indices. We collected both continuous and categorical environmental variables, e.g. age and a grouping variable with 4 factors "group". I would also like to adjust for the impact of a dichotomous variable, let's call it a. To analyze the effect of group on diversity, my approach now is as follows:
fit = lm(log(index) ~ a + group))
anova(fit)
My current understand is that anova() gives the overall effect of group, while lm compares each level of group to the reference level. This seems fine and appropriate to answer my question. However, I'm not sure if the way I adjust for the confounder a is correct.
If it is, I still struggle to interpret the p-value for a (the confounder) that is returned by anova(). If "group" is significant, but a is not, can I infer that I might as well remove a from the model?