Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get R to spit out the critical value for F-statistic based on ANOVA?

Tags:

r

anova

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?
like image 795
Tom Avatar asked May 25 '16 18:05

Tom


People also ask

How do you find the critical value of F statistic?

There are several different F-tables. Each one has a different level of significance. So, find the correct level of significance first, and then look up the numerator degrees of freedom and the denominator degrees of freedom to find the critical value.


1 Answers

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
like image 75
bouncyball Avatar answered Oct 03 '22 06:10

bouncyball