risk_difference(): absolute risks and the risk
difference between two groups for a binary outcome, as a gt
or flextable table. The crude analysis uses the
Miettinen-Nurminen score interval and score test. With
adjust_for, risks are standardised over the analysis
population from a main-effects logistic regression, and the Wald
interval and p-value use the influence-function standard error.
event_type = "harmful" or "beneficial" adds
NNTB / NNTH with an Altman interval that runs through infinity when the
risk-difference interval includes zero. The event and the direction of
the contrast are always stated in the table footnote.
modify_table() supports captions, caveats, labels and
headers for these tables; merge_tables(),
plot_reg(), plot_reg_combine(),
forest_df() and forest_reg() reject them with
a clear message.conditional_logit_reg() for matched case-control
studies: crude, adjusted and joint multivariable matched odds ratios,
with matched-set accounting and informative-set, case and control
counts.multilevel_reg() for continuous and binary outcomes
with one grouping variable and a random intercept: fixed-effect
estimates, cluster and observation counts, random-intercept variance,
intraclass correlation where appropriate, and convergence or
singular-fit guidance. Random slopes and nested structures are outside
its scope.ordinal_reg() for ordered outcomes with three or more
categories: crude, adjusted and joint multivariable proportional-odds
models with common odds ratios, explicit outcome ordering, model-fit
statistics and term-level proportional-odds checks.multinomial_reg() for unordered outcomes with three or
more categories. Each non-reference outcome comparison has its own
column, and a standard regression object is kept per comparison for
plots and forest tables.competing_risk_reg() for Fine-Gray regression, with
crude and adjusted SHR tables, and
cuminc_plot() for cumulative incidence curves with explicit
censoring and event-of-interest coding, confidence intervals, optional
grouping and Gray’s test. The documentation explains how cumulative
incidence, subdistribution hazards, cause-specific hazards and
Kaplan-Meier estimates differ.plot_cox_survival() draws adjusted survival curves and
confidence bands from coxph or cox_reg()
models.import_data() imports CSV, TSV, TXT, Excel, RDS, Stata,
SPSS and SAS files through one validated interface, keeps labelled
columns, and uses optional readers only when they are installed. The app
uses the same importer.data_competing_risk, a fully synthetic
oncology teaching dataset for competing-risk analysis.cox_reg() supports delayed entry (start-stop data),
clustered robust variance, case weights, tie handling and Cox fitting
controls. baseline_strata stratifies the baseline hazard on
one or more categorical variables while estimating common hazard ratios;
no hazard ratio is reported for those variables and a footnote says so.
It is distinct from stratifier, which fits separate models
within each stratum.check_ph() keeps its Schoenfeld-residual diagnostics
and supports plot(), including model and term
selection.modify_table(),
merge_tables(), plot_reg(),
plot_reg_combine(), forest_df(),
forest_reg() and the export helpers where statistically
appropriate. plot_reg_combine() accepts crude and adjusted
Fine-Gray, conditional logistic, ordinal and individual multinomial
results, with model-specific axis labels.forest_df() / forest_reg(): effect columns
use the same header as the source table, so
conditional_logit_reg() shows “Matched OR” and
ordinal_reg() “Common OR”. Exposure-specific adjusted
results (adjust_for) can be shown next to the single
multivariable model of the same family, labelled “Mutually adjusted”.
forest_df(multi = ) works without uni.
Infinite confidence limits are kept and shown with the infinity symbol.
Default axes use rounded ticks spaced so that labels do not overlap;
xlim and ticks_at still override them.forest_reg() works with forestploter 1.2.0 (axis
settings through set_xaxis(), labels through
set_labs(), themes through style) and remains
compatible with forestploter 1.1.x. The ineffective effects
argument is kept only as a deprecated compatibility argument.merge_tables() handles sensitivity-analysis layouts,
including several univariable or several multivariable tables with
user-defined headings, with stable row alignment and each table’s own
notes.uni_reg(),
multi_reg() and the stratified functions are now t-based
(as confint.lm()), consistent with the reported p-values.
Intervals are slightly wider in small samples. forest_df()
recovers the standard error with the same t quantile.TRUE or the second level is the event, and a message names
the event that was modelled. In stratified analyses the coding is
decided once on the full data.cox_reg(), surv_reg() and
competing_risk_reg(): unused factor levels are dropped per
fitted model, so Ref. is the level the model actually used
and unused levels no longer appear as NA rows. Ordered
factors are reported as level-versus-reference effects; estimates for
ordered-factor exposures therefore change from polynomial to treatment
contrasts. Treatment contrasts are also used for display in the other
regression functions.cox_reg(baseline_strata = ) builds the model with
strata() so that the baseline hazard is stratified on every
supported version of survival.time_start, weights or cluster
values). surv_model_compare() and
surv_reg(model_stats = TRUE) count events on the rows used
by the model.select_models() fits every candidate on one
complete-case sample, returns n_used and
n_excluded, and backward selection can reach the
intercept-only model.identify_confounder(): the interaction p-value is a
likelihood-ratio test for all approaches; numeric-coded candidates with
at most 10 distinct values are treated as categories; unstable strata
are ignored; the recommendation can be
"not_estimable".interaction_models() with
approach = "robpoisson" uses a robust Wald test.compare_models(): the change from the first model is
computed on the ratio scale for ratio measures.mediation_analysis(): the confidence-interval label
follows conf_level, invalid exposure values are an error,
failed bootstrap replicates give a warning, and a footnote states the
logit approximation.descriptive_table(): Date and date-time variables are
excluded with a message; logical and constant variables are shown as
categories; continuous variables with missing values gain a
(Missing) row; numeric levels are sorted numerically; an
unknown value is an error. A by variable that
is also listed in exposures is left out of the summarised
variables, with a message.show_ref = FALSE hides the reference row only for
binary predictors; categorical predictors with more than two levels keep
their reference category. The same rule applies to regression,
stratified and merged tables, regression plots and forest plots.uni_reg() writes confidence intervals with an en dash,
as all other tables already did, and the N column is in the
same position in all regression tables.uni_reg() keeps exposures whose model could not be
fitted: the row shows a dash, a footnote names them, and the result
gains failed_exposures.NA (NA-NA)) in single, stratified and merged tables.No and
Yes line up.: and duplicated coefficient names are
displayed correctly.Stratified by: footnote shows the variable label when the
stratifier has one.cox_reg() and surv_reg() with
stratifier: show_sample now defaults to
"both" (N and events); it has no effect without
stratifier. The N footnote shows a range with an en dash
when models differ, uses “analysis intervals” with
time_start, and the adjustment footnote uses variable
labels. New footnotes report rows excluded for a missing stratifier and
reference categories that differ between strata.cox_reg(), surv_reg() and
competing_risk_reg() tables end with a
Number of events: footnote. New footnotes, when applicable,
name the event level of a factor or character event and
state that robust variance was used with case weights.N column and its footnote. Their adjustment footnotes
follow labels changed with modify_table() and can be
removed before adding a custom caveat.rmst_table(): confidence-interval headers follow
conf.level; a warning and a footnote are given when
tau exceeds the follow-up of a group.merge_tables(): a variable shown as a single row in one
table and with level rows in another is aligned on one block (with
Ref. marked where the reference level differs); a
continuous variable with a (Missing) row stays on one row;
column labels, spanners, column order and footnotes are taken from the
source tables (source spanners become an inner spanner row);
abbreviation notes are combined into one line. Merged flextables use
publication-style header and outer rules without rules between exposure
rows.modify_table() starts from the notes, labels, spanners
and column order of the source table, so calling it without arguments
leaves a table unchanged. remove_N_obs = TRUE removes every
wording of the complete-observation footnote;
remove_N = TRUE removes the N column and the
notes that only explain that column."clinical", "striped", "jama")
keep the indentation of level rows.plot_reg() and plot_reg_combine() place
every estimate on the row of its own variable and level, including
relabelled levels, adjusted-only levels and interaction rows. Without
the ggtext package the axis labels are plain text.km_plot(): the curve and the risk table share the same
x limits. cuminc_plot():
xlim/ylim zoom without dropping data and
groups follow the factor level order. plot_cox_survival()
supports models with baseline_strata.cox_reg() and surv_reg() refuse the time or
event variable as an exposure or adjustment variable;
identify_confounder(), interaction_models()
and select_models() refuse the outcome as a predictor;
interaction_models() refuses an effect modifier equal to
the exposure or covariates repeating either;
mediation_analysis() refuses covariates that repeat the
exposure, mediator or outcome; km_plot(),
survival_summary() and logrank_test() refuse a
by variable equal to the time or event variable.theme is an error in every table function
and in merge_tables().weights must be greater than zero; surv_reg()
requires time greater than zero;
ties = "exact" cannot be combined with
time_start.cox_reg(baseline_strata = ) checks for overlap with
time, event, exposures,
adjust_for and stratifier, and warns about
strata with very small samples or no events.logrank_test() without
by, cuminc_plot() limits that are not
increasing, competing_risk_reg() /
cuminc_plot() without event_of_interest,
plot_cox_survival(by = ) naming a baseline-strata variable,
and surv_predict() on stratified input.multinomial_reg() names the exposure and level in the
error raised when a level is lost in the fitted sample.modify_table() gives a clear error for
mediation_analysis() results.save_table() explains the alternatives when a flextable
is saved as PDF.uni_reg(): failed_exposures.
select_models(): n_used,
n_excluded.stratified_uni_reg(),
stratified_multi_reg(), stratified cox_reg() /
surv_reg()) and rmst_table():
footnotes.multinomial_reg(): a single format, plus
column_labels, spanners and
theme. Merged tables: inner_spanners and
theme.plot_cox_survival(): plot_data gains
profile and stratum.data always refers to
that column, even when an object of the same name exists in the
workspace or in a package (for example time,
rank, class, by).function(d, by) descriptive_table(d, "x", by = by): the
value passed by the caller is used. This applies to all variable
arguments, including time, event,
stratifier, weights and by in the
survival functions.import_data() falls back to Latin-1 when a text file is
not valid UTF-8, and no longer treats ' as a quote
character.gtregression_app().risk_difference(),
beside Regression and Survival: choose the outcome and which value is
the event, the treatment variable and its reference group, optional
adjustment variables, and whether the number needed to treat is
reported. The table, DOCX / RTF / HTML export, R code and Session Code
come from risk_difference() itself.multi_result_1,
multi_result). A session keeps up to 30 results in the
desktop app and 15 on a web server; when fitted models exceed 500 MB
(200 MB on a web server) the oldest results keep their table but release
their models. Session Code lists the kept results and can remove earlier
ones..gtrsession file.save_table()).Archived release: https://doi.org/10.5281/zenodo.22049943
flextable output as the default
table format across package table functions, while retaining
gt and tibble-style outputs where appropriate.approach = logit and
format = flextable.adjust_for support for adjusted multivariable
workflows, including downstream regression plots and combined regression
plots.uni_reg() and
multi_reg() via model_stats = TRUE, with AIC,
BIC, log-likelihood, deviance, pseudo R-squared, linear-model R-squared,
and model N stored in $model_stats.approach = "firth" /
approach = firth for Firth penalized logistic regression in
uni_reg(), multi_reg(),
stratified_uni_reg(), and
stratified_multi_reg(), with OR tables and compatibility
with regression plots and forest plot helpers.data_endometrial, a classic endometrial cancer
dataset with a separation pattern, for teaching and testing Firth
logistic regression.cox_reg() for Cox proportional hazards regression
using time, event, exposures, and
optional adjust_for, returning HR and adjusted HR
tables.surv_reg() for parametric survival regression
using time, event, exposures,
optional adjust_for, and a selectable survival
distribution, returning time-ratio tables.stratifier argument in cox_reg() and
surv_reg(), with stratum-specific N, event counts, and
formatted regression tables.km_plot() for Kaplan-Meier survival curves with
optional confidence intervals, censoring marks, log-rank p-values, and
number-at-risk tables.km_plot(), including
y-axis limits, percentage-scale display, optional grid removal, theme
selection, confidence interval styling, and title/subtitle sizing for
patchwork-style figure panels.km_risk_table() for standalone Kaplan-Meier risk
tables at requested follow-up times, with at-risk, event, and censored
counts.rmst_table() for restricted mean survival time
summaries up to a chosen follow-up time, with optional two-group RMST
difference.surv_model_compare() for comparing candidate
parametric survival distributions by AIC, BIC, log-likelihood, scale,
events, and N.plot_surv_fit() for visually comparing observed
Kaplan-Meier curves with fitted parametric survival curves.surv_predict() for model-based survival
probability predictions from fitted parametric survival regression
models.survival_summary() for Kaplan-Meier median
survival summaries with total N, events, censored counts, and
publication-style table outputs.survival_quantiles() for Kaplan-Meier survival
time quantiles, including event percentiles, corresponding survival
probabilities, and confidence intervals.survival_prob() for Kaplan-Meier survival
probabilities at fixed follow-up times, with at-risk, event, censored,
and confidence interval columns.logrank_test() for formal comparison of
Kaplan-Meier survival curves, with observed and expected events plus
formatted p-value output.check_ph() for proportional hazards screening of
Cox models using Schoenfeld residual tests, with flextable, gt, and
tibble outputs.plot_model_fit() for visual model diagnostics
from fitted lm/glm models and from models
stored in uni_reg() and multi_reg()
outputs.mediation_analysis() for regression-based
mediation analysis with formatted direct, indirect, total, and
proportion mediated tables.plot_mediation() for drawing a mediation path
diagram from mediation_analysis() outputs.data_diabetes_mediation, a health-related
diabetes teaching dataset for practicing obesity, glucose, and diabetes
mediation workflows.compare_models() for publication-ready comparison
of fitted gtregression model outputs, including AIC, BIC,
log-likelihood, likelihood ratio statistics, primary exposure estimates,
percent change, analysis-sample checks, and highlighted best-fit
summaries.save_forest() for exporting
forest_reg() outputs with reproducible sizing across
graphics devices and operating systems.labelled::var_label(), across descriptive,
regression, stratified, merged, plotted, and forest-style outputs.dissect(), select_models(),
interaction_models(), and
identify_confounder().identify_confounder() to support confounding assessment
alongside crude and adjusted model comparisons.dev/manual-tests/
for real-time testing of logistic, linear, log-binomial, robust Poisson,
Poisson, negative binomial, Cox, parametric survival, Firth, and
mediation workflows.descriptive_table(), uni_reg(),
multi_reg(), stratified_uni_reg(), and
stratified_multi_reg() documentation with clearer examples
using package datasets.merge_tables() so descriptive, crude, and
adjusted tables can be combined more reliably, including when visible
variable labels differ between input tables.modify_table() so merged tables retain clean
headers, spanners, and footnotes after relabelling.forest_df() and forest_reg()
support for descriptive summaries combined with univariable and
multivariable regression outputs.forest_df() and forest_reg()
support for stratified regression outputs, including one-object
stratified forest plots with highlighted stratum headers and preserved
row order.cox_reg() and
surv_reg() outputs work with plot_reg(),
plot_reg_combine(), forest_df(),
forest_reg(), merge_tables(),
modify_table(), and select_models().cox_reg() and surv_reg()
consistency with the rest of the package: both now support single
multivariable models, adjusted exposure workflows, interaction terms,
stratified workflows, and coherent table labels.compare_models() output so user-supplied or
object-derived model names are displayed instead of generic model
labels, and context-aware warnings distinguish same-sample comparisons
from different-sample comparisons.save_table() handling for wide Word tables by
preferring landscape orientation before reducing font size, respecting
minimum font sizes, and allowing users to turn width fitting off.save_docx(table_width = ...) available for custom document
layouts.select_models() output so formatted tables
clearly report the model selection direction used.merge_tables() flextable headers so internal
merge suffixes such as _p1, _p2, and
_p3 are not shown in rendered tables.merge_tables() row alignment when descriptive and
regression tables contain the same variables but different visible
labels.modify_table() handling of merged flextable
outputs so clean subheaders and group spanners are preserved.check_convergence() so failed multivariable model
fits return a clear non-converged table rather than failing during table
formatting.time, event, and
the current exposure rather than using a single complete-case dataset
across all exposures.survival model
functions, while negative follow-up times remain invalid.forest_df() row-order handling after joins and
merges so forest plots follow the same display order as the source
regression table.data_SynthDiabetes, a
synthetic replacement based on mlbench::SynthDiabetes2
(mlbench >= 2.1-11), and regenerated all mediation teaching fixtures
that depended on the prior dataset.plot_reg(),
plot_reg_combine()).