malDist: Mahalanobis Distance.

Description Usage Arguments Details Value See Also Examples

Description

malDist returns a vector indicating the Mahalanobis Distance for each participant in a dataframe.

Usage

1
malDist(x, nitems = NA)

Arguments

x

An R dataframe or matrix object.

nitems

An integer. If dataset is multivariate, indicate the number of items per scale. At present, this is only defined for factors assessed with the same number of indicators.

Details

By default, this function is designed for univariate tests, and assumes that all variables passed belong to the same factor. However, see nitems if there is a multidimensional structure. Note: if the data are passed as factors, it is converted to integer before calculating the Mahalanobis Distance. If missing data is present, the function will return NA for that observation.

Value

A vector of type numeric. If nitems is given, the return is of type matrix and contains one vector per factor (D1...Dn), as well as their average (AverageD).

See Also

longString

Examples

1
2
3
4
5
6
7
## Not run: 
set.seed(77)
dat <- matrix(sample(1:3, 200, replace = TRUE),20,10)
malDist(dat)
malDist(dat, nitems = 5)

## End(Not run)

mattsigal/careless documentation built on May 21, 2019, 1:25 p.m.