ewma: EWMA chart

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/ewma.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
ewma(data, sizes, center, std.dev, lambda = 0.2, nsigmas = 3, 
     data.name, labels, newdata, newsizes, newlabels, 
     plot = TRUE, ...)

## S3 method for class 'ewma.qcc'
print(x, ...)

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

## S3 method for class 'ewma.qcc'
plot(x, add.stats = TRUE, chart.all = TRUE, 
     label.limits = c("LCL", "UCL"), title, xlab, ylab, ylim, 
     axes.las = 0, digits = getOption("digits"),
     restore.par = TRUE, ...)

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.

data.name

a string specifying the name of the variable which appears on the plots. If not provided is taken from the object given as data.

labels

a character vector of labels for each group.

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.

newlabels

a character vector of labels for each new group defined in the argument newdata.

plot

logical. If TRUE an EWMA chart is plotted.

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.

label.limits

a character vector specifying the labels for control limits.

title

a string giving the label for the main title.

xlab

a string giving the label for the x-axis.

ylab

a string giving the label for the y-axis.

ylim

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

axes.las

numeric in {0,1,2,3} specifying the style of axis labels. See help(par).

digits

the number of significant digits to use.

restore.par

a logical value indicating whether the previous par settings must be restored. If you need to add points, lines, etc. to a control chart set this to FALSE.

object

an object of class 'ewma.qcc'.

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. (2005) Introduction to Statistical Quality Control, 5th ed. New York: John Wiley & Sons.
Ryan, T. P. (2000), Statistical Methods for Quality Improvement, 2nd 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
##
## Grouped-data
##
data(pistonrings)
attach(pistonrings)
diameter <- qcc.groups(diameter, sample)

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

q <-  ewma(diameter[1:25,], lambda=0.2, nsigmas=2.7, newdata=diameter[26:40,], plot = FALSE) 
summary(q)
plot(q)

detach(pistonrings)

##
## Individual observations: viscosity data (Montgomery, pag. 242)
##
x <- c(33.75, 33.05, 34, 33.81, 33.46, 34.02, 33.68, 
33.27, 33.49, 33.20, 33.62, 33.00, 33.54, 33.12, 33.84)
q <-  ewma(x, lambda=0.2, nsigmas=2.7)
summary(q)

Example output

Package 'qcc' version 2.7
Type 'citation("qcc")' for citing this R package in publications.

Call:
ewma(data = diameter[1:25, ], lambda = 0.2, nsigmas = 3)

ewma chart for diameter[1:25, ] 

Summary of group statistics:
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
73.99020 73.99820 74.00080 74.00118 74.00420 74.01020 

Group sample size:  5
Number of groups:  25
Center of group statistics:  74.00118
Standard deviation:  0.009785039 

Smoothing parameter: 0.2 
Control limits:
         LCL      UCL
1   73.99855 74.00380
2   73.99781 74.00454
...                  
25  73.99680 74.00555

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

ewma chart for diameter[1:25, ] 

Summary of group statistics:
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
73.99020 73.99820 74.00080 74.00118 74.00420 74.01020 

Group sample size:  5
Number of groups:  25
Center of group statistics:  74.00118
Standard deviation:  0.009785039 

Summary of group statistics in diameter[26:40, ]:
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
73.99220 74.00290 74.00720 74.00765 74.01270 74.02340 

Group sample size:  5
Number of groups:  15 

Smoothing parameter: 0.2 
Control limits:
         LCL      UCL
1   73.99881 74.00354
2   73.99815 74.00420
...                  
40  73.99724 74.00511

Call:
ewma(data = x, lambda = 0.2, nsigmas = 2.7)

ewma chart for x 

Summary of group statistics:
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
33.00000 33.23500 33.54000 33.52333 33.78000 34.02000 

Group sample size:  1
Number of groups:  15
Center of group statistics:  33.52333
Standard deviation:  0.4261651 

Smoothing parameter: 0.2 
Control limits:
           LCL      UCL
[1,]  33.29320 33.75346
[2,]  33.22862 33.81804
...                    
[15,] 33.14002 33.90664

qcc documentation built on May 2, 2019, 9:15 a.m.