| TE | Taylor Enterprises, Inc. www.variation.com |
Quality and Statistics Books, Software, Training and Consulting |
Search variation.com
Site MapCAPAs and Trending of Quality Data Spec Setting, Tolerance Analysis and Robust Design Store What's New Technical Library FAQ Contact Info
Subscribe to our Web SiteBy entering your e-mail address and clicking the Subscribe button, you will automatically be added to our mailing list. You will receive an e-mail when new versions of our software or books are available as well as other significant announcements. (privacy policy). |
A Pattern Test for Distinguishing Between
Statistical methods such as control charts and change-point analysis are commonly used to determine whether the mean has shifted. Such methods assume independent errors around a possibly changing mean. When such techniques are applied to autoregressive data, erroneous conclusions can result. However, shifts of the mean create autocorrelation between the observations making it difficult to distinguish mean-shift data from autoregressive data. A pattern test has been devised that can reliably distinguish between these two important cases.
Table of Contents
Introduction IntroductionLook at Figures 1-3. Which two sets of data are most similar in structure?
Figure 1: Mean-Shift Model
Figure 2: First Order Autoregressive Model - Positive Correlation
Figure 3: First Order Autoregressive Model - Negative Correlation
Would you be surprised to find out it is the plots in Figures 2 and 3? Both were generated using a first order autoregressive model. The plot in Figure 1 was generated using a different model, called the mean-shift model. When analyzing data collected over time, it is important to be able to distinguish between these two important cases. Visual inspection of such data is unreliable. A pattern test has been developed which can reliably distinguish between these two models.
The Mean-Shift ModelStatistical methods such as control charts and change-point analysis assume a series of independent observations collected over time. At one or more points in time the mean may shift. Let X1, X2, ... represent the data in time order. The mean-shift model can be written as
Xi = mi + ei
where mi is the average at time i. Generally mi = mi-1 except for a small number of values of i called the change-points. ei is the random error associated with the i-th value. It is assumed that the ei are independent and identically distributed with means of zero. Other assumptions including normality may also be made by some of these statistical methods but are not required for the proposed pattern test.
The data shown in Figure 1 was generated using the following model:
ei~ N(0,1) and independent m1, m21, m41, m61, m81~ N(10,1) and independent For all other i, mi = mi-1
N(m,s) means normally distributed with mean m and standard deviation s. This model could result from a process where the mean shifts as a result of periodic material changes. It could also result from a process subject to both setup and within setup variation. In other cases, the mean-shifts could occur at random times. The proposed pattern test works for any of these situations.
The First Order Autoregressive ModelThe data shown in Figures 2 and 3 were generated using the first order autoregressive model:
ei~ N(0,1) and independent ri = f ri-1 + ei r0 = 0 Xi = 10 + ri
f is a constant between -1 and 1. The above model results in a correlation between successive values of:
Corr{Xi, Xi-1} = f
Values of f=0.7 and f=-0.7 were used respectively in Figures 2 and 3. When f=0, the autoregressive model reduces to what is called the white noise model where Xi ~ N(10,1) and independent. This is also a special case of the mean-shift model with no shifts.
When checking for an autoregressive model, one frequently calculates the autocorrelations and displays them in the form of a correologram. However, this is only useful for distinguishing between an autoregressive model and white noise. The mean-shift model also results in autocorrelations between the values. In Figure 1 the correlation between consecutive values is 0.43. Looking at the autocorrelations will not allow one to distinguish between these two models.
The Pattern TestFigure 4 shows the six possible patterns that can result from plotting three consecutive points when there are no ties. Pattern 1 is called the double up pattern and Pattern 6 is called the double down pattern. The other 4 patterns will be referred to as reversal patterns. For the autoregressive model, the double up and double down patterns are most common when there is a positive autocorrelation as in Figure 2. The reversal patterns are most common when there is a negative correlation as in Figure 3.
When the means of the 3 points are the same, all six patterns are equally likely. In this case, the double up and double down patterns should occur 1/3 the time and the reversal patterns should occur 2/3 of the time. The pattern test involves counting the number of times the double up/down patterns occur. This count is slightly biased when the mean shifts or there is an outlier. However the bias is small and easily compensated for making this count useful for distinguishing between mean-shift and autoregressive data. If this count is significantly greater than a third the number of values, the data is autoregressive with positive correlation. If this count is significantly less than a third, the data is autoregressive with negative correlation. Otherwise the mean-shift model fits the observed data.
Figure 4: Six Patterns for Three Consecutive Points
Table 1 gives critical values for S for a 2-sided test with a=0.05 for n between 10 and 200. If S £ slower, the data is autocorrelated with negative correlation. If S ³ supper, the data is autocorrelated with positive correlation. Otherwise, the data is consistent with the mean-shift model. These critical values and the approximations given below are all based on the assumption that the number of shifts and outliers is less than 1 per 20 data points. This assumption should rarely restrict the use of this procedure.
Table 1: Two-Sided Critical Values for S = Number of Double Up/Down Patterns (a=0.05)
Note: n = sample size. If S £ slower, the data is autocorrelated with negative correlation. If S ³ supper, the data is autocorrelated with positive correlation. Otherwise, the data is consistent with the mean-shift model.
Formulas 1 and 2 can also be used to calculate significance levels. If alower£ 0.025, the data is autocorrelated with negative correlation. If aupper£ 0.025, the data is autocorrelated with positive correlation. Otherwise, any correlation in the data is the result of mean shifts.
where
where
Ip(a,b) is the incomplete beta function. The derivation of these formulas is given in Appendix A. They are within 2% of the true value for 0.01£a£0.1 and n³10. Formulas 3 and 4 give a second less accurate approximation that can be used when n³100.
Applications of the Pattern TestTable 2 shows the results of applying the pattern test to the three sets of generated data in Figures 1-3 plus the three real sets of data shown in Figures 5-7. In Figures 1-3, n=100 resulting in critical values slower=24 and supper=44. For the mean-shift data in Figure 1, S=38 which falls between the two critical values. This is consistent with a mean-shift model. For the Figure 2 autoregressive data with positive correlation, S=46. This exceeds the upper critical value proving the data is not consistent with a mean-shift model. For the Figure 3 autoregressive data with negative correlation, S=19. This is below the lower critical value again proving the data is not consistent with a mean-shift model. The a values from Equations 1-4 support these same conclusions. Also shown are the true a values obtained through simulation. All four approximations are accurate to three digits when n=100.
Table 2: Analysis of Example Data Sets
Figure 5 shows the number of sunspots for a 50 year period of time. This data is Series E from Box and Jenkins (1976). The number of double up/down patterns is S=38. This exceeds the upper critical value supper=23 indicating the data is autoregressive with positive correlation. The a values from Equations 1-4 support this same conclusion.
Figure 5: Wölfer Sunspot Data
Figure 6 shows the yields from 70 consecutive batches of a chemical process. This data is Series F from Box and Jenkins (1976). The number of double up/down patterns is S=9. This is below the lower critical value slower=15 indicating the data is autoregressive with negative correlation. The a values from Equations 1-4 support this same conclusion.
Figure 6: Batch Yields
Figure 7 shows part strength readings taken once an hour over 52 consecutive hours. The number of double up/down patterns is S=19. This is between the lower critical value slower=10 and the upper critical value supperr=24 indicating the data is consistent with the mean-shift model. The a values from Equations 1-4 support this same conclusion.
Figure 7: Part Strength
Handling TiesWhen ties are possible, two new patterns can occur: the single tie and the double tie. In this case, let Pi be defined in terms of Xi-2, Xi-1, Xi as follows:
Further, let S be defined as:
When Xi-2, Xi-1, Xi are identically distributed, E{Pi} = 1/3. Again a test for autoregression can be constructed based on S averaging above or below 1/3 the number of patterns. If the number of ties is small, Table 1 and Equations 1-4 may still be used. But if ties are more common, Table 1 and Equations 1-4 can no longer be used because the ties reduce the variation of S. Instead Equations 5-8 should be used:
where
where
Estimates of Var{Pi}, Cov{Pi,Pi+1} and Cov{Pi,Pi+2} can be obtained from the data. A special case with numerous ties is pass/fail data. In this case:
Then:
This gives:
For pass/fail data, the variance and covariances of Pi are:
For pass/fail data, an estimate of p can be obtained from the data and substituted into Equations 9-11 to estimate Var{Pi}, Cov{Pi,Pi+1} and Cov{Pi,Pi+2}. These estimates can then be plugged into Equations 5-8 to obtain approximate a levels.
Other Applications of PiAn example of a data set with ties is shown in Figure 8. 197 chemical concentrations are shown. This data is Series A from Box and Jenkins (1976).
Figure 8: Chemical Concentration Data
From this data P3, ..., P197 can be calculated. The Pi values are time ordered data that reacts to changes in the autoregressive behavior of the data. A CUSUM chart of the Pi values is shown in Figure 9. The sudden change in direction in the CUSUM chart indicates a sudden change in the autoregressive behavior of this data.
Figure 9: CUSUM Chart of Pi for Chemical Concentration Data
A change-point analysis was then performed on the Pi using Taylor (2000). This software performs a bootstrap analysis on the CUSUM chart to obtain confidence levels and confidence intervals for the change. The results of this analysis are shown in Figure 10. It verifies a change occurred with 98% confidence. The change is estimated to have occurred just prior to point 145. With 95% confidence it occurred between points 83 and 179.
Figure 10: Results of Change-Point Analysis of Pi for Chemical Concentration Data
The average Pi before the change is 0.326, which is close to 1/3, indicating a lack of autoregressive behavior. The average Pi following the change is 0.542 indicating autoregression with a positive correlation. Separate tests for autoregression were performed on points 1-144 and points 1405-197. The results are shown in Table 3. These tests confirm that following the change, the data is autoregressive with positive correlation, while before the change, the data is consistent with the mean-shift model.
Table 3: Pattern Test for Chemical Concentration Data
ConclusionThe pattern test has proven to be useful for distinguishing between two very important models: the mean-shift model and the first order autoregressive model. The pattern test can be used to detect a violation of the assumption of independent errors when control charting data and performing a change-point analysis. The series Pi can also be used to detect changes in the autoregressive behavior of the data. It provides a useful new tool for helping to analyze complicated time series data.
Appendix AThe distribution of the test statistic S will be derived assuming no mean shifts or ties. Assume that a series of n data points X1, X2, ..., Xn has been collected in time order. Let Pi be an indicator function of whether the double up/down pattern occurred for points Xi-2, Xi-1, Xi. Further let:
The average and variance of S are:
Assuming no ties or mean shifts, the Pi are identically distributed with:
E{Pi} = 1/3 Var{Pi} = 2/9 Cov{Pi,Pi+1}= -1/36 Cov{Pi,Pi+2} = 1/180
All other covariances are zero. The above moments were calculated by generating the 5!=120 possible patterns for 5 points. Substituting the moments of Pi into Equations 12 and 13 gives the following moments for S:
When the mean shifts between time i-1 and i, the following values change:
E{Pi} = E{Pi+1} = 1/2 Var{Pi} = Var{Pi+1} = 1/4 Cov{Pi-1,Pi}= 0 Cov{Pi,Pi+1}= 0 Cov{Pi+1,Pi+2}= 0 Cov{Pi-2,Pi}= 0 Cov{Pi-1,Pi+1}= 0 Cov{Pi,Pi+2}= 0 Cov{Pi+1,Pi+3}= 0
All other values are as before. The above moments were calculated by generating the (4!)2= 576 possible patterns for 8 points where the first 4 points are all less than the last four points. Let t be the number of shifts. When t shifts occur:
Shifts increase both E{S} and Var{S}. To see what effect this has on the critical values, take E{S} ± 2 SD{S} as an approximate critical values. Both upper and lower critical values increase as t increases. Figure 11 shows the percentage increase in these approximate critical values as t ranges from 0% to 10% of n. When t is 5% of n, i.e. a change occurs once every 20 points, the critical values increase only 5%.
Figure 11: Approximate Percent Increase in Critical Values As t Increases
Since the number of changes is not known, one cannot exactly determine the distribution of S. However, by assuming an upper bound on the number of changes, one can bound its distribution. It would seem reasonable to expect no more than one change per twenty points (t £ n/20). A lower critical value is then calculated based on t=0 changes while the upper critical value is based on t=n/20 changes.
If the Pi where uncorrelated, S would follow the binomial distribution. Since the correlations are small, one would expect the binomial distribution to provide a close approximation. The binomial distribution B(x|nb,pb) has parameters nb and pb. It has a mean of nbpb and variance nbpb(1-pb). Setting E{S} = nbpb and Var{S} = nbpb(1-pb) and solving for nb and pb gives:
Since nb may not be an integer as required by the binomial distribution, the more general incomplete Beta function, Ip(a,b), will be used. Assuming t changes, the upper and lower significance levels for S can be approximated by:
Equation 1 was obtained from Equation 20 by substituting Equations 18 and 19 and setting t=0. Equation 2 was derived from Equation 21 by substituting Equations 18 and 19 and setting t=n/20. Equation 5 was obtained from Equation 20 by substituting Equations 13 and 16 and setting t=0. Equation 6 was derived from Equation 21 by substituting Equations 13 and 16 and setting t=n/20. Simulations indicate that Equations 20 and 21 are accurate to within 2% of the true value for 0.01£a£0.1 and n³10.
A second less accurate estimate can be obtained by approximating the distribution of S using the normal distribution with continuity correction. This results in Equations 22 and 23. Equation 3 was derived from Equation 22 by substituting Equations 16 and 17 and setting t=0. Equation 4 was derived from Equation 23 by substituting Equations 16 and 17 and setting t=n/20. Equation 7 was derived from Equation 22 by substituting Equations 13 and 16 and setting t=0. Equation 8 was derived from Equation 23 by substituting Equations 13 and 16 and setting t=n/20. These approximations should only be used when n³100.
ReferencesBox, George E. P. and Jenkins, Gwilym (1976). Time Series Analysis: Forecasting and Control, Holden-Day, San Francisco, California.
Taylor, Wayne (2000). Change-Point Analyzer 2.0 software package, Taylor Enterprises, Libertyville, Illinois. WEB: www.variation.com/cpa
Key Words: Mean-Shift, Autoregression, Change-Point Analysis, Control Chart, Time Series
Citation: Taylor, Wayne A. (2000), "A Pattern Test for Distinguishing Between Autoregressive and Mean-Shift Data," WEB: www.variation.com/cpa/tech/pattern.html. |
Copyright © 1997-2012 Taylor Enterprises, Inc.
Last modified:
August 04, 2012