Package 'IQCC'

Title: Improved Quality Control Charts
Description: Builds statistical control charts with exact limits for univariate and multivariate cases.
Authors: Flavio Barros [aut, cre], Emanuel Barbosa [ctb], Elias Goncalves [ctb], Daniela Recchia [ctb]
Maintainer: Flavio Barros <[email protected]>
License: GPL-2 | file LICENSE
Version: 0.7
Built: 2025-02-25 04:30:21 UTC
Source: https://github.com/flaviobarros/iqcc

Help Index


Updates the Hotelling Control Chart.

Description

This function is used to update the phase II control chart with new observations.

Usage

add.data(datum2, estat, T2II, n, j, m = NULL)

Arguments

datum2

The data set for the phase II. Shoul be a vector.

estat

The values of the auxiliary statistics. Should be a list with a vector with the mean of the mean vectors, a matrix with the average of the variance-covariance matrices and a matrix with the means.

T2II

A vector with the value of T2 statistic for one sample.

n

The sample size. For individual observations, use n = 1.

j

The index of the current sample.

m

The number of samples in phase I. Only needed if the phase I data set is show on the plot.

Details

To use this function it is necessary to have the output given by the function T2.2. At every step you should entry with the new data set.

Value

Add the new observation to the current Hoteliing control chart for phase II.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

See Also

T2.2

Examples

mu <- c(5.682, 88.22)
Sigma <- 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)

False Alarm probability for the 3-sigma R chart.

Description

Used to calculate the real probability of false alarm in the 3-sigma R chart.

Usage

alpha.risk(n)

Arguments

n

The sample size.

Details

This alpha risk is calculated under the exact R statistics distribution and its values for small sample sizes will be much larger than the reference value 0,0027.

Value

Return the value of the alpha risk for a given sample size n.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

See Also

d2,d3,c4

Examples

alpha.risk(15)

Binomial Data.

Description

This is a binomial data set used on P-charts.

Format

A data frame with 25 observations on the following 4 variables.

i

Index.

ni

The sample Size.

Di

Number of non-conforming units per sample.

pi

Proportion of non-conforming units per sample.

Source

Montgomery, D.C.,2001."Introduction to Statistical Quality Control".

Examples

data(binomdata)

C4 Constant.

Description

This function is used to calculate the bias correction constant c4 for the sample standard deviation statistic.

Usage

c4(n)

Arguments

n

The sample size.

Details

It is used to correct the bias for small sample sizes in the sample standard deviation statistic.

Value

Return the value of c4 for a given sample size n.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

See Also

d2,d3

Examples

c4(5)

p-chart

Description

This function builds p-charts.

Usage

cchart.p(x1 = NULL, n1 = NULL, type = "norm", p1 = NULL, x2 = NULL,
  n2 = NULL, phat = NULL, p2 = NULL)

Arguments

x1

The phase I data that will be plotted (if it is a phase I chart).

n1

A value or a vector of values specifying the sample sizes associated with each group for the phase I data.

type

The type of p-chart to be plotted. The options are "norm" (traditional Shewhart p-chart), "CF" (Cornish Fisher p-chart) and "std" (standardized p-chart). If not specified, a Shewhart p-chart will be plotted.

p1

The data used to estimate the phat (x1 / n1).

x2

The phase II data that will be plotted in a phase II chart.

n2

A value or a vector of values specifying the sample sizes associated with each group for the phase II data.

phat

The estimate of p.

p2

The values corresponding to x2 / n2.

Details

For a phase I p-chart, n1 must be specified and either x1 or p1. For a phase II p-chart, n2 must be specified, plus x2 or p2 and either phat, x1 and n1, or p1 and n1. The Shewhart is based on normal-aprroximation and should be used only for large values of np or n*p (n*p > 6).

Value

Return a p-chart.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

References

Montgomery, D.C.,(2008)."Introduction to Statistical Quality Control". Chapter 11. Wiley

Examples

data(binomdata)
attach(binomdata)
cchart.p(x1 = Di[1:12], n1 = ni[1:12])
cchart.p(x1 = Di[1:12], n1 = ni[1:12], type = "CF", x2 = Di[13:25], n2 = ni[13:25])
cchart.p(type = "std", p2 = Di[13:25], n2 = ni[13:25], phat = 0.1115833)

R control chart

Description

This function builds a R control chart.

Usage

cchart.R(x, n, type = "norm", y = NULL)

Arguments

x

The data to be plotted.

n

The sample size.

type

The type of R chart to be plotted. The options are "norm" (traditional Shewhart R chart) and "tukey" (exact R chart). If not specified, a Shewhart R chart will be plotted.

