# algA: Robust estimation of location and scale using Algorithm A In metRology: Support for Metrological Applications

## Description

Algorithm A is an implementation of Huber's location and scale estimate with iterated scale.

## Usage

 ```1 2``` ``` algA(x, k = 1.5, na.rm = FALSE, tol = .Machine\$double.eps^0.25, maxiter = 25, verbose = FALSE) ```

## Arguments

 `x` numeric vector or array of values. `k` Tuning factor; Winsorisation occurs ar k standard deviations. `na.rm` a logical value indicating whether `NA` values should be removed before the computation proceeds. `tol` Convergence tolerance Iteration continues until the relative change in estimated sd drops below `tol`. `maxiter` Maximum number of iterations permitted. `verbose` Controls information displayed during iteration; see Details.

## Details

Algorithm A is the robust estimate of location described in ISO 5725-5:1998. It proceeds by winsorisation and re-estimation of scale and location.

The argument `k` controls the point at which values are Winsorised and hence controls the efficiency. At `k=1.5`, the value chosen by ISO 5725, the estimator has asymptotic efficiency at the Normal of 0.964. With iterated estimate of scale and `k=1.5`, the estimator has a breakdown point of about 30

The convergence criterion for Algorithm A is not specified in ISO 5725-5:1998. The criterion chosen here is reasonably stringent but the results will differ from those obtained using other choices. Use `verbose=2` to check the effect of different tolerance or maximum iteration count.

If `verbose` is non-zero, the current iteration number and estimate are printed; if `verbose>1`, the current set of truncated values w is also printed.

## Value

 `mu` Robust estimate of location `s` Robust estimate of scale

## Warning

Algorithm A uses the corrected median absolute deviation as the initial estimate of scale; an error is returned if the resulting scale estimate is zero, which can occur with over 50% of the data set equal. `huberM` in the robustbase package uses an alternative scale estimate in these circumstances.

## Note

Algorithm A is identical to Huber's estimate with variable scale. The implementation here differs from `hubers` from MASS in:

• hubers allows prior specification of fixed scale (which provides higher breakdown if chosen properly) or location

• the option of verbose output in `algA`,

• a maximum iteration option in `algA`

• the convergence criterion; hubers converges on changes in `mu`, whilst this implementation of Algorithm A converges on changes in `s`.

• Internally, Algorithm A multiplies by a correction factor for standard deviation whilst `hubers` divides by a correction factor applied to the variance; the actual correction to `s` is identical.

The principal reasons for providing an implementation in the metRology package are i) to ensure a close implementation of the cited Standard irrespective of other package developments (though the MASS implementation has proved very stable) and ii) to make the implementation easy to recognise for users of the ISO standard.

## Author(s)

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

## References

ISO 5725-5:1998 Accuracy (trueness and precision) of measurement methods and results - Part 5: Alternative methods for the determination of the precision of a standard measurement method

Maronna R A, Martin R D, Yohai V J (2006) Robust statistics - theory and methods. Jhn Wiley and Sons, West Sussex, England.

`algS`, `hubers`, `huberM`

## Examples

 ```1 2 3 4 5 6 7``` ```#Creosote example from ISO 5725-5:1998 #Means for each group are: cm <-c(24.140, 20.155, 19.500, 20.300, 20.705, 17.570, 20.100, 20.940, 21.185) algA(cm, verbose=TRUE) #Iteration 4 corresponds very closely to the ISO 5725 answer ```

### Example output

```Attaching package: 'metRology'

The following objects are masked from 'package:base':

cbind, rbind

0: mu=20.300000; s=0.948864
1: mu=20.387222; s=0.984891
2: mu=20.406605; s=1.008644
3: mu=20.410912; s=1.025393
4: mu=20.411869; s=1.037324
5: mu=20.412082; s=1.045860
6: mu=20.412129; s=1.051985
7: mu=20.412140; s=1.056389
8: mu=20.412142; s=1.059559
9: mu=20.412143; s=1.061844
10: mu=20.412143; s=1.063492
11: mu=20.412143; s=1.064682
12: mu=20.412143; s=1.065540
13: mu=20.412143; s=1.066160
14: mu=20.412143; s=1.066608
15: mu=20.412143; s=1.066931
16: mu=20.412143; s=1.067165
17: mu=20.412143; s=1.067333
18: mu=20.412143; s=1.067455
\$mu
 20.41214

\$s
 1.067455
```

metRology documentation built on May 2, 2019, 12:20 p.m.