ewma: EWMA chart

View source: R/ewma.R

ewmaR Documentation

EWMA chart

Description

Create an object of class 'ewma.qcc' to compute and draw an Exponential Weighted Moving Average (EWMA) chart for statistical quality control.

Usage

ewma(data, sizes, center, std.dev, 
     lambda = 0.2, nsigmas = 3, 
     newdata, newsizes, ...)

## S3 method for class 'ewma.qcc'
print(x, digits = getOption("digits"), ...)

## S3 method for class 'ewma.qcc'
plot(x, 
     xtime, 
     add.stats = qcc.options("add.stats"), 
     chart.all = qcc.options("chart.all"), 
     fill = qcc.options("fill"),
     label.center = "CL",
     label.limits = c("LCL", "UCL"), 
     title, xlab, ylab, xlim, ylim, 
     digits = getOption("digits"), ...)

Arguments

data

a data frame, a matrix or a vector containing observed data for the variable to chart. Each row of a data frame or a matrix, and each value of a vector, refers to a sample or ”rationale group”.

sizes

a value or a vector of values specifying the sample sizes associated with each group. If not provided the sample sizes are obtained counting the non-NA elements of each row of a data frame or a matrix; sample sizes are set all equal to one if data is a vector.

center

a value specifying the center of group statistics or target.

std.dev

a value or an available method specifying the within-group standard deviation(s) of the process.
Several methods are available for estimating the standard deviation. See sd.xbar and sd.xbar.one for, respectively, the grouped data case and the individual observations case.

lambda

the smoothing parameter 0 <= lambda <= 1

nsigmas

a numeric value specifying the number of sigmas to use for computing control limits.

newdata

a data frame, matrix or vector, as for the data argument, providing further data to plot but not included in the computations.

newsizes

a vector as for the sizes argument providing further data sizes to plot but not included in the computations.

xtime

a vector of date-time values as returned by Sys.time and Sys.Date. If provided it is used for x-axis so it must be of the same length as the statistic charted.

add.stats

a logical value indicating whether statistics and other information should be printed at the bottom of the chart.

chart.all

a logical value indicating whether both statistics for data and for newdata (if given) should be plotted.

fill

a logical value specifying if the in-control area should be filled with the color specified in qcc.options("zones")$fill.

label.center

a character specifying the label for center line.

label.limits

a character vector specifying the labels for control limits.

title

a character string specifying the main title. Set title = NULL to remove the title.

xlab, ylab

a string giving the label for the x-axis and the y-axis.

xlim, ylim

a numeric vector specifying the limits for the x-axis and the y-axis.

digits

the number of significant digits to use.

x

an object of class 'ewma.qcc'.

...

additional arguments to be passed to the generic function.

Details

EWMA chart smooths a series of data based on a moving average with weights which decay exponentially. Useful to detect small and permanent variation on the mean of the process.

Value

Returns an object of class 'ewma.qcc'.

Author(s)

Luca Scrucca

References

Mason, R.L. and Young, J.C. (2002) Multivariate Statistical Process Control with Industrial Applications, SIAM.

Montgomery, D.C. (2013) Introduction to Statistical Quality Control, 7th ed. New York: John Wiley & Sons.

Ryan, T. P. (2011), Statistical Methods for Quality Improvement, 3rd ed. New York: John Wiley & Sons, Inc.

Scrucca, L. (2004). qcc: an R package for quality control charting and statistical process control. R News 4/1, 11-17.

Wetherill, G.B. and Brown, D.W. (1991) Statistical Process Control. New York: Chapman & Hall.

See Also

qcc, ewmaSmooth, cusum

Examples

##
## Grouped-data
##
data(pistonrings)
diameter <- qccGroups(data = pistonrings, diameter, sample)

q = ewma(diameter[1:25,], lambda=0.2, nsigmas=3)
summary(q)
plot(q)

ewma(diameter[1:25,], lambda=0.2, nsigmas=2.7, newdata=diameter[26:40,]) 

##
## Individual observations
##
data(viscosity)
with(viscosity, 
     ewma(viscosity[trial], lambda = 0.2, nsigmas = 2.7,
          newdata = viscosity[!trial]))

luca-scr/qcc documentation built on Feb. 25, 2023, 3:33 p.m.