bd_row: Breakdown for Mahalanobis Distance

Description Usage Arguments Value See Also Examples

View source: R/bd_row.R

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

1

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## 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)

AFIT-R/anomalyDetection documentation built on Oct. 14, 2019, 5:24 p.m.