| Title: | Improved Quality Control Charts |
|---|---|
| Description: | Implements improved statistical process control charts with exact, Cornish-Fisher corrected, standardized, and simulation-based probability limits. Methods include univariate attribute and variable charts, double-sampling charts for rare nonconformities, Hotelling T-squared charts, and generalized variance charts for multivariate process variability. Numerical functions for limits, false-alarm risk, average run length, and average sample size are separated from plotting interfaces to support reproducible statistical validation. |
| Authors: | Flavio Barros [aut, cre], Emanuel Barbosa [ctb], Elias Goncalves [ctb], Daniela Recchia [ctb] |
| Maintainer: | Flavio Barros <[email protected]> |
| License: | GPL-2 |
| Version: | 0.8.0 |
| Built: | 2026-10-14 08:53:56 UTC |
| Source: | https://github.com/flaviobarros/iqcc |
IQCC implements statistical process control charts with exact, Cornish-Fisher corrected, standardized, or simulation-based probability limits. The package covers univariate variable and attribute charts, double-sampling np charts for rare nonconformities, Hotelling T-squared charts, and generalized variance charts for multivariate variability.
Numerical functions for limits, false-alarm risk, average run length, and average sample size are exposed separately from plotting functions so that calculations can be inspected, tested, and reused in simulation studies.
Report bugs at https://github.com/flaviobarros/IQCC/issues
Maintainer: Flavio Barros [email protected]
Other contributors:
Emanuel Barbosa [contributor]
Elias Goncalves [contributor]
Daniela Recchia [contributor]
pchart_limits, uchart_limits,
dsnp_limits, gv_limits,
cchart.R, cchart.DSnp,
cchart.GV
Add a new Phase II point to an existing Hotelling T² chart. Computes the T²
statistic via T2.2 and plots it. Use after
cchart.T2.2 to build the chart incrementally.
add.data(datum2, estat, T2II, n, j, m = NULL)add.data(datum2, estat, T2II, n, j, m = NULL)
datum2 |
New Phase II data (vector for |
estat |
Phase I statistics (list from |
T2II |
Previous T² vector (updated in calling code). |
n |
Subgroup size. Use |
j |
Index of this new sample. |
m |
Optional. Number of Phase I samples (needed if Phase I data is shown). |
To use this function it is necessary to have the output given by the
function T2.2. At every step you should enter the new data set.
Invisibly, the new T² statistic.
Daniela R. Recchia, Emanuel P. Barbosa
mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) datum <- data.1(20, 10, mu, Sigma) estat <- stats(datum, 20, 10, 2) datum2 <- data.2(estat, 10, p = 2) T2II <- T2.2(datum2, estat, 10) #Not showing the phase I data set. cchart.T2.2(T2II, 20, 10, 1, 25, 2) datum3 <- data.2(estat, 10, p = 2) add.data(datum3, estat, T2II, 10, 2) #Showing the phase I data set. cchart.T2.2(T2II, 20, 10, 1, 25, 2, datum = datum) datum3 <- data.2(estat, 10, p = 2) add.data(datum3, estat, T2II, 10, 2, 20) #Example with individual observations datum <- data.1(50, 1, mu, Sigma) estat <- stats(datum, 50, 1, 2) datum2 <- data.2(estat, 1, p = 2) T2II <- T2.2(datum2, estat, 1) #Not showing the phase I data set. cchart.T2.2(T2II, 50, 1, 1, 25, 2) datum3 <- data.2(estat, 1, p = 2) add.data(datum3, estat, T2II, 1, 2) #Showing the phase I data set. cchart.T2.2(T2II, 50, 1, 1, 25, 2, datum = datum) datum3 <- data.2(estat, 1, p = 2) add.data(datum3, estat, T2II, 1, 2, 50)mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) datum <- data.1(20, 10, mu, Sigma) estat <- stats(datum, 20, 10, 2) datum2 <- data.2(estat, 10, p = 2) T2II <- T2.2(datum2, estat, 10) #Not showing the phase I data set. cchart.T2.2(T2II, 20, 10, 1, 25, 2) datum3 <- data.2(estat, 10, p = 2) add.data(datum3, estat, T2II, 10, 2) #Showing the phase I data set. cchart.T2.2(T2II, 20, 10, 1, 25, 2, datum = datum) datum3 <- data.2(estat, 10, p = 2) add.data(datum3, estat, T2II, 10, 2, 20) #Example with individual observations datum <- data.1(50, 1, mu, Sigma) estat <- stats(datum, 50, 1, 2) datum2 <- data.2(estat, 1, p = 2) T2II <- T2.2(datum2, estat, 1) #Not showing the phase I data set. cchart.T2.2(T2II, 50, 1, 1, 25, 2) datum3 <- data.2(estat, 1, p = 2) add.data(datum3, estat, T2II, 1, 2) #Showing the phase I data set. cchart.T2.2(T2II, 50, 1, 1, 25, 2, datum = datum) datum3 <- data.2(estat, 1, p = 2) add.data(datum3, estat, T2II, 1, 2, 50)
Compute the actual in-control false-alarm probability of the conventional
three-sigma range chart under the exact distribution of the relative range
statistic .
alpha.risk(n)alpha.risk(n)
n |
Numeric vector of integer subgroup sizes, each at least 2. |
The conventional limits are
and
Because the relative range is not normally distributed for the small subgroup sizes commonly used in practice, the resulting false-alarm probability can be substantially larger than 0.0027.
A numeric vector with the same length and order as n.
Element is
where is evaluated with stats::ptukey() using infinite
denominator degrees of freedom.
The result is the probability that an in-control subgroup falls below the conventional lower limit or above the conventional upper limit. It is not the nominal value requested by an exact probability-limit design.
An error is raised when any subgroup size is smaller than 2. The underlying
d2() and d3() calculations also require finite admissible
subgroup sizes.
Daniela R. Recchia, Emanuel P. Barbosa
Barbosa, E. P., Gneri, M. A., and Meneguetti, A. (2013). Range control charts revisited: Simpler Tippett-like formulae, its practical implementation, and the study of false alarm. Communications in Statistics - Simulation and Computation, 42(2), 247–262. doi:10.1080/03610918.2011.639967.
cchart.R, d2, d3,
table.qtukey
alpha.risk(5) alpha.risk(c(3, 5, 10, 15))alpha.risk(5) alpha.risk(c(3, 5, 10, 15))
25 subgroups with sample sizes (ni), number of nonconforming units
(Di), and proportion nonconforming (pi). This data set is used
for -chart examples.
A data frame with 25 observations on the following 4 variables.
Index.
The sample Size.
Number of non-conforming units per sample.
Proportion of non-conforming units per sample.
Montgomery, D. C. (2009). Introduction to Statistical Quality Control, 6th ed. Wiley.
data(binomdata)data(binomdata)
Compute the constant , which corrects the bias of the sample
standard deviation as an estimator of the process standard deviation
under normality.
c4(n)c4(n)
n |
Integer sample size, at least 2. Can be a vector. |
The constant is given by
so that . Multiplying by
produces an unbiased estimator of .
Numeric vector of values, the same length as n.
Daniela R. Recchia, Emanuel P. Barbosa
Montgomery, D. C. (2009). Introduction to Statistical Quality Control, 6th ed. Wiley.
d2, d3, table.const
c4(5) c4(2:15)c4(5) c4(2:15)
Build and optionally plot a double-sampling np (DS-np) control chart for monitoring the nonconforming proportion in high-quality processes.
cchart.DSnp( x1, n1, n2, p0, x2 = NULL, wl = NULL, ucl1 = NULL, ucl2 = NULL, limits = NULL, alpha = 0.0027, p1 = NULL, plot = TRUE, curtailed = FALSE, ... )cchart.DSnp( x1, n1, n2, p0, x2 = NULL, wl = NULL, ucl1 = NULL, ucl2 = NULL, limits = NULL, alpha = 0.0027, p1 = NULL, plot = TRUE, curtailed = FALSE, ... )
x1 |
Integer vector of nonconforming counts from the first sample. |
n1 |
First-stage sample size (positive integer). |
n2 |
Second-stage sample size (positive integer). |
p0 |
In-control nonconforming proportion. |
x2 |
Optional integer vector of nonconforming counts from the second
sample. Must have the same length as |
wl |
Fractional warning limit. Must be less than |
ucl1 |
Fractional upper control limit for the first stage. Must be
greater than |
ucl2 |
Fractional upper control limit for the combined samples. |
limits |
Optional object returned by |
alpha |
Maximum desired false alarm probability at |
p1 |
Optional out-of-control proportion. When provided, performance
metrics at |
plot |
Logical. If |
curtailed |
Logical. If |
... |
Additional arguments passed to |
The DS-np chart uses two sampling stages. At the first stage, a sample of
size n1 is inspected. If the count x1 is at or below the
warning limit, the process is accepted. If x1 exceeds the first
upper control limit, the process signals out-of-control immediately.
Otherwise, a second sample of size n2 is inspected and the combined
count x1 + x2 is compared to the second upper control limit.
Limits can be supplied manually via wl, ucl1, and
ucl2, obtained from a pre-computed dsnp_limits() object via
the limits argument, or computed automatically inside the function
when neither is provided.
The fractional limits are converted to integer thresholds using the convention from the numerical core functions:
wl_accept = floor(wl): accept at first stage if
x1 <= wl_accept.
ucl1_reject = floor(ucl1) + 1: signal at first stage if
x1 >= ucl1_reject.
ucl2_accept = floor(ucl2): accept at second stage if
x1 + x2 <= ucl2_accept.
An object of class "cchart.DSnp", which is a list with the
following elements:
The matched call.
A data.frame with columns index, x1,
x2, total, stage, and signal.
A list with the fractional and integer thresholds:
wl, ucl1, ucl2, wl_accept,
ucl1_reject, ucl2_accept.
A list with n1, n2, p0,
alpha, p1, and curtailed.
A list with in-control performance metrics
(arl0, ass0, p_signal0), and optionally
out-of-control metrics (arl1, ass1,
p_signal1) when p1 is provided.
Daniela R. Recchia, Emanuel P. Barbosa
Joekes, S., Smrekar, M. and Barbosa, E. (2015). Extending a double sampling control chart for non-conforming proportion in high quality processes to the case of small samples. Statistical Methodology.
dsnp_limits, dsnp_prob_accept,
dsnp_arl, dsnp_ass
# Small example with manual limits x1 <- c(0, 1, 2, 3, 1, 0, 2, 4, 1, 0) x2 <- c(NA, NA, 2, NA, NA, NA, 3, NA, NA, NA) res <- cchart.DSnp(x1, n1 = 10, n2 = 20, p0 = 0.05, x2 = x2, wl = 1.5, ucl1 = 2.5, ucl2 = 4.5, plot = FALSE) res$limits res$performance# Small example with manual limits x1 <- c(0, 1, 2, 3, 1, 0, 2, 4, 1, 0) x2 <- c(NA, NA, 2, NA, NA, NA, 3, NA, NA, NA) res <- cchart.DSnp(x1, n1 = 10, n2 = 20, p0 = 0.05, x2 = x2, wl = 1.5, ucl1 = 2.5, ucl2 = 4.5, plot = FALSE) res$limits res$performance
Construct and optionally plot a Shewhart-type chart for multivariate process
variability based on the generalized variance statistic , the
determinant of each subgroup sample covariance matrix.
cchart.GV( x1, size = NULL, x2 = NULL, Sigma = NULL, alpha = 0.0027, type = c("normal", "cf", "exact", "simulation"), side = c("upper", "two.sided"), cf_order = 1, nsim = 1e+05, seed = NULL, plot = TRUE, ... ) ## S3 method for class 'cchart.GV' plot(x, ...)cchart.GV( x1, size = NULL, x2 = NULL, Sigma = NULL, alpha = 0.0027, type = c("normal", "cf", "exact", "simulation"), side = c("upper", "two.sided"), cf_order = 1, nsim = 1e+05, seed = NULL, plot = TRUE, ... ) ## S3 method for class 'cchart.GV' plot(x, ...)
x1 |
Phase I subgroup data in any format accepted by
|
size |
Positive integer subgroup size when |
x2 |
Optional Phase II subgroup data in a format accepted by
|
Sigma |
Optional finite symmetric positive-definite
where |
alpha |
Nominal probability of a false alarm per subgroup, strictly
between 0 and 1. For |
type |
Character string selecting the limit calculation:
Partial matching is not used. |
side |
Either |
cf_order |
Integer 1 or 2. Order 1 uses the skewness correction. Order
2 additionally uses excess kurtosis and the squared-skewness term. It is
used only when |
nsim |
Integer number of Monte Carlo draws, at least 1000. It is used
by |
seed |
|
plot |
Logical scalar. If |
... |
Additional graphical arguments passed to
|
x |
An object of class |
Phase I subgroups define the chart design and, unless Sigma is
supplied, estimate the in-control generalized variance. Optional Phase II
subgroups are then evaluated using the same subgroup size, process
dimension, and fixed control limits.
Each subgroup must contain finite observations on at least two variables,
and the subgroup size must exceed the process dimension. When
Sigma = NULL, the average Phase I covariance matrix must itself be
positive definite. The control-line center is the exact in-control mean of
, not generally .
plot.cchart.GV() displays subgroup generalized variances, the center
line, lower and upper limits, a vertical separator before Phase II, and
solid points at signaled subgroups. The plot method returns its input
invisibly.
An object of class "cchart.GV", a list with components:
statisticsGeneralized variances for all Phase I followed by all Phase II subgroups.
phase1, phase2
Integer indices identifying the two
phases in statistics.
limitsThe complete list returned by gv_limits().
out.of.controlIndices for which
statistics < lcl or statistics > ucl. Equality to a limit
does not signal.
SbarThe average Phase I covariance matrix when
Sigma is estimated, otherwise NULL.
SigmaThe supplied in-control covariance matrix, or
NULL when the determinant is estimated from Phase I.
b3The determinant bias-correction factor when Phase I
estimation is used, otherwise NA_real_.
n, p
Subgroup size and process dimension.
callThe matched function call.
For plot.cchart.GV(), x invisibly.
Phase I data are used both as historical plotted points and, when
Sigma is absent, to estimate the in-control determinant. Phase II
data do not alter the estimate or the limits. For a strict prospective
chart with known parameters, supply Sigma.
When type = "simulation", nsim and seed are passed to
gv_limits(). A supplied seed makes the result reproducible and the
caller's existing random-number state is restored.
Errors are raised for invalid subgroup representations, unequal subgroup
dimensions, non-finite observations, , an invalid or
non-positive-definite Sigma, a singular Phase I average covariance
matrix, and any unsupported limit configuration documented in
gv_limits().
Barbosa, E. P., Gneri, M. A., and Meneguetti, A. Improving Shewhart-type Generalized Variance Control Charts for Multivariate Process Variability Monitoring using Cornish-Fisher Quantile Correction, Meijer-G Function and Other Tools. Research report.
Alt, F. B. (1984). Multivariate quality control. In Johnson, N. L. and Kotz, S. (eds.), Encyclopedia of Statistical Sciences, Vol. 6, 110–122. Wiley.
gv_stat, gv_limits,
gv_alpha_risk, print.cchart.GV
set.seed(123) phase1 <- array(rnorm(6 * 8 * 2), dim = c(6, 8, 2)) # Known in-control covariance, exact dimension-two limits. chart <- cchart.GV( phase1, Sigma = diag(2), type = "exact", plot = FALSE ) chart$limits[c("lcl", "center", "ucl")] summary(chart) # Estimate |Sigma| from Phase I and evaluate two Phase II subgroups. phase2 <- array(rnorm(2 * 8 * 2), dim = c(2, 8, 2)) estimated <- cchart.GV( phase1, x2 = phase2, type = "cf", plot = FALSE ) estimated$phase2set.seed(123) phase1 <- array(rnorm(6 * 8 * 2), dim = c(6, 8, 2)) # Known in-control covariance, exact dimension-two limits. chart <- cchart.GV( phase1, Sigma = diag(2), type = "exact", plot = FALSE ) chart$limits[c("lcl", "center", "ucl")] summary(chart) # Estimate |Sigma| from Phase I and evaluate two Phase II subgroups. phase2 <- array(rnorm(2 * 8 * 2), dim = c(2, 8, 2)) estimated <- cchart.GV( phase1, x2 = phase2, type = "cf", plot = FALSE ) estimated$phase2
Build normal, Cornish-Fisher corrected, or standardized p charts.
cchart.p( x1 = NULL, n1 = NULL, type = "norm", p1 = NULL, x2 = NULL, n2 = NULL, phat = NULL, p2 = NULL, alpha = ALPHA )cchart.p( x1 = NULL, n1 = NULL, type = "norm", p1 = NULL, x2 = NULL, n2 = NULL, phat = NULL, p2 = NULL, alpha = ALPHA )
x1 |
Phase I nonconforming counts. |
n1 |
Phase I sample size or vector of sample sizes. |
type |
Chart type. Accepted values are |
p1 |
Phase I subgroup proportions. Used instead of |
x2 |
Phase II nonconforming counts. |
n2 |
Phase II sample size or vector of sample sizes. |
phat |
Known or previously estimated in-control proportion. |
p2 |
Phase II subgroup proportions. Used instead of |
alpha |
Nominal two-sided false alarm probability. Defaults to 0.0027. |
For a Phase I chart, n1 and exactly one of x1 or p1
must be supplied. For a Phase II chart, n2 and exactly one of
x2 or p2 must be supplied, together with Phase I information
or a known phat.
When sample sizes vary, the process proportion is estimated by the pooled
binomial estimator, , rather than by the unweighted
mean of subgroup proportions. The plotting wrapper uses two-sided limits;
use pchart_limits() directly for one-sided upper limits.
Invisibly returns the qcc object used to draw the chart.
Daniela R. Recchia, Emanuel P. Barbosa
Montgomery, D. C. (2008). Introduction to Statistical Quality Control. Wiley.
Joekes, S. and Barbosa, E. P. (2013). An improved attribute control chart for monitoring non-conforming proportion in high quality processes. Control Engineering Practice, 21, 407–412. doi:10.1016/j.conengprac.2012.12.005.
data(binomdata) cchart.p(x1 = binomdata$Di[1:12], n1 = binomdata$ni[1:12]) cchart.p(x1 = binomdata$Di[1:12], n1 = binomdata$ni[1:12], type = "cf2", x2 = binomdata$Di[13:25], n2 = binomdata$ni[13:25]) cchart.p(type = "standardized", p2 = binomdata$Di[13:25] / binomdata$ni[13:25], n2 = binomdata$ni[13:25], phat = 0.1115833)data(binomdata) cchart.p(x1 = binomdata$Di[1:12], n1 = binomdata$ni[1:12]) cchart.p(x1 = binomdata$Di[1:12], n1 = binomdata$ni[1:12], type = "cf2", x2 = binomdata$Di[13:25], n2 = binomdata$ni[13:25]) cchart.p(type = "standardized", p2 = binomdata$Di[13:25] / binomdata$ni[13:25], n2 = binomdata$ni[13:25], phat = 0.1115833)
Build a control chart for subgroup ranges using either the conventional
three-sigma approximation or exact probability limits from the distribution
of the relative range .
cchart.R(x, n, type = c("norm", "tukey"), y = NULL)cchart.R(x, n, type = c("norm", "tukey"), y = NULL)
x |
Phase II subgroup data accepted by |
n |
Integer subgroup size, at least 2. It is used to evaluate the actual false-alarm probability of the conventional chart and to obtain Tukey relative-range quantiles for the exact chart. |
type |
Either |
y |
Phase I subgroup data used to estimate |
The numerical limits are computed by r_shewhart_limits (for
type = "norm") or r_exact_limits (for type =
"tukey"), keeping the plotting wrapper separate from the pure limit
calculations.
For type = "norm", limits are delegated to the standard
qcc range-chart implementation. For type = "tukey", the
lower and upper limits are
and
where is estimated from y and the quantiles are
obtained with stats::qtukey().
Invisibly, the "qcc" object returned by qcc::qcc().
The function also draws the chart. For type = "norm", a message is
added below the plot showing the actual false-alarm probability returned by
alpha.risk(n).
The exact chart treats y as Phase I reference data and x as
the plotted monitoring data. The conventional chart uses the standard
estimation behavior of qcc::qcc() on x.
An error is raised for an unsupported type, for n < 2, or
when y is omitted for the exact chart. Additional data validation is
performed by qcc::qcc() and qcc::sd.R().
Daniela R. Recchia, Emanuel P. Barbosa
Barbosa, E. P., Gneri, M. A., and Meneguetti, A. (2013). Range control charts revisited: Simpler Tippett-like formulae, its practical implementation, and the study of false alarm. Communications in Statistics - Simulation and Computation, 42(2), 247–262. doi:10.1080/03610918.2011.639967.
r_shewhart_limits, r_exact_limits,
alpha.risk, cchart.S,
table.qtukey
data(pistonrings) conventional <- cchart.R(pistonrings[1:25, ], 5) exact <- cchart.R( pistonrings[26:40, ], 5, type = "tukey", y = pistonrings[1:25, ] )data(pistonrings) conventional <- cchart.R(pistonrings[1:25, ], 5) exact <- cchart.R( pistonrings[26:40, ], 5, type = "tukey", y = pistonrings[1:25, ] )
Build a control chart for subgroup standard deviations using either the
conventional Shewhart limits used historically by qcc or exact
probability limits derived from the chi-square distribution of the sample
variance. Numerical limits are delegated to s_shewhart_limits
and s_exact_limits.
cchart.S(x, type = c("n", "e"), m = NULL)cchart.S(x, type = c("n", "e"), m = NULL)
x |
Subgroup data accepted by |
type |
Either |
m |
Integer subgroup size, at least 2. It is required when
|
For exact limits, follows a chi-square distribution
with degrees of freedom under normality. The historical wrapper
estimates from x using qcc::sd.S() and supplies
that estimate to s_exact_limits(); these are therefore plug-in
probability limits.
For type = "n", the legacy qcc convention is deliberately preserved:
the center is the weighted mean of the observed subgroup standard deviations,
while is estimated separately by qcc::sd.S(). The
resulting standard error is . This differs
in finite Phase I samples from replacing the observed center by the
theoretical ; cchart.S() does not make that
replacement.
Invisibly, the "qcc" object returned by qcc::qcc().
The function also draws the chart.
The existing API has no separate Phase I argument. Both the chart center and
estimate are obtained from x; exact limits additionally
use the supplied historical design size m. Thus both normalized and
exact limits are plug-in limits when used through this wrapper.
An error is raised for an unsupported type or an invalid supplied
m. If exact limits are requested without m, the function
warns and falls back to the normalized chart. Additional data validation is
performed by qcc::qcc(), qcc::stats.S(), and
qcc::sd.S().
Daniela R. Recchia, Emanuel P. Barbosa
Montgomery, D. C. (2009). Introduction to Statistical Quality Control, 6th ed. Wiley.
s_shewhart_limits, s_exact_limits,
cchart.R, c4
data(softdrink) normalized <- cchart.S(softdrink, type = "n") exact <- cchart.S(softdrink, type = "e", m = 10)data(softdrink) normalized <- cchart.S(softdrink, type = "n") exact <- cchart.S(softdrink, type = "e", m = 10)
Build a Phase I T² control chart. For :
.
For :
.
The control limits are based on the beta and F distributions.
cchart.T2.1(T2, m, n, p)cchart.T2.1(T2, m, n, p)
T2 |
Numeric vector of T² statistics from |
m |
Number of subgroups in Phase I. |
n |
Subgroup size. Use |
p |
Number of variables (dimension). |
Draws the chart. Returns nothing.
Phase I retrospective analysis. All points are plotted simultaneously.
Stop if .
Daniela R. Recchia, Emanuel P. Barbosa
Montgomery, D.C., (2009). "Introduction to Statistical Quality Control". Chapter 11. Wiley.
mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) datum <- data.1(20, 10, mu, Sigma) estat <- stats(datum, 20, 10, 2) T2 <- T2.1(estat, 20, 10) # estat is a list with the auxiliary statistics. T2 is a matrix with the values of the T2 statistic. cchart.T2.1(T2, 20, 10, 2)mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) datum <- data.1(20, 10, mu, Sigma) estat <- stats(datum, 20, 10, 2) T2 <- T2.1(estat, 20, 10) # estat is a list with the auxiliary statistics. T2 is a matrix with the values of the T2 statistic. cchart.T2.1(T2, 20, 10, 2)
Build or update a Phase II T² chart. Can optionally display Phase I
reference data. Limits: For :
.
For :
.
cchart.T2.2(T2II, m, n, j, t, p, datum = NULL, stats = NULL, T2 = NULL)cchart.T2.2(T2II, m, n, j, t, p, datum = NULL, stats = NULL, T2 = NULL)
T2II |
Vector with Phase II T² values (from |
m |
Number of Phase I subgroups. |
n |
Subgroup size. |
j |
Index of the current Phase II sample (1-based). |
t |
Maximum x-axis limit (number of Phase II samples to show). |
p |
Number of variables. |
datum |
Optional. Phase I data array to display reference points. |
stats |
Optional. Phase I statistics to compute T² if not provided. |
T2 |
Optional. Pre-computed Phase I T² values. |
Draws the chart. Returns nothing.
Phase II monitoring. The vertical dashed line separates Phase I (left) from Phase II (right).
Daniela R. Recchia, Emanuel P. Barbosa
Montgomery, D.C., (2009). "Introduction to Statistical Quality Control". Chapter 11. Wiley.
mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) datum <- data.1(20, 10, mu, Sigma) estat <- stats(datum, 20, 10, 2) datum2 <- data.2(estat, 10, p = 2) T2II <- T2.2(datum2, estat, 10) # For the first sample j = 1. T2II is a vector with the value of the first T2 statistic. cchart.T2.2(T2II, 20, 10, 1, 25, 2) # Same of the above, but now showing the phase I data set. cchart.T2.2(T2II, 20, 10, 1, 25, 2, datum = datum) #Example with individual observations datum <- data.1(50, 1, mu, Sigma) estat <- stats(datum, 50, 1, 2) datum2 <- data.2(estat, 1, p = 2) T2II <- T2.2(datum2, estat, 1) # For the first sample j = 1. T2II is a vector with the value of the first T2 statistic. cchart.T2.2(T2II, 50, 1, 1, 25, 2) # Same of the above, but now showing the phase I data set. cchart.T2.2(T2II, 50, 1, 1, 25, 2, datum = datum)mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) datum <- data.1(20, 10, mu, Sigma) estat <- stats(datum, 20, 10, 2) datum2 <- data.2(estat, 10, p = 2) T2II <- T2.2(datum2, estat, 10) # For the first sample j = 1. T2II is a vector with the value of the first T2 statistic. cchart.T2.2(T2II, 20, 10, 1, 25, 2) # Same of the above, but now showing the phase I data set. cchart.T2.2(T2II, 20, 10, 1, 25, 2, datum = datum) #Example with individual observations datum <- data.1(50, 1, mu, Sigma) estat <- stats(datum, 50, 1, 2) datum2 <- data.2(estat, 1, p = 2) T2II <- T2.2(datum2, estat, 1) # For the first sample j = 1. T2II is a vector with the value of the first T2 statistic. cchart.T2.2(T2II, 50, 1, 1, 25, 2) # Same of the above, but now showing the phase I data set. cchart.T2.2(T2II, 50, 1, 1, 25, 2, datum = datum)
Construct and optionally plot a Shewhart-type upper control chart for
multivariate process variability using the standardized trace statistic
.
cchart.trV( x, size = NULL, Sigma0 = NULL, alpha = 0.0027, type = c("chisq", "simulation"), nsim = 1e+05, seed = NULL, newdata = NULL, plot = TRUE, ... ) ## S3 method for class 'cchart.trV' plot(x, ...) ## S3 method for class 'cchart.trV' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'cchart.trV' summary(object, ...) ## S3 method for class 'summary.cchart.trV' print(x, digits = max(3L, getOption("digits") - 3L), ...)cchart.trV( x, size = NULL, Sigma0 = NULL, alpha = 0.0027, type = c("chisq", "simulation"), nsim = 1e+05, seed = NULL, newdata = NULL, plot = TRUE, ... ) ## S3 method for class 'cchart.trV' plot(x, ...) ## S3 method for class 'cchart.trV' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'cchart.trV' summary(object, ...) ## S3 method for class 'summary.cchart.trV' print(x, digits = max(3L, getOption("digits") - 3L), ...)
x |
An object of class |
size |
Positive integer subgroup size when |
Sigma0 |
Optional finite symmetric positive-definite in-control covariance matrix. If omitted, the average Phase I covariance matrix is used as a plug-in estimate. |
alpha |
Nominal upper-tail false-alarm probability, strictly between 0 and 1. |
type |
Character string selecting the calculation:
|
nsim |
Integer number of Monte Carlo draws, at least 1000. Used only
when |
seed |
|
newdata |
Optional Phase II subgroup data in any format accepted by
|
plot |
Logical scalar. If |
... |
Currently unused. |
digits |
Number of significant digits used for numerical output. |
object |
An object of class |
The tr(V) chart complements cchart.GV. The generalized
variance chart monitors determinant changes, while the trace chart monitors
the sum of standardized covariance eigenvalues. When Sigma0 = NULL,
limits are plug-in limits conditional on the Phase I estimate and do not
include additional Phase I estimation uncertainty.
An object of class "cchart.trV", a list with components:
statisticsTrace statistics for all Phase I followed by all Phase II subgroups.
phase1, phase2
Integer indices identifying the two
phases in statistics.
limitsThe complete list returned by
trv_limits().
out.of.controlIndices for which
statistics > ucl. Equality to the limit does not signal.
Sigma0The supplied or estimated in-control covariance matrix.
SbarThe average Phase I covariance matrix when
Sigma0 is estimated, otherwise NULL.
n, p
Subgroup size and process dimension.
callThe matched function call.
For plot.cchart.trV(), x invisibly.
x, invisibly.
An object of class "summary.cchart.trV".
x, invisibly.
set.seed(123) phase1 <- array(rnorm(6 * 8 * 2), dim = c(6, 8, 2)) chart <- cchart.trV(phase1, Sigma0 = diag(2), plot = FALSE) chart$limits[c("center", "ucl")]set.seed(123) phase1 <- array(rnorm(6 * 8 * 2), dim = c(6, 8, 2)) chart <- cchart.trV(phase1, Sigma0 = diag(2), plot = FALSE) chart$limits[c("center", "ucl")]
Build normal, Cornish-Fisher corrected, or standardized u charts.
cchart.u( x1 = NULL, n1 = NULL, type = "norm", u1 = NULL, x2 = NULL, n2 = NULL, lambda = NULL, u2 = NULL, alpha = ALPHA )cchart.u( x1 = NULL, n1 = NULL, type = "norm", u1 = NULL, x2 = NULL, n2 = NULL, lambda = NULL, u2 = NULL, alpha = ALPHA )
x1 |
Phase I defect counts. |
n1 |
Phase I inspection size or vector of sizes. |
type |
Chart type: |
u1 |
Phase I rates, used instead of |
x2 |
Phase II defect counts. |
n2 |
Phase II inspection size or vector of sizes. |
lambda |
Known or estimated in-control defect rate. |
u2 |
Phase II rates, used instead of |
alpha |
Nominal two-sided false-alarm probability. |
For Phase I, supply n1 and exactly one of x1 or u1.
For Phase II, supply n2 and exactly one of x2 or u2,
together with Phase I information or a known lambda.
When inspection sizes vary, the in-control rate is estimated by the pooled
Poisson estimator .
Invisibly returns the qcc object used to draw the chart.
data(moonroof) cchart.u(x1 = moonroof$yi[1:17], n1 = moonroof$ni[1:17]) cchart.u(x1 = moonroof$yi[1:17], n1 = moonroof$ni[1:17], type = "CF", x2 = moonroof$yi[18:34], n2 = moonroof$ni[18:34]) cchart.u(type = "std", u2 = moonroof$ui[18:34], n2 = moonroof$ni[18:34], lambda = 1.4)data(moonroof) cchart.u(x1 = moonroof$yi[1:17], n1 = moonroof$ni[1:17]) cchart.u(x1 = moonroof$yi[1:17], n1 = moonroof$ni[1:17], type = "CF", x2 = moonroof$yi[18:34], n2 = moonroof$ni[18:34]) cchart.u(type = "std", u2 = moonroof$ui[18:34], n2 = moonroof$ni[18:34], lambda = 1.4)
Builds and displays an X-bar control chart for Phase I (retrospective
analysis), Phase II (monitoring of future production), or both phases
in a single call. When Phase I data is supplied without Phase II data,
the chart uses estimated control limits. If Phase II data is supplied
without Phase I data, the chart requires x2bars and sigma
as reference values.
cchart.Xbar( x1 = NULL, n1 = NULL, x2 = NULL, n2 = NULL, x2bars = NULL, sigma = NULL )cchart.Xbar( x1 = NULL, n1 = NULL, x2 = NULL, n2 = NULL, x2bars = NULL, sigma = NULL )
x1 |
Phase I data. A matrix or data frame where each row is a subgroup. |
n1 |
Phase I subgroup size(s). A single integer (equal sizes) or a vector. |
x2 |
Phase II data. Same structure as x1. |
n2 |
Phase II subgroup size(s). |
x2bars |
Mean of subgroup means from Phase I (center line). Can be NULL and computed from x1. |
sigma |
Standard deviation from Phase I (for control limits). Can be NULL and computed from x1. |
Draws the X-bar control chart using qcc. For Phase I only, invisibly returns a list with components x2bar (mean of means) and sigma (standard deviation).
Phase I when only Phase I data is supplied; limits are estimated from the data. Phase II when Phase II data is supplied (with or without Phase I reference data).
Daniela R. Recchia, Emanuel P. Barbosa
Montgomery, D.C., (2009). "Introduction to Statistical Quality Control". Chapter 6. Wiley.
cchart.Xbar1, cchart.Xbar2, cchart.Xbar_R
data(pistonrings) cchart.Xbar(x1 = pistonrings[1:25, ], n1 = 5) cchart.Xbar(x1 = pistonrings[1:25, ], n1 = 5, x2 = pistonrings[26:40, ], n2 = 5)data(pistonrings) cchart.Xbar(x1 = pistonrings[1:25, ], n1 = 5) cchart.Xbar(x1 = pistonrings[1:25, ], n1 = 5, x2 = pistonrings[26:40, ], n2 = 5)
Draws the X-bar control chart and the R (range) control chart side by side in the same graphics window, using estimated Phase I control limits. Both charts share the same subgroup data.
cchart.Xbar_R(x, sizes)cchart.Xbar_R(x, sizes)
x |
Phase I data. Matrix or data frame with subgroups in rows. |
sizes |
Subgroup size(s). A single integer (equal sizes) or a vector. |
Draws two control charts side by side. Returns nothing.
Phase I --- control limits estimated from the data for both charts.
Daniela R. Recchia, Emanuel P. Barbosa
Montgomery, D.C., (2009). "Introduction to Statistical Quality Control". Chapter 6. Wiley.
cchart.Xbar1, cchart.Xbar2, cchart.Xbar
data(pistonrings) attach(pistonrings) cchart.Xbar_R(pistonrings[1:25, ], 5)data(pistonrings) attach(pistonrings) cchart.Xbar_R(pistonrings[1:25, ], 5)
Builds the X-bar control chart for Phase I retrospective analysis. The control limits are estimated from the supplied data. Even if the data is not normal, the X-bar statistic is approximately normal by the central limit theorem when subgroup sizes are sufficiently large.
cchart.Xbar1(x, sizes)cchart.Xbar1(x, sizes)
x |
Phase I data. Matrix or data frame with subgroups in rows. |
sizes |
Subgroup size(s). A single integer (equal sizes) or a vector. |
A list with components x2bar (mean of subgroup means) and sigma (standard deviation), returned invisibly. The control chart is drawn as a side effect.
Phase I --- control limits estimated from the data.
Daniela R. Recchia, Emanuel P. Barbosa
Montgomery, D.C., (2009). "Introduction to Statistical Quality Control". Chapter 6. Wiley.
cchart.Xbar2, cchart.Xbar, cchart.Xbar_R
data(pistonrings) cchart.Xbar1(pistonrings[1:25, ], 5)data(pistonrings) cchart.Xbar1(pistonrings[1:25, ], 5)
Builds the X-bar control chart for Phase II monitoring using reference
limits obtained from a Phase I analysis. The Phase I estimates of
x2bar (mean of means) and sigma (standard deviation) are
required, typically obtained from cchart.Xbar1.
cchart.Xbar2(x, x2bar, sigma, sizes)cchart.Xbar2(x, x2bar, sigma, sizes)
x |
Phase II data. Matrix or data frame with subgroups in rows. |
x2bar |
Mean of subgroup means from Phase I (center line). |
sigma |
Standard deviation from Phase I (for control limits). |
sizes |
Phase II subgroup size(s). |
Draws the X-bar control chart. Returns nothing.
Phase II --- tests new data against Phase I reference distribution.
Daniela R. Recchia, Emanuel P. Barbosa
Montgomery, D.C., (2009). "Introduction to Statistical Quality Control". Chapter 6. Wiley.
data(pistonrings) stat <- cchart.Xbar1(pistonrings[1:25, ], 5) cchart.Xbar2(pistonrings[26:40, ], stat[[1]][1], stat[[1]][2], 5)data(pistonrings) stat <- cchart.Xbar1(pistonrings[1:25, ], 5) cchart.Xbar2(pistonrings[26:40, ], stat[[1]][1], stat[[1]][2], 5)
Compute the constant , the expected value of the relative range
for a sample of size drawn from a normal
distribution, where is the sample range and is the
process standard deviation.
d2(n)d2(n)
n |
Integer sample size, at least 2. Can be a vector. |
Under normality, has the studentized range distribution with infinite
denominator degrees of freedom. Its expectation is the integral of the
survival function, , which is
evaluated numerically using ptukey with infinite
degrees of freedom.
Numeric vector of values, the same length as n.
Daniela R. Recchia, Emanuel P. Barbosa
Montgomery, D. C. (2009). Introduction to Statistical Quality Control, 6th ed. Wiley.
Barbosa, E. P., Gneri, M. A. and Meneguetti, A. (2013). Range control charts revisited: Simpler Tippett-like formulae, its practical implementation, and the study of false alarm. Communications in Statistics - Simulation and Computation, 42(2), 247–262. doi:10.1080/03610918.2011.639967.
d3, c4, table.const
d2(5) d2(2:10)d2(5) d2(2:10)
Compute the constant , the standard deviation of the relative range
for a sample of size drawn from a normal
distribution, where is the sample range and is the
process standard deviation.
d3(n)d3(n)
n |
Integer sample size, at least 2. Can be a vector. |
Under normality, has the studentized range distribution with infinite
denominator degrees of freedom. Using the identity , the standard deviation is obtained as , where is computed by d2. The
integrals are evaluated numerically using ptukey with
infinite degrees of freedom.
Numeric vector of values, the same length as n.
Daniela R. Recchia, Emanuel P. Barbosa
Montgomery, D. C. (2009). Introduction to Statistical Quality Control, 6th ed. Wiley.
Barbosa, E. P., Gneri, M. A. and Meneguetti, A. (2013). Range control charts revisited: Simpler Tippett-like formulae, its practical implementation, and the study of false alarm. Communications in Statistics - Simulation and Computation, 42(2), 247–262. doi:10.1080/03610918.2011.639967.
d3(7) d3(2:10)d3(7) d3(2:10)
Generate samples from a -variate normal distribution for
Phase I Hotelling T² chart development. For : returns an
matrix. For : returns an
array.
data.1(m, n, mu, Sigma)data.1(m, n, mu, Sigma)
m |
Number of samples. |
n |
Sample size per subgroup. Use |
mu |
Mean vector (length |
Sigma |
|
For : an matrix. For : an
array.
Uses MASS::mvrnorm(). Set the seed externally for reproducibility.
Daniela R. Recchia, Emanuel P. Barbosa
mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) #Simulated data with individual observations datum <- data.1(50, 1, mu, Sigma) #Simulated data with sub-group observations datum <- data.1(20, 10, mu, Sigma)mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) #Simulated data with individual observations datum <- data.1(50, 1, mu, Sigma) #Simulated data with sub-group observations datum <- data.1(20, 10, mu, Sigma)
Generate a single new observation from using
Phase I reference parameters for Phase II monitoring.
data.2(estat, n, delta = 0, p)data.2(estat, n, delta = 0, p)
estat |
List from |
n |
Subgroup size. Use |
delta |
Optional shift added to mean vector for out-of-control simulation. |
p |
Dimension. |
To use this function it is necessary to have the information about Phase I
given by the functions data.1 and stats.
For : a numeric vector. For : an
matrix.
Daniela R. Recchia, Emanuel P. Barbosa
mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) datum <- data.1(20, 10, mu, Sigma) # estat is the list with the values of the auxiliary statistics. estat <- stats(datum, 20, 10, 2) datum2 <- data.2(estat, 10, p = 2)mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) datum <- data.1(20, 10, mu, Sigma) # estat is the list with the values of the auxiliary statistics. estat <- stats(datum, 20, 10, 2) datum2 <- data.2(estat, 10, p = 2)
Compute the average run length for the double-sampling np chart as the reciprocal of the signal probability at each supplied nonconforming proportion.
dsnp_arl(p, n1, n2, wl, ucl1, ucl2)dsnp_arl(p, n1, n2, wl, ucl1, ucl2)
p |
Nonconforming proportion to evaluate, a finite numeric scalar or
vector in |
n1 |
First-stage sample size, a positive integer. |
n2 |
Second-stage sample size, a positive integer. |
wl |
Finite fractional warning limit. |
ucl1 |
Finite fractional first-stage upper control limit greater than
|
ucl2 |
Finite fractional combined upper control limit greater than
|
For signal probability , the ARL is
. It is infinite when the signal probability is zero.
A list with arl, the average run length; pt, total
acceptance probability; p_signal, signal probability; and the
validated chart parameters n1, n2, wl, ucl1,
and ucl2.
Daniela R. Recchia, Emanuel P. Barbosa
Joekes, S., Smrekar, M. and Barbosa, E. P. (2015). Extending a double sampling control chart for non-conforming proportion in high quality processes to the case of small samples. Statistical Methodology, 23, 35–49.
arl0 <- dsnp_arl(0.005, 34, 162, 1.5, 2.5, 4.5)$arl arl1 <- dsnp_arl(0.0075, 34, 162, 1.5, 2.5, 4.5)$arl c(arl0 = arl0, arl1 = arl1)arl0 <- dsnp_arl(0.005, 34, 162, 1.5, 2.5, 4.5)$arl arl1 <- dsnp_arl(0.0075, 34, 162, 1.5, 2.5, 4.5)$arl c(arl0 = arl0, arl1 = arl1)
Compute the average sample size for the double-sampling np chart.
dsnp_ass(p, n1, n2, wl, ucl1, ucl2 = NULL, curtailed = FALSE)dsnp_ass(p, n1, n2, wl, ucl1, ucl2 = NULL, curtailed = FALSE)
p |
Nonconforming proportion to evaluate, a finite numeric scalar or
vector in |
n1 |
First-stage sample size, a positive integer. |
n2 |
Second-stage sample size, a positive integer. |
wl |
Finite fractional warning limit. |
ucl1 |
Finite fractional first-stage upper control limit greater than
|
ucl2 |
Finite fractional second-stage upper control limit. Required
when |
curtailed |
Logical. If |
By default (curtailed = FALSE), every second-stage sample that is
requested is fully inspected. Therefore
When curtailed = TRUE, inspection of the second sample stops as soon
as the cumulative count of non-conformities exceeds ucl2. For each
warning-zone first-stage count , define
as the number of
non-conformances needed to reject. The expected number of stage-2 items
inspected is
with when . Then
Curtailed inspection does not change the signal probability or ARL; it only reduces the number of items inspected when the eventual decision is already determined before the full second sample is observed.
A list with:
Average sample size (numeric vector).
Probability that the second sample is required.
Validated chart parameters.
The convention used.
Daniela R. Recchia, Emanuel P. Barbosa
Joekes, S., Smrekar, M. and Barbosa, E. P. (2015). Extending a double sampling control chart for non-conforming proportion in high quality processes to the case of small samples. Statistical Methodology, 23, 35–49. doi:10.1016/j.stamet.2014.09.003.
dsnp_ass(0.005, 34, 162, 1.5, 2.5)$ass # Curtailed inspection dsnp_ass(0.005, 34, 162, 1.5, 2.5, ucl2 = 4.5, curtailed = TRUE)$assdsnp_ass(0.005, 34, 162, 1.5, 2.5)$ass # Curtailed inspection dsnp_ass(0.005, 34, 162, 1.5, 2.5, ucl2 = 4.5, curtailed = TRUE)$ass
Perform a joint discrete search over first-stage sample size (n1),
second-stage sample size (n2), and DS-np control limits to find
optimal chart designs. This function performs an exhaustive search
over the Cartesian product of n1_range and n2_range,
calling dsnp_limits for each pair and collecting the
best feasible candidates across all pairs.
dsnp_design( p0, p1, n1_range, n2_range, arl0_min = 200, alpha = NULL, objective = c("arl1", "ass0", "weighted"), weights = c(arl1 = 1, ass0 = 1), allow_empty_warning = FALSE, max_results = 20, progress = FALSE, ass0_max = NULL, curtailed = FALSE ) ## S3 method for class 'dsnp_design' print(x, ...)dsnp_design( p0, p1, n1_range, n2_range, arl0_min = 200, alpha = NULL, objective = c("arl1", "ass0", "weighted"), weights = c(arl1 = 1, ass0 = 1), allow_empty_warning = FALSE, max_results = 20, progress = FALSE, ass0_max = NULL, curtailed = FALSE ) ## S3 method for class 'dsnp_design' print(x, ...)
p0 |
In-control nonconforming proportion. Scalar in (0, 1). |
p1 |
Out-of-control nonconforming proportion. Scalar in (0, 1).
Must be greater than |
n1_range |
Integer vector of first-stage sample sizes to evaluate. Positive integers, no duplicates, no NAs. |
n2_range |
Integer vector of second-stage sample sizes to evaluate. Positive integers, no duplicates, no NAs. |
arl0_min |
Minimum acceptable in-control ARL. Scalar greater than 1,
or |
alpha |
Maximum acceptable false alarm probability. Scalar in (0, 1),
or |
objective |
Optimization objective. One of |
weights |
Named numeric vector with elements |
allow_empty_warning |
Logical. If |
max_results |
Maximum number of feasible candidates to return. Positive integer. |
progress |
Logical. If |
ass0_max |
Optional maximum in-control average sample size. When
supplied, it must be a finite positive scalar and candidates must satisfy
|
curtailed |
Logical. If |
x |
An object of class |
... |
Additional arguments (ignored). |
The search is discrete and exhaustive within the supplied ranges; it is not a continuous optimization. The cost grows with the number of (n1, n2) pairs and the number of limit candidates evaluated per pair.
When alpha is NULL and arl0_min is provided, an
effective alpha of 1 / arl0_min is used to guide
dsnp_limits(), but final feasibility is checked against the
explicit arl0 >= arl0_min condition.
The published design problem minimizes out-of-control ARL subject to
ass0 <= ass0_max and arl0 >= arl0_min. Setting
ass0_max = NULL omits only the ASS constraint and preserves the
behavior of earlier IQCC versions. The argument is appended to the function
signature so existing positional calls retain their meaning.
An object of class "dsnp_design" with the following
elements:
The top-ranked feasible candidate (a one-row data.frame).
Up to max_results feasible candidates, sorted
by the chosen objective.
A list of the input parameters.
A list with search summary counts:
Number of (n1, n2) pairs evaluated.
Total number of limit candidates evaluated across all pairs.
Number of candidates satisfying global feasibility.
Number of (n1, n2) pairs where
dsnp_limits() failed.
A data.frame of failed pairs with columns n1, n2, and message. Empty if no failures occurred.
Daniela R. Recchia, Emanuel P. Barbosa
Joekes, S., Smrekar, M. and Barbosa, E. P. (2015). Extending a double sampling control chart for non-conforming proportion in high quality processes to the case of small samples. Statistical Methodology, 23, 35-49. doi:10.1016/j.stamet.2014.09.003.
dsnp_limits, dsnp_prob_accept, dsnp_arl, dsnp_ass
# Small example for fast execution res <- dsnp_design( p0 = 0.05, p1 = 0.10, n1_range = 5:6, n2_range = 8:10, arl0_min = 50, objective = "arl1" ) res$best[, c("n1", "n2", "wl", "ucl1", "ucl2", "arl0", "arl1")]# Small example for fast execution res <- dsnp_design( p0 = 0.05, p1 = 0.10, n1_range = 5:6, n2_range = 8:10, arl0_min = 50, objective = "arl1" ) res$best[, c("n1", "n2", "wl", "ucl1", "ucl2", "arl0", "arl1")]
Search for feasible fractional control limits for the double-sampling np
chart by enumerating integer threshold combinations and evaluating each
candidate with the shared numerical core used by dsnp_prob_accept(),
dsnp_arl(), and dsnp_ass(). This function searches limits for
fixed sample sizes; it does not optimize the complete sampling design.
dsnp_limits( p0, n1, n2, alpha = 0.0027, p1 = NULL, conservative = TRUE, allow_empty_warning = FALSE, max_results = 20, curtailed = FALSE )dsnp_limits( p0, n1, n2, alpha = 0.0027, p1 = NULL, conservative = TRUE, allow_empty_warning = FALSE, max_results = 20, curtailed = FALSE )
p0 |
In-control nonconforming proportion, a finite scalar in
|
n1 |
First-stage sample size, a positive integer. |
n2 |
Second-stage sample size, a positive integer. |
alpha |
Maximum desired false-alarm probability, a finite scalar in
|
p1 |
Optional out-of-control proportion, a finite scalar in
|
conservative |
Logical. If |
allow_empty_warning |
Logical. If |
max_results |
Positive integer maximum number of ranked candidates to retain. |
curtailed |
Logical. If |
The function enumerates valid combinations of wl_accept,
ucl1_reject, and ucl2_accept, then converts them to fractional
limits. A candidate is feasible when its in-control signal probability is
no greater than alpha.
With p1, candidates are ranked by feasibility when
conservative = TRUE, then by increasing ARL1, ASS0, and distance from
alpha. Without p1, they are ranked by feasibility, distance
from alpha, ASS0, and ARL0. Setting conservative = FALSE
removes feasibility from the front of the corresponding ordering.
When ucl1_reject = wl_accept + 1, the warning zone is empty and the
chart degenerates to a single-sample scheme. Such candidates are excluded
by default; when allowed, their probabilities are computed directly with
stats::pbinom().
A list with the following elements:
The first row of candidates, retained as a data frame.
A data frame containing up to max_results ranked
candidates. Columns are wl, ucl1, ucl2,
wl_accept, ucl1_reject, ucl2_accept, pt0,
p_signal0, arl0, ass0, and feasible; when
p1 is supplied, pt1, p_signal1, arl1, and
ass1 are also included.
The validated input parameters.
The validated input flags.
Daniela R. Recchia, Emanuel P. Barbosa
Joekes, S., Smrekar, M. and Barbosa, E. P. (2015). Extending a double sampling control chart for non-conforming proportion in high quality processes to the case of small samples. Statistical Methodology, 23, 35–49.
dsnp_prob_accept, dsnp_arl,
dsnp_ass
limits0 <- dsnp_limits(0.05, 5, 10, alpha = 0.05) limits0$best nrow(limits0$candidates) limits1 <- dsnp_limits(0.05, 5, 10, alpha = 0.05, p1 = 0.10) limits1$best[, c("wl", "ucl1", "ucl2", "arl0", "arl1", "ass0")]limits0 <- dsnp_limits(0.05, 5, 10, alpha = 0.05) limits0$best nrow(limits0$candidates) limits1 <- dsnp_limits(0.05, 5, 10, alpha = 0.05, p1 = 0.10) limits1$best[, c("wl", "ucl1", "ucl2", "arl0", "arl1", "ass0")]
Compute the total probability that the double-sampling np chart accepts (does not signal) at a given nonconforming proportion.
dsnp_prob_accept(p, n1, n2, wl, ucl1, ucl2)dsnp_prob_accept(p, n1, n2, wl, ucl1, ucl2)
p |
Nonconforming proportion to evaluate, a finite numeric scalar or
vector in |
n1 |
First-stage sample size, a positive integer. |
n2 |
Second-stage sample size, a positive integer. |
wl |
Finite fractional warning limit. |
ucl1 |
Finite fractional first-stage upper control limit greater than
|
ucl2 |
Finite fractional combined upper control limit greater than
|
A subgroup is accepted immediately when the first-stage count is
at or below floor(wl) and signals immediately when is at or
above floor(ucl1) + 1. Counts between those thresholds continue to
the second stage. A continued subgroup is accepted when is
at or below floor(ucl2) and signals otherwise.
A list with the following elements:
First-stage acceptance probability.
Second-stage acceptance probability.
Total acceptance probability, pa1 + pa2.
Total signal probability, 1 - pt.
Probability of either accepting or signaling at the first stage.
Probability that the second sample is required.
The validated chart parameters.
Integer threshold floor(wl); accept at stage one
when does not exceed this value.
Integer threshold floor(ucl1) + 1; signal at
stage one when is at least this value.
Integer threshold floor(ucl2); accept at stage
two when does not exceed this value.
Daniela R. Recchia, Emanuel P. Barbosa
Joekes, S., Smrekar, M. and Barbosa, E. P. (2015). Extending a double sampling control chart for non-conforming proportion in high quality processes to the case of small samples. Statistical Methodology, 23, 35-49.
dsnp_arl, dsnp_ass,
dsnp_limits
result <- dsnp_prob_accept( 0.005, n1 = 34, n2 = 162, wl = 1.5, ucl1 = 2.5, ucl2 = 4.5 ) result$pt result$p_signalresult <- dsnp_prob_accept( 0.005, n1 = 34, n2 = 162, wl = 1.5, ucl1 = 2.5, ucl2 = 4.5 ) result$pt result$p_signal
Evaluate the actual in-control probability that the generalized variance
statistic crosses limits produced by gv_limits(), and report the
corresponding zero-state in-control average run length.
gv_alpha_risk( n, p, det_sigma = 1, alpha = 0.0027, type = c("normal", "cf", "exact", "simulation"), side = c("upper", "two.sided"), cf_order = 1, nsim = 2e+05, seed = NULL )gv_alpha_risk( n, p, det_sigma = 1, alpha = 0.0027, type = c("normal", "cf", "exact", "simulation"), side = c("upper", "two.sided"), cf_order = 1, nsim = 2e+05, seed = NULL )
n |
Integer subgroup sample size. It must satisfy |
p |
Integer process dimension, at least 2. |
det_sigma |
Positive finite scalar equal to |
alpha |
Nominal probability of a false alarm per subgroup, strictly
between 0 and 1. For |
type |
Character string selecting the limit calculation:
Partial matching is not used. |
side |
Either |
cf_order |
Integer 1 or 2. Order 1 uses the skewness correction. Order
2 additionally uses excess kurtosis and the squared-skewness term. It is
used only when |
nsim |
Integer number of Monte Carlo draws, at least 1000. It is used
by |
seed |
|
The diagnostic is useful because Gaussian and Cornish-Fisher limits are
approximations and therefore need not attain the requested nominal risk
exactly. For dimension , the crossing probability is evaluated
from the exact chi-square representation of . For , it is
estimated independently by Monte Carlo simulation from Bartlett's
product-of-chi-squares representation.
The function first calls gv_limits() using the requested
type. It then evaluates
for an upper chart, or
for a two-sided chart. The inequalities are strict, matching the signaling
rule used by cchart.GV().
For , nsim controls both any simulation used to construct
the limits and the independent simulation used to evaluate their risk. If
seed is supplied, the limits use that seed and the risk evaluation
uses seed + 1; each seeded simulation restores the caller's previous
random-number state on exit. With seed = NULL, the global RNG state
advances normally.
A list with components:
alphaActual or Monte Carlo estimated false-alarm probability.
nominal_alphaThe requested nominal value.
arl0Zero-state in-control average run length,
1 / alpha; Inf if no simulated crossing is observed.
limitsThe complete object returned by
gv_limits().
methodEither "exact evaluation" for or
"simulation" for higher dimensions.
For , the reported risk is a binomial proportion based on
nsim draws. Its approximate Monte Carlo standard error is
. Very small false-alarm risks
therefore require substantially more simulations than routine examples.
Input and exact-method restrictions are inherited from gv_limits().
In addition, simulation requires an integer nsim of at least 1000
and a valid optional seed.
Barbosa, E. P., Gneri, M. A., and Meneguetti, A. Improving Shewhart-type Generalized Variance Control Charts for Multivariate Process Variability Monitoring using Cornish-Fisher Quantile Correction, Meijer-G Function and Other Tools. Research report.
# Exact evaluation shows that exact p = 2 limits attain the nominal risk. exact_risk <- gv_alpha_risk(10, 2, type = "exact") exact_risk$alpha exact_risk$arl0 # Diagnose the false-alarm inflation of moment-matched normal limits. gv_alpha_risk(10, 2, type = "normal") # Reproducible risk evaluation for a higher-dimensional chart. gv_alpha_risk(8, 3, type = "cf", nsim = 10000, seed = 2026)# Exact evaluation shows that exact p = 2 limits attain the nominal risk. exact_risk <- gv_alpha_risk(10, 2, type = "exact") exact_risk$alpha exact_risk$arl0 # Diagnose the false-alarm inflation of moment-matched normal limits. gv_alpha_risk(10, 2, type = "normal") # Reproducible risk evaluation for a higher-dimensional chart. gv_alpha_risk(8, 3, type = "cf", nsim = 10000, seed = 2026)
Compute one-sided upper or equal-tail two-sided control limits for the
generalized variance statistic under independent sampling from a
-variate normal process with in-control covariance matrix .
gv_limits( n, p, det_sigma = 1, alpha = 0.0027, type = c("normal", "cf", "exact", "simulation"), side = c("upper", "two.sided"), cf_order = 1, nsim = 1e+05, seed = NULL )gv_limits( n, p, det_sigma = 1, alpha = 0.0027, type = c("normal", "cf", "exact", "simulation"), side = c("upper", "two.sided"), cf_order = 1, nsim = 1e+05, seed = NULL )
n |
Integer subgroup sample size. It must satisfy |
p |
Integer process dimension, at least 2. |
det_sigma |
Positive finite scalar equal to |
alpha |
Nominal probability of a false alarm per subgroup, strictly
between 0 and 1. For |
type |
Character string selecting the limit calculation:
Partial matching is not used. |
side |
Either |
cf_order |
Integer 1 or 2. Order 1 uses the skewness correction. Order
2 additionally uses excess kurtosis and the squared-skewness term. It is
used only when |
nsim |
Integer number of Monte Carlo draws, at least 1000. It is used
by |
seed |
|
If is the usual covariance matrix from a subgroup of size ,
then has a Wishart distribution and can be
represented as a scaled product of independent chi-square variables. The
function uses that representation to obtain moments, approximations, exact
cases, or simulated quantiles.
A list with components:
lcl, ucl
Lower and upper control limits.
centerThe exact in-control mean of ; this is the
center line used by cchart.GV().
type, side, alpha
The selected method, chart sidedness, and nominal false-alarm probability.
n, p, det_sigma
The validated design parameters.
momentsA list containing the first four ordinary moments,
mean, variance, standard deviation, skewness, excess kurtosis, the
constants b1 and b2, and the design parameters.
cf_order, nsim, seed
The requested numerical settings.
The exact distribution is available for both upper and two-sided
charts. The implementation is deliberately limited to the
published one-sided upper quantiles described above. No generic Meijer-G
evaluator is claimed; use type = "simulation" outside those cases.
A plotted subgroup signals when or .
Equality to either limit is treated as in control.
Errors are raised for invalid dimensions, , a nonpositive
det_sigma, invalid alpha, unsupported exact cases, invalid
Cornish-Fisher order, fewer than 1000 simulations, or an invalid seed.
Barbosa, E. P., Gneri, M. A., and Meneguetti, A. Improving Shewhart-type Generalized Variance Control Charts for Multivariate Process Variability Monitoring using Cornish-Fisher Quantile Correction, Meijer-G Function and Other Tools. Research report.
Anderson, T. W. (1984). An Introduction to Multivariate Statistical Analysis, 2nd ed. Wiley.
Cornish, E. A. and Fisher, R. A. (1960). The percentage points of distributions having known cumulants. Technometrics, 2, 209–225.
gv_stat, gv_alpha_risk,
cchart.GV
# Published dimension-two illustration: |Sigma| = 0.5320, n = 10. gv_limits(10, 2, det_sigma = 0.5320, type = "normal")$ucl gv_limits(10, 2, det_sigma = 0.5320, type = "cf")$ucl gv_limits(10, 2, det_sigma = 0.5320, type = "exact")$ucl # Equal-tail exact limits are also available in dimension two. gv_limits(10, 2, side = "two.sided", type = "exact") # A reproducible simulation-based limit for higher dimension. gv_limits(8, 3, type = "simulation", nsim = 5000, seed = 2026)# Published dimension-two illustration: |Sigma| = 0.5320, n = 10. gv_limits(10, 2, det_sigma = 0.5320, type = "normal")$ucl gv_limits(10, 2, det_sigma = 0.5320, type = "cf")$ucl gv_limits(10, 2, det_sigma = 0.5320, type = "exact")$ucl # Equal-tail exact limits are also available in dimension two. gv_limits(10, 2, side = "two.sided", type = "exact") # A reproducible simulation-based limit for higher dimension. gv_limits(8, 3, type = "simulation", nsim = 5000, seed = 2026)
Compute the generalized variance, defined as the determinant of the unbiased sample covariance matrix, for each multivariate subgroup.
gv_stat(x, size = NULL)gv_stat(x, size = NULL)
x |
Multivariate subgroup data in one of three forms:
Every observation must be finite. |
size |
Positive integer subgroup size. It is required when |
For subgroup with observations on variables,
gv_stat() calculates
All subgroups must have the same and , with
and . The latter condition permits a nonsingular sample
covariance matrix under nondegenerate data, although an observed subgroup
may still have determinant zero because of exact linear dependence.
A numeric vector of length equal to the number of subgroups. Element
is . A determinant that is slightly negative only because
of floating-point roundoff is returned as zero.
An error is raised for unsupported input types, empty or unequal-sized
subgroups, non-finite observations, fewer than two variables, ,
an invalid matrix size, or a covariance determinant that is genuinely
negative.
Barbosa, E. P., Gneri, M. A., and Meneguetti, A. Improving Shewhart-type Generalized Variance Control Charts for Multivariate Process Variability Monitoring using Cornish-Fisher Quantile Correction, Meijer-G Function and Other Tools. Research report.
Anderson, T. W. (1984). An Introduction to Multivariate Statistical Analysis, 2nd ed. Wiley.
gv_limits, gv_alpha_risk,
cchart.GV
g1 <- cbind(c(0, 1, 2, 3), c(0, 2, 1, 3)) g2 <- cbind(c(1, 2, 4, 7), c(3, 1, 5, 2)) gv_stat(list(g1, g2)) gv_stat(rbind(g1, g2), size = 4) x <- array(c(g1, g2), dim = c(2, 4, 2)) gv_stat(x)g1 <- cbind(c(0, 1, 2, 3), c(0, 2, 1, 3)) g2 <- cbind(c(1, 2, 4, 7), c(3, 1, 5, 2)) gv_stat(list(g1, g2)) gv_stat(rbind(g1, g2), size = 4) x <- array(c(g1, g2), dim = c(2, 4, 2)) gv_stat(x)
34 subgroups with defect counts (yi) and sample sizes (ni) for
moonroof installation. This data set is used for -chart examples.
A data frame with 34 observations on the following 4 variables.
Index.
The number of defects.
The sample size.
The proportion of defects.
DeVor, R. E., Chang, T., and Sutherland, J. W. (2007). Statistical Quality Design and Control, 2nd ed. Pearson.
data(moonroof)data(moonroof)
Compute the actual false-alarm probability of p-chart limits under the
in-control binomial model. The calculation respects the discreteness of
and treats a signal as
or .
pchart_alpha_risk(p, n, lcl, ucl)pchart_alpha_risk(p, n, lcl, ucl)
p |
In-control nonconforming proportion. |
n |
Positive integer sample size or vector of sample sizes. |
lcl |
Lower control limit or vector of limits. |
ucl |
Upper control limit or vector of limits. |
A numeric vector with the exact false-alarm probability for each sample size and pair of limits.
limits <- pchart_limits(0.015, 20, type = "cf2") pchart_alpha_risk(0.015, 20, limits$lcl, limits$ucl)limits <- pchart_limits(0.015, 20, type = "cf2") pchart_alpha_risk(0.015, 20, limits$lcl, limits$ucl)
Compute normal or Cornish-Fisher probability limits for a p chart without constructing a plot. The Cornish-Fisher formulas retain the original proportion scale and correct the normal approximation using binomial cumulants.
pchart_limits( p, n, alpha = ALPHA, type = c("normal", "cf1", "cf2"), sides = c("two.sided", "upper"), truncate = TRUE )pchart_limits( p, n, alpha = ALPHA, type = c("normal", "cf1", "cf2"), sides = c("two.sided", "upper"), truncate = TRUE )
p |
In-control nonconforming proportion. A scalar strictly between zero and one. |
n |
Positive integer sample size or vector of sample sizes. |
alpha |
Nominal false alarm probability. Defaults to 0.0027. |
type |
Limit method: |
sides |
Either |
truncate |
Logical. If |
type = "cf1" uses the first skewness correction proposed by
Winterbottom (1993). type = "cf2" uses the operational two-adjustment
limits in equation (8) of Joekes and Barbosa (2013). In particular, the
second adjustment is evaluated with the positive normal quantile and is
applied with the same sign to both limits. This convention reproduces the
published limits and false-alarm risks in Tables 2 and 3.
The article recommends the normal approximation for approximately
, CF1 for approximately , and
CF2 for approximately . The returned
applicable field reports whether each sample size meets the
corresponding recommendation.
A list containing center, lcl, ucl,
n, alpha, type, sides, npq, and
applicable.
Winterbottom, A. (1993). Simple adjustment to improve control limits on attribute charts. Quality and Reliability Engineering International.
Joekes, S. and Barbosa, E. P. (2013). An improved attribute control chart for monitoring non-conforming proportion in high quality processes. Control Engineering Practice, 21, 407–412. doi:10.1016/j.conengprac.2012.12.005.
pchart_limits(0.015, n = 20, type = "normal") pchart_limits(0.015, n = 20, type = "cf1") pchart_limits(0.015, n = 20, type = "cf2")pchart_limits(0.015, n = 20, type = "normal") pchart_limits(0.015, n = 20, type = "cf1") pchart_limits(0.015, n = 20, type = "cf2")
40 subgroups of size 5 containing diameter measurements of piston rings.
This data set is used extensively in statistical process control textbooks
and throughout the IQCC package to illustrate , , and
charts.
A data frame with 40 observations on the following 5 variables.
The first measure.
The second measure.
The third measure.
The fourth measure.
The fifth measure.
Montgomery, D. C. (2009). Introduction to Statistical Quality Control, 6th ed. Wiley. ISBN 978-0-470-16992-6.
data(pistonrings)data(pistonrings)
Plot first-stage and second-stage DS-np decisions on separate panels so that the first-stage count and combined count are shown on their proper scales.
## S3 method for class 'cchart.DSnp' plot(x, ...)## S3 method for class 'cchart.DSnp' plot(x, ...)
x |
An object of class |
... |
Additional graphical parameters passed to the first panel. |
The upper panel displays x1, the warning limit, and the first-stage
upper control limit. The lower panel displays x1 + x2 only for
observations that reached the second stage, together with the second-stage
upper control limit.
Invisible x.
Display or construct a compact summary of a double-sampling np chart, including sample sizes, decision thresholds, operating characteristics, stage outcomes, and signaled observations.
## S3 method for class 'cchart.DSnp' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'cchart.DSnp' summary(object, ...) ## S3 method for class 'summary.cchart.DSnp' print(x, digits = max(3L, getOption("digits") - 3L), ...)## S3 method for class 'cchart.DSnp' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'cchart.DSnp' summary(object, ...) ## S3 method for class 'summary.cchart.DSnp' print(x, digits = max(3L, getOption("digits") - 3L), ...)
x |
An object of class |
digits |
Number of significant digits used for numerical output. |
... |
Additional arguments passed to the summary print method; otherwise currently unused. |
object |
An object of class |
summary.cchart.DSnp() returns an object of class
"summary.cchart.DSnp". The returned list contains call,
observations, parameters, limits, performance,
stage_counts, and signals. The print methods return their
input invisibly.
Display or construct a compact statistical summary of a generalized variance chart, including design dimensions, Phase I and Phase II subgroup counts, control-limit method, covariance source, descriptive statistics, and signaled subgroups.
## S3 method for class 'cchart.GV' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'cchart.GV' summary(object, ...) ## S3 method for class 'summary.cchart.GV' print(x, digits = max(3L, getOption("digits") - 3L), ...)## S3 method for class 'cchart.GV' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'cchart.GV' summary(object, ...) ## S3 method for class 'summary.cchart.GV' print(x, digits = max(3L, getOption("digits") - 3L), ...)
x |
An object of class |
digits |
Number of significant digits used for numerical output. |
... |
Additional arguments passed to the summary print method; otherwise currently unused. |
object |
An object of class |
summary.cchart.GV() returns an object of class
"summary.cchart.GV". The returned list contains call,
dimensions, subgroups, method, limits,
covariance, statistics, and signals. The print methods
return their input invisibly.
Compute exact equal-tail probability control limits for the R chart without
constructing a plot. The limits are based on the distribution of the relative
range under normality, using the Studentized range
distribution implemented by stats::qtukey().
r_exact_limits(sigma, n, alpha = ALPHA)r_exact_limits(sigma, n, alpha = ALPHA)
sigma |
Positive finite scalar. The in-control process standard
deviation. When |
n |
Integer subgroup size, at least 2. |
alpha |
Nominal false-alarm probability per subgroup. Defaults to 0.0027. One half is placed in each tail. |
The exact limits are
and
where is the quantile function of .
A named list with components:
Lower control limit.
Upper control limit.
, the expected value of the range under
normality.
The supplied sigma.
The supplied subgroup size.
The supplied nominal false-alarm probability.
These limits are computed for a known or separately estimated sigma.
When sigma is estimated from a Phase I reference sample, the limits
are plug-in limits and do not account for Phase I sampling variability.
A subgroup range signals out of control when or
. Equality to a limit is treated as in control.
An error is raised when sigma is NA, NaN, or
non-positive; when n is smaller than 2, non-integer, or non-finite;
or when alpha is not between 0 and 1.
Barbosa, E. P., Gneri, M. A., and Meneguetti, A. (2013). Range control charts revisited: Simpler Tippett-like formulae, its practical implementation, and the study of false alarm. Communications in Statistics - Simulation and Computation, 42(2), 247–262. doi:10.1080/03610918.2011.639967.
r_shewhart_limits, cchart.R,
alpha.risk, d2
# Known-sigma limits for subgroup size n = 5, sigma = 2, alpha = 0.0027 r_exact_limits(sigma = 2, n = 5) # Custom alpha r_exact_limits(sigma = 1, n = 10, alpha = 0.01)# Known-sigma limits for subgroup size n = 5, sigma = 2, alpha = 0.0027 r_exact_limits(sigma = 2, n = 5) # Custom alpha r_exact_limits(sigma = 1, n = 10, alpha = 0.01)
Compute the conventional three-sigma (Shewhart) control limits for the R
chart without constructing a plot. The limits are based on the constants
and , the mean and standard deviation of the
relative range under normality.
r_shewhart_limits(sigma, n, nsigmas = SIGMA_MULT)r_shewhart_limits(sigma, n, nsigmas = SIGMA_MULT)
sigma |
Positive finite scalar. The in-control process standard deviation. When estimated from Phase I data, the returned limits are plug-in estimates. |
n |
Integer subgroup size, at least 2. |
nsigmas |
Positive numeric scalar. The number of sigma units for the control limits. Defaults to 3. |
The conventional limits are
and
where is the number of sigma units (default 3). Because the
distribution of the relative range is not normal, the actual false-alarm
probability of these limits can be substantially larger than the nominal
0.0027 associated with three-sigma limits for a normal variate. Use
alpha.risk to evaluate the exact false-alarm probability.
A named list with components:
Lower control limit (zero-truncated).
Upper control limit.
, the expected value of the range under
normality.
The supplied multiplier.
The supplied sigma.
The supplied subgroup size.
These limits are computed for a known or separately estimated sigma.
When sigma is estimated from a Phase I reference sample, the limits
are plug-in limits.
A subgroup range signals out of control when or
. Equality to a limit is treated as in control.
An error is raised when sigma is NA, NaN, or
non-positive; when n is smaller than 2, non-integer, or non-finite;
or when nsigmas is non-positive.
Montgomery, D. C. (2009). Introduction to Statistical Quality Control, 6th ed. Wiley.
Barbosa, E. P., Gneri, M. A., and Meneguetti, A. (2013). Range control charts revisited: Simpler Tippett-like formulae, its practical implementation, and the study of false alarm. Communications in Statistics - Simulation and Computation, 42(2), 247–262. doi:10.1080/03610918.2011.639967.
r_exact_limits, cchart.R,
alpha.risk, d2, d3
# Conventional three-sigma limits for n = 5, sigma = 2 r_shewhart_limits(sigma = 2, n = 5) # Custom multiplier r_shewhart_limits(sigma = 1, n = 10, nsigmas = 2)# Conventional three-sigma limits for n = 5, sigma = 2 r_shewhart_limits(sigma = 2, n = 5) # Custom multiplier r_shewhart_limits(sigma = 1, n = 10, nsigmas = 2)
Remove the -th subgroup from a Phase I data set (array or matrix).
Used during Phase I retrospective analysis to eliminate out-of-control
signals before recomputing reference limits.
remove.data(datum, i)remove.data(datum, i)
datum |
Phase I data (matrix for |
i |
Index of the subgroup to remove (1-based). |
The data set without the -th subgroup.
Daniela R. Recchia, Emanuel P. Barbosa
mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) datum <- data.1(20, 10, mu, Sigma) # Removing the observatiob 13 from the data set "datum" and updating it: datum <- remove.data(datum, 13)mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) datum <- data.1(20, 10, mu, Sigma) # Removing the observatiob 13 from the data set "datum" and updating it: datum <- remove.data(datum, 13)
Compute exact probability control limits for subgroup standard deviations without constructing a plot. Under normal sampling,
For a two-sided chart, the nominal false-alarm probability is divided equally
between the two tails. For an upper chart, all of alpha is assigned to
the upper tail and the lower limit is zero.
s_exact_limits(sigma, n, alpha = ALPHA, side = c("two.sided", "upper"))s_exact_limits(sigma, n, alpha = ALPHA, side = c("two.sided", "upper"))
sigma |
Positive finite scalar. The in-control process standard deviation. When estimated from Phase I data, the returned limits are plug-in limits and do not incorporate Phase I estimation uncertainty. |
n |
Integer subgroup size(s), each at least 2. |
alpha |
Nominal false-alarm probability per subgroup, strictly between 0 and 1. Defaults to 0.0027. |
side |
Either |
A named list with components lcl, ucl, center,
sigma, n, alpha, side, and method.
The theoretical center is .
These functions take sigma as known. If a Phase I estimate is
supplied instead, the resulting limits are plug-in limits. The historical
cchart.S() wrapper estimates sigma from the data using
qcc::sd.S() before calling this function for exact limits.
A subgroup standard deviation signals out of control when it is below
lcl or above ucl. Equality to a limit is treated as in control.
Montgomery, D. C. (2009). Introduction to Statistical Quality Control, 6th ed. Wiley.
s_shewhart_limits, cchart.S,
c4
s_exact_limits(sigma = 2, n = 5) s_exact_limits(sigma = 1, n = 2:6, side = "upper")s_exact_limits(sigma = 2, n = 5) s_exact_limits(sigma = 1, n = 2:6, side = "upper")
Compute conventional Shewhart limits for subgroup standard deviations
without constructing a plot. Under normality,
and
. With the default theoretical center,
the limits are therefore
and
where is nsigmas.
s_shewhart_limits( sigma, n, nsigmas = SIGMA_MULT, side = c("two.sided", "upper"), center = NULL )s_shewhart_limits( sigma, n, nsigmas = SIGMA_MULT, side = c("two.sided", "upper"), center = NULL )
sigma |
Positive finite scalar. The in-control process standard deviation, known or estimated separately. |
n |
Integer subgroup size(s), each at least 2. |
nsigmas |
Positive finite scalar giving the number of standard-error units used for the limits. Defaults to 3. |
side |
Either |
center |
Optional finite numeric center. It may be a scalar or have the
same length as |
The optional center argument exists to reproduce the historical
qcc S-chart convention, which centers the limits on the observed
weighted mean of subgroup standard deviations while estimating sigma
separately. When center = NULL, the theoretical center
is used.
A named list with components lcl, ucl, center,
sigma, n, nsigmas, side, and method.
The current qcc::limits.S() implementation computes
std.dev * sqrt(1 - c4(sizes)^2) as the standard error of the plotted
S statistic and centers conventional limits on the chart center supplied by
qcc. Consequently, cchart.S(type = "n") passes its Phase I
weighted S center explicitly to this function. This preserves the historical
IQCC/qcc numerical behavior rather than silently replacing the sample center
by .
Montgomery, D. C. (2009). Introduction to Statistical Quality Control, 6th ed. Wiley.
Scrucca, L. qcc: Quality Control Charts. R package.
s_shewhart_limits(sigma = 2, n = 5) s_shewhart_limits(sigma = 2, n = 5, center = 1.9)s_shewhart_limits(sigma = 2, n = 5) s_shewhart_limits(sigma = 2, n = 5, center = 1.9)
Monte Carlo simulation to study the convergence of the Hotelling T²
statistic to its asymptotic distribution under various
multivariate distributions. Used to validate the asymptotic robustness
result of Gneri and Barbosa (2006).
sim_t2_asymptotic( n = c(10, 30, 100, 500), p = c(2, 5), distributions = c("normal", "t5", "gamma2"), nsim = 10000, sig_levels = c(0.9, 0.95, 0.99), seed = 42, rho = 0.3 )sim_t2_asymptotic( n = c(10, 30, 100, 500), p = c(2, 5), distributions = c("normal", "t5", "gamma2"), nsim = 10000, sig_levels = c(0.9, 0.95, 0.99), seed = 42, rho = 0.3 )
n |
Integer vector of sample sizes to evaluate. Each element must
satisfy |
p |
Integer vector of dimensions to evaluate. Default is
|
distributions |
Character vector of distribution names. Available options:
|
nsim |
Number of Monte Carlo replications. A single positive integer. Default is 10000. |
sig_levels |
Numeric vector of quantile levels in |
seed |
Random seed for reproducibility. A single integer.
Default is |
rho |
Correlation parameter for the equicorrelation matrix
|
For each combination of sample size , dimension , and
distribution, the function generates nsim samples, computes the
Hotelling T² statistic, and compares empirical quantiles against the
limiting distribution.
The T² statistic is computed from a single sample
as where
is the known null mean and is the sample
covariance. This matches the form in Theorem 3 of Gneri and Barbosa
(2006). It does not match the Phase I statistic
T2.1, which uses estimated grand means and pooled
covariance from multiple subgroups.
A data frame with columns:
nSample size.
pDimension.
distributionDistribution name.
levelQuantile level (e.g., 0.95).
empiricalEmpirical quantile of simulated T².
chisqTheoretical quantile.
mcseEmpirical Monte Carlo standard error estimate for the simulated quantile.
nsimNumber of valid replications (after discarding singular covariance draws).
The function saves and restores .Random.seed on exit, so it
does not alter the global RNG state.
The MCSE is estimated from the spacing of simulated order statistics.
For probability , an approximate 95 percent binomial interval
for the quantile rank is mapped back to the ordered simulated T² values;
the interval width divided by estimates the standard
error. This calculation is distribution-free at the rank level and does
not assume that the simulated statistic already follows
.
Gneri, M. A. and Barbosa, E. P. (2006). "Robustez Asintótica de la Estadística de Hotelling". Sección 4.2, Teorema 3, pp. 34-36.
# Quick test with few replications res <- sim_t2_asymptotic( n = c(30, 100), p = 2, distributions = c("normal", "t5"), nsim = 500, seed = 42 ) res# Quick test with few replications res <- sim_t2_asymptotic( n = c(30, 100), p = 2, distributions = c("normal", "t5"), nsim = 500, seed = 42 ) res
15 subgroups of size 10 containing volume measurements of soft drink bottles. This data set is used throughout the IQCC package for multivariate and univariate control chart examples.
A data frame with 15 lines and 10 columns.
The first measure.
The second measure.
The third measure.
The fourth measure.
The fifth measure.
The sixth measure.
The seventh measure.
The eighth measure.
The ninth measure.
The tenth measure.
Montgomery, D. C. (2009). Introduction to Statistical Quality Control, 6th ed. Wiley.
data(softdrink)data(softdrink)
Compute the reference statistics needed by T2.1 and
T2.2 from Phase I data. Returns a list with: [[1]]
grand mean vector (), [[2]] pooled covariance
matrix (), [[3]] matrix of subgroup means.
stats(datum, m, n, p)stats(datum, m, n, p)
datum |
For |
m |
Number of subgroups. |
n |
Subgroup size. |
p |
Dimension. |
To use this function it is necessary to have the information from
data.1.
A list with three components: grand mean (vector), pooled covariance
(matrix), subgroup means ( matrix).
Designed for Phase I reference data.
Daniela R. Recchia, Emanuel P. Barbosa
mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) #Example with individual observations datum <- data.1(50, 1, mu, Sigma) estat <- stats(datum, 50, 1, 2) #Example with sub-group observations datum <- data.1(20, 10, mu, Sigma) estat <- stats(datum, 20, 10, 2)mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) #Example with individual observations datum <- data.1(50, 1, mu, Sigma) estat <- stats(datum, 50, 1, 2) #Example with sub-group observations datum <- data.1(20, 10, mu, Sigma) estat <- stats(datum, 20, 10, 2)
Calculate the Hotelling T² statistic for Phase I using estimated mean vector
and covariance matrix. For individual observations ():
. For subgroups ():
.
T2.1(estat, m, n)T2.1(estat, m, n)
estat |
A list returned by |
m |
Number of subgroups (Phase I sample size). |
n |
Subgroup size. Use |
Before using this function it is necessary to execute stats
(that calculates the auxiliary statistics involved in the T² formula) and
the function data.1 (or other way to supply the data).
A numeric vector of length with the T² statistics.
Phase I --- uses parameters estimated from the same data being
plotted. The T² statistics are not independent.
Stop if .
A Phase I point signals when T² exceeds the UCL from
cchart.T2.1.
Daniela R. Recchia, Emanuel P. Barbosa
Montgomery, D.C., (2009). "Introduction to Statistical Quality Control". Chapter 11. Wiley.
T2.2, cchart.T2.1,
stats, data.1,
robustez
mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) #Example with individual observations datum <- data.1(50, 1, mu, Sigma) estat <- stats(datum, 50, 1, 2) T2.1(estat, 50, 1) #Example with sub group observations datum <- data.1(20, 10, mu, Sigma) estat <- stats(datum, 20, 10, 2) T2.1(estat, 20, 10)mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) #Example with individual observations datum <- data.1(50, 1, mu, Sigma) estat <- stats(datum, 50, 1, 2) T2.1(estat, 50, 1) #Example with sub group observations datum <- data.1(20, 10, mu, Sigma) estat <- stats(datum, 20, 10, 2) T2.1(estat, 20, 10)
Calculate T² for new (Phase II) observations using Phase I reference
parameters. For individual observations:
.
For subgroups:
.
T2.2(datum2, estat, n)T2.2(datum2, estat, n)
datum2 |
Phase II data. For |
estat |
List from |
n |
Subgroup size. Use |
Before using this function it is necessary to execute stats
(that calculates the auxiliary statistics involved in the T² formula) and
the function data.2 (or other way to supply the data).
A scalar T² statistic.
Phase II --- tests new observations against Phase I reference
distribution.
Daniela R. Recchia, Emanuel P. Barbosa
Montgomery, D.C., (2009). "Introduction to Statistical Quality Control". Chapter 11. Wiley.
mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) #Example with individual observations datum <- data.1(50, 1, mu, Sigma) estat <- stats(datum, 50, 1, 2) datum2 <- data.2(estat, 1, p = 2) T2II <- T2.2(datum2, estat, 1) #Example with subgroup observations datum <- data.1(20, 10, mu, Sigma) estat <- stats(datum, 20, 10, 2) datum2 <- data.2(estat, 10, p = 2) T2II <- T2.2(datum2, estat, 10)mu <- c(5.682, 88.22) Sigma <- miscTools::symMatrix(c(3.770, -5.495, 13.53), 2) #Example with individual observations datum <- data.1(50, 1, mu, Sigma) estat <- stats(datum, 50, 1, 2) datum2 <- data.2(estat, 1, p = 2) T2II <- T2.2(datum2, estat, 1) #Example with subgroup observations datum <- data.1(20, 10, mu, Sigma) estat <- stats(datum, 20, 10, 2) datum2 <- data.2(estat, 10, p = 2) T2II <- T2.2(datum2, estat, 10)
Build a matrix with the constants , , and for
sample sizes the specified maximum.
table.const(n)table.const(n)
n |
Maximum sample size (must be |
The three constants are those returned by d2,
d3, and c4 respectively. They are the standard
Shewhart chart constants for the relative range and the standard deviation
under normality.
A matrix with rows and 3 columns named "d2",
"d3", "c4". Row names are the sample sizes.
Stops if n < 2, raised by the internal d2 call.
Daniela R. Recchia, Emanuel P. Barbosa
Montgomery, D. C. (2009). Introduction to Statistical Quality Control, 6th ed. Wiley.
table.const(10) table.const(5)table.const(10) table.const(5)
Print a table of quantiles of the studentized range distribution
for sample sizes through the specified
maximum, using qtukey with infinite denominator degrees
of freedom.
table.qtukey(alpha, n)table.qtukey(alpha, n)
alpha |
Type-I error probability ( |
n |
Maximum sample size ( |
Four tail probabilities are tabulated for each : ,
, , and . The default examples
use (US convention) and
(European convention).
Invisibly, a matrix with rows and 4 columns. The matrix
is also printed to the console.
Stops if n < 2 or if alpha is not strictly between 0 and 1.
Daniela R. Recchia, Emanuel P. Barbosa
Barbosa, E. P., Gneri, M. A. and Meneguetti, A. (2013). On the the evaluation of the relative range distribution. Communications in Statistics - Simulation and Computation, 42, 1311–1339. doi:10.1080/03610918.2011.639967.
table.qtukey(0.0027, 15) table.qtukey(0.0020, 10)table.qtukey(0.0027, 15) table.qtukey(0.0020, 10)
Evaluate the actual in-control upper-tail probability of a supplied
tr(V) upper control limit.
trv_alpha_risk( n, p, ucl, Sigma0 = NULL, type = c("chisq", "simulation"), nsim = 1e+05, seed = NULL )trv_alpha_risk( n, p, ucl, Sigma0 = NULL, type = c("chisq", "simulation"), nsim = 1e+05, seed = NULL )
n |
Integer subgroup sample size, at least 2. |
p |
Integer process dimension, at least 2. |
ucl |
Positive finite upper control limit on the trace statistic. |
Sigma0 |
Optional in-control covariance matrix. It is accepted for API
symmetry with |
type |
Character string selecting the calculation:
|
nsim |
Integer number of Monte Carlo draws, at least 1000. Used only
when |
seed |
|
A list with components alpha, arl0, ucl,
n, p, df, and method.
lim <- trv_limits(8, 2) trv_alpha_risk(8, 2, lim$ucl)lim <- trv_limits(8, 2) trv_alpha_risk(8, 2, lim$ucl)
Compute one-sided upper control limits for the auxiliary trace statistic
.
trv_limits( n, p, alpha = 0.0027, type = c("chisq", "simulation"), nsim = 1e+05, seed = NULL )trv_limits( n, p, alpha = 0.0027, type = c("chisq", "simulation"), nsim = 1e+05, seed = NULL )
n |
Integer subgroup sample size, at least 2. |
p |
Integer process dimension, at least 2. |
alpha |
Nominal upper-tail false-alarm probability, strictly between 0 and 1. |
type |
Character string selecting the calculation:
|
nsim |
Integer number of Monte Carlo draws, at least 1000. Used only
when |
seed |
|
Table 3 of Barbosa, Gneri, and Meneguetti uses as the row label,
although its numerical values correspond to subgroup size and
degrees of freedom. Its printed probability headings also
appear reversed: the column headed 0.9980 matches the 0.9973 quantile and
vice versa. This function follows the mathematical definition and evaluates
qchisq(1 - alpha, df = p * (n - 1)); it does not interchange tail
probabilities to reproduce the apparent table-label error.
A list with components lcl, ucl, center,
type, alpha, n, p, df, nsim,
and seed. The lower control limit is zero because the chart is
one-sided upper.
trv_limits(n = 8, p = 2) trv_limits(n = 8, p = 2, type = "simulation", nsim = 5000, seed = 2026)trv_limits(n = 8, p = 2) trv_limits(n = 8, p = 2, type = "simulation", nsim = 5000, seed = 2026)
Compute the auxiliary trace statistic
where is the unbiased subgroup covariance matrix and
is the in-control covariance matrix.
trv_stat(x, size = NULL, Sigma0)trv_stat(x, size = NULL, Sigma0)
x |
Multivariate subgroup data in any format accepted by
|
size |
Positive integer subgroup size when |
Sigma0 |
Finite symmetric positive-definite in-control covariance matrix. |
The statistic complements the generalized variance . Two
covariance matrices can have the same determinant but different trace after
standardization by ; trv_stat() is designed to make
that structural change visible.
Under independent sampling from a multivariate normal process with
covariance ,
and therefore
The implementation evaluates the trace as
(n - 1) * sum(Sigma0_inverse * S), avoiding an explicit matrix
square root while preserving the same value.
A numeric vector with one trace statistic per subgroup.
Errors are raised for invalid subgroup data, non-finite observations,
subgroup sizes smaller than two, a non-square or non-symmetric
Sigma0, a dimension mismatch, or a covariance matrix that is not
positive definite.
Barbosa, E. P., Gneri, M. A., and Meneguetti, A. Improving Shewhart-type Generalized Variance Control Charts for Multivariate Process Variability Monitoring using Cornish-Fisher Quantile Correction, Meijer-G Function and Other Tools. Research report.
Anderson, T. W. (1984). An Introduction to Multivariate Statistical Analysis, 2nd ed. Wiley.
trv_limits, trv_alpha_risk,
cchart.trV, gv_stat
g1 <- cbind(c(0, 1, 2, 3), c(0, 2, 1, 3)) g2 <- cbind(c(1, 2, 4, 7), c(3, 1, 5, 2)) trv_stat(list(g1, g2), Sigma0 = diag(2))g1 <- cbind(c(0, 1, 2, 3), c(0, 2, 1, 3)) g2 <- cbind(c(1, 2, 4, 7), c(3, 1, 5, 2)) trv_stat(list(g1, g2), Sigma0 = diag(2))
Compute the actual false-alarm probability under
, with a signal when
or .
uchart_alpha_risk(lambda, n, lcl, ucl)uchart_alpha_risk(lambda, n, lcl, ucl)
lambda |
In-control defect rate per inspection unit. |
n |
Positive inspection size or vector of inspection sizes. |
lcl |
Lower control limit or vector of limits. |
ucl |
Upper control limit or vector of limits. |
A numeric vector of exact false-alarm probabilities.
limits <- uchart_limits(1.4, 10, type = "cf2") uchart_alpha_risk(1.4, 10, limits$lcl, limits$ucl)limits <- uchart_limits(1.4, 10, type = "cf2") uchart_alpha_risk(1.4, 10, limits$lcl, limits$ucl)
Compute normal or Cornish-Fisher probability limits for a u chart without
constructing a plot. The model is and the
monitored rate is .
uchart_limits( lambda, n, alpha = ALPHA, type = c("normal", "cf1", "cf2"), sides = c("two.sided", "upper"), truncate = TRUE )uchart_limits( lambda, n, alpha = ALPHA, type = c("normal", "cf1", "cf2"), sides = c("two.sided", "upper"), truncate = TRUE )
lambda |
In-control defect rate per inspection unit. A positive scalar. |
n |
Positive inspection size or vector of inspection sizes. |
alpha |
Nominal false-alarm probability. Defaults to 0.0027. |
type |
Limit method: |
sides |
Either |
truncate |
Logical. If |
For , the standardized third and fourth cumulants are
and .
Consequently, the first Cornish-Fisher correction is
and the second-order correction reduces to
. Each tail is evaluated at its
signed normal quantile: for the UCL and
for the LCL.
With , the CF2 limits recover
and
before optional truncation at zero.
A list containing center, lcl, ucl,
n, alpha, type, sides, and mean_count.
uchart_limits(1.4, 10, type = "normal") uchart_limits(1.4, 10, type = "cf1") uchart_limits(1.4, 10, type = "cf2")uchart_limits(1.4, 10, type = "normal") uchart_limits(1.4, 10, type = "cf1") uchart_limits(1.4, 10, type = "cf2")