5

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?
Tom
  • 919
  • 3
  • 9
  • 22

1 Answers1

8

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
bouncyball
  • 10,631
  • 19
  • 31
  • Wait, why do I have two inputs for qf? What does each field mean? And what is cbind doing in this case? – Tom May 25 '16 at 20:11
  • @Tom You should look at `?qf` for a good explanation. The `cbind` just binds the columns from the `anova` table to the result from the `qf` function. It was my way of appending the results to the ANOVA table. – bouncyball May 25 '16 at 20:36