Tutorials › Introduction to Statistics › Permutation Tests for Correlation

Bootstrap and Permutation Methods · Tutorial 993 of 996

Permutation Tests for Correlation

Use response permutations to assess whether an observed correlation is stronger than would be expected under a null model of no association.

Intermediate 10 min read

What You'll Learn

  • State the null hypothesis tested by permuting response values across fixed predictor values.
  • Calculate Pearson’s sample correlation and use it as a test statistic.
  • Construct an exact permutation distribution for a small data set.
  • Estimate a permutation p-value from a Monte Carlo sample of permutations.
  • Check when response values are exchangeable under the null model.
  • Distinguish evidence against independence from proof of causation or a claim about every kind of association.

Why Permute Responses to Test Correlation?

A sample correlation describes the direction and strength of a linear pattern in paired quantitative data. But an observed correlation can arise from chance variation even when the variables have no underlying association. A permutation test asks how unusual the observed correlation would be if the response values had no systematic connection to the predictor values.

The procedure keeps the predictor values fixed and rearranges the responses among them. Each rearrangement makes a new set of pairs, and its correlation is calculated. The resulting correlations form a null distribution against which the observed correlation can be compared. This is a test of association based on the particular data and assumptions; it does not establish that changes in one variable cause changes in the other.

Definition: A permutation test for correlation compares the observed sample correlation between paired quantitative variables with a null distribution formed by repeatedly reassigning the observed response values to the fixed predictor values. Under the null hypothesis of independence, and when the responses are exchangeable across predictor values, those reassignments represent outcomes consistent with the null.

Statistic, Hypotheses, and Assumptions

Let \(x_i\) be the predictor value and \(y_i\) the response value for observational unit \(i\), for \(i=1,\ldots,n\). The usual statistic is Pearson’s sample correlation, \(r\). It measures linear association and is dimensionless, so it has no physical units. It is defined when both variables have nonzero sample variation.

$$ r=\frac{\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})} {\sqrt{\sum_{i=1}^{n}(x_i-\bar{x})^2\sum_{i=1}^{n}(y_i-\bar{y})^2}} $$

For a two-sided test of no association, the hypotheses are \(H_0\): the predictor and response are independent, versus \(H_a\): they are associated. A positive-direction alternative asks whether the association is positive; a negative-direction alternative asks whether it is negative. The direction must be chosen before examining the permutation results. The alternative is not simply “the sample correlation is nonzero”: the null model used here is independence, which is stronger than a population correlation of zero.

The permutation calculation relies on conditions that make response reassignment reasonable:

  • Paired quantitative measurements: each observational unit contributes one predictor and one response value, and the statistic is defined for the data.
  • Independent observational units: the pairs come from units that can reasonably be treated as independent. Repeated measurements on the same unit or clustered observations require a different analysis.
  • Exchangeable responses under the null: under \(H_0\), the response values have the same distribution across the fixed predictor values. In particular, independence of response and predictor supports this condition for independent observations.
  • No unaccounted-for structure in the pairings: the data collection must not impose a pairing, time order, or group structure that makes some response assignments more plausible than others under the null.

These assumptions are about the data and null model, not just the arithmetic. For instance, if measurements are recorded in time order and nearby responses tend to be similar, freely shuffling them may break a real dependence structure. A permutation distribution is only a suitable reference when the allowed rearrangements reflect the null model.

How the Permutation Distribution Is Built

1
Calculate the observed statistic.
Use the original pairs to calculate \(r_{\text{obs}}\).
2
Reassign the responses.
Keep \(x_1,\ldots,x_n\) fixed and permute the \(y\)-values across them.
3
Recalculate correlation.
For each reassignment, calculate a new correlation \(r^*\). The collection of these values is the permutation distribution.
4
Compare with the observed value.
Count the permuted statistics at least as extreme as \(r_{\text{obs}}\) in the direction specified by \(H_a\), then calculate the permutation p-value.

If all \(n!\) assignments are enumerated, the test is exact under the stated null assumptions. For a two-sided test based on correlation, extremeness is measured by absolute value: count assignments with \(|r^*|\geq |r_{\text{obs}}|\). For a positive-direction test, count assignments with \(r^*\geq r_{\text{obs}}\); for a negative-direction test, count assignments with \(r^*\leq r_{\text{obs}}\). In each case, the exact p-value is the proportion of all enumerated assignments meeting that criterion.

