Description Usage Arguments Details Value Author(s) See Also Examples
this function is an extension of cor.test() that calculates correlation coefficients, p-values and confidence intervals for a pair of variables or for all pairs of variables if more than two are provided in a data.frame. It can calculate Pearson, Kendall or Spearman correlation coefficients and p-values for a two-tailed or one-tailed alternative hypothesis. For Kendall or Spearman correlation, confidence intervals are calculated by bootstrap samling. In case of NAs the complete row can be taken out or only for the affected comparisons
1 2 3 4 5 6 7 8 9 10 11 |
data |
a character string without ” specifying a data.frame object with the data, each variable must be in only one column, or a subset of a data.frame with two or more variables or two vectors in a list |
method |
a character string specifying the correlation method to be used, options are pearson, spearman or kendall, names can be abbreviated |
alternative |
a character string indicating the alternative hypothesis and must be one of 'two.sided', 'greater' or 'less', 'greater' corresponds to a positive association, 'less' to a negative association, names can be abbreviated |
conf.level |
numeric an decimal specifying the confidence level for the returned confidence interval |
use |
an character string giving a method for computing covariances in the presence of missing values, options are (an abbreviation of) one of the strings 'complete.obs' or 'pairwise.complete.obs' (default) |
boots |
a single positive integer indicating the number of bootstrap replicates, default=2000 |
verbose |
a logical indicating whether a summary of the output should be printed to the console |
exact |
a logical indicating whether an exact p-value should be computed (used for Kendall's tau and Spearman's rho), see 'details' for the meaning of NULL (the default) |
continuity |
logical: if true, a continuity correction is used for Kendall's tau and Spearman's rho when not computed exactly |
the three methods each estimate the association between paired samples and compute a test of the value being zero. They use different measures of association, all in the range -1, 1 with 0 indicating no association, these are sometimes referred to as tests of no correlation, but that term is often confined to the default method. If method is 'pearson', the test statistic is based on Pearson's product moment correlation coefficient cor(x, y) and follows a t distribution with length(x)-2 degrees of freedom if the samples follow independent normal distributions. If there are at least 4 complete pairs of observation, an asymptotic confidence interval is given based on Fisher's Z transform. If method is 'kendall' or 'spearman', Kendall's tau or Spearman's rho statistic is used to estimate a rank-based measure of association, these tests may be used if the data do not necessarily come from a bivariate normal distribution. For Kendall's test, by default (if exact is NULL), an exact p-value is computed if there are less than 50 paired samples containing finite values and there are no ties, otherwise, the test statistic is the estimate scaled to zero mean and unit variance, and is approximately normally distributed. For Spearman's test, p-values are computed using algorithm AS 89 for n<1290 and exact=TRUE, otherwise via the asymptotic t approximation. Note that these are ‘exact’ for n<10, and use an Edgeworth series approximation for larger sample sizes (the cutoff has been changed from the original paper)
if the input are two vectors or two columns of a data.frame and the method is pearson the function returns invisibly and print to the console the output of cor.test(), if the method is kendall or spearman the function returns invisibly a list and prints to the console (if verbose=TRUE) the output of cor.test() and the confidence interval from boot.ci(), if the input is a data.frame with more than two variables the function returns invisibly a list with the call, relevant input parameters and the matrices with correlation coefficients, p-values and lower and upper limits of confidence intervals for all combinations of variables, if verbose=TRUE the function prints to the console the matrices with correlation coefficients, p-values and lower and upper limits of confidence intervals for all combinations of variables
gerardo esteban antonicelli
'check_contrasts'
'omega_factorial'
1 2 3 4 5 6 7 8 9 10 | data(examData)
data(personalityData)
data(stalkerData)
corr.test(examData[ , c(2, 4)], 'pearson', 'greater', 0.99)
corr.test(list(examData$Revise, examData$Anxiety), 'kendall', 'less', 0.99, boots=1000)
corr.test(examData[ , 2:4], 'spearman', 'greater', 0.95, 'complete.obs', exact=FALSE, verbose=FALSE)
corr.test(personalityData[ , c(3:12)], 'pearson', 'less', 0.99, 'complete.obs')
corr.test(personalityData[ , c(3:12)], conf.level=0.99)
corr.test(personalityData[ , c(3:12)], 'kendall', boots=500)
corr.test(stalkerData[ , c(2, 3)], 'spearman', conf.level=0.99, exact=FALSE, continuity=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.