Permutation and randomization tests

Julia Fukuyama

Simulation-Based Inference · Lecture 23

Today

Simulation for hypothesis testing, but trying to be a little bit clever.

Another example of writing down generative models + conditioning.

In particular:

  • Defining a hypothesis test.
  • A randomization test for controlled experiments.
  • A permutation test for equality of distributions.
  • A permutation test for independence.

Hypothesis tests

A null hypothesis \(H_0\) specifies a collection of possible distributions for the data.

A hypothesis test with level \(\alpha\) is a rule for rejecting or not rejecting \(H_0\), such that

\[ \Pr(\text{reject }H_0)\leq\alpha \]

under every distribution allowed by \(H_0\).

Test statistics and rejection regions

To construct a hypothesis test:

  • Choose a test statistic \(T(D)\): a numerical summary of the data \(D\).
  • Choose a rejection region \(R\): a set of values of the statistic.
  • Reject \(H_0\) when \(T(D)\in R\); otherwise, do not reject.

To get a level-\(\alpha\) test, we need

\[ \Pr(T(D)\in R)\leq\alpha \]

under every distribution allowed by \(H_0\).

To make the test useful, we want \(T(D)\in R\) to be more likely under alternatives we care about.

For example, to compare two groups, we might use

\[ T(X,Y)=|\overline X-\overline Y| \]

and reject when this difference is sufficiently large.

A valid test need not be useful

Note that the definition on its own doesn’t give us a useful procedure; it just specifies one property that we want.

Picking a uniform \([0,1]\) random variable independently of the data and rejecting when it comes up \(\leq\alpha\) is also a valid test, but it’s not useful.

Usefulness depends on the alternative and the test statistic.

Randomization tests for controlled experiments

Suppose we have \(n\) participants. Let \(Z_i\) be participant \(i\)’s outcome without treatment, \(W_i\) indicate whether they receive treatment, and \(Y_i\) be their observed outcome.

Write \(Z=(Z_1,\ldots,Z_n)\), and similarly for \(W\) and \(Y\).

Our model is

\[ Z_1,\ldots,Z_n\overset{\mathrm{iid}}{\sim}P, \]

\[ W\sim Q,\qquad W\perp Z, \]

\[ Y\mid Z,W\sim\text{something else}. \]

Here \(Q\) is the treatment-assignment distribution, controlled by the experimenter.

Our null hypothesis \(H_0\) is \(Y=Z\).

This is called the “sharp null”: treatment doesn’t do anything to anyone.

How could we get a test of \(H_0\)?

If we could simulate from \(H_0\):

\[ Z_1^*,\ldots,Z_n^*\overset{\mathrm{iid}}{\sim}P, \]

\[ W^*\sim Q,\qquad W^*\perp Z^*, \]

\[ Y^*=Z^*, \]

our simulations would give us an approximation of the distribution of our statistic \(T(Y^*,W^*)\) under the null.

Null distribution of \(T(Y^*, W^*)\) to a test

Once we have an approximation of the null distribution, we can:

  • Choose any set \(R\) such that \(P(T(Y^*, W^*) \in R) \le \alpha\).
  • Define our hypothesis test procedure as rejecting when \(T(Y, W) \in R\) and not rejecting otherwise.
  • Because of the way we chose \(R\), we know that the probability of rejecting under the null is \(\le \alpha\).

How do we choose \(R\)?

  • Usually, we try to construct \(T\) so that large values are more likely under some alternative and less likely under the null.
  • Then we reject when \(T(Y, W) > c\), where \(c\) is the \(1-\alpha\) quantile of the null distribution, which would correspond to \(R = (c, \infty)\) in the description above. In practice, the \(1 - \alpha\) quantile of the null distribution would be estimated as the \(1 - \alpha\) quantile of the values we simulated under the null distribution.

Example

Suppose

\[ Z_1,\ldots,Z_n\overset{\mathrm{iid}}{\sim}N(\mu,\sigma^2). \]

The experimenter chooses exactly \(m\) of the \(n\) participants to receive treatment, with every group of \(m\) equally likely, where \(1\leq m<n\):

\[ W\sim\operatorname{Uniform} \left\{w\in\{0,1\}^n:\sum_{i=1}^n w_i=m\right\}. \]

Our test statistic is the absolute difference in group means:

\[ T(Y,W)= \left| \frac{1}{m}\sum_{i:W_i=1}Y_i - \frac{1}{n-m}\sum_{i:W_i=0}Y_i \right|. \]