If only a random sample of \(B\) permutations is generated, the resulting p-value is a Monte Carlo estimate. A common calculation is \((b+1)/(B+1)\), where \(b\) is the number of simulated statistics at least as extreme as the observed statistic. The added one includes the observed arrangement in the comparison and avoids reporting a p-value of zero just because no simulated permutation was as extreme.

Why This Null Distribution Is Appropriate

The key justification is that, under independence, the assignment of response values to fixed predictor values is not favored in any particular order. Conditional on the observed predictor values and the observed response values, each assignment is equally likely when responses are exchangeable under the null. Thus the observed pairing is one of the assignments represented in the permutation distribution.

More explicitly, if the \(n\) response values are treated as distinguishable, there are \(n!\) possible assignments. Under the null, each assignment has probability \(1/n!\). The fraction of assignments whose statistic is at least as extreme as the observed statistic is therefore the null probability of seeing a statistic that extreme or more extreme. This fraction is the exact permutation p-value. If some response values are tied, distinct labeled assignments can produce the same numerical arrangement; counting all labeled assignments still gives the correct weighting under the same exchangeability condition.

This argument explains both the appeal and the limitation of the method: it avoids a normal-theory model for the sampling distribution of correlation, but it does not avoid assumptions about how observations were generated. Nor does it mean that every permutation test is automatically valid; the response shuffling must match the null model.

Worked Example: An Exact Test With Three Pairs

Suppose a hypothetical data set records predictor values \(x=(1,2,3)\) and responses \(y=(1,2,3)\). Test for any association using a two-sided exact permutation test. The units are assumed independent, and under \(H_0\) the response values are exchangeable across the fixed predictor values.

For the observed data, \(\bar{x}=\bar{y}=2\). The numerator of \(r\) is \((-1)(-1)+0(0)+1(1)=2\), and each sum of squared deviations is \(2\). Therefore

$$ r_{\text{obs}}=\frac{2}{\sqrt{2\cdot 2}}=1 $$

There are \(3!=6\) assignments of the three response values. Their correlations are \(1,\ 0.5,\ 0.5,\ -0.5,\ -0.5,\ -1\). A two-sided test counts values with absolute correlation at least \(|1|\). Only \(1\) and \(-1\) qualify, so

$$ p=\frac{2}{6}=0.3333 $$

The observed pairs are perfectly increasing, but with only three observations the exact two-sided p-value is about 0.333. At a significance level of \(0.05\), this test does not provide strong evidence against independence. The result illustrates why the size and structure of the sample matter: an extreme sample correlation alone does not determine the p-value.

Worked Example: A Two-Sided Monte Carlo Test

In a hypothetical sample of five independent units, let \(x=(1,2,3,4,5)\) and \(y=(2,1,4,3,5)\). Assume the response values would be exchangeable across the fixed \(x\)-values under \(H_0\). Calculate the observed correlation, then interpret an illustrative run of 999 random permutations.

The means are \(\bar{x}=3\) and \(\bar{y}=3\). The centered values are \(x_i-\bar{x}=(-2,-1,0,1,2)\) and \(y_i-\bar{y}=(-1,-2,1,0,2)\). The sum of cross-products is \(2+2+0+0+4=8\), and each sum of squared deviations is \(10\). Thus

$$ r_{\text{obs}}=\frac{8}{\sqrt{10\cdot10}}=0.8000 $$

For a two-sided test, simulated permutations are counted when \(|r^*|\geq 0.8000\). Suppose 112 of the 999 simulated statistics meet this condition. The estimated p-value, using the plus-one calculation, is

$$ \hat{p}_{\text{perm}}=\frac{112+1}{999+1} =\frac{113}{1000}=0.113 $$

This hypothetical run gives an estimated p-value of 0.113. At \(\alpha=0.05\), it does not provide sufficient evidence to reject the independence null. The positive sample correlation describes the observed linear pattern; the permutation p-value assesses how surprising a correlation at least that extreme would be under the null. Because this is a Monte Carlo estimate, another random run could give a slightly different value.

