Computes distance between features(variables) weighing the loadings proportional to corresponding eigenvalues

dist_pca(model, ...)

Arguments

model

Object of class 'prcomp' or 'princomp'.

...

Arguments to be passed to 'proxy::dist'

Details

See the book: 'An introduction to applied multivariate analysis with R' by Everitt (et al) section 3.6 on 'Rescaling the principal components'

Examples

pca_iris <- stats::prcomp(scale(iris[,1:4])) feature_dist_iris <- dist_pca(pca_iris) feature_dist_iris
#> Sepal.Length Sepal.Width Petal.Length #> Sepal.Width 2.36441184 #> Petal.Length 0.38799175 2.61263496 #> Petal.Width 0.36928628 2.55802891 0.09765659
plot(stats::hclust(feature_dist_iris))
pca_iris2 <- stats::princomp(covmat = cor(iris[,1:4]), cor = TRUE) feature_dist_iris2 <- dist_pca(pca_iris2) feature_dist_iris2
#> Sepal.Length Sepal.Width Petal.Length #> Sepal.Width 2.36441184 #> Petal.Length 0.38799175 2.61263496 #> Petal.Width 0.36928628 2.55802891 0.09765659
all.equal(feature_dist_iris, feature_dist_iris2)
#> [1] TRUE
plot(stats::hclust(feature_dist_iris))