
Check reported odds ratios against a labelled table, under every relabelling
Source:R/categorical_guard.R
morie_odds_ratio_check.RdGiven a k-by-2 table of counts (rows = groups, columns = outcome absent / present), a reference group and the odds ratios a report states for the other groups, this recomputes the odds ratios from the table and then recomputes them under every permutation of the row labels (and with the outcome columns swapped). It says whether the reported values follow from the table as labelled, and if not, which relabelling reproduces them. A four-fold odds ratio that a report gives as thirty-six-fold is typically reproduced exactly by one such permutation.
Value
A list: computed (odds ratios from the table as labelled),
reported, consistent (the reported values follow from the
labels as given), matches (a data frame of the relabellings that
reproduce the reported values, possibly none), and verdict.
Examples
tab <- matrix(c(900, 100, 700, 300, 400, 600), ncol = 2, byrow = TRUE,
dimnames = list(c("A", "B", "C"), c("no", "yes")))
morie_odds_ratio_check(tab, "A", c(B = 3.857, C = 13.5))
#> $computed
#> B C
#> 3.857143 13.500000
#>
#> $reported
#> B C
#> 3.857 13.500
#>
#> $consistent
#> [1] TRUE
#>
#> $matches
#> [1] relabelling outcome_columns_swapped
#> <0 rows> (or 0-length row.names)
#>
#> $verdict
#> [1] "the reported odds ratios follow from the table as labelled"
#>