pdchisq {metRology}R Documentation

Pair-difference chi-squared statistic

Description

Generates the pair-difference chi-squared statistic for each point in a data set, summing over scaled differences frm other points.

Usage

      
        pdchisq(x, s=sd, cov=NULL, cor = NULL, na.rm=FALSE, ...)
	

Arguments

x

Vector of observations

s

Either a function returning an estimate of scale for x or a vector of length length(x) of standard errors or standard uncertainties in x.

cov, cor

Covariance or correlation matrix, respectively, describing the covariance structure across x.

na.rm

logical. Controls whether missing values should be removed. NOTE: na.rm is passed to s as well as sum; s must accordingly accept an argument na.rm.

...

Parameters passed to s if s is a function.

Details

For each observation x_j, pdchisq calculates the pairwise chi-squared statistic

\chi_{j \rm PD}^2 = \frac{1}{N-1} \sum_{i=1}^{N} (x_i - x_j)^2/(s_i^2 + s_j^2 - 2 {\rm cov}(x_i, x_j))

that is, the sum of squared differences divided by the estimated uncertainties of the distances.

If s is a function, it is applied to x and replicated to length length(x). Note that na.rm is passed to s, so s must accept an argument na.rm. For some scale functions that may require s to be defined as a wrapper to avoid unused argument warnings. For example, if foo is a scale function that does not accept an na.rm argument, use s=function(x, na.rm, ...) foo(x, ...) .

If s is a scalar, it is replicated to length length(x).

If cov is present, s is silently ignored. If cor is present, cov is constructed from cor and s

The pair-difference chi-squared statistic is a measure of how ‘far’ an individual observation is from all the other values in the data set, taking account of uncertainties.

Value

An object of class "PDchisq", consisting of a vector of length length(x) of median scaled absolute deviations for each observation, with attributes:

names

character vector of names, taken from x

x

values supplied as x

s

values supplied as s

Print and plotting methods are provided for the “PDchisq” class; see PDchisq-class.

Author(s)

S. L. R. Ellison s.ellison@lgcgroup.com

References

R J Douglas, A G Steele (2006) Pair-difference chi-squared statistics for Key Comparisons, Metrologia 43, 89-97

See Also

PDchisq-class, bootPDchisq.

Examples


  data(Pb)
  pdchisq(Pb$value)  # Uses mad(Pb$value) as scale estimate
  pdchisq(Pb$value, Pb$u)  # Scales differences using standard uncertainties


[Package metRology version 0.9-29-2 Index]