testFun {qAnalyst}R Documentation

Internal function to perform control chart tests

Description

testFun executes control charts test.

Usage

  testFun(x, sg, type, xbarVariability, testType, k, p, nSigma, mu = NA, sigma = NA)

Arguments

x

data vector

sg

Subgroup variable. This argument has a different meaning according to chart type.

xbar, r and s charts: sg represents rational sub-group of observations. It can be specified either as a vector, of the same length of x of ordered subgroup id, or as a constant value that will be replicated along x. Subgroup dimension must be greather than one.

i and mr charts: sg represents the width of the window over which moving range are computed. Must be a scalar. Default value is set to two.

p, np and u charts: sg represents sample size of observation. It can be specified either as a vector, of the same length of x or as a constant value that will be replicated along x.

c chart: sg is not required

type

Chart type. String identifying chart type. Charts can be of type: "xbar", "r", "s", "i", "mr", "p", "np", "u", "c".

xbarVariability

How to compute variability for xbar charts.

"auto": (default) use the ranges if all subgroups have the same numerosity, and it is less than 7; otherwise it use the standard deviations.

"r" : use the ranges for the variaibility of the xbar charts.

"s" : use the standard deviations for the variability of the xbar charts.

testType

A vector or a scalar of test codes to be performed. Eight tests are implemented corrensponding to codes 1-8. Default performed test is 1.

test 1: At least k out of p points in a row beyond Zone A (outside the control limits). Default values: k = p = 1, nSigma = 3.

test 2: At least k out of p points in a row on one side of central line. Default values: k = p = 9.

test 3: At least k out of p points in a row all increasing or all decreasing. Default values: k = p = 6.

test 4: At least k out of p points in a row all up and down. Default values: k = p = 14.

test 5: At least k out of p points in a row in Zone A or beyond (> (2/3)*nSigma*sigma from central line; same side of central line). Default values: k = 2, p = 3, nSigma = 3.

test 6: At least k out of p points in a row in Zone B or beyond (> (1/3)*nSigma*sigma from central line; same side of central line). Default values: k = 4, p = 5, nSigma = 3.

test 7: At least k out of p points in a row in Zone C (both sides of central line). Default values: k = p = 15, nSigma = 3

test 8: At least k out of p points in a row with no one in Zone C. Default values: k = p = 8, nSigma = 3

k

A vector or a scalar of parameters to be used by tests. If k is not specified, tests are performed with k default values. If k is specified, its length must be of the same length as testType.

p

A vector or a scalar of parameters to be used by tests. If p is not specified, tests are performed with p default values. If p is specified, its length must be of the same length as testType.

nSigma

A vector or a scalar of parameters to be used by tests. If nSigma is not specified, tests are performed with nSigma default values. If nSigma is specified, its length must be of the same length as testType.

mu

A scalar containing the process mean. Its use will be different depending from chart type.

xbar and i charts: mu represents the center line. If mu is specified also sigma must be specified. If mu is not specified, then the process mean is calculated from data.

p, np, c and u charts: mu represents the parameter value for the in-control process, and then the center line. If mu is not specified, then the process mean is calculated from data.

s, r and mr charts: mu is not used.

sigma

A scalar containing the process within samples standard deviation. Its use will be different depending from chart type.

xbar and i charts: the within samples variability around the center line. If sigma is specified also mu must be specified. If sigma is not specified, then the process within samples standard deviation is calculated from data.

s chart: sigma represents the center line. If sigma is not specified, then the process standard within samples deviation is calculated from data.

r and mr charts: sigma is used to calculate the center line. If sigma is not specified, then the process standard within samples deviation is calculated from data.

p, np, c and u charts: sigma is not used.

Value

A binary vector whose dimension is equal to the points plotted on the control chart is returned. A value of 1 means that the i-th point failed the performed test, a value of 0 means that the i-th points did not failed the performed test.

Note

This function is for internal use. For more details see spc.

Author(s)

Andrea Spano'

References

Montgomery, Statistical Quality Control

See Also

spc

Examples

# example of test 3
x = c(1,0,3,2,3,5,6,8,7,6)
sg = 2
#i chart used for simplicity
outTest = testFun(x=x, type="i", sg=sg, testType=3, k=4, p=4, nSigma=3)
print(outTest)
# 0 0 0 0 0 0 1 1 0 0 ok

[Package qAnalyst version 0.6.4 Index]