Test on device-events using the x-bar control chart. Includes the first 4 Western Electric rules common to statistical process control.
xbar(df, ...)# S3 method for mds_ts
xbar(df, ts_event = c(Count = "nA"), analysis_of = NA, ...)
# S3 method for default
xbar(
df,
analysis_of = NA,
eval_period = NULL,
zero_rate = 1/3,
we_rule = 1,
mu = NULL,
sigma = NULL,
...
)
Required input data frame of class mds_ts
or, for generic
usage, any data frame with the following columns:
Unique times of class Date
Either the event count or rate of class numeric
Further arguments passed onto xbar
methods
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")
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"
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
.
Required maximum proportion of event
s 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 event
s in
df
in order to run.
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.
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.
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.
A named list of class mdsstat_test
object, as follows:
Name of the test run
English description of what was analyzed
Named boolean of whether the test was run. The name contains the run status.
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
.
The test parameters
The data on which the test was run
mds_ts
: x-bar on mds_ts data
default
: x-bar on general data
Function xbar()
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.
Montgomery, Douglas C. Introduction to Statistical Quality Control by Douglas C. Montgomery, 5th Edition: Study Guide. Cram101, 2013.
# NOT RUN {
# Basic Example
data <- data.frame(time=c(1:25), event=as.integer(stats::rnorm(25, 100, 25)))
a1 <- xbar(data)
# Example using an mds_ts object
a2 <- xbar(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 <- xbar(data, c(Rate="rate"))
# }
Run the code above in your browser using DataLab