FDist {stats} R Documentation

## The F Distribution

### Description

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`).

### Usage

```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)
```

### Arguments

 `x, q` vector of quantiles. `p` vector of probabilities. `n` number of observations. If `length(n) > 1`, the length is taken to be the number required. `df1, df2` degrees of freedom. `Inf` is allowed. `ncp` non-centrality 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 P[X ≤ x], otherwise, P[X > x].

### Details

The F distribution with `df1 =` n1 and `df2 =` n2 degrees of freedom has density

f(x) = Γ((n1 + n2)/2) / (Γ(n1/2) Γ(n2/2)) (n1/n2)^(n1/2) x^(n1/2 - 1) (1 + (n1/n2) x)^-(n1 + n2)/2

for x > 0.

It is the distribution of the ratio of the mean squares of n1 and n2 independent standard normals, and hence of the ratio of two independent chi-squared variates each divided by its degrees of freedom. Since the ratio of a normal and the root mean-square 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 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.

### Value

`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.

### Note

Supplying `ncp = 0` uses the algorithm for the non-central 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 non-zero `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.

### Source

For the central case of `df`, computed via a binomial probability, code contributed by Catherine Loader (see `dbinom`); for the non-central 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`.

### References

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.

### Examples

```## 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:  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(x-y)/mean(abs(c(x,y))))
quantile(rel.err(qf(2*p - 1, df1 = 1, df2 = df), qt(p, df)^2), .90)  # ~= 7e-9
```

[Package stats version 4.1.2 Index]
{"ft_lang_label":"__label__en","ft_lang_prob":0.74483097,"math_prob":0.9954685,"size":3729,"snap":"2022-05-2022-21","text_gpt3_token_len":1153,"char_repetition_ratio":0.11516778,"word_repetition_ratio":0.018867925,"special_character_ratio":0.304103,"punctuation_ratio":0.18727915,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9993506,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-28T11:57:17Z\",\"WARC-Record-ID\":\"<urn:uuid:be702e62-f70c-43a7-a752-15f04ddacfb9>\",\"Content-Length\":\"6931\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9ab19886-472f-468b-a1b0-aa56a16b2920>\",\"WARC-Concurrent-To\":\"<urn:uuid:31d3807f-f294-4e4f-94f3-88769cbbda2e>\",\"WARC-IP-Address\":\"129.132.119.195\",\"WARC-Target-URI\":\"https://stat.ethz.ch/R-manual/R-patched/library/stats/html/Fdist.html\",\"WARC-Payload-Digest\":\"sha1:6ZIYYY42IPNPLILZRV7VF5J43GNTGY2A\",\"WARC-Block-Digest\":\"sha1:6DM5PY73OY7GTHC7U2CBVEOOOBJXVB32\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652663016373.86_warc_CC-MAIN-20220528093113-20220528123113-00291.warc.gz\"}"}