Large values are evidence against \(H_0\).

Example in code: one dataset

n <- 20; m <- 10
mu <- 0; sigma <- 1

Z <- rnorm(n, mu, sigma)                 # outcomes without treatment
W <- sample(rep(c(1, 0), c(m, n - m)))   # exactly m treated, all groups equally likely
Y <- Z                                   # sharp null: treatment does nothing

T_stat <- function(Y, W) abs(mean(Y[W == 1]) - mean(Y[W == 0]))
T_stat(Y, W)

Example in code: null distribution of \(T\)

alpha <- 0.05
T_null <- replicate(10000, {
  Z <- rnorm(n, mu, sigma)
  W <- sample(rep(c(1, 0), c(m, n - m)))
  Y <- Z
  T_stat(Y, W)
})

quantile(T_null, 1 - alpha)   # reject when T >= this

This requires knowing \(\mu\) and \(\sigma\).

Problem: We don’t know what \(P\) is

Solution: Instead of simulating

\[ Z_1^*,\ldots,Z_n^*\overset{\mathrm{iid}}{\sim}P, \qquad W^*\sim Q, \qquad Y^*=Z^*, \]

we simulate from the distribution of \((Y, W) \mid Y = y_{\text{obs}}\) under the null to get the distribution of \(T(Y^*, W^*) \mid Y^* = y_{\text{obs}}\) under the null.

One way to think about this distribution:

  • When we simulate from the conditional distribution above, we are asking: “Suppose I ran the experiment many more times under the null hypothesis, and only kept the ones where the observed values \(Y\) were exactly the same as the ones I actually saw. Then what would the distribution of my test statistic look like?”
  • The reason this is helpful in practice is that you don’t need to know \(P\) to simulate from this conditional distribution.

How do you implement this?

  • If you were doing rejection sampling, you would simulate \(Z_1^*, \ldots, Z_n^* \overset{\mathrm{iid}}{\sim} P\), simulate \(W^* \sim Q\), let \(Y_i^* = Z_i^*\), check whether \(Y^* = y_{\text{obs}}\), keep \((Y^*, W^*)\) if so and otherwise try again.
  • But! This gives the same results as fixing \(Y^* = y_{\text{obs}}\), simulating \(W^* \sim Q\), and keeping \((Y^*, W^*)\).
  • So simulating from this conditional distribution is just re-running the experimental assignment.
  • Notice that the second version of the procedure doesn’t depend on knowing \(P\).

The randomization test

Choose a test statistic \(T\) for which large values are evidence against \(H_0\).

  1. Compute the observed statistic: \[ t_{\mathrm{obs}}=T(y_{\mathrm{obs}},w_{\mathrm{obs}}). \]

  2. For \(b=1,\ldots,B\):

    • Independently simulate a new treatment assignment \(W^{*(b)}\sim Q\).
    • Hold the outcomes fixed and compute \[ T^{*(b)}=T(y_{\mathrm{obs}},W^{*(b)}). \]
  3. Use the simulated statistics to estimate the \((1-\alpha)\)-quantile \(c\) of the conditional null distribution.

  4. Reject \(H_0\) if \(t_{\mathrm{obs}}>c\).

Why does this have the correct level?

Discrete case: The overall probability of rejection is a convex combination of the conditional rejection probabilities.

\[ \Pr(\text{reject }H_0) = \sum_y \Pr(\text{reject }H_0\mid Y=y)\Pr(Y=y). \]

Every conditional rejection probability is \(\leq\alpha\), so the whole thing is also \(\leq\alpha\).

The same idea works in the continuous case, with an integral instead of a sum.

Example: exactly \(m\) treated

An experiment with \(n=20\), \(m=10\), and a true treatment effect of 1 (\(Y=Z+W\)):

T_stat <- function(y, w) abs(mean(y[w == 1]) - mean(y[w == 0]))

n <- 20; m <- 10
z <- rnorm(n)
w_obs <- sample(rep(c(1, 0), c(m, n - m)))   # the experiment's assignment
y_obs <- z + 1 * w_obs                       # observed outcomes
t_obs <- T_stat(y_obs, w_obs)
alpha <- 0.05

## Randomization test: hold y_obs fixed, re-draw W from Q
T_star <- replicate(10000,
  T_stat(y_obs, sample(rep(c(1, 0), c(m, n - m)))))
