Create plot of variances explained from pca_test object
Create plot of variances explained from pca_test object
The variance explained by each PC in a dataset is plotted with confidence intervals generated by bootstrapping and a null distribution generated by permutation. The function accepts the result of calling the pca_test
pca_test: an object of class pca_test_results generated by pca_test.
pc_max: the maximum number of PCs to plot. If NA, plot all PCs.
percent: if TRUE, represent variance explained as a percentage. If FALSE, represent as eigenvalues.
Returns
ggplot object.
Details
By default, variance explained is represented as a percentage. If the argument percent is set to FALSE, then the variance explained is represented by the eigenvalues corresponding to each PC.
Examples
onze_pca <- pca_test(onze_intercepts |> dplyr::select(-speaker), n =10)# Plot with percentages plot_variance_explained(onze_pca)# Plot with eigenvalues and only the first 5 PCs. plot_variance_explained(onze_pca, pc_max =5, percent =FALSE)