I'm moving from JMP to R for my statistical analysis and have noticed that the two-way ANOVA test function aov() does not report model effect. This is standard in JMP and to me it's essential for hypothesis testing, as one can't assume a main effect if there isn't a Model effect.
- My first question, is there a reason why model effects aren't evaluated in the hypothesis testing within the R community?
- My second question is, if Model effects aren't built into the aov() function then how can I use R to access the F table to obtain the model effect and prob > F?
##Calculate model effects with a F table lookup.
Data.X <- data.frame(mtcars)
fit.ANOVA <- aov(mpg ~ cyl * gear, data = Data.X)
tests <- as.data.frame(summary(fit.ANOVA)[[1]])
Model.Effect.AOV.DF.M <- sum(tests$Df[1:(nrow(tests) - 1)])
Model.Effect.AOV.DF.error <- tests$Df[nrow(tests)]
Model.Effect.AOV.SS <- sum(tests$`Sum Sq`[1:(nrow(tests) - 1)])
Model.Effect.AOV.MS <- Model.Effect.AOV.SS / Model.Effect.AOV.DF
Model.Effect.AOV.FRatio <- Model.Effect.AOV.MS / tests$`Mean Sq`[nrow(tests)]
Model.Effect.AOV.Fcrit.0.05 <- qf(1 -0.05, df1 = Model.Effect.AOV.DF.error, df2=Model.Effect.AOV.DF.M)
#You should not reject the null if your F critical value is smaller than your F Ratio (F Value).
if(Model.Effect.AOV.Fcrit.0.05 <= Model.Effect.AOV.FRatio){
print('Data Contains Significantly Different Populations')
} else {
print('Data is the same Population')
}