c_hat <- quantile(T_star, 1 - alpha)
t_obs > c_hat           # reject?
mean(T_star >= t_obs)   # p-value

Example: exactly \(m\) treated

With \(\alpha=0.05\): \(t_{\mathrm{obs}}=1.30\), \(\hat c=1.00\): reject \(H_0\). p-value \(0.008\).

Example: independent assignment

Now each participant is treated independently with probability \(1/2\), so \(Q\) is different. Only the lines that draw \(W\) change:

w_obs <- rbinom(n, 1, 0.5)
y_obs <- z + 1 * w_obs
t_obs <- T_stat(y_obs, w_obs)

T_star <- replicate(10000, T_stat(y_obs, rbinom(n, 1, 0.5)))

The number treated now varies from draw to draw. If every participant lands in the same group, \(T\) is undefined; set \(T=0\) in that case:

T_stat <- function(y, w) {
  if (all(w == w[1])) return(0)
  abs(mean(y[w == 1]) - mean(y[w == 0]))
}

Example: independent assignment

The observed assignment treated 8 participants; the re-drawn assignments treated between 2 and 18.

With \(\alpha=0.05\): \(t_{\mathrm{obs}}=1.21\), \(\hat c=1.00\): reject \(H_0\). p-value \(0.015\).

Permutation test: Different model, (sometimes) same procedure

Suppose

\[ X_1,\ldots,X_n\overset{\mathrm{iid}}{\sim}P, \qquad Y_1,\ldots,Y_m\overset{\mathrm{iid}}{\sim}Q, \]

with the two samples independent.

Write \(X=(X_1,\ldots,X_n)\) and \(Y=(Y_1,\ldots,Y_m)\).

Our null hypothesis is

\[ H_0:\quad P=Q. \]

How could we get a hypothesis test?

If we knew the common distribution \(P=Q\), we could simulate under \(H_0\):

\[ X_1^*,\ldots,X_n^*,Y_1^*,\ldots,Y_m^* \overset{\mathrm{iid}}{\sim}P. \]

Compute \(T(X^*,Y^*)\) on simulated replicates, and reject for sufficiently extreme values of the observed statistic.

For example,

\[ T(X,Y)=|\overline X-\overline Y|. \]

Same problem

We don’t know \(P\).

Similar solution

Let \(S(X,Y)\) be the sorted vector of all \(n+m\) pooled observations, including any repetitions.

We will try to get the sampling distribution of \(T(X^*, Y^*) \mid S(X^*, Y^*) = S(x_{\text{obs}}, y_{\text{obs}})\) under \(H_0\).

Note that under \(H_0\), our model is just \(X_i, Y_j \overset{\mathrm{iid}}{\sim} P\).

As before:

  • It initially seems like we’ve made the problem worse (we need to simulate from a conditional distribution instead of from the model we wrote down initially).
  • It turns out that under \(H_0\) this conditional distribution is easy to simulate from.
  • It also turns out that under \(H_0\), we don’t need to know \(P\) to simulate from this conditional distribution.

Sampling from \(Y\mid S(Y)=S(y_{\mathrm{obs}})\)

Suppose

\[ Y_1,\ldots,Y_n\overset{\mathrm{iid}}{\sim}P, \]

and let \(S(Y)\) be the sorted vector of values.

We have \(y_{\mathrm{obs}}\).

If we had a way of simulating from \(P\), we could use our rejection sampling algorithm and repeatedly draw \(Y\) until we got

\[ S(Y)=S(y_{\mathrm{obs}}). \]

Two problems: we don’t know \(P\), and even if we did, this could take forever.

Let’s be a little clever

Suppose the \(Y_i\) are discrete, with common probability mass function

\[ p(a)=\Pr(Y_i=a). \]

Suppose that \(\tilde y\) is any other element of the set we are conditioning on:

\[ S(\tilde y)=S(y_{\mathrm{obs}}). \]

What does this mean? \(\tilde y\) has the same values as \(y_{\mathrm{obs}}\), the same number of times.

We can write down \(\Pr(Y=\tilde y)\) in terms of the unknown \(p\):

\[ \Pr(Y=\tilde y) = p(\tilde y_1)\cdots p(\tilde y_n). \]

This is the same for every \(\tilde y\) with

\[ S(\tilde y)=S(y_{\mathrm{obs}}), \]

because the product contains the same factors, just in a different order.

