shewhart and
cusum.
qcc(data, type, std.dev=<<see below>>, sizes=2,
labels=<<see below>>)
"qcc" object is being created.
If
data is a vector, each element corresponds to a different group center and both
std.dev and
sizes are required.
If
data is a matrix or data frame, each row corresponds to a different group and the number of columns is the sample size for all groups.
If the sample sizes are unequal,
data must be a list in which each component corresponds to a different group.
type is one of the following character strings, built-in functions are used to compute the group summary statistics:
"xbar",
"s",
"R",
"p",
"np",
"u",
"c",
"ma",
"ms",
"mR", and
"ewma".
See the
stats.xbar help file for more details on the built-in functions.
If
type is the name of a function, it is used to compute the group summary statistics and a central value for the group summary statistics; in this case, the
std.dev argument must also be given.
See the DETAILS section below.
std.dev is of length 1, it is taken as the within-group standard deviation pooled over all the groups.
If it is of length greater than 1, it must have length equal to the number of groups, in which case it contains the individual within-group standard deviations in the same order as the groups in
data.
If
std.dev is a function, it is used to compute the within-group standard deviation from
data.
If
std.dev is missing, the default method for
type is used.
This argument is required if
type is given as a function. See the DETAILS section below.
data argument, rather than the original data set.
This argument is necessary if
type is
"p",
"np", or
"u".
If
length(sizes)==1, its value is assumed to be the size of all the groups. By default,
sizes=2.
data argument:
it is the
"names" attribute for a vector or list, the first component of the
"dimnames" attribute for a matrix, or the
"row.names" attribute of a data frame.
If the appropriate attribute is
NULL, the default for
labels is the integers 1 through
n, where
n is the number of groups.
"qcc" containing the following components:
"names" attribute equal to
labels.
statistics, computed as specified by
type.
type.
data.
The
data argument provides the data for computing
statistics,
center, and
std.dev.
It can also contain summary statistics for the data provided that both
std.dev and
sizes are also given.
The examples below show the different forms that
data can take.
Missing values (
NAs) must be removed from
data prior to calling
qcc.
The
type argument specifies the kind of control chart wanted. If
type is a character string, it must be one of those in first column of the table below. The common name for the corresponding chart is given in the second column.
type common name ---- --------------------------- "xbar" x Bar s Chart "s" s Chart "R" R or Range Chart "p" p Chart for Defectives "np" np Chart for Defectives "u" u Chart for Nonconformities "c" c Chart for Nonconformities "ma" Moving Average Chart "ms" Moving Standard Deviation Chart "mR" Moving Range Chart "ewma" Exponentially Weighted Moving Average ChartAppropriate default functions are used to compute
statistics,
center and
std.dev for each of the types above; these are specified in the next table.
The names of the default functions that do the computations are formed by pasting together either
"stats" (for
statistics and
center) or
"sd" (for
std.dev), a period, and the value of
type.
Thus, the summary statistics and center for an xbar chart are computed by
stats.xbar and the within-group standard deviation is computed by
sd.xbar.
'std.dev' sample size
type statistic is based on can be
------ -------------- --------------- -------------
"xbar" mean var. within equal/unequal
"s" std dev within var. within equal/unequal
"R" range var. within equal/unequal
"p" prop. defective prop. defective equal/unequal
"np" num. defective prop. defective equal/unequal
"c" nonconformities nonconformities equal (1)
"u" nonconformities nonconformities equal/unequal
"ma" moving average moving sd/range window based
"ms" moving std.dev moving sd/range window based
"mR" moving range moving sd/range window based
"ewma" exp. weighted moving sd/range window based
moving average
For more information on the built-in functions for computing group summary statistics and within-group standard deviations, see the help files. For example, to obtain information on how group summary statistics and within-group standard deviations are computed for the xbar chart, see
help(stats.xbar) and
help(sd.xbar), respectively.
If
type is a function name, it must return a list with two components named
statistics and
center that correspond to the components of the return value with the same name. In this case,
std.dev must also be given.
The
std.dev argument may be given as a numeric vector or function.
If
std.dev is a function, it is assumed to return an estimate of the within-group standard deviation suitable for computing the control limits or decision boundaries of the charts produced by
shewhart or
cusum.
If you specify your own function for
std.dev, you may not give summary statistics as
data for the
"xbar",
"s", or
"R" charts.
Montgomery, D.C. (1985). Statistical Quality Control. New York: John Wiley & Sons.
Ryan, T.P. (1989). Statistical Methods For Quality Improvement. New York: John Wiley & Sons.
Wetherill, G.B. and Brown, D.W. (1991). Statistical Process Control. New York: Chapman and Hall.
# ewma object.
qcc(rnorm(50), type="ewma")
# xbar object for matrix data.
qcc(matrix(rnorm(100), ncol=5), type="xbar")
# xbar object for vector data.
# The data vector holds the group centers, the within-group
# standard deviation is 1 for all groups, and the size of
# all groups is 10.
qcc(rnorm(100), std.dev=1, sizes=10, type="xbar")
# Create some sample data.
x <- cbind(c(1,2,3), c(1.1, 2.1, 3.1))
# xbar charts using both raw and summary data.
# The statistic of interest is the mean.
shewhart(qcc(x, type="xbar"))
shewhart(qcc(rowMeans(x), sizes=numCols(x),
std.dev=sqrt(rowVars(x)), type="xbar"))
# s charts using both raw and summary data.
# The statistic of interest is the standard deviation.
shewhart(qcc(x, type="s"))
shewhart(qcc(sqrt(rowVars(x)), sizes=numCols(x),
std.dev=sqrt(rowVars(x)), type="s"))
# R charts using both raw and summary data.
# The statistic of interest is the range.
shewhart(qcc(x, type="R"))
shewhart(qcc(apply(x, 1, function(x) diff(range(x))),
sizes=numCols(x), std.dev=sqrt(rowVars(x)), type="R"))