# Significant main effect but no interaction which post hoc test to do?

I have an experiment looking at the effect of rearing condition on development of the number of neural networks (ensembles) in mice. I therefore have two factors (Age 3, 5, 7 dpf) and Rearing Condition (GR and NR). I ran a two way anova in R :

my_anova <- aov(numb_ensembles ~ age * Rearing_conditions, data = dev)
Anova(my_anova, type = "II")

Anova Table (Type II tests)

Response: numb_ensembles
Sum Sq Df F value  Pr(>F)
age                    1230.9  2  4.9170 0.01352 *
Rearing_conditions        0.7  1  0.0057 0.94053
age:Rearing_conditions  452.2  2  1.8062 0.18014
Residuals              4130.5 33
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


This revealed a significant main effect of age. I am now unsure which post hoc test to use. I'm guessing looking at all pairwise comparisons (such as Tukey's HSD) would be unsuitable based on the fact that their is no interaction. However, can i do planned pair wise comparisons (t.test with bonferrori) between ages conditional to the rearing condition? ie for the GR group is there a difference between each time point.

• Is this a balanced design (equal n in each cell)? With N=38 and 6 conditions, there is at least some unbalance. However, if rearing is balanced within each age, that will make things easier. Given that only age is significant, the only post-hoc tests you should do are between the three age categories. However, what do you want to know? Are the 3 paired-comparisons what is most interesting or are you interested in a test of the linear relationship across the age groups? If rearing is balanced, then a post-hoc test on age with a Bonferroni correction would be fine. – dbwilson Dec 10 '19 at 17:03
• Thanks this is very useful. The groups are not balanced (GR: 3 dpf = 4, 5 dpf = 5, 7 dpf = 7, NR: 3 dpf = 6, 5 dpf = 9, 7 dpf = 8 ). The most interesting differences to us between rearing group at each time point and the pair wise comparisons between each age conditional to the rearing group. However since there is no significant interaction we should not pursue these tests? The effect of age regardless of rearing group is still interesting because it would at least show that there is an increase in the number of networks over the course of development – neurosoup Dec 10 '19 at 19:09
• I agree with @Sal Mangiafico's answer below. With unbalanced designs, using these built-in procedures are easier than trying to something manually, which would require weighting to balance the groups. – dbwilson Dec 10 '19 at 21:56

My recommendation for any relatively complicated (multi-way, unbalanced) model is to use a flexible approach that reflects the structure of the model, such as emmeans in R, or EMMEANS statements in SAS or SPSS.

To give a reproducible example in R:

if(!require(car)){install.packages("car")}
if(!require(emmeans)){install.packages("emmeans")}

library(car)
library(emmeans)

numb_ensembles     = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24)
age                = factor(rep(c("A","B","C"), 1, each = 8))
Rearing_conditions = factor(rep(c("X","Y"), 12))

dev=data.frame(numb_ensembles, age, Rearing_conditions)

my_anova <- aov(numb_ensembles ~ age * Rearing_conditions, data = dev)

Anova(my_anova, type = "II")

emmeans(my_anova, ~age)

pairs(emmeans(my_anova, ~age))

### contrast estimate   SE df t.ratio p.value
###   A - B          -8 1.29 18  -6.197 <.0001
###   A - C         -16 1.29 18 -12.394 <.0001
###   B - C          -8 1.29 18  -6.197 <.0001

###   Results are averaged over the levels of: Rearing_conditions
###   P value adjustment: tukey method for comparing a family of 3 estimates

• Could you explain the advantage of using estimated marginal means to me (sorry for my ignorance!). From reading through the documentation emmeans calculates the means from the model rather than the data? Can this same package be used to calculate the simple main effects and contrasts if there was a significant interaction? – neurosoup Dec 11 '19 at 12:24
• 1. One question is why you might want to use estimated marginal means instead of arithmetic means. Imagine you are measuring the heights of 14-year-olds in two schools. And let's say than in reality at this age girls are taller than boys. Also in reality there is no effect of the school. But let's say that the proportion of girls in the schools is really unequal. – Sal Mangiafico Dec 11 '19 at 19:38
• 2. If you calculated the arithmetic mean, one school would have a much higher average than the other. But if you analyzed this with anova, you would find a significant effect of sex, but no effect of school. E.M. means will reflect this result:. The e.m. means for the schools will be equal. – Sal Mangiafico Dec 11 '19 at 19:45
• 3. Yes, one nice thing about the emmeans package is that it will return results for interactions, can report comparisons sliced by another model term, and the user can ask for custom contrasts. – Sal Mangiafico Dec 11 '19 at 19:48
• Thank you once again. This was a very helpful/intuitive explanation. – neurosoup Dec 12 '19 at 9:31