The conditional distribution

Therefore,

\[ \Pr\!\left(Y=\tilde y\mid S(Y)=S(y_{\mathrm{obs}})\right) \propto \begin{cases} 0, & S(\tilde y)\neq S(y_{\mathrm{obs}}),\\ 1, & S(\tilde y)=S(y_{\mathrm{obs}}). \end{cases} \]

So every distinct reordering of \(y_{\mathrm{obs}}\) has the same conditional probability.

This we can simulate from directly: choose a reordering of \(y_{\mathrm{obs}}\), with all distinct reorderings equally likely.

Equivalently, uniformly permute the indices of \(y_{\mathrm{obs}}\).

The permutation test for equality of distributions

Choose a test statistic \(T\) for which large values are evidence against \(H_0\).

  1. Compute the observed statistic: \(t_{\mathrm{obs}}=T(x_{\mathrm{obs}},y_{\mathrm{obs}}).\)

  2. Pool the observed values into one vector: \[ v=(x_{\mathrm{obs},1},\ldots,x_{\mathrm{obs},n}, y_{\mathrm{obs},1},\ldots,y_{\mathrm{obs},m}). \]

  3. For \(b=1,\ldots,B\):

    • Independently choose a uniformly random permutation \(\pi_b\) of \(1,\ldots,n+m\).
    • Split the reordered values into two samples: \[ X^{*(b)}=(v_{\pi_b(1)},\ldots,v_{\pi_b(n)}), \qquad Y^{*(b)}=(v_{\pi_b(n+1)},\ldots,v_{\pi_b(n+m)}). \]
    • Compute \(T^{*(b)}=T(X^{*(b)},Y^{*(b)})\).
  4. Use the simulated statistics to estimate the \((1-\alpha)\)-quantile \(c\) of the conditional null distribution.

  5. Reject \(H_0\) if \(t_{\mathrm{obs}}>c\).

The permutation test in code

T_stat <- function(x, y) abs(mean(x) - mean(y))

n <- 15; m <- 10
x_obs <- rnorm(n, 0, 1)          # observed data (here: simulated,
y_obs <- rnorm(m, 1, 1)          #   with Q shifted by 1)
t_obs <- T_stat(x_obs, y_obs)
alpha <- 0.05

v <- c(x_obs, y_obs)             # pool
T_star <- replicate(10000, {
  v_star <- sample(v)            # uniformly random reordering
  T_stat(v_star[1:n], v_star[(n + 1):(n + m)])   # split
})
c_hat <- quantile(T_star, 1 - alpha)
t_obs > c_hat                    # reject?
mean(T_star >= t_obs)            # p-value
t.test(x_obs, y_obs, var.equal = TRUE)$p.value   # for comparison

hist(T_star, breaks = 50)
abline(v = c(c_hat, t_obs), col = c("black", "red"), lty = c(2, 1), lwd = 2)

Example: Unconditional versus conditional null distributions

Suppose, just for illustration, that we know \(P=Q=N(0,1)\), with \(n=m=10\).

Then the unconditional null distribution of the signed difference \(D=\overline X-\overline Y\) is \(N(0,\,1/10+1/10)\), standard deviation \(0.447\).

Three observed datasets

Draw many datasets from \(H_0\) and pick three: pooled standard deviation at the 5th percentile (\(0.72\)), median (\(0.97\)), and 95th percentile (\(1.24\)).

Permuting each dataset

Conditional standard deviation is \(s_{\text{pool}}\sqrt{1/n+1/m}\): \(0.32\), \(0.44\), \(0.56\).

Conditioning fixes the observed values, so the conditional distribution can be narrower or wider than the unconditional one. Averaged over datasets, the rejection rate is still \(\leq\alpha\).

Permutation test for independence

Suppose

\[ (X_1,Y_1),\ldots,(X_n,Y_n) \overset{\mathrm{iid}}{\sim}R, \]

where \(R\) is a joint distribution with marginal distributions \(P\) and \(Q\).

Our null hypothesis is

\[ H_0:\quad X_i\perp Y_i. \]

Under \(H_0\),

\[ X_1,\ldots,X_n\overset{\mathrm{iid}}{\sim}P, \qquad Y_1,\ldots,Y_n\overset{\mathrm{iid}}{\sim}Q, \]

with the entire \(X\) vector independent of the entire \(Y\) vector.

How could we get a hypothesis test?

