mahad {careless}R Documentation

Find and graph Mahalanobis Distance (D) and flag potential outliers.

Description

Takes a matrix of item responses and computes Mahalanobis D. Can additionally return a vector of binary outlier flags. Mahalanobis distance is calculated using the function psych::outlier of the psych package, an implementation which supports missing values.

Usage

mahad(x, plot = TRUE, flag = FALSE, confidence = 0.99, na.rm = TRUE)

Arguments

x

a matrix of data

plot

Plot the resulting QQ graph

flag

Flag potential outliers using the confidence level specified in parameter confidence

confidence

The desired confidence level of the result

na.rm

Should missing data be deleted

Author(s)

Richard Yentes ryentes@gmail.com, Francisco Wilhelm franciscowilhelm@gmail.com

References

Meade, A. W., & Craig, S. B. (2012). Identifying careless responses in survey data. Psychological Methods, 17(3), 437-455. doi:10.1037/a0028085

See Also

psych::outlier on which this function is based.

Examples

mahad_raw <- mahad(careless_dataset) #only the distances themselves
mahad_flags <- mahad(careless_dataset, flag = TRUE) #additionally flag outliers
mahad_flags <- mahad(careless_dataset, flag = TRUE, confidence = 0.999) #Apply a strict criterion

[Package careless version 1.2.2 Index]