shewhart: Shewhart x-bar Control Chart

Description Usage Arguments Details Value Methods (by class) References Examples

Description

Test on device-events using the Shewhart x-bar control chart. Includes the first 4 Western Electric rules common to statistical process control.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
shewhart(df, ...)

## S3 method for class 'mds_ts'
shewhart(df, ts_event = c(Count = "nA"), analysis_of = NA, ...)

## Default S3 method:
shewhart(
  df,
  analysis_of = NA,
  eval_period = NULL,
  zero_rate = 1/3,
  we_rule = 1,
  mu = NULL,
  sigma = NULL,
  ...
)

Arguments

df

Required input data frame of class mds_ts or, for generic usage, any data frame with the following columns:

time

Unique times of class Date

event

Either the event count or rate of class numeric

...

Further arguments passed onto shewhart methods

ts_event

Required if df is of class mds_ts. Named string indicating the variable corresponding to the event count or rate. Rate must be calculated in a separate column in df as it is not calculated by default. The name of the string is an English description of what was analyzed.

Default: c("Count"="nA") corresponding to the event count column in mds_ts objects. Name is generated from mds_ts metadata.

Example: c("Rate of Bone Filler Events in Canada"="rate")

analysis_of

Optional string indicating the English description of what was analyzed. If specified, this will override the name of the ts_event string parameter.

Default: NA indicates no English description for plain df data frames, or ts_event English description for df data frames of class mds_ts.

Example: "Rate of bone cement leakage"

eval_period

Optional positive integer indicating the number of unique times counting in reverse chronological order to assess. This will be used to establish the process mean and moving range.

Default: NULL considers all times in df.

zero_rate

Required maximum proportion of events in df (constrained by eval_period) containing zeroes for this algorithm to run. Because Shewhart does not perform well on time series with many 0 values, a value >0 is recommended.

Default: 1/3 requires no more than 1/3 zeros in events in df in order to run.

we_rule

Required integer from 1 to 4 representing the Western Electric rule to use. See details for descriptions.

Default: 1 represents the first Western Electric rule of one point over the 3-sigma limit.

mu

Optional value of the in-control process mean, typically measured from historical data.

Default: NULL estimates the in-control process mean from timepoints prior to the most recent timepoint in the time series. The most recent measurement is then tested using this estimate.

sigma

Optional value of the in-control process standard deviation, typically measured from historical data.

Default: NULL estimates the in-control process standard deviation from timepoints prior to the most recent timepoint in the time series using a moving range calculation assuming an n=2 sampling approach. The most recent measurement is then tested using this estimate.

Details

Function shewhart() is an implementation of the x-bar Control Chart test from the family of statistical process control tests originally proposed by Walter Shewhart.

we_rule has four possible values: 1 is one point over the 3-sigma limit. 2 is two out of three consecutive points over the 2-sigma limit. 3 is four of five consecutive points over the 1-sigma limit. 4 is nine consecutive points over the process mean.

Value

A named list of class mdsstat_test object, as follows:

test_name

Name of the test run

analysis_of

English description of what was analyzed

status

Named boolean of whether the test was run. The name contains the run status.

result

A standardized list of test run results: statistic for the test statistic, lcl and ucl for the 95 confidence bounds, p for the p-value, signal status, and signal_threshold.

params

The test parameters

data

The data on which the test was run

Methods (by class)

References

Montgomery, Douglas C. Introduction to Statistical Quality Control by Douglas C. Montgomery, 5th Edition: Study Guide. Cram101, 2013.

Examples

1
2
3
4
5
6
7
8
9
# Basic Example
#  data <- data.frame(time=c(1:25), event=as.integer(stats::rnorm(25, 100, 25)))
# a1 <- shewhart(data)
# Example using an mds_ts object
# a2 <- shewhart(mds_ts[[3]])
# Example using a derived rate as the "event"
# data <- mds_ts[[3]]
# data$rate <- ifelse(is.na(data$nA), 0, data$nA) / data$exposure
# a3 <- shewhart(data, c(Rate="rate"))

mdsstat documentation built on March 13, 2020, 2:58 a.m.