# Permutation paired test with signed statistic

I have one paired data from 7 patients: $$(X_i ,Y_i)=\{(5,1),(-2,-4),(4,2),(-6,-3),(-3,-3),(-5,2),(3,1)\},\quad (i=1,\ldots, 7)$$

where $X$ means placebo $Y$ means the test drug.

My classmate asked me can we have permutation test for the sign statistics to identify $X < Y$. I think the coin function can help me shuffle all the observation into $2^7$ permutations, and then we are not sure if we can just implement Wilcoxon rank sum statistics for each permutation to see the $p$-value?

So the question is how to shuffle all these data and implement the test?

-
What software are you using? Do you just want to understand teh algorithm conceptually? –  gung Oct 28 '12 at 2:07
I am using R for statistic analysis –  user1489975 Oct 28 '12 at 2:13
I wondered if that was the coin you were referring to. So do you just need to know how to use coin to do a permutation test, or do you want to understand PT's conceptually? –  gung Oct 28 '12 at 2:16
I understand the permutation idea for comparing two groups, but not for paired. So that's why I think I need some advice here. –  user1489975 Oct 28 '12 at 2:20
So you know that wilcoxsign_test(Y ~ X, alternative="less", zero.method="Pratt", distribution="exact") from package coin does what you want? Note that you have ties as well as zero-differences which can be handled in different ways. –  caracal Oct 28 '12 at 14:27
show 1 more comment

c(5, 1, -2, -4, 4, 2, -6, -3, -3, -3, -5, 2, 3, 1)

And make both predictor(x) and subject(s) variables...

x <- factor(rep(c('placebo', 'drug'), 7))
s <- factor(rep(1:7, each = 2))

then you could do a permutation test with coin package wilcoxonsign_test

wilcoxsign_test(y ~ x| s, distribution="exact")
-
it should be different than sign test, right? –  user1489975 Oct 28 '12 at 18:32
Asymptotically a sign test and a permutation sign test are the same. The result could be different, but it could also be the same. –  John Oct 28 '12 at 18:39
if H0:drug = active H1: drug > active, then i can just put alternative='greater' in the commend? –  user1489975 Oct 28 '12 at 19:24
you should try that –  John Oct 28 '12 at 20:11
@user1489975, if you have found this answer helpful, you should consider upvoting it (by clicking on the upward facing normal distribution), & accepting it (by clicking on the check mark to the left of it). –  gung Oct 29 '12 at 17:18