Dixon | R Documentation |
Density, distribution function, quantile function and random generation for Dixon's ratio statistics r[j,i-1] for outlier detection.
qdixon(p, n, i = 1, j = 1, log.p = FALSE, lower.tail = TRUE) pdixon(q, n, i = 1, j = 1, lower.tail = TRUE, log.p = FALSE) ddixon(x, n, i = 1, j = 1, log = FALSE) rdixon(n, i = 1, j = 1)
p |
vector of probabilities. |
n |
number of observations. If |
i |
number of observations <= x_i |
j |
number of observations >= x_j |
log.p |
logical; if |
lower.tail |
logical; if |
q |
vector of quantiles |
x |
vector of quantiles. |
log |
logical; if |
According to McBane (2006) the density of the statistics r[j,i-1] of Dixon can be yield if x and v are integrated over the range (-∞ < x < ∞, 0 ≤ v < ∞)
f(r) = n! / [(i-1)! (n-j-i-1)! (j-1)!] Int[-∞,∞] Int[0,∞] [Int[-∞,x-v] φ(t)dt ] [Int[x-v,x-rv] φ(t)dt]^(n-j-i-1) [Int[x-rv,x] φ(t)dt]^(j-1) φ(x-v)φ(x-rv)φ(x)v dv dx
where v is the Jacobian and φ(.) is the density of the standard normal distribution. McBane (2006) has proposed a numerical solution using Gaussian quadratures (Gauss-Hermite quadrature and half-range Hermite quadrature) and coded a library in Fortran. These R functions are wrapper functions to use the respective Fortran code.
ddixon
gives the density function,
pdixon
gives the distribution function,
qdixon
gives the quantile function and
rdixon
generates random deviates.
The R code is a wrapper to the Fortran code released under GPL >=2 in the electronic supplement of McBane (2006). The original files are ‘rfuncs.f’, ‘utility.f’ and ‘dixonr.fi’. They were slightly modified to comply with current CRAN policy and the R manual ‘Writing R Extensions’.
The file ‘slowTest/d-p-q-r-tests.R.out.save’ that is included in this package contains some results for the assessment of the numerical accuracy.
The slight numerical differences between McBane's original Fortran output
(see files ‘slowTests/test[1,2,4].ref.output.txt’) and
this implementation are related to different floating point rounding
algorithms between R (see ‘round to even’ in round
)
and Fortran's write(*,'F6.3')
statement.
Dixon, W. J. (1950) Analysis of extreme values. Ann. Math. Stat. 21, 488–506. doi: 10.1214/aoms/1177729747.
Dean, R. B., Dixon, W. J. (1951) Simplified statistics for small numbers of observation. Anal. Chem. 23, 636–638. doi: 10.1021/ac60052a025.
McBane, G. C. (2006) Programs to compute distribution functions and critical values for extreme value ratios for outlier detection. J. Stat. Soft. 16. doi: 10.18637/jss.v016.i03.
set.seed(123) n <- 20 Rdixon <- rdixon(n, i = 3, j = 2) Rdixon pdixon(Rdixon, n = n, i = 3, j = 2) ddixon(Rdixon, n = n, i = 3, j = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.