If we knew \(P\) and \(Q\), we could simulate under \(H_0\):

\[ X_1^*,\ldots,X_n^*\overset{\mathrm{iid}}{\sim}P, \qquad Y_1^*,\ldots,Y_n^*\overset{\mathrm{iid}}{\sim}Q, \]

independently.

Compute \(T(X^*,Y^*)\) on simulated replicates, and reject for sufficiently extreme values of the observed statistic.

For example, to look for linear association,

\[ T(X,Y)=|\operatorname{cor}(X,Y)|. \]

Same problem

We don’t know \(P\) or \(Q\).

Same solution

Simulate from a conditional distribution.

Let \(S(X), S(Y)\) be the sorted vectors of \(X\) and \(Y\) values, including any repetitions.

We condition on \(S(X)\) and \(S(Y)\).

Under \(H_0\), we simulate from the conditional distribution

\[ \boxed{ (X, Y)\mid S(X)=S(x_{\mathrm{obs}}),\ S(Y)=S(y_{\mathrm{obs}}). } \]

Because \(X\) and \(Y\) are independent under \(H_0\), this has the same distribution as simulating \(X\) and \(Y\) independently from

\[ Y\mid S(Y)=S(y_{\mathrm{obs}}), \quad X\mid S(X)=S(x_{\mathrm{obs}}), \]

These conditional distributions do not depend on \(P\) or \(Q\), for the same reason as before.

Why does this have the correct level?

Same reasoning as before.

For each \(S(X)\), \(S(Y)\) values, we choose a rejection region with conditional probability at most \(\alpha\).

Every conditional rejection probability is at most \(\alpha\), so the overall rejection probability is also at most \(\alpha\).

The permutation test for independence

Choose a test statistic \(T\) for which large values are evidence against \(H_0\).

  1. Compute the observed statistic: \[ t_{\mathrm{obs}}=T(x_{\mathrm{obs}},y_{\mathrm{obs}}). \]

  2. For \(b=1,\ldots,B\):

    • Independently choose two uniformly random permutations \(\pi_b\) and \(\rho_b\) of \(1,\ldots,n\).
    • Reorder each vector: \[ X^{*(b)}=(x_{\mathrm{obs},\pi_b(1)},\ldots,x_{\mathrm{obs},\pi_b(n)}), \] \[ Y^{*(b)}=(y_{\mathrm{obs},\rho_b(1)},\ldots,y_{\mathrm{obs},\rho_b(n)}). \]
    • Compute \(T^{*(b)}=T(X^{*(b)},Y^{*(b)})\).
  3. Use the simulated statistics to estimate the \((1-\alpha)\)-quantile \(c\) of the conditional null distribution.

  4. Reject \(H_0\) if \(t_{\mathrm{obs}}>c\).

Example: Unusual observations and apparent association

Suppose \(X_i\) and \(Y_i\) each have the mixture distribution

\[ 0.9\,N(0,0.05^2)+0.1\,N(1,0.05^2): \]

usually small, occasionally large. Under \(H_0\), \(X\) and \(Y\) are independent.

Observed data, \(n=10\): one large \(x\) and one large \(y\), and they are in the same pair. \(r=0.99\).

Compare two null distributions of \(r\):

  • Permutation: hold \(x_{\mathrm{obs}}\) fixed and permute \(y_{\mathrm{obs}}\) (this is equivalent to permuting both, and is slightly less computation so it’s usually implemented this way).
  • Unconditional: draw new \(X\) and \(Y\) independently from the mixture.

Example: Unusual observations and apparent association

Permutation p-value \(0.012\); unconditional p-value \(0.0008\).

Example: Unusual observations and apparent association

Unconditionally, it is unusual to see exactly one large \(x\) and one large \(y\) in the same pair.

Conditionally on seeing exactly one large \(x\) and one large \(y\), it’s not so unusual for them to be paired.

So should we try not to condition?

  • We saw that in the permutation test, conditioning on the observed data can throw away some useful information.
  • Maybe there is a general rule that we should try to condition as little as possible?

Cox example

This is a very old example from David Cox. “Some problem connected with statistical inference,” (1958) Annals of Mathematical Statistics. open pdf here

Suppose our model is:

\[ \begin{aligned} Z &\sim \text{Bern}(.5) \\ X \mid Z &\sim N(\theta, \sigma^2_Z) \end{aligned} \]

