permutation_test function

Run permutation test on PCA analysis.

Run permutation test on PCA analysis.

Permute data fed to PCA a given number of times, collecting the number of significant pairwise correlations in the permuted data and the variances explained for a given number of PCs.

permutation_test( pca_data, pc_n = 5, n = 100, scale = TRUE, cor.method = "pearson" )

Arguments

  • pca_data: data fed to the prcomp function. Remove non-continuous variables.
  • pc_n: the number of PCs to collect variance explained from.
  • n: the number of times to permute that data. Warning: high values will take a long time to compute.
  • scale: whether the PCA variables should be scaled (default = TRUE).
  • cor.method: method to use for correlations (default = "pearson"). Alternative is "spearman".

Returns

object of class permutation_test

  • $permuted_variances n x pc_no matrix of variances explained by first pc_no PCs in n permutations of original data.
  • $permuted_correlations list of length n of significant pairwise correlations in n permutations of the data (<= 0.05).
  • $actual_variances pc_n x 2 tibble of variances explained by first pc_n PCs with original data.
  • $actual_correlations the number of significant pairwise correlations (<= 0.05) in the original data.

Details

This function is now superseded. Use correlation_test() for pairwise correlations and pca_test() for variance explained and loadings.

Examples

permutation_test( onze_intercepts |> dplyr::select(-speaker), pc_n = 5, n = 10, scale = TRUE, cor.method = 'pearson' )