FDist {stats}  R Documentation 
Density, distribution function, quantile function and random
generation for the F distribution with df1
and df2
degrees of freedom (and optional noncentrality parameter ncp
).
df(x, df1, df2, ncp, log = FALSE)
pf(q, df1, df2, ncp, lower.tail = TRUE, log.p = FALSE)
qf(p, df1, df2, ncp, lower.tail = TRUE, log.p = FALSE)
rf(n, df1, df2, ncp)
x, q 
vector of quantiles. 
p 
vector of probabilities. 
n 
number of observations. If 
df1, df2 
degrees of freedom. 
ncp 
noncentrality parameter. If omitted the central F is assumed. 
log, log.p 
logical; if TRUE, probabilities p are given as log(p). 
lower.tail 
logical; if TRUE (default), probabilities are

The F distribution with df1 =
\nu_1
and df2 =
\nu_2
degrees of freedom has density
f(x) = \frac{\Gamma(\nu_1/2 + \nu_2/2)}{\Gamma(\nu_1/2)\Gamma(\nu_2/2)}
\left(\frac{\nu_1}{\nu_2}\right)^{\nu_1/2} x^{\nu_1/2 1}
\left(1 + \frac{\nu_1 x}{\nu_2}\right)^{(\nu_1 + \nu_2) / 2}%
for x > 0
.
The F distribution's cumulative distribution function (cdf),
F_{\nu_1,\nu_2}
fulfills (Abramowitz & Stegun 26.6.2, p.946)
F_{\nu_1,\nu_2}(qF) = 1  I_x(\nu_2/2, \nu_1/2) = I_{1x}(\nu_1/2, \nu_2/2),
where
x := \frac{\nu_2}{\nu_2 + \nu_1*qF}
, and
I_x(a,b)
is the incomplete beta function; in R, =
pbeta(x, a,b)
.
It is the distribution of the ratio of the mean squares of
\nu_1
and \nu_2
independent standard normals, and hence
of the ratio of two independent chisquared variates each divided by its
degrees of freedom. Since the ratio of a normal and the root
meansquare of m
independent normals has a Student's t_m
distribution, the square of a t_m
variate has a F distribution on
1 and m
degrees of freedom.
The noncentral F distribution is again the ratio of mean squares of
independent normals of unit variance, but those in the numerator are
allowed to have nonzero means and ncp
is the sum of squares of
the means. See Chisquare for further details on
noncentral distributions.
df
gives the density,
pf
gives the distribution function
qf
gives the quantile function, and
rf
generates random deviates.
Invalid arguments will result in return value NaN
, with a warning.
The length of the result is determined by n
for
rf
, and is the maximum of the lengths of the
numerical arguments for the other functions.
The numerical arguments other than n
are recycled to the
length of the result. Only the first elements of the logical
arguments are used.
Supplying ncp = 0
uses the algorithm for the noncentral
distribution, which is not the same algorithm used if ncp
is
omitted. This is to give consistent behaviour in extreme cases with
values of ncp
very near zero.
The code for nonzero ncp
is principally intended to be used
for moderate values of ncp
: it will not be highly accurate,
especially in the tails, for large values.
For the central case of df
, computed via a binomial
probability, code contributed by Catherine Loader (see
dbinom
); for the noncentral case computed via
dbeta
, code contributed by Peter Ruckdeschel.
For pf
, via pbeta
(or for large
df2
, via pchisq
).
For qf
, via qchisq
for large df2
,
else via qbeta
.
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, volume 2, chapters 27 and 30. Wiley, New York.
Distributions for other standard distributions, including
dchisq
for chisquared and dt
for Student's
t distributions.
## Equivalence of pt(.,nu) with pf(.^2, 1,nu):
x < seq(0.001, 5, length.out = 100)
nu < 4
stopifnot(all.equal(2*pt(x,nu)  1, pf(x^2, 1,nu)),
## upper tails:
all.equal(2*pt(x, nu, lower.tail=FALSE),
pf(x^2, 1,nu, lower.tail=FALSE)))
## the density of the square of a t_m is 2*dt(x, m)/(2*x)
# check this is the same as the density of F_{1,m}
all.equal(df(x^2, 1, 5), dt(x, 5)/x)
## Identity (F <> t): qf(2*p  1, 1, df) == qt(p, df)^2 for p >= 1/2
p < seq(1/2, .99, length.out = 50); df < 10
rel.err < function(x, y) ifelse(x == y, 0, abs(xy)/mean(abs(c(x,y))))
stopifnot(all.equal(qf(2*p  1, df1 = 1, df2 = df),
qt(p, df)^2))
## Identity (F <> Beta <> incompl.beta):
n1 < 7 ; n2 < 12; qF < c((0:4)/4, 1.5, 2:16)
x < n2/(n2 + n1*qF)
stopifnot(all.equal(pf(qF, n1, n2, lower.tail=FALSE),
pbeta(x, n2/2, n1/2)))