# dmandelh: Mandel's h statistic. In metRology: Support for Metrological Applications

## Description

Density, distribution function, quantile function and random generation for Mandel's h statistic, a measure of relative deviation from a common mean.

## Usage

 ```1 2 3 4``` ```dmandelh(x, g, log = FALSE) pmandelh(q, g, lower.tail = TRUE, log.p = FALSE) qmandelh(p, g, lower.tail = TRUE, log.p = FALSE) rmandelh(B, g) ```

## Arguments

 `x, q` vector of quantiles. `p` vector of probabilities. `g` number of means for which h is calculated. `B` Number of observations. If 'length(B) > 1', the length is taken to be the number required. `lower.tail` logical; if TRUE (default), probabilities are P[X <= x]; otherwise, P[X > x]. `log, log.p` logical; if TRUE, probabilities p are given as log(p).

## Details

Mandel's h is calculated for a particular mean value `y[i]` in a set of mean values `y` as `h[i] = ( y[i] - mean(y) )/sd(y) )`

The density, probabilities and quantiles can be derived from the beta distribution: (1+h*sqrt(g)/(g-1))/2 is distributed as Beta((g-2)/2, (g-2)/2).

## Value

dmandelh returns the density at `x`, pmandelh the cumulative probability, qmandelh the quantiles for probability `p` and rmandelh returns `B` random values drawn from the distribution.

Vector values of x, p, q and g are permitted, in which case the functions return vectors.

## Warning

Note that `rmandelh` uses `B` and not `n` (as do most R random number functions) for number of random draws; this is for compatibility with the relevant functions for Mandel's k, for which `n` is conventionally used for the number of replicates per group. Be careful when using named parameters!

## Author(s)

S. L. R. Ellison, s.ellison@lgc.co.uk

## References

None.

`pmandelk`
 ```1 2 3 4 5 6 7``` ``` #Generate the 95% and 99% quantiles for comparison with tables in #ISO 5725:1996 Part 2: n <- 3:30 round(qmandelh(0.975, n), 2) #95% 2-tailed round(qmandelh(0.995, n), 2) #99% 2-tailed ```