Glass rank biserial correlation coefficient
wilcoxonRG.RdCalculates Glass rank biserial correlation coefficient effect size for Mann-Whitney two-sample rank-sum test, or a table with an ordinal variable and a nominal variable with two levels; confidence intervals by bootstrap.
Usage
wilcoxonRG(
x,
g = NULL,
group = "row",
ci = FALSE,
conf = 0.95,
type = "perc",
R = 1000,
histogram = FALSE,
digits = 3,
reportIncomplete = FALSE,
verbose = FALSE,
na.last = NA,
...
)Arguments
- x
Either a two-way table or a two-way matrix. Can also be a vector of observations.
- g
If
xis a vector,gis the vector of observations for the grouping, nominal variable. Only the first two levels of the nominal variable are used.- group
If
xis a table or matrix,groupindicates whether the"row"or the"column"variable is the nominal, grouping variable.- 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.- digits
The number of significant digits in the output.
- reportIncomplete
If
FALSE(the default),NAwill be reported in cases where there are instances of the calculation of the statistic failing during the bootstrap procedure.- verbose
If
TRUE, prints information on factor levels and ranks.- na.last
Passed to
rank. For example, can be set toTRUEto assignNAvalues a minimum rank.- ...
Additional arguments passed to
rank
Value
A single statistic, rg. Or a small data frame consisting of rg, and the lower and upper confidence limits.
Details
rg is calculated as 2 times the difference of mean of ranks for each group divided by the total sample size. It appears that rg is equivalent to Cliff's delta.
NA values can be handled by the rank function.
In this case, using verbose=TRUE is helpful
to understand how the rg statistic is calculated.
Otherwise, it is recommended that NAs be removed
beforehand.
When the data in the first group are greater than in the second group, rg is positive. When the data in the second group are greater than in the first group, rg is negative.
Be cautious with this interpretation, as R will alphabetize
groups if g is not already a factor.
When rg 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.
References
King, B.M., P.J. Rosopa, and E.W. Minium. 2011. Statistical Reasoning in the Behavioral Sciences, 6th ed.
Author
Salvatore Mangiafico, mangiafico@njaes.rutgers.edu
Examples
data(Breakfast)
Table = Breakfast[1:2,]
library(coin)
chisq_test(Table, scores = list("Breakfast" = c(-2, -1, 0, 1, 2)))
#>
#> Asymptotic Linear-by-Linear Association Test
#>
#> data: Breakfast (ordered) by Travel (Walk, Bus)
#> Z = -1.5204, p-value = 0.1284
#> alternative hypothesis: two.sided
#>
wilcoxonRG(Table)
#> rg
#> -0.245
data(Catbus)
wilcox.test(Steps ~ Gender, data = Catbus)
#> Warning: cannot compute exact p-value with ties
#>
#> Wilcoxon rank sum test with continuity correction
#>
#> data: Steps by Gender
#> W = 127.5, p-value = 0.01773
#> alternative hypothesis: true location shift is not equal to 0
#>
wilcoxonRG(x = Catbus$Steps, g = Catbus$Gender)
#> rg
#> 0.545
### Example from King, Rosopa, and Minium
Criticism = c(-3, -2, 0, 0, 2, 5, 7, 9)
Praise = c(0, 2, 3, 4, 10, 12, 14, 19, 21)
Y = c(Criticism, Praise)
Group = factor(c(rep("Criticism", length(Criticism)),
rep("Praise", length(Praise))))
wilcoxonRG(x = Y, g = Group, verbose=TRUE)
#>
#> Levels: Criticism Praise
#> n for Criticism = 8
#> n for Praise = 9
#> Mean of ranks for Criticism = 6.3125
#> Mean of ranks for Praise = 11.38889
#> Difference in mean of ranks = -5.076389
#> Total n = 17
#> 2 * difference / total n = -0.597
#>
#> rg
#> -0.597