# Correlation test issues

No error in 10.0.2

When using Correlation[] function I sometimes get the strange warning:

CorrelationTest::nortst: "At least one of the p-values in {0.0527317}, resulting from a test for normality, is below 0.05. The tests in \!$${\"PearsonCorrelation\"}$$ require that the data is normally distributed."


But take a look that there's only one p-value and it is actually greater than $0.05$:

0.0527317 < 0.05
False


The code that causes this:

x = RandomReal[{-5, 5}, 100];
y = 2 x + 1 + RandomReal[{-0.1, 0.1}, 100];
X = Transpose[{x, y}];
ListPlot[X]
Correlation[X] // MatrixForm
CorrelationTest[X, 99995/100000, "PearsonCorrelation"]


Why this happens? (to reproduce the issue a few repetitions are usually required)

• The end of the warning states: "The tests in {PearsonCorrelation} require that the data is normally distributed." You are drawing from a uniform distribution so your data is not sufficiently "normal" looking for the test. – Bob Hanlon Aug 12 '14 at 17:11
• @BobHanlon yes, but it is stated on the basis of the PValue. And PValue is greater than the $\alpha=0.05$ so it shouldn't write that warning in my opinion. – Misery Aug 13 '14 at 6:54

## 2 Answers

It appears to be a bug in the reporting mechanism. The individual components x and y are being tested for normality but the reported value is that of a joint test for multivariate normality. The conclusion is correct, the message is wrong.

SeedRandom[2154];

x = RandomReal[{-5, 5}, 100];
y = 2 x + 1 + RandomReal[{-0.1, 0.1}, 100];
X = Transpose[{x, y}];
CorrelationTest[X, 99995/100000, "PearsonCorrelation"]

(* CorrelationTest::nortst: At least one of the p-values
in {0.0492268}, resulting from a test for normality, is below 0.05. The tests in
{PearsonCorrelation} require that the data is normally distributed. >>

0.540402 *)


Marginal tests:

DistributionFitTest[x]

(* 0.00121523 *)

DistributionFitTest[y]

(* 0.00123259 *)


Joint test for multivariate normality. Notice the p-value matches the one in the message:

DistributionFitTest[X]

(* 0.0492268 *)


No error nv 10.0.2. On windows 7, 64 bit

SeedRandom[0];
x = RandomReal[{-5, 5}, 100];
y = 2 x + 1 + RandomReal[{-0.1, 0.1}, 100];
X = Transpose[{x, y}];
ListPlot[X]
Correlation[X] // MatrixForm
CorrelationTest[X, 99995/100000, "PearsonCorrelation"]


No error messages.