AddOutlier {rsvddpd}R Documentation

Add outlier to matrix

Description

AddOutlier returns a matrix with outliers randomly added to a matrix given certain proportion of contamination

Usage

AddOutlier(X, proportion, value, seed = NULL, method = "element")

Arguments

X

matrix, to which outliers are added

proportion

numeric, proportion of elements, rows or columns to be contaminated. Must be between 0 and 1.

value

numeric, the outlying value to be used for contamination

seed

numeric, a seed to reproduce the randomization behaviour

method

character, must be one of the following:

  • "element" - For contaminating at random positions of the matrix

  • "row" - For contaminating an entire row of the matrix

  • "col" - For contaminating an entire column of the matrix

Value

A matrix with elements / rows / columns contaminated.

Note

Due to randomization, it is possible that the none of the entries of the matrix become contaminated. In that case, it is recommended to use different seed value.

Examples

X = matrix(1:20, nrow = 4, ncol = 5)
AddOutlier(X, 0.5, 10, seed = 1234)

[Package rsvddpd version 1.0.0 Index]