Check whether requested models converge, either one exposure at a time or as a single multivariable model.
Usage
check_convergence(
data,
exposures,
outcome,
approach = "logit",
multivariate = FALSE,
format = c("flextable", "gt", "tibble")
)Arguments
- data
A data frame containing the dataset.
- exposures
A character vector of predictor variable names. Quoted names are recommended in scripts, and bare names are also accepted. If
multivariate = FALSE, each exposure is assessed separately. Ifmultivariate = TRUE, exposures are included together.- outcome
A character string specifying the outcome variable. Quoted and bare names are accepted.
- approach
A character string specifying the regression approach. One of:
"logit","logbinomial","poisson","robpoisson", or"negbin".- multivariate
Logical. If
TRUE, checks convergence for a multivariable model; otherwise, performs checks for each univariate model.- format
Output format. One of
"flextable"(default),"gt", or"tibble". Useformat = "tibble"for the original data-frame style output.
Value
A data frame, gt_tbl, or flextable summarizing
convergence diagnostics, including:
ExposureName of the exposure variable.
ModelThe regression approach used.
ConvergedTRUEif the model converged successfully;FALSEotherwise.Max.prob.Maximum predicted probability or fitted value in the dataset.
Details
For robpoisson, predicted probabilities (fitted values) may exceed 1,
which is acceptable when estimating risk ratios but should not be interpreted
as actual probabilities.
This is especially useful for "logbinomial" models, where convergence
problems are common and robust Poisson may be a practical alternative.
Examples
if (requireNamespace("gtregression", quietly = TRUE)) {
data(data_PimaIndiansDiabetes, package = "gtregression")
check_convergence(
data = data_PimaIndiansDiabetes,
exposures = c("age", "mass"),
outcome = "diabetes",
approach = "logit",
format = "tibble"
)
check_convergence(
data = data_PimaIndiansDiabetes,
exposures = c("age", "mass"),
outcome = "diabetes",
approach = "logit",
multivariate = TRUE,
format = "gt"
)
}
Convergence check
Screening aid only; inspect non-convergence, impossible fitted values, and model specification before interpreting estimates.