Tidy a matchatr fit into a coefficient / odds-ratio table

Description

Returns the fitted unmatched case-control logistic regression as a tidy coefficient table — one row per model term — on the log-odds scale by default, or the odds-ratio scale with exponentiate = TRUE.

Usage

## S3 method for class 'matchatr_fit'
tidy(
  x,
  conf.int = TRUE,
  conf.level = 0.95,
  exponentiate = FALSE,
  robust = FALSE,
  ...
)

Arguments

x A matchatr_fit whose model is a fitted binomial glm.
conf.int Logical; add conf.low / conf.high Wald bounds. Default TRUE.
conf.level Numeric confidence level in (0, 1). Default 0.95.
exponentiate Logical; report estimate and confidence bounds on the odds-ratio scale. Default FALSE.
robust Logical; use the Huber-White sandwich standard error instead of the model information matrix. Default FALSE.
Unused; present for generic consistency.

Details

Standard errors come from the model information matrix, or the Huber-White sandwich when robust = TRUE. The Wald statistic and p-value are always on the coefficient (log-odds) scale; with exponentiate = TRUE the estimate and the confidence bounds are exponentiated while std.error stays on the log-odds scale (the broom convention). The intercept row is included but is not an interpretable baseline risk: under separate case / control sampling it is offset by the log sampling-fraction ratio (Prentice & Pyke, 1979). Only the parametric coefficients are reported: when the fit is an mgcv::gam, the smooth-basis terms (s(age).1, …) are penalized basis weights, not odds ratios, and are excluded.

Value

A data.table with columns term, estimate, std.error, statistic, p.value, and (when conf.int) conf.low, conf.high. For a polytomous (estimator = “polytomous”) fit the coefficients form one equation per non-reference outcome group, so a leading y.level column names the group each row’s contrast is against the reference.

See Also

matcha(), contrast(), summary.matchatr_fit()

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

Examples

library("matchatr")

set.seed(1)
df <- data.frame(case = rep(c(1, 0), each = 100), x = rbinom(200, 1, 0.4))
fit <- matcha(df, outcome = "case", exposure = "x", design = unmatched_cc())
tidy(fit, exponentiate = TRUE)
          term estimate std.error  statistic   p.value  conf.low conf.high
        <char>    <num>     <num>      <num>     <num>     <num>     <num>
1: (Intercept) 0.950000 0.1849609 -0.2773197 0.7815346 0.6611266  1.365094
2:           x 1.131579 0.2871695  0.4304564 0.6668637 0.6445338  1.986662