mandel.k {metRology}R Documentation

Calculate Mandel's k statistics for replicate observations

Description

mandel.k calculates Mandel's k statistics for replicate observations. Mandel's k an indicator of precision compared to the pooled standard deviation across all groups.

Usage

	mandel.k(x, g = NULL, m = NULL, na.rm = T, rowname = NULL, 
			method=c("classical", "robust"), n = NA, ...)

	## Default S3 method:
mandel.k(x, g = NULL, m = NULL, na.rm = T, rowname = NULL, 
			method=c("classical", "robust"), n = NA, ...)

	## S3 method for class 'ilab'
mandel.k(x, g = NULL, m = NULL, na.rm = T, rowname = NULL, 
			method=c("classical", "robust"), n = NA, ...)

Arguments

x

An R object (see Details below), which contains replicate observations or, if g is absent, means or standard deviations.

g

A primary grouping factor, usually corresponding to Laboratory in an inter-laboratory study. If not present, x is taken as a set of means or standard deviations (depending on whether type is "h" or "k".

m

A secondary grouping factor, usually corresponding to test item or measured quantity. m is ignored if x has more than one column.

na.rm

A logical value indicating whether 'NA' values should be stripped before the computation proceeds. Passed to functions such as mean and sd.

rowname

A single character label for the primary grouping factor (e.g. "Lab", "Organisation").

method

Character scalar giving the calculation method. "classical" gives the traditional calculation; "robust" gives a robust variant (see Details).

n

scalar number of observations per group. Required only if x consists of calculated standard deviations.

...

Additional parameters passed to other methods. Currently not implemented.

Details

mandel.k is a convenience wrapper for mandel.kh(..., type="k"). It is generic, with methods for numeric vectors, arrays, data frames, matrices and objects of class 'ilab'. All parameters are passed to mandel.kh.

Mandel's kk is an indicator of relative dispersion for grouped sets of observations. Given a set of observations xijlx_{ijl} where i,j,li, j, l denotes observation ll, l=1,2,...nl=1, 2, ... n for measurand or test item jj and group (usually laboratory) ii, i=1,2,...pi=1, 2, ... p, Mandel's kk is given by:

k=sij2i=1psij2/pk=\sqrt{\frac{s_{ij}^2}{\sum_{i=1}^p{s_{ij}^2/p}}}

where sijs_{ij} is the standard deviation of values xijkx_{ijk} over k=1,2,...,nk=1, 2, ..., n.

If x is a vector, one-dimensional array or single-column matrix, values are aggregated by g and, if present, by m. If x is a data frame or matrix, each column is aggregated by g and m silently ignored if present. In all cases, if g is NULL or missing, each row (or value, if a vector) in x is taken as a pre-calculated mean (for Mandel's h) or standard deviation (for Mandel's k).

If x is an object of class 'ilab', g defaults to '$org' and m to $measurand.

The returned object includes a label ('grouped.by') for the primary grouping factor. For the 'ilab' method, this is "Organisation". For other methods, If rowname is non-null, rowname is used. If rowname is NULL, the default is deparse(substitute(g)); if g is also NULL or missing, "Row" is used.

If method="robust", Mandel's kk is calculated by replacing the classical pooled standard deviation with the robust pooled standard deviation calculated by algorithm S (see algS).

Value

mandel.k returns an object of class "mandel.kh", which is a data frame consisting of the required Mandel's statistics and in which each row corresponds to a level of g and each column to a level of m or (if x was a matrix or data frame) to the corresponding column in x. In addition to the class, the object has attributes:

'mandel.type'

"h" or "k"

'grouped.by'

Character scalar giving the label used for the grouping factor g; see Details above for the defaults.

'n'

Number of observations per group (n if specified

Author(s)

S Ellison s.ellison@lgc.co.uk

References

Accuracy (trueness and precision) of measurement methods and results – Part 2: Basic method for the determination of repeatability and reproducibility of a standard measurement method. ISO, Geneva (1994).

See Also

mandel.h, mandel.kh; pmandelh, pmandelk for probabilities, quantiles etc.; plot.mandel.kh, barplot.mandel.kh for plotting methods.

Examples

	data(RMstudy)

	#Data frame examples: note no secondary grouping factor
	h <- with(RMstudy, mandel.k(RMstudy[2:9], g=Lab))
	plot(h, las=2)

	#Vector variant
	RMstk <- stack(RMstudy[,2:9])
	names(RMstk) <- c("x", "meas")
		#names replace 'values' and 'ind'
	RMstk$Lab <- rep(RMstudy$Lab, 8)
	h2 <- with(RMstk, mandel.k(x, g=Lab, m=meas, rowname="Laboratory"))
		#Note use of rowname to override g
	plot(h2, las=2)
	
	#ilab method
	RM.ilab <- with(RMstk, construct.ilab(org=Lab, x=x, measurand=meas, 
		item=factor(rep("CRM", nrow(RMstk))) ) )

	plot(mandel.k(RM.ilab))
	
	#Robust variant
	krob <- with(RMstudy, mandel.kh(RMstudy[2:9], g=Lab, type="k", method="robust"))
	plot(krob, las=2)

[Package metRology version 0.9-28-1 Index]