Exact and McNemar symmetry tests for paired contingency tables
nominalSymmetryTest.RdConducts an omnibus symmetry test for a paired contingency table and then post-hoc pairwise tests. This is similar to McNemar and McNemar-Bowker tests in use.
Arguments
- x
A two-way contingency table. It must be square. It can have two or more levels for each dimension.
- method
The method to adjust multiple p-values. See
stats::p.adjust.- digits
The number of significant digits in the output.
- exact
If
TRUE, uses thebinom.testfunction. IfFALSE, uses themcnemar.testfunction.- ...
Additional arguments
Value
A list containing: a data frame of results of the global test; a data frame of results of the pairwise results; and a data frame mentioning the p-value adjustment method.
Details
The omnibus McNemar test may fail when there are zeros in critical cells.
Currently, the exact=TRUE with a table greater
than 2 x 2 will not produce an omnibus test result.
Author
Salvatore Mangiafico, mangiafico@njaes.rutgers.edu
Examples
### 2 x 2 repeated matrix example
data(AndersonRainBarrel)
nominalSymmetryTest(AndersonRainBarrel)
#>
#> $Global.test.for.symmetry
#> Dimensions p.value
#> 1 2 x 2 0.019
#>
#> $Statistical.method
#> Method
#> 1 McNemar test
#>
### 3 x 3 repeated matrix example
data(AndersonRainGarden)
nominalSymmetryTest(AndersonRainGarden,
exact = FALSE)
#>
#> $Global.test.for.symmetry
#> Dimensions p.value
#> 1 3 x 3 0.000476
#>
#> $Pairwise.symmetry.tests
#> Comparison p.value p.adjust
#> 1 Yes.before/Yes.after : No.before/No.after 0.0736 0.0771
#> 2 Yes.before/Yes.after : Maybe.before/Maybe.after 0.00937 0.0281
#> 3 No.before/No.after : Maybe.before/Maybe.after 0.0771 0.0771
#>
#> $p.adjustment
#> Method
#> 1 fdr
#>
#> $statistical.method
#> Method
#> 1 McNemar test
#>