Type: | Package |
Title: | Output Results from 'rms' Models for Medical Journals |
Version: | 1.0.0 |
Date: | 2025-06-16 |
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. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
URL: | https://rmsmd.github.io/rmsMD/ |
BugReports: | https://github.com/rmsMD/rmsMD/issues/ |
RoxygenNote: | 7.3.2 |
Imports: | rms, ggplot2, rlang, cowplot |
Suggests: | knitr, rmarkdown, devtools, officer, flextable, dplyr, testthat (≥ 3.0.0), vdiffr |
VignetteBuilder: | knitr |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2025-06-17 16:14:43 UTC; samueltingle |
Author: | Samuel Tingle |
Maintainer: | Samuel Tingle <samjamestingle@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-06-17 23:50:02 UTC |
Create plots for RCS variables from an rms
model
Description
The 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.
Usage
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,
...
)
Arguments
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 |
Value
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
.
Examples
# For details examples and plots please see the provided vignettes
Create model summary for rms models
Description
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.
Usage
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
)
Arguments
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 |
Value
Returns a dataframe of results. This can easily be outputted to word using packages such as flextable and officer.
Examples
# For detailed examples please see the provided vignettes
Simulated Data for the Vignette
Description
Generates a synthetic dataset for testing and demonstration purposes in the rmsMD
package.
Usage
simulated_rmsMD_data(type = c("complete_case", "missing_for_MI"))
Arguments
type |
Character string; either |
Value
A data frame with simulated variables: age
, bmi
, sex
, smoking
, majorcomplication
, lengthstay
, time
, and event
.