library("matchatr")
set.seed(1)
df <- data.frame(
case = rep(c(1, 0), each = 100),
x = rbinom(200, 1, 0.4),
age = rnorm(200, 50, 10)
)
fit <- matcha(df, outcome = "case", exposure = "x",
design = unmatched_cc(), confounders = ~ age)
# The conditional odds ratio is identified:
contrast(fit, type = "or")<matchatr_result>
Estimator: logistic (engine: glm_logistic)
Estimand: conditional OR
Contrast: Odds ratio
CI method: model
N: 200
Contrasts:
comparison estimate se ci_lower ci_upper
<char> <num> <num> <num> <num>
1: x 1.127078 0.3239669 0.6416305 1.979808
# The risk difference is not (no prevalence q0):
try(contrast(fit, type = "difference"))Error in contrast(fit = fit, type = "difference") :
The risk difference is not identified from an unmatched case-control sample without the source-population prevalence q0.
ℹ Report the conditional odds ratio with `type = "or"`.
ℹ For a marginal risk difference / ratio, supply `prevalence =` on the design and use a case-control-weighted estimator (e.g. `estimator = "ccw_gformula"`).