R Functions for F Distributions
This is a very short page. Like other brand name distributions, the F distribution has its set of functions that handle probability look-up
-
pf
does the cumulative distribution function (c. d. f.), thep
standing forprobability
. -
qf
does the the inverse c. d. f, theq
standing forquantile
. -
df
does the probability density function (p. d. f.), thed
standing fordensity
. -
rf
generates random variates having the F distribution, ther
standing forrandom
.
Similar functions for other distributions and the general use of such functions is explained on the web page about probability distributions in R.
Here we just cover two simple uses.
P-Value Look-Up
Given an observed value of a test statistic tobs
that is supposed
(under the null hypothesis) to be F distributed with df1
numerator
degrees of freedom and df2
denominator degrees of freedom,
the P-value for
- a lower-tailed test is the lower tail area given by
pf(tobs, df1, df2)
- an upper-tailed test is the upper tail area given by
1 - pf(tobs, df1, df2)
- a two-tailed test is twice whichever one-tailed
P-value is smaller
plow <- pf(tobs, df1, df2) 2 * min(plow, 1 - plow)
In example 8.7.2 in DeGroot and Schervish, the (obviously made up)
observed
value of the test statistic
(they call it V) is 3.0,
the numerator degrees of freedom is 5,
and the denominator degrees of freedom is 20.
The following R statement does the (upper-tailed) look-up
And the result 0.03520134
agrees with that given
by the book.
Critical Value Look-Up
The critical value or values corresponding to a significance
level alpha
for an F distribution
with df1
numerator
degrees of freedom and df2
denominator degrees of freedom
for
- a lower-tailed test is given by
qf(alpha, df1, df2)
- an upper-tailed test is given by
qf(1 - alpha, df1, df2)
- a two-tailed test are given by
qf(c(alpha / 2, 1 - alpha / 2), df1, df2)
In example 8.7.3 in DeGroot and Schervish, the following R statement does the look-up
And the results 0.4483698
and 2.2303021
agree with those given by the book.
Other Functions that Do F Tests
The R function var.test
(on-line
help) does the F test for equality of variances
described in Section 8.7 in DeGroot and Schervish.
However, we won't give any examples because
This test is so non-robust, so critically dependent on exact normality of the population distributions, as to be practically worthless.
We needed to do this section in the book for pedigogical reasons. The F distribution is very important. This is where the book introduces the F distribution. So we cover it. But the only point of this section is to introduce the F distribution. Don't take the examples seriously.
The R functions aov
(on-line
help)
and anova
(on-line
help)
do analysis of variance, which is the primary practical
use of the F distribution (and why we learn about it). This is described
in Sections 10.5 and Section 10.6 in DeGroot and Schervish.