colIQRDiffs {DelayedMatrixStats} | 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

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

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

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

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

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

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

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

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

    ## S4 method for signature 'DelayedMatrix'
    colIQRDiffs(x, rows = NULL, cols = NULL,
      na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE,
      ...)

    ## S4 method for signature 'DelayedMatrix'
    colMadDiffs(x, rows = NULL, cols = NULL,
      na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE,
      ...)

    ## S4 method for signature 'DelayedMatrix'
    colSdDiffs(x, rows = NULL, cols = NULL,
      na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE,
      ...)

    ## S4 method for signature 'DelayedMatrix'
    colVarDiffs(x, rows = NULL, cols = NULL,
      na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE,
      ...)

    ## S4 method for signature 'DelayedMatrix'
    rowIQRDiffs(x, rows = NULL, cols = NULL,
      na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE,
      ...)

    ## S4 method for signature 'DelayedMatrix'
    rowMadDiffs(x, rows = NULL, cols = NULL,
      na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE,
      ...)

    ## S4 method for signature 'DelayedMatrix'
    rowSdDiffs(x, rows = NULL, cols = NULL,
      na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE,
      ...)

    ## S4 method for signature 'DelayedMatrix'
    rowVarDiffs(x, rows = NULL, cols = NULL,
      na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE,
      ...)

### Arguments

`x` | A NxK DelayedMatrix.
`rows` | A `vector` indicating subset of elements (or rows and/or columns) to operate over. If `NULL`, no subsetting is done.
`cols` | A `vector` indicating subset of elements (or rows and/or columns) to operate over. If `NULL`, no subsetting is done.
`na.rm` | If `TRUE`, `NA`s are excluded, otherwise not.
`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.
`...` | Additional arguments passed to specific methods.
`force_block_processing` | `FALSE` (the default) means that a seed-aware, optimised method is used (if available). This can be overridden to use the general block-processing strategy by setting this to `TRUE` (typically not advised). The block-processing strategy loads one or more (depending on `getOption("DelayedArray.block.size")`) columns (`colFoo()`) or rows (`rowFoo()`) into memory as an ordinary base::array.

### 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.

### 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`().

### Examples

    # A DelayedMatrix with a 'Matrix' seed
    dm_Matrix <- DelayedArray(Matrix::Matrix(c(rep(1L, 5),
                                               as.integer((0:4) ^ 2),
                                               seq(-5L, -1L, 1L)),
                                             ncol = 3))
    # A DelayedMatrix with a 'SolidRleArraySeed' seed
    dm_Rle <- RleArray(Rle(c(rep(1L, 5),
                             as.integer((0:4) ^ 2),
                             seq(-5L, -1L, 1L))),
                       dim = c(5, 3))

    colIQRDiffs(dm_Matrix)

    colMadDiffs(dm_Matrix)

    colSdDiffs(dm_Matrix)

    colVarDiffs(dm_Matrix)

    # Only using rows 2-4
    rowIQRDiffs(dm_Rle, rows = 2:4)

    # Only using rows 2-4
    rowMadDiffs(dm_Rle, rows = 2:4)

    # Only using rows 2-4
    rowSdDiffs(dm_Rle, rows = 2:4)

    # Only using rows 2-4
    rowVarDiffs(dm_Rle, rows = 2:4)

[Package DelayedMatrixStats version 1.0.3 Index]