calculate_sample_mahalanobis_distances | R Documentation |
Determine each samples distance from the center of the data using Mahalanobis distance.
calculate_sample_mahalanobis_distances(
tomic,
value_var = NULL,
max_pcs = 10,
scale = FALSE
)
tomic |
Either a |
value_var |
the measurement variable to use for calculating distances |
max_pcs |
the maximum number of principal components to used for representing the covariance matrix. |
scale |
if TRUE then the data will be scaled before calculating distances |
Since 'romic' is built around using tall data where there are more features than samples calculating Mahalanobis distance off of the covariance matrix is not possible. Instead, we use SVD to create a low-dimensional representation of the covariance matrix and calculate distances from the center of the data in this space. This essentially involves weighting the principal components by their loadings.
The samples tibble with a new column 'pc_distance' which contains the Mahalanobis distances of individual samples from the PC elipsoid
calculate_sample_mahalanobis_distances(brauer_2008_tidy)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.