Categories &

Functions List

Function Reference: correlation_test

statistics: h = correlation_test (x, y)

statistics: [h, p] = correlation_test (y, x)

statistics: [h, p, stats] = correlation_test (y, x)

statistics: […] = correlation_test (y, x, Name, Value)

Perform a correlation coefficient test to determine whether two samples x and y come from uncorrelated populations.

h = correlation_test (y, x) tests the null hypothesis that the two samples x and y come from uncorrelated populations. The result is h = 0 if the null hypothesis cannot be rejected at the significance level alpha, or h = 1 if it can. y and x must be vectors of equal length with finite real numbers.

The p-value of the test is returned in p. stats is a structure with the following fields:

FieldValue
methodthe type of correlation coefficient used for the test
tstatthe t statistic, for Pearson’s and Spearman’s coefficients
dfits degrees of freedom, n - 2
zvalthe z statistic, for Kendall’s coefficient
distthe respective distribution for the test
altthe alternative hypothesis for the test
CorrCoefthe correlation coefficient, the effect size
CorrCoefCIits 100 (1 - alpha)% confidence interval, one-sided for a one-sided test

Pearson’s and Spearman’s coefficients are tested with t = r sqrt ((n - 2) / (1 - r^2)) on n - 2 degrees of freedom, as R’s cor.test does without an exact test; Kendall’s with its normal approximation, whose variance allows for ties. The confidence interval is Fisher’s z transform of the coefficient, with standard error 1 / sqrt (n - 3) for Pearson’s, sqrt ((1 + r^2 / 2) / (n - 3)) for Spearman’s and sqrt (0.437 / (n - 4)) for Kendall’s, after Bonett and Wright (2000).

[…] = correlation_test (…, name, value) specifies one or more of the following name/value pairs:

NameValue
'alpha'the significance level of h and the level of the confidence interval. Default is 0.05.
'tail'a string specifying the alternative hypothesis
'both'corrcoef is not 0 (two-tailed, default)
'left'corrcoef is less than 0 (left-tailed)
'right'corrcoef is greater than 0 (right-tailed)
'method'a string specifying the correlation coefficient used for the test
'pearson'Pearson’s product moment correlation (Default)
'kendall'Kendall’s rank correlation tau
'spearman'Spearman’s rank correlation rho

See also: regression_ftest, regression_ttest

Source Code: correlation_test