Skip to contents

Overview

autospc provides a rigorous and consistent means of re-establishing limits on Shewhart charts (also known as control charts), using the Stable Shift Algorithm.

The main function is autospc(), which plots Shewhart charts of various types appropriate for different types of data, with limits established using the algorithm.

Installation

autospc can be installed using the devtools package.

Install devtools if you have not already done so

install.packages("devtools")

Then you can install autospc

devtools::install_github("HorridTom/autospc")

This may then give you the option to install other packages that autospc is dependent on.

Once installed, you can load autospc as usual with

library(autospc)

Usage

The example dataset ed_attendances_monthly, provided with autospc, is typical of the time series data that the Stable Shift Algorithm is designed for. The example code below uses this dataset, and can be executed once autospc is loaded.

For a C, C’ or XmR chart the data must have the following columns:

  • Your x-axis variable: date, POSIXct, numeric or integer type. The name of this column can be specified in the x argument of autospc().

  • Your y-axis variable : numeric or integer type. The name of this column can be specified in the y argument of the autospc() function.

For example:

autospc(ed_attendances_monthly,
                chart_type = "C'",
                x = month_start,
                y = att_all)

For a P or P’ chart the data must have the following columns:

  • Your x-axis variable: date, POSIXct, numeric or integer type. The name of this column can be specified in the x argument of autospc().

  • The denominator or total count (e.g. number of ED attendances): numeric or integer type. The name of this column can be specified in the n argument of autospc().

  • The numerator (e.g. number of ED attendances less than 4 hours in duration): numeric or integer type. The name of this column can be specified in the y argument of autospc().

For example:

autospc(ed_attendances_monthly,
                chart_type = "P'",
                x = month_start,
                y = within_4h,
                n = att_all)

The parameters of the Stable Shift Algorithm, and the appearance of the chart, can be configured through various arguments. Use ?autospc::autospc to find out more.

Analysis output as a table

In addition to the default plot output, analysis results can be obtained in table format using plot_chart = FALSE, as follows:

limits_table <- autospc(ed_attendances_monthly,
                              chart_type = "P'",
                              x = month_start,
                              y = within_4h,
                              n = att_all,
                              plot_chart = FALSE)

head(limits_table,
      n = 5L)

Getting help

If you encounter a clear bug, please file an issue with a minimal reproducible example on GitHub.