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")
print(test_homogeneity(fit))<matchatr_homogeneity>
Estimator: polytomous (engine: multinom)
Test: Homogeneity of subtype odds ratios (Wald)
Reference: control
N: 2000
Common (pooled) odds ratio per exposure term and homogeneity test:
term common_or se ci_lower ci_upper 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
Per-subtype odds ratios (pooled):
comparison or ci_lower ci_upper
<char> <num> <num> <num>
1: A: x 2.267207 1.836532 2.798877
2: B: x 2.035590 1.605604 2.580728
A small p-value is evidence the exposure odds ratio differs across subtypes.