
Density, distribution function, quantile function and random
generation for the F distribution with df1
and df2
degrees of freedom (and optional non-centrality 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)
vector of quantiles.
vector of probabilities.
number of observations. If length(n) > 1
, the length
is taken to be the number required.
degrees of freedom. Inf
is allowed.
non-centrality parameter. If omitted the central F is assumed.
logical; if TRUE, probabilities p are given as log(p).
logical; if TRUE (default), probabilities are
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.
The F distribution with df1 =
df2 =
It is the distribution of the ratio of the mean squares of
The non-central F distribution is again the ratio of mean squares of
independent normals of unit variance, but those in the numerator are
allowed to have non-zero means and ncp
is the sum of squares of
the means. See Chisquare for further details on
non-central distributions.
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 chi-squared and dt
for Student's
t distributions.
# NOT RUN {
## Equivalence of pt(.,nu) with pf(.^2, 1,nu):
x <- seq(0.001, 5, len = 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=FALSE),
pf(x^2, 1,nu, lower=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: qf(2*p - 1, 1, df) == qt(p, df)^2 for p >= 1/2
p <- seq(1/2, .99, length = 50); df <- 10
rel.err <- function(x, y) ifelse(x == y, 0, abs(x-y)/mean(abs(c(x,y))))
# }
# NOT RUN {
quantile(rel.err(qf(2*p - 1, df1 = 1, df2 = df), qt(p, df)^2), .90) # ~= 7e-9
# }
Run the code above in your browser using DataLab