Learn R Programming

r6qualitytools (version 1.0.1)

pcr: pcr: Process Capability Indices

Description

Calculates the process capability cp, cpk, cpkL (onesided) and cpkU (onesided) for a given dataset and distribution. A histogram with a density curve is displayed along with the specification limits and a Quantile-Quantile Plot for the specified distribution. Lower-, upper and total fraction of nonconforming entities are calculated. Box-Cox Transformations are supported as well as the calculation of Anderson Darling Test Statistics.

Usage

pcr(
  x,
  distribution = "normal",
  lsl,
  usl,
  target,
  boxcox = FALSE,
  lambda = c(-5, 5),
  main,
  xlim,
  grouping = NULL,
  std.dev = NULL,
  conf.level = 0.9973002,
  bounds.lty = 3,
  bounds.col = "red",
  col.fill = "lightblue",
  col.border = "black",
  col.curve = "red",
  plot = TRUE,
  ADtest = TRUE
)

Value

The function returns a list with the following components:

The function pcr returns a list with lambda, cp, cpl, cpu, ppt, ppl, ppu, A, usl, lsl, target, asTest, plot.

Arguments

x

Numeric vector containing the values for which the process capability should be calculated.

distribution

Character string specifying the distribution of x. The function cp will accept the following character strings for distribution:

  • `normal`

  • `log-normal`

  • `exponential`

  • `logistic`

  • `gamma`

  • `weibull`

  • `cauchy`

  • `gamma3`

  • `weibull3`

  • `lognormal3`

  • `beta`

  • `f`

  • `geometric`

  • `poisson`

  • `negative-binomial`

By default distribution is set to `normal`.

lsl

A numeric value specifying the lower specification limit.

usl

A numeric value specifying the upper specification limit.

target

(Optional) numeric value giving the target value.

boxcox

Logical value specifying whether a Box-Cox transformation should be performed or not. By default boxcox is set to FALSE.

lambda

(Optional) lambda for the transformation, default is to have the function estimate lambda.

main

A character string specifying the main title of the plot.

xlim

A numeric vector of length 2 specifying the x-axis limits for the plot.

grouping

(Optional) If grouping is given the standard deviation is calculated as mean standard deviation of the specified subgroups corrected by the factor c4 and expected fraction of nonconforming is calculated using this standard deviation.

std.dev

An optional numeric value specifying the historical standard deviation (only provided for normal distribution). If NULL, the standard deviation is calculated from the data.

conf.level

Numeric value between 0 and 1 giving the confidence interval. By default conf.level is 0.9973 (99.73%) which is the reference interval bounded by the 99.865% and 0.135% quantile.

bounds.lty

graphical parameter. For further details see ppPlot or qqPlot.

bounds.col

A character string specifying the color of the capability bounds. Default is "red".

col.fill

A character string specifying the fill color for the histogram plot. Default is "lightblue".

col.border

A character string specifying the border color for the histogram plot. Default is "black".

col.curve

A character string specifying the color of the fitted distribution curve. Default is "red".

plot

A logical value indicating whether to generate a plot. Default is TRUE.

ADtest

A logical value indicating whether to print the Anderson-Darling. Default is TRUE.

Details

Distribution fitting is delegated to the function FitDistr from this package, as well as the calculation of lambda for the Box-Cox Transformation. p-values for the Anderson-Darling Test are reported for the most important distributions.

The process capability indices are calculated as follows:

  • cpk: minimum of cpK and cpL.

  • pt: total fraction nonconforming.

  • pu: upper fraction nonconforming.

  • pl: lower fraction nonconforming.

  • cp: process capability index.

  • cpkL: lower process capability index.

  • cpkU: upper process capability index.

  • cpk: minimum process capability index.

For a Box-Cox transformation, a data vector with positive values is needed to estimate an optimal value of lambda for the Box-Cox power transformation of the values. The Box-Cox power transformation is used to bring the distribution of the data vector closer to normality. Estimation of the optimal lambda is delegated to the function boxcox from the MASS package. The Box-Cox transformation has the form \(y(\lambda) = \frac{y^\lambda - 1}{\lambda}\) for \(\lambda \neq 0\), and \(y(\lambda) = \log(y)\) for \(\lambda = 0\). The function boxcox computes the profile log-likelihoods for a range of values of the parameter lambda. The function boxcox.lambda returns the value of lambda with the maximum profile log-likelihood.

In case no specification limits are given, lsl and usl are calculated to support a process capability index of 1.

Examples

Run this code
set.seed(1234)
data <- rnorm(20, mean = 20)
pcr(data, "normal", lsl = 17, usl = 23)

set.seed(1234)
weib <- rweibull(20, shape = 2, scale = 8)
pcr(weib, "weibull", usl = 20)

Run the code above in your browser using DataLab