Within Group Standard Deviation for Control Charts

DESCRIPTION:
Computes the within group standard deviation for qcc. Different functions are available for the different types of control charts.

USAGE:
sd.xbar(data, sizes, sd = NULL, equal.sd = T)
sd.s(data, sizes, sd = NULL, equal.sd = T)
sd.R(data, sizes, sd = NULL, equal.sd = T)
sd.p(data, sizes)
sd.np(data, sizes)
sd.c(data, sizes)
sd.u(data, sizes)

REQUIRED ARGUMENTS:
data:
the data for computing the within group standard deviation. For xbar, s and R charts, data may be a matrix or list. For p, np, c, and u charts, data must be a vector or matrix with one column.
sizes:
vector of the number of observations in each group for xbar, s, and R charts. For p, np, and u charts, sizes corresponds to the number of units examined. For xbar, s, and R charts, sizes is optional. For p, np, and u charts, sizes is required. For the c chart sizes is assumed equal to 1.

OPTIONAL ARGUMENTS:
sd:
optional vector of individual group standard deviations.
equal.sd:
a logical indicating whether the within group standard deviations are assumed equal. The default is TRUE. This argument is currently only available for sd.xbar, sd.s and sd.R.


VALUE:
All these functions return a numeric value estimating the overall within group standard deviation.

DETAILS:
These functions are important to computing the std.dev component of a "qcc" object in preparation to plotting a Shewhart or a cusum quality control chart. Missing values (NA) must be removed prior to using these functions.

The argument equal.sd for "xbar", "s", and "R" charts is built in for added user control. It is not, however, controllable from the argument list to qcc. Consequently, you can either use sd.xbar, sd.s. or sd.R on your data, setting equal.sd = F, and passing the resulting value as the std.dev argument to qcc or make your own copy of these two functions with the default setting changed. References for the two different methods for computing the standard deviation for xbar and s charts are Burr(1969, 1976).

The value for std.dev for each type of chart are computed as follows:

"xbar"

Define c4 <- function(n) (sqrt(2/(n - 1)) * gamma(n/2))/gamma((n - 1)/2) var.df <- sum(sizes - 1) and var.within as the vector of within group variances.

If equal.sd = TRUE std.dev <- sqrt(sum((sizes - 1) * var.within)/var.df) std.dev <- std.dev/c4(var.df + 1) If equal.sd = FALSE g <- c4(sizes)/(1 - c4(sizes)^2) h <- g * c4(sizes) std.dev <- sum(g * sqrt(var.within))/sum(h)

"s" std.dev is computed in the same way it is for an "xbar" chart.

"R" std.dev is computed in the same way it is for an "xbar" chart.

"p" pbar <- sum(sizes * data)/sum(sizes) std.dev <- sqrt(pbar * (1 - pbar))

"np" pbar <- sum(data)/sum(sizes) std.dev <- sqrt(sizes * pbar * (1 - pbar))

"c" std.dev <- sqrt(mean(data)) sizes is assumed equal to 1 (one).

"u" std.dev <- sqrt(sum(sizes * data)/sum(sizes))

You may write your own version of any one of these functions and pass the name of your function to the std.dev argument of qcc. You can use these functions as templates. Be sure, however, to include either a sizes argument or the ... argument, since qcc will pass in sizes in the call to your function.


REFERENCES:
Burr, I. W. (1969). Control charts for measurements with varying sample sizes. Journal of Quality Technology 1:163-167.

Burr, I. W. (1976). Statistical Quality Control Methods, Volume 16. New York: Marcel Decker, Inc.


SEE ALSO:
qcc , shewhart , cusum