Both \(Z\) and \(X\) are observed.

Interpretation is: we flip a coin. If it comes up heads, we get one measurement from a precise instrument, and if it comes up tails, we get one measurement from an imprecise instrument.

We know whether we are using the precise or the imprecise instrument.

Three ways to build a hypothesis test

Test \(H_0:\theta=0\) with some test statistic \(T\). Given cutoffs \((c_0,c_1)\), apply the rule

\[ \begin{aligned} \text{if } z_{\mathrm{obs}}=0, \text{reject when } T(x_{\mathrm{obs}})>c_0, \\ \text{if } z_{\mathrm{obs}}=1, \text{reject when } T(x_{\mathrm{obs}})>c_1. \end{aligned} \]

Three possibilities for choosing \(c_0, c_1\):

  1. Set \(c_0=c_1=c\) and choose \(c\) so that \(P_0(T(X)>c)=\alpha\).
  2. Choose \(c_z\) so that \(P_0(T(X)>c_z\mid Z=z)=\alpha\) for \(z=0,1\).
  3. Pick \(\theta_1>0\). Among pairs with \(P_0(\text{reject})=\alpha\), choose the pair that maximizes \(P_{\theta_1}(\text{reject})\).

Method 1

An “unconditional” test, doesn’t take into account our knowledge of \(Z\). (This is not even discussed by Cox because it is such a bad idea.)

  • Compare \(T(x_{\text{obs}})\) to the distribution of \(T(X)\) when \(Z \sim \text{Bern}(.5)\), \(X \mid Z \sim N(0, \sigma_Z^2)\).

Method 2

A “conditional” test, where we build null distributions conditional on the observed value of \(Z\).

  • If we observe \(Z = 1\), we compare \(T(x_{\text{obs}})\) to the distribution of \(T(X)\) when \(X \sim N(0, \sigma_1^2)\).
  • If we observe \(Z = 0\), we compare \(T(x_{\text{obs}})\) to the distribution of \(T(X)\) when \(X \sim N(0, \sigma_0^2)\).

Method 3

We’re trying to get a valid test that maximizes the probability of rejecting under a certain non-null setup.

  • Consider all possible pairs of cutoffs \((c_0,c_1)\). Each pair defines a test:
    • If we observe \(Z=0\), reject when \(T(x_{\mathrm{obs}})>c_0\).
    • If we observe \(Z=1\), reject when \(T(x_{\mathrm{obs}})>c_1\).
  • For each pair, imagine repeating the entire experiment under \(H_0\): flip the coin, take a measurement, and use the cutoff for the instrument you got.
  • Keep the pairs that reject with probability at most \(\alpha\).

There will be many different pairs that satisfy our criteria.

Which pair of cutoffs should we use?

Pick a particular alternative, say \(\theta = 1\).

  • Take the pairs of cutoffs that passed the first step.
  • Now repeat the entire experiment under \(\theta = 1\).
  • Choose the pair that rejects most often under this alternative.

The first pass ensures that the test is valid (probability at most \(\alpha\) of rejecting under the null). The second pass looks for cutoffs that will allow us to reject the most often under the specified alternative.

Do you get something different with these two procedures?

Suppose \(\sigma_0 = 1\), \(\sigma_1 = 0.1\), and \(\alpha = 0.05\). A shift of 1 is hard to detect with instrument 0 and easy to detect with instrument 1.

Cutoffs False-positive rate, noisy instrument False-positive rate, precise instrument Overall power at \(\theta=1\)
Conditional test \(\alpha\) (5%) \(\alpha\) (5%) about 63%
Cutoffs chosen for \(\theta=1\) nearly \(2\alpha\) (10%) nearly 0% about 69.5%

The precise instrument can use a much stricter cutoff and still detect the shift almost every time. A looser cutoff helps the noisy instrument detect the shift more often.

Overall

  • We saw three different tests that involve permuting values and recomputing test statistics.
  • We interpreted all of them as obtaining a distribution of the test statistic under the null hypothesis conditional on some aspect of the observed data.
  • They correspond to different models and are motivated by different simplifications of the conditional distribution under the null.
  • If you want a general treatment of permutation tests, you have to think about groups (in the algebraic sense).
  • On conditioning: when we condition on something we saw, does the thing we’re conditioning on potentially hold information about the effect we’re trying to see? Or is it completely unrelated? In the former case, we should try to avoid conditioning, but in the latter case we should condition.