correlation_test {nzilbb.vowels} | R Documentation |
Permutation test of pairwise correlations
Description
Permute data a given number (n) of times, collecting pairwise correlations
and testing them for significance. See plot_correlation_magnitudes()
and
plot_correlation_counts()
for plotting functions which take the output of
this function.
Usage
correlation_test(pca_data, n = 100, cor.method = "pearson")
Arguments
pca_data |
dataframe or matrix containing only continuous variables.
(as accepted by the |
n |
the number of times (integer) to permute that data. Warning: high values will take a long time to compute. Default: 100. |
cor.method |
method to use for correlations (default = "pearson").
Alternative is "spearman" (see |
Value
object of class correlation_test
, with attributes:
-
$permuted_correlations
A tibble of length n of pairs from the original data, their correlations, and the significance of each correlation (as p-values). -
$actual_correlations
the correlations of each pair of variables in the original data and their significance (as p-values). -
$iterations
the number of permutations carried out. -
$cor_method
the form of correlation used.
Examples
# get a small sample of random intercepts.
pca_data <- onze_intercepts |>
dplyr::select(-speaker) |>
dplyr::slice_sample(n=10)
# apply correlation test with 10 permutations.
# actual use requires at least 100.
cor_test <- correlation_test(pca_data, n = 10, cor.method = 'pearson')
# Return summary of significant correlations
summary(cor_test)
# use spearman correlation instead.
cor_test_spear <- correlation_test(pca_data, n = 10, cor.method = 'spearman')