| Title: | Classical and Generalized Process Capability Indices |
|---|---|
| Description: | Computes classical process capability indices (Cp, Cpk, Cpu, Cpl, Cpm, Cpmk, Pp, Ppk, Ppu, Ppl, Z) and the generalized process capability index Cpy (Maiti, Saha & Nanda, 2010) <doi:10.1080/16843703.2010.11673233> for any continuous or discrete quality characteristic. Users supply the probability density function (PDF) and cumulative distribution function (CDF) of the characteristic, and the package returns point estimates, bootstrap confidence intervals (percentile and BCa), and sensitivity tables/plots across ranges of short-term standard deviation (sigma), long-term standard deviation (s), desired yield (p0), and significance levels. Classical indices are recoverable as special cases under the normal distribution. The package follows the theory and notation of Kane (1986) <doi:10.1080/00224065.1986.11978984>, Chan, Cheng & Spiring (1988) <doi:10.1080/00224065.1988.11979102>, Pearn, Kotz & Johnson (1992) <doi:10.1080/00224065.1992.11979403>, Kotz & Johnson (2002) <doi:10.1080/00224065.2002.11980119>, Montgomery (2020, ISBN:978-1-119-39930-8), Juran (1974, ISBN:978-0-07-033176-1), Harry & Schroeder (2000, ISBN:978-0-385-49437-2), and the AIAG SPC Reference Manual (2005, ISBN:978-1-60534-026-3). |
| Authors: | Shikhar Tyagi [aut, cre] (ORCID: <https://orcid.org/0000-0003-1606-0844>), Sumit Kumar [aut], Vrijesh Tripathi [aut] |
| Maintainer: | Shikhar Tyagi <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-13 12:12:53 UTC |
| Source: | https://github.com/cran/ProcessCapabilityR |
.
cp(LSL, USL, sigma)cp(LSL, USL, sigma)
LSL |
Lower specification limit. |
USL |
Upper specification limit. |
sigma |
Short-term (within-subgroup) standard deviation. |
Numeric value of .
cp(LSL = 57, USL = 63, sigma = 1) # 1.0cp(LSL = 57, USL = 63, sigma = 1) # 1.0
.
cpk(LSL, USL, mu, sigma)cpk(LSL, USL, mu, sigma)
LSL |
Lower specification limit. |
USL |
Upper specification limit. |
mu |
Short-term process mean. |
sigma |
Short-term standard deviation. |
Numeric value of .
cpk(LSL = 57, USL = 63, mu = 60, sigma = 1) # 1.0cpk(LSL = 57, USL = 63, mu = 60, sigma = 1) # 1.0
.
cpl(LSL, mu, sigma)cpl(LSL, mu, sigma)
LSL |
Lower specification limit. |
mu |
Short-term process mean. |
sigma |
Short-term standard deviation. |
Numeric value of .
cpl(LSL = 57, mu = 60, sigma = 1) # 1.0cpl(LSL = 57, mu = 60, sigma = 1) # 1.0
.
cpm(LSL, USL, mu, sigma, target)cpm(LSL, USL, mu, sigma, target)
LSL |
Lower specification limit. |
USL |
Upper specification limit. |
mu |
Short-term process mean. |
sigma |
Short-term standard deviation. |
target |
Target value |
Numeric value of .
cpm(LSL = 57, USL = 63, mu = 60, sigma = 1, target = 60) # 1.0cpm(LSL = 57, USL = 63, mu = 60, sigma = 1, target = 60) # 1.0
.
cpmk(LSL, USL, mu, sigma, target)cpmk(LSL, USL, mu, sigma, target)
LSL |
Lower specification limit. |
USL |
Upper specification limit. |
mu |
Short-term process mean. |
sigma |
Short-term standard deviation. |
target |
Target value |
Numeric value of .
cpmk(LSL = 57, USL = 63, mu = 60, sigma = 1, target = 60) # 1.0cpmk(LSL = 57, USL = 63, mu = 60, sigma = 1, target = 60) # 1.0
.
cpu(USL, mu, sigma)cpu(USL, mu, sigma)
USL |
Upper specification limit. |
mu |
Short-term process mean. |
sigma |
Short-term standard deviation. |
Numeric value of .
cpu(USL = 63, mu = 60, sigma = 1) # 1.0cpu(USL = 63, mu = 60, sigma = 1) # 1.0
, where is the CDF from dist
(Maiti, Saha & Nanda, 2010).
cpy(dist, LSL, USL, LDL = NULL, UDL = NULL, p0 = NULL)cpy(dist, LSL, USL, LDL = NULL, UDL = NULL, p0 = NULL)
dist |
A |
LSL |
Lower specification limit. |
USL |
Upper specification limit. |
LDL |
Lower desirable limit (optional if |
UDL |
Upper desirable limit (optional if |
p0 |
Desired yield (optional if |
Numeric value of .
d <- pci_dist_normal(mean = 60, sd = 1) cpy(d, LSL = 57, USL = 63, LDL = 57, UDL = 63) # 1.0d <- pci_dist_normal(mean = 60, sd = 1) cpy(d, LSL = 57, USL = 63, LDL = 57, UDL = 63) # 1.0
Computes a single process capability or performance index from the supplied parameters.
pci( index, dist = NULL, LSL = NULL, USL = NULL, target = NULL, mu = NULL, sigma = NULL, xbar = NULL, s = NULL, LDL = NULL, UDL = NULL, p0 = NULL )pci( index, dist = NULL, LSL = NULL, USL = NULL, target = NULL, mu = NULL, sigma = NULL, xbar = NULL, s = NULL, LDL = NULL, UDL = NULL, p0 = NULL )
index |
Character string: one of |
dist |
A |
LSL, USL
|
Lower and upper specification limits. |
target |
Target value (required for |
mu, sigma
|
Short-term (within-subgroup) mean and standard deviation. |
xbar, s
|
Long-term (overall) mean and standard deviation. |
LDL, UDL
|
Lower and upper desirable limits for |
p0 |
Desired yield for |
The twelve supported indices are:
A single numeric value, or NA with a warning when a
one-sided index is requested but the relevant specification limit is
NULL.
pci("Cp", LSL = 57, USL = 63, sigma = 1) # 1.0 pci("Cpk", LSL = 57, USL = 63, mu = 60, sigma = 1) # 1.0 pci("Z", LSL = 57, USL = 63, mu = 60, sigma = 1) # 3.0 # Generalized Cpy d <- pci_dist_normal(60, 1) pci("Cpy", dist = d, LSL = 57, USL = 63, LDL = 57, UDL = 63) # 1.0pci("Cp", LSL = 57, USL = 63, sigma = 1) # 1.0 pci("Cpk", LSL = 57, USL = 63, mu = 60, sigma = 1) # 1.0 pci("Z", LSL = 57, USL = 63, mu = 60, sigma = 1) # 3.0 # Generalized Cpy d <- pci_dist_normal(60, 1) pci("Cpy", dist = d, LSL = 57, USL = 63, LDL = 57, UDL = 63) # 1.0
Computes a confidence interval for a PCI via parametric or nonparametric bootstrap.
pci_ci( index, dist, n, data = NULL, LSL = NULL, USL = NULL, target = NULL, LDL = NULL, UDL = NULL, p0 = NULL, alpha = 0.05, B = 2000, method = c("percentile", "bca") )pci_ci( index, dist, n, data = NULL, LSL = NULL, USL = NULL, target = NULL, LDL = NULL, UDL = NULL, p0 = NULL, alpha = 0.05, B = 2000, method = c("percentile", "bca") )
index |
Character: one of the 12 index names (see |
dist |
A |
n |
Integer sample size. |
data |
Optional numeric vector of observed data. If supplied, nonparametric bootstrap is used instead of parametric. |
LSL, USL
|
Specification limits. |
target |
Target value (for |
LDL, UDL
|
Desirable limits (for |
p0 |
Desired yield (for |
alpha |
Significance level; the interval covers |
B |
Number of bootstrap replications. Default 2000. |
method |
Character: |
**Parametric bootstrap** (when data = NULL): B samples of size
n are drawn from dist via inverse-CDF sampling.
For each sample the process mean, standard deviation (and, for
, the empirical CDF) are estimated, and the index is
recomputed.
**Nonparametric bootstrap** (when data is supplied): B
resamples of the same length are drawn with replacement from data.
Two interval methods are available:
Uses the alpha/2 and 1 - alpha/2
quantiles of the bootstrap distribution.
Bias-corrected and accelerated interval using jackknife acceleration and bootstrap bias correction (Efron, 1987).
An S3 object of class "pci_ci" with components:
index |
The index name. |
estimate |
Point estimate. |
lower |
Lower CI bound. |
upper |
Upper CI bound. |
alpha |
The significance level used. |
method |
The interval method used. |
boot_values |
Numeric vector of all |
d <- pci_dist_normal(mean = 60, sd = 1) ci <- pci_ci("Cp", dist = d, n = 30, LSL = 57, USL = 63, alpha = 0.05, B = 500) print(ci)d <- pci_dist_normal(mean = 60, sd = 1) ci <- pci_ci("Cp", dist = d, n = 30, LSL = 57, USL = 63, alpha = 0.05, B = 500) print(ci)
Constructs an S3 object of class "pci_dist" that encapsulates the
probability density function (PDF) and cumulative distribution function (CDF)
of a quality characteristic. This object is passed to pci,
pci_ci, and pci_grid when computing generalised
indices such as .
pci_dist(pdf, cdf = NULL, params = list(), support = c(-Inf, Inf))pci_dist(pdf, cdf = NULL, params = list(), support = c(-Inf, Inf))
pdf |
A function |
cdf |
A function |
params |
A named list of distribution parameters forwarded to
|
support |
A length-2 numeric vector giving the lower and upper bounds
of the distribution's support (default |
An S3 object of class "pci_dist" with elements:
pdf_fn |
Closure that evaluates the PDF at a given point. |
cdf_fn |
Closure that evaluates the CDF at a given point. |
params |
The supplied parameter list. |
support |
The supplied support bounds. |
cdf_is_numeric |
Logical; |
# Normal distribution d <- pci_dist( pdf = function(x, mean, sd) dnorm(x, mean, sd), cdf = function(x, mean, sd) pnorm(x, mean, sd), params = list(mean = 0, sd = 1) ) d$cdf_fn(0) # 0.5 # Weibull with only PDF (CDF derived numerically) d2 <- pci_dist( pdf = function(x, shape, scale) dweibull(x, shape, scale), params = list(shape = 2, scale = 10), support = c(0, 60) )# Normal distribution d <- pci_dist( pdf = function(x, mean, sd) dnorm(x, mean, sd), cdf = function(x, mean, sd) pnorm(x, mean, sd), params = list(mean = 0, sd = 1) ) d$cdf_fn(0) # 0.5 # Weibull with only PDF (CDF derived numerically) d2 <- pci_dist( pdf = function(x, shape, scale) dweibull(x, shape, scale), params = list(shape = 2, scale = 10), support = c(0, 60) )
Convenience constructor for a pci_dist based on the normal
distribution. Useful for sanity-checking that collapses to
the classical indices when is the normal CDF.
pci_dist_normal(mean = 0, sd = 1)pci_dist_normal(mean = 0, sd = 1)
mean |
Mean of the normal distribution. |
sd |
Standard deviation of the normal distribution. |
An S3 object of class "pci_dist" encapsulating the normal
distribution PDF and CDF functions, parameter list, and support bounds.
d <- pci_dist_normal(mean = 60, sd = 1) d$cdf_fn(60) # 0.5 d$pdf_fn(60) # ~ 0.3989d <- pci_dist_normal(mean = 60, sd = 1) d$cdf_fn(60) # 0.5 d$pdf_fn(60) # ~ 0.3989
Computes a PCI across a grid of parameter values (short-term standard
deviation sigma, long-term standard deviation s, and/or
desired yield p0), optionally with bootstrap confidence intervals at
multiple significance levels.
pci_grid( index, dist = NULL, LSL = NULL, USL = NULL, target = NULL, sigma_vals = NULL, s_vals = NULL, p0_vals = NULL, mu = NULL, xbar = NULL, alpha_vals = c(0.1, 0.05, 0.01), n = NULL, B = 2000 )pci_grid( index, dist = NULL, LSL = NULL, USL = NULL, target = NULL, sigma_vals = NULL, s_vals = NULL, p0_vals = NULL, mu = NULL, xbar = NULL, alpha_vals = c(0.1, 0.05, 0.01), n = NULL, B = 2000 )
index |
Character: one of the 12 index names (see |
dist |
A |
LSL, USL
|
Specification limits. |
target |
Target value (for |
sigma_vals |
Numeric vector of |
s_vals |
Numeric vector of |
p0_vals |
Numeric vector of |
mu |
Short-term process mean. |
xbar |
Long-term process mean. |
alpha_vals |
Numeric vector of significance levels.
Default |
n |
Sample size for bootstrap CIs. If |
B |
Bootstrap replications. Default 2000. |
A data.frame (with additional class "pci_grid")
in long format with columns:
index, sigma, s, p0, alpha,
estimate, lower, upper.
Columns that do not apply to the chosen index contain NA.
grid <- pci_grid("Cp", LSL = 57, USL = 63, sigma_vals = c(0.5, 1.0, 1.5), mu = 60, alpha_vals = c(0.05, 0.01)) print(grid)grid <- pci_grid("Cp", LSL = 57, USL = 63, sigma_vals = c(0.5, 1.0, 1.5), mu = 60, alpha_vals = c(0.05, 0.01)) print(grid)
Produces a ggplot2 line-and-ribbon plot showing the PCI estimate and confidence bands as a function of the chosen sweep variable, faceted by significance level.
## S3 method for class 'pci_grid' plot(x, x_axis = c("sigma", "s", "p0"), facet_by = "alpha", ...)## S3 method for class 'pci_grid' plot(x, x_axis = c("sigma", "s", "p0"), facet_by = "alpha", ...)
x |
A |
x_axis |
Character: which sweep variable to place on the x-axis.
One of |
facet_by |
Character: column name to facet by. Default |
... |
Additional arguments (currently ignored). |
Invisibly returns a ggplot object representing
the sensitivity plot. Called primarily for its side effect of rendering a
line-and-ribbon plot to the active graphic device.
if (requireNamespace("ggplot2", quietly = TRUE)) { grid <- pci_grid("Cp", LSL = 57, USL = 63, sigma_vals = seq(0.5, 2, 0.1), mu = 60, alpha_vals = c(0.05, 0.01), n = 30, B = 200, dist = pci_dist_normal(60, 1)) plot(grid, x_axis = "sigma") }if (requireNamespace("ggplot2", quietly = TRUE)) { grid <- pci_grid("Cp", LSL = 57, USL = 63, sigma_vals = seq(0.5, 2, 0.1), mu = 60, alpha_vals = c(0.05, 0.01), n = 30, B = 200, dist = pci_dist_normal(60, 1)) plot(grid, x_axis = "sigma") }
.
pp(LSL, USL, s)pp(LSL, USL, s)
LSL |
Lower specification limit. |
USL |
Upper specification limit. |
s |
Long-term (overall) standard deviation. |
Numeric value of .
pp(LSL = 57, USL = 63, s = 1.5) # 0.6667pp(LSL = 57, USL = 63, s = 1.5) # 0.6667
.
ppk(LSL, USL, xbar, s)ppk(LSL, USL, xbar, s)
LSL |
Lower specification limit. |
USL |
Upper specification limit. |
xbar |
Long-term (overall) mean. |
s |
Long-term standard deviation. |
Numeric value of .
ppk(LSL = 57, USL = 63, xbar = 60, s = 1.5) # 0.6667ppk(LSL = 57, USL = 63, xbar = 60, s = 1.5) # 0.6667
.
ppl(LSL, xbar, s)ppl(LSL, xbar, s)
LSL |
Lower specification limit. |
xbar |
Long-term mean. |
s |
Long-term standard deviation. |
Numeric value of .
ppl(LSL = 57, xbar = 60, s = 1.5) # 0.6667ppl(LSL = 57, xbar = 60, s = 1.5) # 0.6667
.
ppu(USL, xbar, s)ppu(USL, xbar, s)
USL |
Upper specification limit. |
xbar |
Long-term mean. |
s |
Long-term standard deviation. |
Numeric value of .
ppu(USL = 63, xbar = 60, s = 1.5) # 0.6667ppu(USL = 63, xbar = 60, s = 1.5) # 0.6667
Print method for pci_ci objects
## S3 method for class 'pci_ci' print(x, ...)## S3 method for class 'pci_ci' print(x, ...)
x |
A |
... |
Additional arguments (ignored). |
Invisibly returns the input x of class "pci_ci".
Called for side effect of printing formatted confidence interval details to the console.
Print method for pci_dist objects
## S3 method for class 'pci_dist' print(x, ...)## S3 method for class 'pci_dist' print(x, ...)
x |
A |
... |
Additional arguments (ignored). |
Invisibly returns the input x of class "pci_dist".
Called for side effect of printing distribution parameters and specification details to the console.
.
z_level(LSL, USL, mu, sigma)z_level(LSL, USL, mu, sigma)
LSL |
Lower specification limit. |
USL |
Upper specification limit. |
mu |
Short-term process mean. |
sigma |
Short-term standard deviation. |
Numeric value of .
z_level(LSL = 57, USL = 63, mu = 60, sigma = 1) # 3.0z_level(LSL = 57, USL = 63, mu = 60, sigma = 1) # 3.0