| Title: | Output Results from 'rms' Models for Medical Journals |
|---|---|
| Description: | Provides streamlined functions for summarising and visualising regression models fitted with the 'rms' package, in the preferred format for medical journals. The 'modelsummary_rms()' function produces concise summaries for linear, logistic, and Cox regression models, including automatic handling of models containing restricted cubic spline (RCS) terms. The resulting summary dataframe can be easily converted into publication-ready documents using the 'flextable' and 'officer' packages. The 'ggrmsMD()' function creates clear and customizable plots ('ggplot2' objects) to visualise RCS terms. |
| Authors: | Samuel Tingle [aut, cre] (ORCID: <https://orcid.org/0000-0001-5529-7815>), Georgios Kourounis [aut] (ORCID: <https://orcid.org/0000-0002-1051-078X>) |
| Maintainer: | Samuel Tingle <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.1 |
| Built: | 2026-05-12 07:40:58 UTC |
| Source: | https://github.com/rmsmd/rmsmd |
rms modelThe ggrmsMD function processes the output from models fitted using the rms package and produces one or more ggplot2 objects visualising restricted cubic splines (RCS).
The function detects RCS terms in the model and plots them all, with a suitable y-axis selected based on the model type. This outputs a list of plots, or a multi-panel figure using the combined argument.
As outputs are ggplot objects they can easily be further customised by the user.
ggrmsMD( modelfit, data, noeffline = TRUE, shade_inferior = "none", combined = TRUE, ylab = NULL, xlabs = NULL, titles = NULL, ylim = NULL, log_y = FALSE, log_y_breaks = NULL, xlims = NULL, log_x_vars = NULL, log_x_breaks = NULL, lrm_prob = FALSE, var = NULL, np = 400, ... )ggrmsMD( modelfit, data, noeffline = TRUE, shade_inferior = "none", combined = TRUE, ylab = NULL, xlabs = NULL, titles = NULL, ylim = NULL, log_y = FALSE, log_y_breaks = NULL, xlims = NULL, log_x_vars = NULL, log_x_breaks = NULL, lrm_prob = FALSE, var = NULL, np = 400, ... )
modelfit |
A model object from |
data |
The dataset used to fit the model. |
noeffline |
Logical. If |
shade_inferior |
Character. Options are |
combined |
Logical. If |
ylab |
Optional character. Override the default y-axis label. |
xlabs |
A named list of x-axis labels for each variable. E.g., |
titles |
A named list of plot titles for each variable. |
ylim |
Numeric vector (length 2). y-axis limits applied to all plots. E.g., |
log_y |
Logical. If |
log_y_breaks |
Optional numeric vector specifying y-axis tick marks when |
xlims |
A named list of x-axis limits per variable. E.g., |
log_x_vars |
Character vector. Names of variables for which x-axis should be log10-transformed. |
log_x_breaks |
A named list specifying x-axis tick marks for variables with log10-transformed x-axis. |
lrm_prob |
Logical. If |
var |
Character vector. Optional. Variables to plot. If |
np |
Integer. Number of points used to predict spline curves. Default is |
... |
Additional arguments passed to |
A ggplot object (if one variable is plotted), a list of ggplot objects (if multiple variables), or a single combined cowplot plot if combined = TRUE.
# For details examples and plots please see the provided vignettes# For details examples and plots please see the provided vignettes
The modelsummary_rms function processes the output from models fitted using the rms package and generates a summarized dataframe of the results.
This summary is tailored for publication in medical journals, presenting effect estimates, confidence intervals, and p-values.
modelsummary_rms( modelfit, combine_ci = TRUE, round_dp_coef = 3, round_dp_p = 3, rcs_overallp = TRUE, hide_rcs_coef = TRUE, exp_coef = NULL, fullmodel = FALSE, MI_lrt = FALSE )modelsummary_rms( modelfit, combine_ci = TRUE, round_dp_coef = 3, round_dp_p = 3, rcs_overallp = TRUE, hide_rcs_coef = TRUE, exp_coef = NULL, fullmodel = FALSE, MI_lrt = FALSE )
modelfit |
The output from an rms model. |
combine_ci |
If |
round_dp_coef |
Specifies the number of decimal places to display for the effect estimates. Default is |
round_dp_p |
Specifies the number of decimal places to display for P values. Default is |
rcs_overallp |
If |
hide_rcs_coef |
If |
exp_coef |
If |
fullmodel |
If |
MI_lrt |
If |
Returns a dataframe of results. This can easily be outputted to word using packages such as flextable and officer.
# For detailed examples please see the provided vignettes# For detailed examples please see the provided vignettes
Generates a synthetic dataset for testing and demonstration purposes in the rmsMD package.
simulated_rmsMD_data(type = c("complete_case", "missing_for_MI"))simulated_rmsMD_data(type = c("complete_case", "missing_for_MI"))
type |
Character string; either |
A data frame with simulated variables: age, bmi, sex, smoking, majorcomplication, lengthstay, time, and event.