Guest User

Untitled

a guest
Jun 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. x = c(1, 4, 7, 3, 11, 6); x
  2. [1] 1 4 7 3 11 6
  3. rank(x)
  4. [1] 1 3 5 2 6 4
  5.  
  6. y = c(1, 4, 6, 2, 4, 6, 11); y
  7. [1] 1 4 6 2 4 6 11
  8. rank(y)
  9. [1] 1.0 3.5 5.5 2.0 3.5 5.5 7.0
  10.  
  11. x = c(1, 2, 2, 4, 5, 3, 0); y = c(4, 6, 3, 8, 11, 11)
  12. wilcox.test(x, y)
  13.  
  14. Wilcoxon rank sum test with continuity correction
  15.  
  16. data: x and y
  17. W = 4, p-value = 0.01778
  18. alternative hypothesis: true location shift is not equal to 0
  19.  
  20. Warning message:
  21. In wilcox.test.default(x, y) : cannot compute exact p-value with ties
  22.  
  23. jx = runif(length(x), -.01, .01); jy = runif(length(y), -.01, .01)
  24. wilcox.test(x+jx, y+jy)
  25.  
  26. Wilcoxon rank sum test
  27.  
  28. data: x + jx and y + jy
  29. W = 4, p-value = 0.01399
  30. alternative hypothesis: true location shift is not equal to 0
  31.  
  32. x; rank(x)
  33. [1] 1 2 2 4 5 3 0
  34. [1] 2.0 3.5 3.5 6.0 7.0 5.0 1.0
  35. round(x+jx, 4); rank(x+jx)
  36. [1] 0.9958 1.9900 2.0035 3.9945 5.0093 2.9995 -0.0095
  37. [1] 2 3 4 6 7 5 1
Add Comment
Please, Sign In to add comment