Package 'EATME'

Title: EWMA-p control charts with correction of measurement error
Description: The package EATME, refered to EWMA with Adjustments To Measuremeant Error, aims to address measurement error effects when constructing EWMA-p control charts. The method primarily focuses on binary random variables, but it can be applied to any continuous random variables by using sign statistic to transform them to discrete ones. With the correction of measurement error effects, we can obtain the corrected control limits of EWMA-p control chart and reasonably adjusted EWMA-p control charts.
Authors: Cheng-Kuan Lin, Li-Pang Chen, Su-Fen Yang
Maintainer: Cheng-Kuan Lin <[email protected]>
License: GPL-3
Version: 0.1.0
Built: 2025-03-12 03:47:20 UTC
Source: https://github.com/kuan-cheng-da/eatme

Help Index


Convert data to M statistic

Description

Convert continuous random variables in in-control process into discrete random variables with M statistic, where M statistic is the total number of samples satisfying Xij>μX_{ij}>\mu at time ii, where XijX_{ij} is the observation for the ithi^{th} sampling period and the jthj^{th} sample in the in-control data, nn is the number of the sample size and mm is the number of the sampling periods. μ\mu is the population mean of continuous in-control data. If μ\mu is unknown, it can be estimated by μ^=x=i=1mj=1nXijn×m\hat{\mu}=\overline{\overline{x}}=\frac{\sum^m_{i = 1}\sum^n_{j=1} X_{ij}}{n\times m}.

Usage

cont_to_disc_M(ICdata, OCdata, mu.p = mean(ICdata))

Arguments

ICdata

The in-control data.

OCdata

The out-of-control data.

mu.p

Mean of the random variable in the in-control data.

Value

M0\hspace{2cm} The M statistic for in-control data.

M1\hspace{2cm} The M statistic for out-of-control data.

p0\hspace{2cm} The process proportion for in-control data.

p1\hspace{2cm} The process proportion for out-of-control data.

n\hspace{2.2cm} The number of the sample size.

References

Yang, S. F., Lin, J. S., & Cheng, S. W. (2011). A new nonparametric EWMA sign control chart. Expert Systems with Applications, 38(5), 6239-6243.

Yang, S. F. & Arnold, B. C. (2014). A simple approach for monitoring business service time variation.The Scientific World Journal, 2014:16.

Yang, S. F. (2016). An improved distribution-free EWMA mean chart. Communications in Statistics-Simulation and Computation, 45(4), 1410-1427.

Examples

IC = matrix(rnorm(100,0,1),ncol = 10,byrow = TRUE)
OC = matrix(rnorm(100,2,1),ncol = 10,byrow = TRUE)
cont_to_disc_M(IC,OC)

Convert data to V statistic

Description

Convert continuous random variables in in-control process to discrete data with V statistic, where V statistic is the total number of sample satisfying Yij=(Xi2jXi(2j1))22>σ2Y_{ij}=\frac{(X_{i2j}-X_{i(2j-1)})^2}{2}>\sigma^2 at time ii, where XijX_{ij} is the observation for the ithi^{th} sampling period and the jthj^{th} sample in the in-control data, nn is the number of the sample size and mm is the number of the sampling periods. σ2\sigma^2 is population variance of continuous in-control data. If σ2\sigma^2 is unknown, it can be estimated by σ^2=i=1mSi2m\hat{\sigma}^2 = \frac{\sum^m_{i=1}S_i^2}{m} and Si2=j=1n(XijXi)2n1S_i^2 = \frac{\sum^n_{j=1}(X_{ij}-\overline{X}_i)^2}{n-1}.

Usage

cont_to_disc_V(ICdata, OCdata, var.p = NULL)

Arguments

ICdata

The in-control data.

OCdata

The out-of-control data.

var.p

Variance of the random variables in the in-control data.

Value

V0\hspace{2cm} The V statistic for in-control data.

V1\hspace{2cm} The V statistic for out-of-control data.

p0\hspace{2cm} The process proportion for in-control data.

p1\hspace{2cm} The process proportion for out-of-control data.

n\hspace{2.2cm} The number of the sample size.

References

Yang, S. F. & Arnold, B. C. (2014). A simple approach for monitoring business service time variation.The Scientific World Journal, 2014:16.

Yang, S. F., & Arnold, B. C. (2016). A new approach for monitoring process variance. Journal of Statistical Computation and Simulation, 86(14), 2749-2765.

Examples

IC = matrix(rnorm(100,0,1),ncol = 10,byrow = TRUE)
OC = matrix(rnorm(100,0,2),ncol = 10,byrow = TRUE)
cont_to_disc_V(IC,OC)

EWMA chart statistics of the data

Description

A conventional exponential weighted moving average (EWMA) charting statistic evaluated by the data.

Usage

ewma(data, lambda, EWMA0)

Arguments

data

An one-dimensional random variable.

lambda

An EWMA smooth constant, which is a scalar in [0,1].

EWMA0

A starting point of EWMA charting statistic.

Value

A vector of EWMA charting statistics of data at different t times.

Examples

