Skip to contents

Combine terms from a regression model into a single row of the table. The p-value comes from stats::anova() comparing the full model against the reduced model without the combined terms; the combined row shows no estimate or confidence interval.

Usage

combine_terms(x, formula_update, label = NULL, ...)

Arguments

x

(tbl_regression)
A tbl_regression object.

formula_update

(formula)
Formula update passed to stats::update(). The updated formula constructs the reduced model, which is then passed to stats::anova() to calculate the p-value of the removed terms. See the formula. argument of stats::update() for the syntax.

label

(string)
Optional label of the combined row.

...

Additional arguments passed to stats::anova(), e.g. test = "LRT".

Value

An ltsummary object.

Examples

# Example 1 ----------------------------------
# Logistic regression, LRT p-value
glm(response ~ marker + I(marker^2) + grade,
    trial[c("response", "marker", "grade")] |> na.omit(), # keep complete cases only!
    family = binomial) |>
  tbl_regression(label = grade ~ "Grade", exponentiate = TRUE) |>
  # collapse non-linear terms to a single row in output using anova
  combine_terms(
    formula_update = . ~ . - marker - I(marker^2),
    label = "Marker (non-linear terms)",
    test = "LRT"
  )