Calculate Mandel's h statistics for replicate observations

Share:

Description

mandel.h calculates Mandel's h statistics for replicate observations. Mandel's h is an indication of relative deviation from the mean value.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
	mandel.h(x, g = NULL, m = NULL, na.rm = T, rowname = NULL, 
			method=c("classical", "robust"), n = NA, ...)

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

	## S3 method for class 'ilab'
mandel.h(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 hubers when method="robust".

Details

mandel.h is a convenience wrapper for mandel.kh(..., type="h"). 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 h is an indicators of relative deviation for grouped sets of observations. Given a set of observations x[i,j,l] where i, j, l denotes observation l, l=1, 2, ... n for measurand or test item j and group (usually laboratory) i, i=1, 2, ... p, Mandel's h is given by:

h=\frac{\bar{x_{ij}}-\bar{x_j}}{s_j}

where s_j=√{∑_{i=1}^p{\frac{(\bar{x_{ij}}-\bar{x_j})}{p-1}}}

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 h is replaced by a robust z score calculated by replacing \bar{x_j} and s_j with the robust estimates of location and scale obtained using Huber's estimate with tuning constant k set to 1.5 (unless otherwise specified in ...).

Value

mandel.h 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.k, mandel.kh; pmandelh, pmandelk for probabilities, quantiles etc.; plot.mandel.kh, barplot.mandel.kh for plotting methods.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
	data(RMstudy)

	#Data frame examples: note no secondary grouping factor
	h <- with(RMstudy, mandel.h(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.h(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.h(RM.ilab))
	
	#Robust variant
	hrob <- with(RMstudy, mandel.kh(RMstudy[2:9], g=Lab, type="h", method="robust"))
	plot(hrob, las=2)
	

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.