Learn R Programming

metRology (version 0.9-28-1)

Mandel-k: Mandel's k statistic.

Description

Density, distribution function, quantile function and random generation for Mandel's k statistic, a measure of relative precision compared to a common variance.

Usage

dmandelk(x, g, n, log = FALSE)
pmandelk(q, g, n, lower.tail = TRUE, log.p = FALSE)
qmandelk(p, g, n, lower.tail = TRUE, log.p = FALSE)
rmandelk(B, g, n)

Arguments

x, q

vector of quantiles.

p

vector of probabilities.

g

number of groups for which k is calculated.

n

number of observations in each group of data for which k 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).

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 rmandelk uses B and not n (as do most R random number functions) for number of random draws; this is because n is conventionally used for the number of replicates per group. Be careful when using named parameters!

Details

Mandel's k for one of a set of \(g\) standard deviations \(s\) is calculated as $$k=\frac{s_{ij}^2}{\sum_{i=1}^p{s_{ij}^2/p}}$$

Since the numerator is chi-squared(n-1), or Gamma((n-1)/2, 2), and the denominator can be written as the sum of the same quantity and a pooled variance with distribution Gamma((g-1)*(n-1)/2, 2), k is distributed as Beta((n-1)/2, (g-1)(n-1)/2). Quantiles, probabilities, density and random numbers can therefore be generated from the Beta distribution. For example, qmandelk is calculated as sqrt( g * qbeta( (n-1)/2, (g-1)*(n-1)/2)).

References

None.

See Also

pmandelh

Examples

Run this code
# NOT RUN {
	#Generate the 95% and 99% quantiles for comparison with tables in 
	#ISO 5725:1996 Part 2:
	
	round(qmandelk(0.95, g=3:30, n=3), 2) #95% upper tail

	round(qmandelk(0.99, g=3:30, n=3), 2) #99% upper tail
	
# }

Run the code above in your browser using DataLab