Model-Agnostic Exposure-Response Plots

Provides a fluent mini-language for building exposure-response plots (model curves/ribbons, quantile-binned summaries, data strips, and grouped distribution panels) from observed data and a fitted exposure-response model. Designed to be model-agnostic: any model object that implements the er_predict() generic (and, optionally, er_simulate() and er_summary()) can be visualised.


erplots

Lifecycle:experimental R-CMD-check Codecov testcoverage CRANstatus

The erplots package provides a mini-language for building exposure-response plots: model curves/ribbons, quantile-binned response-rate summaries, data strips, and grouped distribution panels. It supports time-to-event plots and visual predictive check plots as well as the core exposure-response plots, and it is model agnostic: it can display model predictions and summaries for a particular model type as long an appropriate model interface (consisting of a few key S3 methods) is available. Packages that support the interface include erglm (e.g., logistic regression, linear regression, Poisson regression, etc), ertte (parametric survival models, Cox proportional hazard models), and emaxnls (hyperbolic and sigmoidal Emax regression models for binary and continuous outcomes).

Installation

You can install the latest CRAN release like so:

install.packages("erplots")

Alternatively, you can install the development version of erplots with this:

pak::pak("djnavarro/erplots")

Example

library(erplots)
library(erglm)

mod <- erglm_model(ae1 ~ aucss, erglm_data, family = binomial())

erglm_data |> 
  er_plot(aucss, ae1) |> 
  er_plot_add_model(mod) |> 
  er_plot_add_quantiles() |> 
  er_plot_add_groups(aucss) |> 
  plot()

mod2 <- erglm_model(ae2 ~ aucss + sex, erglm_data, family = binomial())

plt <- erglm_data |> 
   er_plot(aucss, ae2, stratify_by = sex) |> 
   er_plot_add_model(mod2) |> 
   er_plot_add_quantiles(bins = 3) |> 
   er_plot_add_data() |> 
   er_plot_add_groups(group_by = c(aucss, treatment), keep_strata = FALSE)

print(plt)
#> <er_plot>
#>   plot variables:
#>     - exposure:        aucss
#>     - response:        ae2
#>     - stratification:  sex
#>   plot layers:
#>     - model:           erglm_model/glm/lm
#>     - quantile:        3 bins
#>     - overlay:         stratified
#>     - group:           .aucss_quantile, treatment
#>   plots built: <none>
#>   output built: no
plot(plt)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("erplots")

0.2.0 by Danielle Navarro, 8 days ago


https://github.com/djnavarro/erplots, https://erplots.djnavarro.net/


Report a bug at https://github.com/djnavarro/erplots/issues


Browse source code at https://github.com/cran/erplots


Authors: Danielle Navarro [aut, cre] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports dplyr, ggplot2, patchwork, purrr, rlang, scales, stats, survival, tibble, tidyselect, withr

Suggests emaxnls, erglm, hexbin, knitr, MASS, mvtnorm, rmarkdown, spelling, testthat


Suggested by emaxnls, erglm.


See at CRAN