Learn R Programming

rsvddpd (version 1.0.1)

AddOutlier: 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")

Value

A matrix with elements / rows / columns contaminated.

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

Examples

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

Run the code above in your browser using DataLab