Cohen's g and odds ratio for paired contingency tables
cohenG.RdCalculates Cohen's g and odds ratio for paired contingency tables, such as those that might be analyzed with McNemar or McNemar-Bowker tests.
Usage
cohenG(
x,
ci = FALSE,
conf = 0.95,
type = "perc",
R = 1000,
histogram = FALSE,
digits = 3,
reportIncomplete = FALSE,
...
)Arguments
- x
A two-way contingency table. It must be square. It can have two or more levels for each dimension.
- 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.- ...
Additional arguments (ignored).
Value
A list containing: a data frame of results of the global statistics; and a data frame of results of the pairwise statistics.
Details
For a 2 x 2 table, where a and d are the concordant cells and b and c are discordant cells: Odds ratio is b/c; P is b/(b+c); and Cohen's g is P - 0.5.
In the 2 x 2 case, the statistics are directional. That is, when cell [1, 2] in the table is greater than cell [2, 1], OR is greater than 1, P is greater than 0.5, and g is positive.
In the opposite case, OR is less than 1, P is less than 0.5, and g is negative.
In the 2 x 2 case, when the effect is small, the confidence interval for OR can pass through 1, for g can pass through 0, and for P can pass through 0.5.
For tables larger than 2 x 2, the statistics are not directional.
That is, OR is always >= 1, P is always >= 0.5, and
g is always positive.
Because of this, if type="perc", the confidence interval will
never cross the values for no effect
(OR = 1, P = 0.5, or g = 0).
Because of this, the confidence interval range
in this case should not
be used for statistical inference.
However, if type="norm", the confidence interval
may cross the values for no effect.
When the reported statistics are close to their extremes, or with small counts, the confidence intervals determined by this method may not be reliable, or the procedure may fail.
Author
Salvatore Mangiafico, mangiafico@njaes.rutgers.edu
Examples
### 2 x 2 repeated matrix example
data(AndersonRainBarrel)
cohenG(AndersonRainBarrel)
#> $Global.statistics
#> Dimensions OR P g
#> 1 2 x 2 0.294 0.227 -0.273
#>
### 3 x 3 repeated matrix
data(AndersonRainGarden)
cohenG(AndersonRainGarden)
#> $Global.statistics
#> Dimensions OR P g
#> 1 3 x 3 11.5 0.92 0.42
#>
#> $Pairwise.statistics
#> Comparison OR P g
#> 1 Yes.before/Yes.after : No.before/No.after Inf 1 0.5
#> 2 Yes.before/Yes.after : Maybe.before/Maybe.after 11 0.917 0.417
#> 3 No.before/No.after : Maybe.before/Maybe.after 7 0.875 0.375
#>