y

The data used in phase I to estimate the standard deviation.

Details

The Shewhart R chart was designed for phase I (at this moment). The limits of the exact R chart are the alpha/2 and 1-alpha/2 quantiles of the R distribution that are calculated as estimated process sd times the quantiles of the relative range (W=R/sigma) distribution.

Value

Return a R control chart.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

Examples

data(pistonrings)
attach(pistonrings)
cchart.R(pistonrings[1:25,], 5)
cchart.R(pistonrings[26:40, ], 5, type = "tukey", pistonrings[1:25, ])

S Control Chart.

Description

This function builds a S control chart.

Usage

cchart.S(x, type = "n", m = NULL)

Arguments

x

The data to be plotted.

type

A character string specifying the type of S control chart to be plotted where "n" plots a S chart with normalized probability limits and "e" plots a S chart with exact limits.

m

The sample sizes. Only necessary in the control chart with exact (probability) limits.

Details

The exact limits are the alpha/2 and 1-alpha/2 quantiles of the S distribution which is proportional to the square root of a chi-square distribution.

Value

Return a S control chart.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

Examples

data(softdrink)
#S chart with normalized probability limits
cchart.S(softdrink, type = "n")
#S chart with exact probability limits
cchart.S(softdrink, type = "e", 10)

Phase I Hotelling Control Chart.

Description

Builds the phase I Hotelling control chart.

Usage

cchart.T2.1(T2, m, n, p)

Arguments

T2

The values of the T2 statistic. Shoul be a matrix.

m

The number of samples generated previously in data.1.

n

The size of each sample used previously in data.1. If they are individual obsersations, then use n = 1.

p

The dimension used previously in function data.1.

Details

It builds the Hotelling T2 control chart for multivariate normal data (m samples / samples of size n > 1), used retrospective / validation analysis (phase I); the control limits are based on the F distribution.

Value

Return a control chart.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

References

Montgomery, D.C.,(2008)."Introduction to Statistical Quality Control". Chapter 11. Wiley

See Also

cchart.T2.2

Examples

mu <- c(5.682, 88.22)
Sigma <- 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)

Phase II Hotelling Control Chart.

Description

Builds the sub group phase II Hotelling control chart.

Usage

cchart.T2.2(T2II, m, n, j, t, p, datum = NULL, stats = NULL, T2 = NULL)

Arguments

T2II

A vector with the value of T2 statistic for one sample.

m

The number of samples generated previously in data.1.

n

The size of each sample used previously in data.1. If they are individual observations, use n = 1.

j

The index of the current sample.

t

The maximum value of the x axis.

p

The dimension used previously in function data.1.

datum

The data set used in phase I.

stats

The auxiliary statistics created by the function stats.

T2

The Hotelling T2 statistic for multivariate observations at phase I created by the function T2.1.

Details

It builds the Hotelling T2 control chart for multivariate normal data to be used in the operational phase (known as phase II); the control limits are based on the F distribution.

Value

Return a control chart.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

References

Montgomery, D.C.,(2008). "Introduction to Statistical Quality Control". Chapter 11. Wiley

See Also

cchart.T2.1

Examples

mu <- c(5.682, 88.22)
Sigma <- 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 firts 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 firts 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)

u-chart

Description

This function builds a u-chart for the Poisson-based count data statistic.

Usage

cchart.u(x1 = NULL, n1 = NULL, type = "norm", u1 = NULL, x2 = NULL,
  n2 = NULL, lambda = NULL, u2 = NULL)

Arguments

x1

The phase I data that will be plotted (if it is a phase I chart).

n1

A value or a vector of values specifying the sample sizes associated with each group for the phase I data.

type

The type of u-chart to be plotted. The options are "norm" (traditional Shewhart u-chart), "CF" (improved u-chart) and "std" (standardized u-chart). If not specified, a Shewhart u-chart will be plotted.

u1

The sample ratios used to estimate the Poisson parameter (lambda). (x1 / n1).

x2

The phase II data that will be plotted in a phase II chart.

n2

A value or a vector of values specifying the sample sizes associated with each group for the phase II data.

lambda

The estimate of lambda.

u2

The sample ratios of the phase II data (x2 / n2).

Details

For a phase I u-chart, n1 must be specified and either x1 or u1. For a phase II u-chart, n2 must be specified, plus x2 or u2 and either phat, x1 and n1, or u1 and n1. It is important to note that the normal approximation used in the Shewhart u-chart is valid only for n*u large. For small n*p , it should be used an "improved u chart" (with non-normal correction) given by using the argument "CF".

Value

Returns a u-chart.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

Examples