x = rnorm(20,0,1)
ewma(x,0.05,0)

A one-sided lower EWMA-p control chart

Description

This function displays one-sided lower EWMA-p chart control charts based on in-control and out-of-control data that are number of defectives. In the presence of measurement error, this function is able to provide suitable charts with corrections of measurement error effects.

Usage

EWMA_p_chart_one_LCL(
  ICdata,
  OCdata,
  lambda,
  n,
  pi1 = 1,
  pi2 = pi1,
  ARL0 = 200,
  M = 500,
  error = 10
)

Arguments

ICdata

The in-control data for attributes.

OCdata

The out-of-control data for attributes.

lambda

An EWMA smooth constant, which is a scalar in [0,1].

n

A sample size in the data.

pi1

The proportion that the observed defectives are the same as unobserved ones.

pi2

The proportion that the observed non-defectives are the same as unobserved ones.

ARL0

A prespecified average run length (ARL) of a control chart in the in-control process.

M

The number of simulation times for the Monte Carlo method

error

The tolerant for the absolute difference between an iterated ARL value and prespecified ARL0.

Value

The first chart is an EWMA-p chart obtained by the in-control data, and the second chart is an EWMA-p chart based in the out-of-control data. In two figures, horizontal solid line represents lower control limit (LCL), black solid dots are detections of in-control data, and red solid dots are detections of out-of-control data.

References

Chen, L.-P. & Yang, S.-F. (2022). A new p-chart with measurement error correction. arXiv: 2203.03384.

Examples

library(qcr)
data = orangejuice
IC = data[1:30,1]
OC = data[31:54,1]
EWMA_p_chart_one_LCL(IC,OC,0.05,50,1,1)

A one-sided upper EWMA-p control chart

Description

This function displays one-sided upper EWMA-p chart control charts based on in-control and out-of-control data that are number of defectives. In the presence of measurement error, this function is able to provide suitable charts with corrections of measurement error effects.

Usage

EWMA_p_chart_one_UCL(
  ICdata,
  OCdata,
  lambda,
  n,
  pi1 = 1,
  pi2 = pi1,
  ARL0 = 200,
  M = 500,
  error = 10
)

Arguments

ICdata

The in-control data for attributes.

OCdata

The out-of-control data for attributes.

lambda

An EWMA smooth constant, which is a scalar in [0,1].

n

A sample size in the data.

pi1

The proportion that the observed defectives are the same as unobserved ones.

pi2

The proportion that the observed non-defectives are the same as unobserved ones.

ARL0

A prespecified average run length (ARL) of a control chart in the in-control process.

M

The number of simulation times for the Monte Carlo method

error

The tolerant for the absolute difference between an iterated ARL value and prespecified ARL0.

Value

The first chart is an EWMA-p chart obtained by the in-control data, and the second chart is an EWMA-p chart based in the out-of-control data. In two figures, horizontal solid line represents upper control limit (UCL), black solid dots are detections of in-control data, and red solid dots are detections of out-of-control data.

References

Chen, L.-P. & Yang, S.-F. (2022). A new p-chart with measurement error correction. arXiv: 2203.03384.

Examples

library(qcr)
data = orangejuice
IC = data[31:54,1]
OC = data[1:30,1]
EWMA_p_chart_one_UCL(IC,OC,0.05,50,1,1)

A two-sided EWMA-p control chart

Description

This function displays two-sided EWMA-p chart control charts based on in-control and out-of-control data that are number of defectives. In the presence of measurement error, this function is able to provide suitable charts with corrections of measurement error effects.

Usage

EWMA_p_chart_two(
  ICdata,
  OCdata,
  lambda,
  n,
  pi1 = 1,
  pi2 = pi1,
  ARL0 = 200,
  M = 500,
  error = 10
)

Arguments

ICdata

The in-control data for attributes.

OCdata

The out-of-control data for attributes.

lambda

An EWMA smooth constant, which is a scalar in [0,1].

n

A sample size in the data.

pi1

The proportion that the observed defectives are the same as unobserved ones.

pi2

The proportion that the observed non-defectives are the same as unobserved ones.

ARL0

A prespecified average run length (ARL) of a control chart in the in-control process.

M

The number of simulation times for the Monte Carlo method

error

The tolerant for the absolute difference between an iterated ARL value and prespecified ARL0.

Value

The first chart is an EWMA-p chart obtained by the in-control data, and the second chart is an EWMA-p chart based in the out-of-control data. In two figures, horizontal solid lines represents upper control limit (UCL) and lower control limit (LCL), black solid dots are detections of in-control data, and red solid dots are detections of out-of-control data.

References

Chen, L.-P. & Yang, S.-F. (2022). A new p-chart with measurement error correction. arXiv: 2203.03384.

Examples

library(qcr)
data = orangejuice
IC = data[31:54,1]
OC = data[1:30,1]
EWMA_p_chart_two(IC,OC,0.05,50,1,1)

The one-sided lower control limit of an EWMA-p chart

Description

This function is used to calculate the one-sided lower control limit for EWMA-p charts with the correction of measurement error effects. If two truly classified probabilities pi1 and pi2 are given by 1, then the corresponding control limit is free of measurement error.

