Tidy a matchatr homogeneity test

Description

Returns the per-exposure homogeneity results carried by a matchatr_homogeneity object as a tidy data.table, one row per exposure term, following the broom column convention shared with tidy.matchatr_result(): estimate is the common (pooled) odds ratio, std.error its delta-method standard error on the odds-ratio scale, conf.low / conf.high its Wald bounds, and statistic / df / p.value the homogeneity Wald chi-squared test.

Usage

## S3 method for class 'matchatr_homogeneity'
tidy(x, ...)

Arguments

x A matchatr_homogeneity object returned by test_homogeneity().
Unused; present for generic consistency.

Value

A data.table with columns term, estimate (the common odds ratio), std.error, conf.low, conf.high, statistic, df, and p.value.

See Also

test_homogeneity()

Other tidiers: tidy.matchatr_fit(), tidy.matchatr_result()

Examples

library("matchatr")

set.seed(5)
n <- 2000
x <- rbinom(n, 1, 0.4)
eta <- cbind(control = 0, A = -1 + log(2) * x, B = -1.4 + log(2) * x)
prob <- exp(eta) / rowSums(exp(eta))
g <- apply(prob, 1, function(p) sample(c("control", "A", "B"), 1, prob = p))
d <- data.frame(g = g, x = x)
fit <- matcha(d, outcome = "g", exposure = "x",
              design = unmatched_cc(), estimator = "polytomous",
              reference = "control")
tidy(test_homogeneity(fit))
     term estimate std.error conf.low conf.high statistic    df   p.value
   <char>    <num>     <num>    <num>     <num>     <num> <int>     <num>
1:      x 2.168761 0.2006846 1.809033  2.600022 0.6589249     1 0.4169398