Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/johnmackintosh/runcharter

Automating run chart analysis for faceted displays of data across multiple metrics or locations
https://github.com/johnmackintosh/runcharter

chart-analysis healthcare nhs nhs-r-community quality-control quality-improvement quality-improvement-efforts r rdatatable rstats rstats-package

Last synced: 3 months ago
JSON representation

Automating run chart analysis for faceted displays of data across multiple metrics or locations

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```

# runcharter

Automated analysis and re-basing of run charts at scale.

Online documentation and vignettes : [https://johnmackintosh.github.io/runcharter/](https://johnmackintosh.github.io/runcharter/)

[![R-CMD-check](https://github.com/johnmackintosh/runcharter/workflows/R-CMD-check/badge.svg)](https://github.com/johnmackintosh/runcharter/actions)

[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Coverage status](https://codecov.io/gh/johnmackintosh/runcharter/branch/master/graph/badge.svg)](https://codecov.io/github/johnmackintosh/runcharter?branch=master)
[![Render README](https://github.com/johnmackintosh/runcharter/actions/workflows/render-readme.yaml/badge.svg)](https://github.com/johnmackintosh/runcharter/actions/workflows/render-readme.yaml)
[![Codecov test coverage](https://codecov.io/gh/johnmackintosh/runcharter/branch/master/graph/badge.svg)](https://app.codecov.io/gh/johnmackintosh/runcharter?branch=master)
[![CRAN status](https://www.r-pkg.org/badges/version/runcharter)](https://CRAN.R-project.org/package=runcharter)

[![CRAN
Downloads](https://cranlogs.r-pkg.org/badges/runcharter)](https://cran.r-project.org/package=runcharter)

[![Total
Downloads](https://cranlogs.r-pkg.org/badges/grand-total/runcharter)](https://cran.r-project.org/package=runcharter)

## Installation

You can install the latest stable version from CRAN with:

```{r,cran-install, eval = FALSE}
install.packages("runcharter")
```

You can install the development version from github with:

```{r gh-installation, eval = FALSE}
# install.packages("remotes") # if not already installed
remotes::install_github("johnmackintosh/runcharter")

# to ensure the vignettes are built or ensure latest version is installed:

remotes::install_github("johnmackintosh/runcharter",
build_vignettes = TRUE)
```

The rationale for the package is to analyse multiple run charts at once.
More importantly, the package will identify a run of n successive points on the desired side of the median line, and will recalculate / rebase the median accordingly.
Each time a run occurs, the median will be rebased.
This helps to track improvements over time.

The default is to plot a faceted plot, allowing ggplot2 to handle the axis limits.
You can specify the number of columns in the faceted plot however, and you can also specify both the breaks for date labels on the x axis, and whether the y axis limits are fixed, or can vary by facet panel.

```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.width = 8,
fig.height = 5
)
```

# Function arguments and defaults

A default run of 9 is specified as that is the length of run used by the IHI for its patient safety initiatives worldwide.

```{r, eval=FALSE}

library(runcharter)
runcharter(df = signals,
med_rows = 13,
runlength = 9,
direction = "below",
datecol = NULL,
grpvar = NULL,
yval = NULL,
facet_cols = NULL,
facet_scales = "fixed",
chart_title = NULL,
chart_subtitle = NULL,
chart_caption = NULL,
chart_breaks = NULL,
line_colr = "#005EB8", # blue
point_colr ="#005EB8", # blue
median_colr = "#E87722", # orange
highlight_fill = "#DB1884") # magenta

```

The function will return a plot and a summary table showing the original baseline medians, and any sustained runs of improvement beyond the baseline period.

```{r runs_below, fig.width = 8, fig.height= 5}

library(runcharter)

runcharter(signals,
direction = "below",
datecol = date,
grpvar = grp,
yval = y,
chart_title = "Runs identified",
chart_subtitle = "Runs below the median signalling improvement")

```

## Runs in both directions

The package allows for finding runs in both directions (above and below the median).
Generally, for improvement purposes, you would only need to identify runs in one direction at a time.
In other words, if you are trying to reduce adverse events, improvement will be evidenced with a run below the median. Therefore, you would not rebase the median if a run of points above the median was observed.

However, for longer term monitoring, it may be necessary to identify and 'reset' a median if a sustained deterioration in performance occurs. Ideally, you should move to using SPC charts for monitoring purposes.

```{r, runs_7_5_both_directions, fig.width = 8, fig.height= 5}
library(runcharter)
signals %>%
runcharter(med_rows = 7,
runlength = 5,
direction = "both",
datecol = date,
grpvar = grp,
yval = y,
chart_title = "Runs in both directions",
chart_subtitle = "Runs of 5, from median calculated over first 7 data points in each location")

```

## Design decisions and similar packages

This package makes no attempt to identify or highlight 'trends' (consecutively increasing or decreasing points) or shorter 'shifts' of runs below the median.
In 8 years of working with QI data, I very rarely see trends, and when they do appear, they tend to result after a period of process degradation, when the process begins to return back to its natural median state.

In addition, research by qicharts2 author Jacob Anhoej shows that the trend rule is not reliable. There are no plans to add tests to identify trends to the package.

However, analysts are often asked to apply all the run chart rules.
In this case, if you need to apply the rules for trend , and still have the ability to revise run chart medians, you should consider using [the runchart package by Joseph Adams](https://github.com/jsphdms/runchart).

[qicharts2](https://github.com/anhoej/qicharts2) creates run and SPC charts. These can be rebased, but you must specify when to do so. Also, the analysis is based on the author's own rules and not the rules typically used in healthcare (e.g. the rules promoted by the IHI).

## Turn off run chart analysis

You can avoid rebasing medians by setting 'runlength' to 0 (zero).
This will plot the runcharts with the original baseline medians, but no runs analysis will take place.

```{r medians_only, fig.width=8, fig.height=5}
library(runcharter)
signals %>%
runcharter(med_rows = 13,
runlength = 0,
datecol = date,
grpvar = grp,
yval = y,
direction = "both")

```

Similarly, you can plot basic line charts by setting 'med_rows' to 0 (zero)

```{r lines_only, fig.width=8, fig.height=5}
library(runcharter)
signals %>%
runcharter(med_rows = 0,
runlength = 9,
datecol = date,
grpvar = grp,
yval = y,
direction = "both")

```