Calculate inertia for a given subset of the distance matrix from the original
data set provided to x
. Assumes that distance matrices are stored as
matrices and not distance objects.
inertia_calc(x)
x | Distance matrix, not an object of some distance measure. |
---|
Inertia value of the matrix, formula in Chavent (1998). If x
is a
single number, return 0.
data(iris) # Euclidean distance on first 20 rows of the 4 continuous variables dist_mat <- as.matrix(dist(iris[1:20, 1:4])) inertia_calc(dist_mat)#> [1] 7.1885