Computes the chi-squared distance between the rows of a data frame of factors.

dist.chi2(X)

Arguments

X

data frame. All variables should be factors.

Details

This function is adapted from chi2Dist function in ExPosition package.

Value

A symmetrical matrix of distances

Author

Nicolas Robette

Examples

data(Music)
d <- dist.chi2(Music[,1:5])
# a short piece of the distance matrix
d[1:3, 1:3]
#>          [,1]     [,2]     [,3]
#> [1,]  0.00000 33.32566 20.51546
#> [2,] 33.32566  0.00000 12.81019
#> [3,] 20.51546 12.81019  0.00000