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?

  • $\begingroup$ What software are you using? Do you just want to understand teh algorithm conceptually? $\endgroup$ Oct 28, 2012 at 2:07
  • $\begingroup$ I am using R for statistic analysis $\endgroup$ Oct 28, 2012 at 2:13
  • $\begingroup$ 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? $\endgroup$ Oct 28, 2012 at 2:16
  • $\begingroup$ I understand the permutation idea for comparing two groups, but not for paired. So that's why I think I need some advice here. $\endgroup$ Oct 28, 2012 at 2:20
  • 2
    $\begingroup$ 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. $\endgroup$
    – caracal
    Oct 28, 2012 at 14:27

1 Answer 1


If I take your data

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")
  • $\begingroup$ it should be different than sign test, right? $\endgroup$ Oct 28, 2012 at 18:32
  • $\begingroup$ Asymptotically a sign test and a permutation sign test are the same. The result could be different, but it could also be the same. $\endgroup$
    – John
    Oct 28, 2012 at 18:39
  • $\begingroup$ if H0:drug = active H1: drug > active, then i can just put alternative='greater' in the commend? $\endgroup$ Oct 28, 2012 at 19:24
  • $\begingroup$ you should try that $\endgroup$
    – John
    Oct 28, 2012 at 20:11
  • $\begingroup$ @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). $\endgroup$ Oct 29, 2012 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.