bd_row {anomalyDetection}R Documentation

Breakdown for Mahalanobis Distance

Description

bd_row indicates which variables in data are driving the Mahalanobis distance for a specific row r, relative to the mean vector of the data.

Usage

bd_row(data, row, n = NULL)

Arguments

data

numeric data

row

row of interest

n

number of values to return. By default, will return all variables (columns) with their respective differences. However, you can choose to view only the top n variables by setting the n value.

Value

Returns a vector indicating the variables in data that are driving the Mahalanobis distance for the respective row.

See Also

mahalanobis_distance for computing the Mahalanobis Distance values

Examples

## Not run: 
x = matrix(rnorm(200*3), ncol = 10)
colnames(x) = paste0("C", 1:ncol(x))

# compute the relative differences for row 5 and return all variables
x %>%
  mahalanobis_distance("bd", normalize = TRUE) %>%
  bd_row(5)

# compute the relative differences for row 5 and return the top 3 variables
# that are influencing the Mahalanobis Distance the most
x %>%
  mahalanobis_distance("bd", normalize = TRUE) %>%
  bd_row(5, 3)
  
## End(Not run)


[Package anomalyDetection version 0.2.4 Index]