From 88e98fa7dd8b4851a9eb3d13b5770c56e530d1d1 Mon Sep 17 00:00:00 2001 From: Tomczyk Date: Thu, 10 Sep 2026 16:11:31 +0200 Subject: [PATCH] Adding coin package --- R/wilcoxonsr_hodges_lehman.qmd | 36 +++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/R/wilcoxonsr_hodges_lehman.qmd b/R/wilcoxonsr_hodges_lehman.qmd index 9711f187a..613aa357a 100644 --- a/R/wilcoxonsr_hodges_lehman.qmd +++ b/R/wilcoxonsr_hodges_lehman.qmd @@ -118,4 +118,38 @@ DOS2::senWilcox( - Gamma \>= 1 is the value of the sensitivity parameter. If gamma=1, then you are assuming ignorable treatment assignment or equivalently no unmeasured confounding - that is the considered scenario in our example, sensitivity analysis is not performed. - Only p value, estimate and CI are provided -### Coin package - coming soon! {.unnumbered} +#### Coin {.unnumbered} + +### Examples {.unnumbered} + +```{r} +# Exact +# Default method of handling zeros - Pratt (1959): +coin::wilcoxsign_test(blood_p$bp_after~blood_p$bp_before, + zero.method = "Pratt", + distribution = "exact") + +# Wilcoxon (1949) method of handling zeros +# the same results for datasets with no ties and no 0s +coin::wilcoxsign_test(blood_p$bp_after~blood_p$bp_before, + zero.method = "Wilcoxon", + distribution = "exact") + +# Asymptotic approximation & No continuity correction +coin::wilcoxsign_test(blood_p$bp_after~blood_p$bp_before, + zero.method = "Pratt", + distribution = "asymptotic") + +# Monte Carlo resampling (& No continuity correction) +coin::wilcoxsign_test(blood_p$bp_after~blood_p$bp_before, + zero.method = "Pratt", + distribution = "approximate") + + + +``` + +### Important notes on coin::wilcoxsign_test {.unnumbered} +- Only p value, Statistic V and estimate are provided, no H-L CI is calculated +- The default method of handling zeros (Pratt), first rank-transforms the absolute differences (with zeros) and then discards the ranks corresponding to the zero-differences. The alternative one (Wilcoxon) first discards the zero-differences and then rank-transforms the remaining absolute differences +- No continuity correction is applied and there is no option to change that