R: Estimation of scale based on sequential-order differences

varDiff {matrixStats} | R Documentation

## Estimation of scale based on sequential-order differences

### Description

Estimation of scale based on sequential-order differences, corresponding to the scale estimates provided by `var`, `sd`, `mad` and `IQR`.

### Usage

    varDiff(x, idxs = NULL, na.rm = FALSE, diff = 1L, trim = 0, ...)

    sdDiff(x, idxs = NULL, na.rm = FALSE, diff = 1L, trim = 0, ...)

    madDiff(x, idxs = NULL, na.rm = FALSE, diff = 1L, trim = 0,
      constant = 1.4826, ...)

    iqrDiff(x, idxs = NULL, na.rm = FALSE, diff = 1L, trim = 0, ...)

    rowVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
      trim = 0, ..., useNames = NA)

    colVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
      trim = 0, ..., useNames = NA)

    rowSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
      trim = 0, ..., useNames = NA)

    colSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
      trim = 0, ..., useNames = NA)

    rowMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
      trim = 0, ..., useNames = NA)

    colMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
      trim = 0, ..., useNames = NA)

    rowIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
      trim = 0, ..., useNames = NA)

    colIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
      trim = 0, ..., useNames = NA)

### Arguments

`x` | A `numeric` `vector` of length N or a `numeric` NxK `matrix`.
`idxs` | A `vector` indicating subset of elements to operate over. If `NULL`, no subsetting is done.
`na.rm` | If `TRUE`, missing values are excluded.
`diff` | The positional distance of elements for which the difference should be calculated.
`trim` | A `double` in [0,1/2] specifying the fraction of observations to be trimmed from each end of (sorted) `x` before estimation.
`...` | Not used.
`constant` | A scale factor adjusting for asymptotically normal consistency.
`rows` | A `vector` indicating subset of rows to operate over. If `NULL`, no subsetting is done.
`cols` | A `vector` indicating subset of columns to operate over. If `NULL`, no subsetting is done.
`useNames` | If `NA`, the default behavior of the function about naming support is remained. If `FALSE`, no naming support is done. Else if `TRUE`, names attributes of result are set.

### Details

Note that n-order difference MAD estimates, just like the ordinary MAD estimate by `mad`, apply a correction factor such that the estimates are consistent with the standard deviation under Gaussian distributions.

The interquartile range (IQR) estimates does not apply such a correction factor. If asymptotically normal consistency is wanted, the correction factor for IQR estimate is `1 / (2 * qnorm(3/4))`, which is half of that used for MAD estimates, which is `1 / qnorm(3/4)`. This correction factor needs to be applied manually, i.e. there is no `constant` argument for the IQR functions.

### Value

Returns a `numeric` `vector` of length 1, length N, or length K.

### Author(s)

Henrik Bengtsson

### References

[1] J. von Neumann et al., The mean square successive difference. Annals of Mathematical Statistics, 1941, 12, 153-162.

### See Also

For the corresponding non-differentiated estimates, see `var`, `sd`, `mad` and `IQR`. Internally, `diff2`() is used which is a faster version of `diff`().

[Package matrixStats version 0.61.0 Index]