data(moonroof)
attach(moonroof)
cchart.u(x1 = yi[1:17], n1 = ni[1:17])
cchart.u(x1 = yi[1:17], n1 = ni[1:17], type = "CF", x2 = yi[18:34], n2 = ni[18:34])
cchart.u(type = "std", u2 = ui[18:34], n2 = ni[18:34], lambda = 1.4)

X-bar and R control charts

Description

This function builds the X-bar and R control charts in the same window.

Usage

cchart.Xbar_R(x, sizes)

Arguments

x

The data to be plotted.

sizes

A value or a vector of values specifying the sample sizes associated with each group.

Value

Return the two control charts.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa.

Examples

data(pistonrings)
attach(pistonrings)
cchart.Xbar_R(pistonrings[1:25, ])

X-bar Shewhart Control Chart for phase I.

Description

Builds the x-bar control chart for phase I.

Usage

cchart.Xbar1(x, sizes)

Arguments

x

The data to be plotted.

sizes

A value or a vector of values specifying the sample sizes associated with each group.

Details

Even if the data is not normal the x-bar statistic will be close to the normal by the central limit theorem.

Value

Return a x-bar control chart for phase I.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

See Also

cchart.Xbar2

Examples

data(pistonrings)
cchart.Xbar1(pistonrings[1:25, ])

X-bar Shewhart Control Chart for phase II.

Description

Builds the x-bar control chart for phase II.

Usage

cchart.Xbar2(x, x2bar, sigma, sizes)

Arguments

x

The data to be plotted.

x2bar

The mean of means.

sigma

The standar deviation of the data.

sizes

A value or a vector of values specifying the sample sizes associated with each group.

Details

To use this function it is necessary to have the output given by the function XbarI.

Value

Return a x-bar control chart for phase II.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

See Also

cchart.Xbar1

Examples

data(pistonrings)
stat <- cchart.Xbar1(pistonrings[1:25, ])
cchart.Xbar2(pistonrings[26:40, ], stat[[1]][1], stat[[1]][2])

D2 Constant.

Description

This function is used to calculate the mean of the sample relative range (W statistic).

Usage

d2(n)

Arguments

n

The sample size.

Value

Return the value of d2 for a given sample size n.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

See Also

d3,c4

Examples

d2(8)

D3 Constant.

Description

This function is used to calculate the standard deviation of the sample relative range (W statistic).

Usage

d3(n)

Arguments

n

The sample size.

Value

Return the value of d3 for a given sample size n.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

See Also

d2,c4

Examples

d3(7)

Hotelling Control Chart Phase I simulated data.

Description

This function simulate a normal data set to be used in the phase I Hoteliing control charts.

Usage

data.1(m, n, mu, Sigma)

Arguments

m

The number of samples to be generated.

n

The size of each sample. If they are individual observations, then use n = 1.

mu

The vector with the means of the data to be generated.

Sigma

The vector with the variance-covariance matrix of the data to be generated.

Value

Return an array with the simulated data.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

See Also

data.2

Examples

mu <- c(5.682, 88.22)
Sigma <- 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)

Hotelling Control Chart Phase II simulated data.

Description

This function simulate a normal data set to be used in the phase II Hotelling control charts.

Usage

data.2(estat, n, delta = 0, p)

Arguments

estat

The values of the auxiliary statistics. Should be a list with a matrix with the means, mean of the means and mean of the standard deviation.

n

The size of each sample. If they are individual observations, use n = 1.

delta

A value to be added on the vector of means.

p

The dimension.

Details

To use this function it is necessary to have the information about the phase I given by the functions data.1 and stats.

Value

Return an array with the simulated data.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

See Also

data.1

Examples

mu <- c(5.682, 88.22)
Sigma <- 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)

Moonroof

Description

A data set used to build an u-charts.

Format

A data frame with 34 observations on the following 4 variables.

i

Index.

yi

The number of defects.

ni

The sample size.

ui

The proportion of defects.

Details

Defect data for moonroof installation example.

Source

DeVor, R.E.; Chang, T.; Sutherland, J.W., 2007. "Statistical Quality Design and Control".

References

See the source.

Examples

data(moonroof)

Piston Rings Data Set.

Description

The Piston Rings data set was taken from Montgomery's book. It consists of 40 samples of size 5 each of values of the diameter of the piston rings.

Format

A data frame with 40 observations on the following 5 variables.

V1

The fisrt measure.

V2

The second measure.

V3

The third measure.

V4

The fouth measure.

V5

The fifth measure.

Source

Montgomery, D.C.,(2008)."Introduction to Statistical Quality Control".4th Ed. Wiley

