Skip to contents

Given 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.

Usage

morie_odds_ratio_check(counts, reference, reported, tolerance = 0.05)

Arguments

counts

Numeric matrix with row names (groups) and two columns (outcome absent, outcome present), in that order.

reference

Row name of the reference group.

reported

Named numeric vector of the reported odds ratios, one per non-reference row.

tolerance

Relative tolerance for a match (default 0.05).

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"
#>