r effect size for Wilcoxon two-sample paired signed-rank test
wilcoxonPairedR.RdCalculates r effect size for a Wilcoxon two-sample paired signed-rank test; confidence intervals by bootstrap.
Usage
wilcoxonPairedR(
x,
g = NULL,
adjustn = TRUE,
coin = FALSE,
ci = FALSE,
conf = 0.95,
type = "perc",
R = 1000,
histogram = FALSE,
cases = TRUE,
digits = 3,
...
)Arguments
- x
A vector of observations.
- g
The vector of observations for the grouping, nominal variable. Only the first two levels of the nominal variable are used. The data must be ordered so that the first observation of the of the first group is paired with the first observation of the second group.
- adjustn
If
TRUE, reduces the sample size in the calculation ofrby the number of tied pairs.- coin
If
FALSE, the default, the Z value is extracted from a function similar to thewilcox.testfunction in the stats package. IfTRUE, the Z value is extracted from thewilcox_testfunction in the coin package. This method may be much slower, especially if a confidence interval is produced.- ci
If
TRUE, returns confidence intervals by bootstrap. May be slow.- conf
The level for the confidence interval.
- type
The type of confidence interval to use. Can be any of "
norm", "basic", "perc", or "bca". Passed toboot.ci.- R
The number of replications to use for bootstrap.
- histogram
If
TRUE, produces a histogram of bootstrapped values.- cases
By default the
Nused in the formula forris the number of pairs. Ifcases=FALSE, theNused in the formula forris the total number of observations, as some sources suggest.- digits
The number of significant digits in the output.
- ...
Additional arguments passed to the
wilcoxsign_testfunction.
Value
A single statistic, r. Or a small data frame consisting of r, and the lower and upper confidence limits.
Details
r is calculated as Z divided by
square root of the number of observations in one group. This
results in a statistic that ranges from -1 to 1.
This range doesn't hold if cases=FALSE.
This statistic typically reports a smaller effect size
(in absolute value) than does
the matched-pairs rank biserial correlation coefficient
(wilcoxonPairedRC), and may not reach a value
of -1 or 1 if there are ties in the paired differences.
Currently, the function makes no provisions for NA
values in the data. It is recommended that NAs be removed
beforehand.
When the data in the first group are greater than
in the second group, r is positive.
When the data in the second group are greater than
in the first group, r is negative.
Be cautious with this interpretation, as R will alphabetize
groups if g is not already a factor.
When r is close to extremes, or with small counts in some cells, the confidence intervals determined by this method may not be reliable, or the procedure may fail.
Author
Salvatore Mangiafico, mangiafico@njaes.rutgers.edu
Examples
data(Pooh)
Time1 = Pooh$Likert[Pooh$Time==1]
Time2 = Pooh$Likert[Pooh$Time==2]
wilcox.test(x = Time1, y = Time2, paired=TRUE, exact=FALSE)
#>
#> Wilcoxon signed rank test with continuity correction
#>
#> data: Time1 and Time2
#> V = 3.5, p-value = 0.02355
#> alternative hypothesis: true location shift is not equal to 0
#>
wilcoxonPairedR(x = Pooh$Likert, g = Pooh$Time)
#> r
#> -0.777