Skip to contents

Index loadings (Vieira 2012) are presented with confidence intervals on the sampling distribution generated by bootstrapping and a null distribution generated by permutation.

Usage

plot_loadings(
  pca_test,
  pc_no = 1,
  violin = FALSE,
  filter_boots = FALSE,
  quantile_threshold = 0.25
)

Arguments

pca_test

an object of class pca_test_results generated by pca_test.

pc_no

An integer indicating which PC to plot.

violin

If TRUE, violin plots are added for the confidence intervals of the sampling distribution.

filter_boots

if TRUE, only bootstrap iterations in which the variable with the highest median loading is above quantile_threshold.

quantile_threshold

a real value between 0 and 1. Use this to change the threshold used for filtering bootstrap iterations. The default is 0.25.

Value

ggplot object.

Details

If PCs are unstable, there is an option (filter_boots) to take only the bootstrap iterations in which the variable with the highest median loading across all iterations is above quantile_threshold (default: 0.25). This helps to reveal reliable connections of this variable with other variables in the data set.

References

Vieira, Vasco (2012): Permutation tests to estimate significances on Principal Components Analysis. Computational Ecology and Software 2. 103–123.

Examples

  onze_pca <- pca_test(onze_intercepts |> dplyr::select(-speaker), n = 10)
  # Plot PC1
  plot_loadings(onze_pca, pc_no=1)

  # Plot PC2 with violins (not particularly useful in this case!)
  plot_loadings(onze_pca, pc_no=2, violin = TRUE)