The one thing missing from an ANOVA analysis in R is that it doesn't automatically display the critical value. Everything else is given. I can tell that my F-value is way higher than it should be, but I want to know the margin at where the cut-off is. There's this online calculator that yields the critical value for F statistics based on the degrees of freedom, but I want R to do this. http://www.danielsoper.com/statcalc/calculator.aspx?id=4
How do I do it?
Example:
>anova(anovaModel.model1)
Df Sum Sq Mean Sq F value Pr(>F)
data$SIZE 4 0.1193 0.027926 22.056 4.55e-16 ***
Residuals 1372 1.994 0.001352
>F(variance.mod1) #??
>F(4,1372 ) #Something like this?
Try this:
mylm <- lm(wt~mpg, data = mtcars)
myanova <- anova(mylm)
cbind(myanova, 'CriticalValue' = qf(1-.05, myanova[1,1], myanova[2,1]))
Df Sum Sq Mean Sq F value Pr(>F) CriticalValue
mpg 1 22.343135 22.3431348 91.37533 1.293959e-10 4.170877
Residuals 30 7.335613 0.2445204 NA NA 4.170877
The qf
function is your friend in this case.
alpha = .05
qf(1-alpha, myanova[1,1], myanova[2,1])
[1] 4.170877