Shewhart Chart with estimated In-Control State

Using Normality Assumptions

Here we consider a simple application to a two-sided Shewhart chart, assuming that all observations are normally distributed.

Based on \(n\) past in-control observations \(X_{-n},\dots,X_{-1}\), the in-control mean is estimated by \(\hat \mu = \frac{1}{n}\sum_{i=-n}^{-1} X_i\) and the in-control variance by \(\hat \sigma^2=\frac{1}{n-1}\sum_{i=-n}^{-1} (X_i-\hat \mu)^2\). Based on new observations \(X_1,X_2,\dots\) a two-sided Shewhart chart is then defined by \[ S_t=\frac{X_t-\hat \mu}{\hat \sigma}. \] and signals when \(|S_t|>c\) for some threshold \(c\).

The following generates a data set of past observations (replace this with your observed past data).

X <-  rnorm(250)

plot of chunk unnamed-chunk-3

Next, we initialise and compute the resulting estimate for running the chart - in this case \(\hat \mu\) and \(\hat \sigma\).

library(spcadjust)
chartShew <- new("SPCShewNormalCenterScale",twosided=TRUE);
xihat <- xiofdata(chartShew,X)
str(xihat)
## List of 3
##  $ mu: num 0.0251
##  $ sd: num 1.05
##  $ m : int 250

Calibrating the Chart to a Given Average Run Length (ARL)

We now compute a threshold that with roughly 90\% probability results in an average run length of at least 769 in control. This is based on parametric resampling assuming normality of the observations. You should increase the number of bootstrap replications (the argument nrep) for real applications.

cal <- SPCproperty(data=X,nrep=100,
            property=new("calARLShew",chart=chartShew,target=741))
cal
## 90 % CI: A threshold of 3.413 gives an in-control ARL of at least
##   741. 
## Unadjusted result:  3.205 
## Based on  100 bootstrap repetitions.

Run the chart

Next, we run the chart with new observations (that are in-control).

newX <- rnorm(100)
S <- runchart(chartShew, newdata=newX,xi=xihat)

plot of chunk unnamed-chunk-8

In the next example, the chart is run with data that is out-of-control from time 51 onwards.

newX <- rnorm(100,mean=c(rep(0,50),rep(2,50)))
S <- runchart(chartShew, newdata=newX,xi=xihat)

plot of chunk unnamed-chunk-10