Worked Example: Testing for Negative Association

A hypothetical data set has six independent units, with \(x=(1,2,3,4,5,6)\) and \(y=(12,10,11,7,8,6)\). Suppose the scientific question, chosen in advance, is whether the association is negative. Assume responses are exchangeable across the fixed predictor values under \(H_0\).

The means are \(\bar{x}=3.5\) and \(\bar{y}=9\). The centered values are \((-2.5,-1.5,-0.5,0.5,1.5,2.5)\) for \(x\), and \((3,1,2,-2,-1,-3)\) for \(y\). The cross-products sum to \(-20\); the squared deviations sum to \(17.5\) for \(x\) and \(28\) for \(y\). Hence

$$ r_{\text{obs}}=\frac{-20}{\sqrt{17.5\cdot28}} =\frac{-20}{\sqrt{490}} \approx -0.9035 $$

For the pre-specified negative-direction alternative, count permutations with \(r^*\leq -0.9035\), not those with large absolute correlation in either direction. Suppose an illustrative run of 4,999 permutations gives 79 such statistics. The estimated p-value is

$$ \hat{p}_{\text{perm}}=\frac{79+1}{4999+1} =\frac{80}{5000}=0.0160 $$

At the \(0.05\) significance level, this result is evidence against independence in the negative direction: the observed negative correlation is unusual under the stated null model. It does not show that increasing \(x\) causes \(y\) to decrease, and the conclusion depends on the independence and exchangeability assumptions.

What the Test Can and Cannot Detect

Pearson correlation is designed to summarize linear association. A permutation test using \(r\) uses that statistic, even though the null distribution is generated without assuming a normal distribution for \(r\). If a strong curved relationship has a correlation near zero, a test based on Pearson’s \(r\) may not detect it well. A non-significant result therefore does not establish that the variables are independent in every practical or scientific sense.

Conversely, the null hypothesis of independence implies zero population correlation when the relevant expectations exist, but zero correlation alone does not generally imply independence. A permutation test calibrated for independence should not be described as a test of only “zero correlation” unless additional model assumptions justify that interpretation. Always state the null model actually used.

The p-value is a probability calculated under \(H_0\): it is the probability of obtaining a statistic at least as extreme as the observed one, according to the chosen tail rule and permutation scheme. It is not the probability that \(H_0\) is true, nor the probability that the result occurred “by chance” without qualification. The size of \(r_{\text{obs}}\) communicates the observed linear association; the p-value addresses its compatibility with the null model. They answer different questions.

Common Mistakes

  • Permuting paired rows together. This preserves the original pairing and does not create the null distribution described here. Keep the predictor values fixed and reassign the response values across them.
  • Using a one-sided tail after seeing the result. Choosing the direction after observing \(r_{\text{obs}}\) makes the reported p-value misleading. Select the alternative before analyzing the permutation distribution, or use a two-sided test for an undirected question.
  • Calling zero correlation the same as independence. They are not equivalent in general. State whether the test’s null is independence or, under a specified model, a zero population correlation.
  • Interpreting a small p-value as causation. A permutation test for observational pairs can provide evidence of association under its assumptions; it does not by itself establish a causal effect.
  • Ignoring dependence among observations. If responses are clustered, repeated, or ordered in a way relevant under the null, unrestricted shuffling can give an inappropriate reference distribution.
Key takeaway: A correlation permutation test holds predictor values fixed, shuffles responses under a justified null of exchangeability, and compares the observed correlation with the resulting null distribution. The p-value is meaningful only when the permutation scheme and assumptions match the data and the question.

Check Your Understanding

Try these questions before reviewing the explanations above.

  1. In a response-permutation test, which values stay fixed and which values are reassigned?
  2. For a two-sided test with observed correlation \(r_{\text{obs}}=-0.62\), what condition should a permuted correlation \(r^*\) meet to count as at least as extreme?
  3. Why does a null hypothesis of independence support permuting response values across fixed predictor values?
  4. A researcher reports a small p-value from a permutation test using Pearson’s correlation. Does this prove that the predictor causes the response to change? Explain.
  5. Why is a test based on Pearson’s correlation not guaranteed to detect every form of association?