Can I use a permutation test to test the null hypothesis ''The difference between two groups is X''? From what I read on permutation test, the null hypothesis is usually that there is no difference between the two groups.
I want to test if the difference between the mean of the two groups is $\theta$ ($H_0 : \mu_2 - \mu_1 = \theta$). Can I use a permutation test for that? How could I do it?
I figured that if my null is ''Group A average is 4 units higher than group B average'', maybe I could substract 4 from all values in Group A and then my null would become that there is no difference between the two groups?
My feeling is that I should use another method (maybe bootstrapping) but I am really not sure.
Small precision : my data does not follow normal distribution so that's why I am looking at resampling techniques.
 A: With the null hypothesis being that the means differ by some fixed constant, and against a two sided alternative.
There's a couple if ways to approach this. Here's one (which is indeed as you suggest, subtracting the hypothesized difference from the first sample and testing for no difference in means):
Let $y^*=y-\theta_0$
Compute $T = |\bar{y}^* - \bar{x}|$
Assuming sample sizes are not small, we sample the permutation distribution of the difference in means by randomly drawing new samples without replacement from the combined sample $(y^*, x)$ and computing $T^*_t$ each time, for $t=1, 2, ..., B$, for large $B$ - I suggest at least 9999. I typically do many more, since it's generally fast to do.
We then compute the proportion of such statistics (including the original) that equal or exceed $T$; this is the p value, approximately.
If the sample sizes are small we can instead compute all possible resamples and get the exact permutation distribution rather than sampling it.
(It is possible to shortcut this a little, allowing us to count only the cases in the tail, but details are beyond an answer of a few paragraphs).