Examples

data(pistonrings)

Remove an undesirable observation.

Description

This function removes an undesirable data that might be out of control in you data set. It is used at Hotelling T2 control charts for phase I.

Usage

remove.data(datum, i)

Arguments

datum

The data set. Should be an array.

i

The index in the matrix of the data to be removed.

Value

Return the new data set without the observation that was removed.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

Examples

mu <- c(5.682, 88.22)
Sigma <- 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)

Soft Drink Data Set.

Description

Consists of 15 samples of 10 bottles where it is measured the volume of soft drink.

Format

A data frame with 15 lines and 10 columns.

x1

The first measure.

x2

The second measure.

x3

The third measure.

x4

The fourth measure.

x5

The fifth measure.

x6

The sixth measure.

x7

The seventh measure.

x8

The eigth measure.

x9

The ninth measure.

x10

The tenth measure.

Source

Montgomery, D.C.,(2001)."Introduction to Statistical Quality Control".4th ed. Wiley.

Examples

data(softdrink)

Auxiliary statistics for the multivariate control chart.

Description

This function calculate the auxiliary statistics necessary to build the control chart reference lines.

Usage

stats(datum, m, n, p)

Arguments

datum

The data set. Should be an array.

m

The number of sub groups generated previously in data.1.

n

The size of each sub group used previously in data.1.

p

The dimension used previously in function data.1.

Details

To use this function it is necessary to have the information about the data.1.

Value

Return the values of the three statistics: a vector with the mean of the means, the mean of the estimated variance-covariance matrixes and a matrix with the means of each sample.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

Examples

mu <- c(5.682, 88.22)
Sigma <- 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)

Hotelling T2 Statistic for Phase I.

Description

Calculate the Hotelling T2 statistic for multivariate observations at phase I , to be used to build the corresponding control chart.

Usage

T2.1(estat, m, n)

Arguments

estat

The values of the auxiliary statistics. Should be a list with a matrix with the means, mean of the means and mean of the standard deviation.

m

The number of samples generated previously in data.1.

n

The size of each samples used previously in data.1.

Details

Before using this function it is necessary to execute the function "stats"(that calculate the auxiliary statistics involved in the T2 formula) and the function "data.1" (or other way to supply the data).

Value

Return a vector with the Hotelling T2 statistics.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

References

Montgomery, D.C.,(2008)."Introduction to Statistical Quality Control". Chapter 11. Wiley.

See Also

stats, data.1, cchart.T2.1

Examples

mu <- c(5.682, 88.22)
Sigma <- 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)

Hotelling T2 Statistic for Phase II.

Description

Calculate the Hotelling T2 statistic for multivariate observations at phase II , to be used to build the corresponding control chart.

Usage

T2.2(datum2, estat, n)

Arguments

datum2

The data set for the phase II. Shoul be a vector.

estat

The values of the auxiliary statistics. Should be a list with a matrix with the means, mean of the means and mean of the standard deviation.

n

The size of each sample used previously in data.2. If they are individual observations, use n = 1.

Details

Before using this function it is necessary to execute the function "stats"(that calculate the auxiliary statistics involved in the T2 formula) and the function "data.2" (or other way to supply the data).

Value

Return a vector with the Hotelling T2 statistics.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

References

Montgomery, D.C.,(2008)."Introduction to Statistical Quality Control". Chapter 11. Wiley.

See Also

T2.1,stats, data.2, cchart.T2.2

Examples

mu <- c(5.682, 88.22)
Sigma <- 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)

Table of values for the constants d2, d3 and c4.

Description

This function is used to build a table of values for the constants d2, d3 and c4 for sucessive values of sample size n.

Usage

table.const(n)

Arguments

n

The maximum size.

Details

It builds a table in matrix form with 3 columns (one for each constant) and one row for each value of n from 2 to a specified value.

Value

Return the values of these three constants.

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

See Also

d2,d3,c4

Examples

table.const(17)

Tukey Quantile Table

Description

Builds a table with quantiles of the sample relative range distribution.

Usage

table.qtukey(alpha, n)

Arguments

alpha

The probability of type-I error of false alarm , that is equal to 1 minus the confidence level.

n

The maximum sample size.

Value

It is used the fact that the sample relative range distribution is the same as the sample studentized range distribution (tukey distribution) with infinity d.f. in the denominator . It is considered 4 quantiles: alpha/2 , alpha , 1-alpha and 1-alpha/2, for different sample size values .

Author(s)

Daniela R. Recchia, Emanuel P. Barbosa

See Also

table.const,alpha.risk,qtukey

Examples

table.qtukey(0.0027, 15)