The Fisher (F) distribution is an absolute continuous probability distribution that arises frequently in the analysis of variance (ANOVA) and in hypothesis testing. It is defined by two degrees of freedom parameters \(d_1 > 0\) and \(d_2 > 0\).
Usage
Fisher(df1 = 1, df2 = 1)
# S4 method for class 'Fisher,numeric'
d(distr, x, log = FALSE)
# S4 method for class 'Fisher,numeric'
p(distr, q, lower.tail = TRUE, log.p = FALSE)
# S4 method for class 'Fisher,numeric'
qn(distr, p, lower.tail = TRUE, log.p = FALSE)
# S4 method for class 'Fisher,numeric'
r(distr, n)
# S4 method for class 'Fisher'
mean(x)
# S4 method for class 'Fisher'
median(x)
# S4 method for class 'Fisher'
mode(x)
# S4 method for class 'Fisher'
var(x)
# S4 method for class 'Fisher'
sd(x)
# S4 method for class 'Fisher'
skew(x)
# S4 method for class 'Fisher'
kurt(x)
# S4 method for class 'Fisher'
entro(x)
llf(x, df1, df2)
# S4 method for class 'Fisher,numeric'
ll(distr, x)
Arguments
- df1, df2
numeric. The distribution degrees of freedom parameters.
- distr
an object of class
Fisher
.- x
For the density function,
x
is a numeric vector of quantiles. For the moments functions,x
is an object of classFisher
. For the log-likelihood functions,x
is the sample of observations.- log, log.p
logical. Should the logarithm of the probability be returned?
- q
numeric. Vector of quantiles.
- lower.tail
logical. If TRUE (default), probabilities are \(P(X \leq x)\), otherwise \(P(X > x)\).
- p
numeric. Vector of probabilities.
- n
number of observations. If
length(n) > 1
, the length is taken to be the number required.
Value
Each type of function returns a different type of object:
Distribution Functions: When supplied with one argument (
distr
), thed()
,p()
,q()
,r()
,ll()
functions return the density, cumulative probability, quantile, random sample generator, and log-likelihood functions, respectively. When supplied with both arguments (distr
andx
), they evaluate the aforementioned functions directly.Moments: Returns a numeric, either vector or matrix depending on the moment and the distribution. The
moments()
function returns a list with all the available methods.Estimation: Returns a list, the estimators of the unknown parameters. Note that in distribution families like the binomial, multinomial, and negative binomial, the size is not returned, since it is considered known.
Variance: Returns a named matrix. The asymptotic covariance matrix of the estimator.
Details
The probability density function (PDF) of the F-distribution is given by: $$ f(x; d_1, d_2) = \frac{\sqrt{\left(\frac{d_1 x}{d_1 x + d_2}\right)^{d_1} \left(\frac{d_2}{d_1 x + d_2}\right)^{d_2}}}{x B(d_1/2, d_2/2)}, \quad x > 0 .$$
Examples
# -----------------------------------------------------
# Fisher Distribution Example
# -----------------------------------------------------
# Create the distribution
df1 <- 14 ; df2 <- 20
D <- Fisher(df1, df2)
# ------------------
# dpqr Functions
# ------------------
d(D, c(0.3, 2, 10)) # density function
#> [1] 1.881857e-01 1.451440e-01 2.928738e-06
p(D, c(0.3, 2, 10)) # distribution function
#> [1] 0.01256583 0.92359588 0.99999638
qn(D, c(0.4, 0.8)) # inverse distribution function
#> [1] 0.8676318 1.4961699
x <- r(D, 100) # random generator function
# alternative way to use the function
df <- d(D) ; df(x) # df is a function itself
#> [1] 0.50410625 0.43598010 0.05783994 0.49138451 0.11114179 0.27445372
#> [7] 0.65851612 0.52481527 0.83115002 0.80464500 0.88235902 0.86605381
#> [13] 0.65564316 0.55611627 0.78462865 0.27846456 0.50160315 0.75105185
#> [19] 0.88317653 0.89965395 0.52350916 0.32816152 0.83145608 0.88019032
#> [25] 0.29866335 0.83062933 0.56256621 0.87980550 0.87626494 0.39679180
#> [31] 0.43580665 0.38359265 0.67139442 0.82187365 0.83805235 0.90177703
#> [37] 0.59072685 0.89510540 0.41067246 0.64469869 0.63658505 0.86921164
#> [43] 0.35140882 0.80408232 0.87328420 0.86568503 0.90090492 0.89216623
#> [49] 0.83552855 0.17022810 0.81192302 0.90014363 0.81342169 0.89658161
#> [55] 0.75599087 0.88324463 0.61950167 0.68920316 0.74003765 0.46443344
#> [61] 0.79191007 0.12706952 0.89417812 0.76989275 0.77780084 0.86105316
#> [67] 0.32021668 0.88398724 0.85312747 0.48132007 0.57261040 0.64794971
#> [73] 0.13994524 0.57530144 0.38867046 0.79208293 0.89881213 0.75898254
#> [79] 0.81741636 0.87156977 0.74841887 0.29435389 0.68223119 0.79292539
#> [85] 0.81053348 0.80723222 0.90198989 0.66787152 0.89822277 0.21541686
#> [91] 0.84341915 0.87563657 0.44269213 0.29651848 0.30842226 0.73597629
#> [97] 0.38326217 0.88868038 0.88198966 0.20699983
# ------------------
# Moments
# ------------------
mean(D) # Expectation
#> [1] 1.111111
median(D) # Median
#> [1] 0.9854796
mode(D) # Mode
#> [1] 12
var(D) # Variance
#> [1] 0.3527337
sd(D) # Standard Deviation
#> [1] 0.5939139
skew(D) # Skewness
#> [1] 1.756288
kurt(D) # Excess Kurtosis
#> [1] 184909824
entro(D) # Entropy
#> [1] -1.237507
# List of all available moments
mom <- moments(D)
mom$mean # expectation
#> [1] 1.111111
# ------------------
# Point Estimation
# ------------------
ll(D, x)
#> [1] -53.07676
llf(x, df1, df2)
#> [1] -53.07676