Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wilcox_test shouldn't hide warnings, or one may end up with this nonsense #127

Open
Generalized opened this issue Sep 2, 2021 · 1 comment

Comments

@Generalized
Copy link

Generalized commented Sep 2, 2021

Let's take this data:

d <- structure(list(PatientId = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 
4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 9L, 10L, 10L, 11L, 
11L, 12L, 12L), .Label = c("1", "2", "3", "4", "5", "6", "7", 
"8", "9", "10", "11", "12"), class = "factor"), Timepoint = structure(c(1L, 
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 
2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("Baseline", "Month 3"
), class = "factor"), Result = c(0, 9, 6, 8, 0, 0, 0, 0, 0, 0, 
0, 0, 1, 2, 3, 3, 1, 2, 1, 1, 3, 3, 7, 7)), row.names = c(NA, 
-24L), class = "data.frame")

Let's check the result:

> rstatix::wilcox_test(Result ~ Timepoint, data=d, paired=T,detailed = T)
# A tibble: 1 x 12
  estimate .y.    group1   group2     n1    n2 statistic      p conf.low conf.high method   alternative
*    <dbl> <chr>  <chr>    <chr>   <int> <int>     <dbl>  <dbl>    <dbl>     <dbl> <chr>    <chr>      
1    -1.71 Result Baseline Month 3    12    12         0 0.0975    -5.00        -1 Wilcoxon two.sided  

How can be p>0.05 if the CI doesn't cover 0?
It cannot be.

The CI is calculated wrongly by the underlying wilcox.test, which warns us about the fact the confidence level couldn't be reached.

The warning may prevent the user from reporting nonsenses. Hiding it (e.g. by wrapping with suppressWarnings()) - may cause put one into real troubles, if one is going to publish it.


wilcox.test(Result ~ Timepoint, data=d, paired=TRUE, conf.int=TRUE)

	Wilcoxon signed rank test with continuity correction

data:  Result by Timepoint
V = 0, p-value = 0.1
alternative hypothesis: true location shift is not equal to 0
60 percent confidence interval:
 -5 -1
sample estimates:
(pseudo)median 
         -1.71 

Warning messages:
1: In wilcox.test.default(x = c(0, 6, 0, 0, 0, 0, 1, 3, 1, 1, 3, 7),  :
  requested conf.level not achievable
2: In wilcox.test.default(x = c(0, 6, 0, 0, 0, 0, 1, 3, 1, 1, 3, 7),  :
  cannot compute exact p-value with ties
3: In wilcox.test.default(x = c(0, 6, 0, 0, 0, 0, 1, 3, 1, 1, 3, 7),  :
  cannot compute exact confidence interval with ties
4: In wilcox.test.default(x = c(0, 6, 0, 0, 0, 0, 1, 3, 1, 1, 3, 7),  :
  cannot compute exact p-value with zeroes
5: In wilcox.test.default(x = c(0, 6, 0, 0, 0, 0, 1, 3, 1, 1, 3, 7),  :
  cannot compute exact confidence interval with zeroes

@Generalized
Copy link
Author

Hello, @kassambara just wanted to ask, is you had a chance to fix this issue with suppressWarnings? I'd like to use this package in near future and recommend to a friend of mine, but this one is very dangerous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant