Test on device-events using the EWMA method based on the normal distribution.
ewma(df, ...)# S3 method for mds_ts
ewma(df, ts_event = c(Count = "nA"), analysis_of = NA, ...)
# S3 method for default
ewma(
df,
analysis_of = NA,
eval_period = NULL,
delta = 3,
lambda = 0.85,
zero_rate = 1/3,
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 ewma
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 number of sigmas at which to detect a mean shift. Sigma in this context refers to the estimated standard deviation of the EWMA statistic.
Default: 3
detects a EWMA shift of three sigmas.
Required "memory" parameter in the range (0, 1]. Lower values assign more weight to prior measurements. A value of 1 indicates no memory and only considers the current measurement.
Default: 0.85
assigns higher weight to the current measurement with
"light memory" of prior measurements.
Required maximum proportion of event
s in df
(constrained by eval_period
) containing zeroes for this algorithm to
run. Because EWMA 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.
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
: EWMA on mds_ts data
default
: EWMA on general data
Function ewma()
is an implementation of the EWMA
method originally proposed by S.W. Roberts based on the normal distribution.
EWMA is part of the family of statistical process control tests.
S. W. Roberts (1959) Control Chart Tests Based on Geometric Moving Averages, Technometrics, 1:3, 239-250, DOI: 10.1080/00401706.1959.10489860
# NOT RUN {
# Basic Example
data <- data.frame(time=c(1:25), event=as.integer(stats::rnorm(25, 100, 25)))
a1 <- ewma(data)
# Example using an mds_ts object
a2 <- ewma(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 <- ewma(data, c(Rate="rate"))
# }
Run the code above in your browser using DataLab