Usage

EWMA_p_one_LCL(
  p,
  lambda,
  n,
  pi1 = 1,
  pi2 = pi1,
  ARL0 = 200,
  M = 500,
  error = 10
)

Arguments

p

The proportion of defectives in the in-control process.

lambda

An EWMA smooth constant, which is a scalar in [0,1].

n

A sample size in the data.

pi1

The proportion that the observed defectives are the same as unobserved ones.

pi2

The proportion that the observed non-defectives are the same as unobserved ones.

ARL0

A prespecified average run length (ARL) of a control chart in the in-control process.

M

The number of simulation times for the Monte Carlo method

error

The tolerant for the absolute different between an itevated ARL calue and prespecified ARL0.

Value

L2\hspace{2.2cm} The coefficient of the lower control limit.

hat_ARL0\hspace{1.1cm} The estimated in-control average run length based on given L2.

hat_MRL0\hspace{1.1cm} The estimated in-control median of run length based on given L2.

hat_SDRL0\hspace{0.9cm} The estimated in-control standard deviation of run length based on given L2.

LCL\hspace{2cm} The limiting value of the lower control limit with L2.

Examples

EWMA_p_one_LCL(0.2,0.05,5,1,1)

The one-sided upper control limit of an EWMA-p chart

Description

This function is used to calculate the one-sided upper control limit for EWMA-p charts with the correction of measurement error effects. If two truly classified probabilities pi1 and pi2 are given by 1, then the corresponding control limit is free of measurement error.

Usage

EWMA_p_one_UCL(
  p,
  lambda,
  n,
  pi1 = 1,
  pi2 = pi1,
  ARL0 = 200,
  M = 500,
  error = 10
)

Arguments

p

The proportion of defectives in the in-control process.

lambda

An EWMA smooth constant, which is a scalar in [0,1].

n

A sample size in the data.

pi1

The proportion that the observed defectives are the same as unobserved ones.

pi2

The proportion that the observed non-defectives are the same as unobserved ones.

ARL0

A prespecified average run length (ARL) of a control chart in the in-control process.

M

The number of simulation times for the Monte Carlo method

error

The tolerant for the absolute different between an itevated ARL calue and prespecified ARL0.

Value

L1\hspace{2.2cm} The coefficient of the upper control limit.

hat_ARL0\hspace{1.1cm} The estimated in-control average run length based on given L1.

hat_MRL0\hspace{1.1cm} The estimated in-control median of run length based on given L1.

hat_SDRL0\hspace{0.9cm} The estimated in-control standard deviation of run length based on given L1.

UCL\hspace{2cm} The limiting value of the upper control limit with L1.

Examples

EWMA_p_one_UCL(0.2,0.05,5,1,1)

The two-sided control limits of an EWMA-p chart

Description

This function is used to calculate the two-sided control limit for EWMA-p charts with the correction of measurement error effects. If two truly classified probabilities pi1 and pi2 are given by 1, then the corresponding control limit is free of measurement error.

Usage

EWMA_p_two(p, lambda, n, pi1 = 1, pi2 = pi1, ARL0 = 200, M = 500, error = 10)

Arguments

p

The proportion of defectives in the in-control process.

lambda

An EWMA smooth constant, which is a scalar in [0,1].

n

A sample size in the data.

pi1

The proportion that the observed defectives are the same as unobserved ones.

pi2

The proportion that the observed non-defectives are the same as unobserved ones.

ARL0

A prespecified average run length (ARL) of a control chart in the in-control process.

M

The number of simulation times for the Monte Carlo method

error

The tolerant for the absolute different between an itevated ARL calue and prespecified ARL0.

Value

L1\hspace{2.2cm} The coefficient of the upper control limit.

L2\hspace{2.2cm} The coefficient of the lower control limit.

hat_ARL0\hspace{1.1cm} The estimated in-control average run length based on given L1 and L2.

hat_MRL0\hspace{1.1cm} The estimated in-control median of run length based on given L1 and L2.

hat_SDRL0\hspace{0.9cm} The estimated in-control standard deviation of run length based on given L1 and L2.

UCL\hspace{2cm} The limiting value of the upper control limit with L1.

LCL\hspace{2cm} The limiting value of the lower control limit with L2.

Examples

EWMA_p_two(0.2,0.05,5,1,1)

Generate the discrete random variable with measurement error

Description

Generate the discrete random variable with measurement error.

Usage

ME_data_generate(p, n, m, pi1, pi2 = pi1)

Arguments

p

A probability of the unobserved defectives.

n

A number of sample size in the data.

m

A number of observation in the data.

pi1

The proportion that the observed defectives are the same as unobserved ones.

pi2

The proportion that the observed non-defectives are the same as unobserved ones.

Value

real_data\hspace{1.2cm} The generated data without measurement error.

obs_data\hspace{1.4cm} The generated data with measurement error.

n\hspace{2.6cm} A sample size in the generated data.

Examples

ME_data_generate(0.7,50,50,0.95)