Monitoring and data filtering I. Classical Methods Advanced Quantitative Methods in Herd Management Dan Børge Jensen, IPH Dias 1
Outline Framework and Introduction Shewart Control chart • Basic principles • Examples: milk yield and daily gain • Alarms ---- Break Moving Average Control Chart EWMA Control Chart Monitoring autocorrelation • Model for autocorrelation • Use EWMA ---- Break & exercises Dias 2
Framework Dias 3
Class Question: what’s going on, and what to do? (2 minutes) Average daily weight gain, Pig herds Results from 2 herds 880 870 860 850 840 Gain (g) 830 820 810 800 790 780 0 2 4 6 8 10 12 Quarter Expected Herd A Herd B Is the conclusion the same in both herds? Dias 4
Introduction (2/3) So far Control: compare key figures (k) with expected results κ = θ + e s + e o Deviation: see if significant from a statistical point of view If deviation: adjustement plan or/and implementation Problem: we assume that results can be evaluated without considering results from the previous period Dias 5
Introduction (3/3) Key figures regarded as a time series of observations, treated as a whole How to model the results? κ t = θ + e st + e ot = θ + ν t κ t : observed value of the key figure θ : true underlying value e st : sample error (biological variation) e ot : observation error (observation method) Dias 6
The Shewart Control Chart: basic principles (1/2) Upper Control Limit (UCL) Sample quality characteristic κ 1 , κ 2 , ... κ n Center Line θ' Lower Control Limit (LCL) Sample number, or time Here: all the points fall inside the CL. Process in control Dias 7
The Shewart Control Chart: basic principles (2/2) Center line = target value • CL = θ’ Determination of the control limits • UCL t = θ’ + a σ t • LCL t = θ’ - a σ t Usually distance parameter a = 2 or 3 • If a = 2 : ”2-sigma” control limit We test the hypothesis H 0 : θ’ = θ • a = 2 corresponds to approx. 5% precision level Dias 8
Example 7.1: milk yield – I’ll show you! Target value: CL = θ’ = 25.60 kg for first lactation Overall herd SD over 24 weeks: 490 kg milk N.Cows at beginning: 275 Control limits: UCL t = θ’ + a σ t LCL t = θ’ - a σ t Standard deviation calculated according to number of cows behind the average Dias 9
Example 1: milk yield Shewart control chart, 2-sigma CL Dias 10
Example 1: milk yield Shewart control chart, 2-sigma CL Dias 11
Control and warning limits (1/3) UCL and LCL determined by a (e.g. a=2 <-> p=0.05) Choice of significance level / distance parameter: tradeoff between number of False Positives and False Negatives! Possible Scenarios: Low a High a Alarm Alarm Alarm No Alarm No Alarm No Alarm Type II Error System System System True True False HAS changed HAS changed HAS changed Positive Positive Negative System has NOT System has NOT System has NOT False True True changed changed changed Positive Negative Negative Type I Error Dias 12
Class Questions (5 minutes): If you have a HIGH observation frequency ( e.g. every hour or every second ) which sort of error should you MINIMIZE? And why? If you have a very LOW observation frequency ( e.g. every quarter or every year ) which sort of error should you MINIMIZE? And why? Alarm Alarm No Alarm No Alarm Alarm No Alarm System System True System True False HAS changed HAS changed Positive HAS changed Positive Negative System has NOT System has NOT True System has NOT False True changed changed Negative changed Positive Negative Dias 13
Control and warning limits (2/3) Sampling Frequency The more frequent κ is calculated, the higher a should be Average Run Length ARL =1/ q ARL: expected number of obs between 2 out-of-control alarms. q: the probability of an arbitrary point exceeding the control limits Average Time to Signal ATS =ARL/ ν v: sampling frequency, defined as observations per time unit Dias 14
Control and warning limits (2.1/3) Example: Process in control � q = p a = 2 � p = 0.05 ARL 0 = 1/ q = 1/ p = 1/0.05 = 20 Obs/Alarm Quaterly obs ATS 0 = ARL 0 / ν Two obs per second ATS 0 = ARL 0 / ν Dias 15
Control and warning limits (3/3) What is the cost of a What is the cost of a False Negative? False Positive? Alternative: use of warning limits Dias 16
5 Minute Break Dias 17
Pattern detection What do we detect? - Level change, outliers, increase in variation (c ontrol limits) - Trend (increase, decrease), cyclic pattern, autocorrelation Rules of thumb: 1- One point outside the control limits 2- Two out of three consecutive points outside the warning limits 3- Four out of five consecutive points at a distance of more than 1 σ from the expected level 4- Eight consecutive points on the same side of the expected level Dias 18
Illustration of pattern detection From Example 1 ! Rule 4 Dias 19
Example 2: daily gain of growing pigs Target value: θ’ = CL = 775 g Precision estimates ( σ ) Random sampling: 20.2 g Control limits: UCL = 775 + a σ, a = 2 LCL = 775 − a σ, a = 2 Dias 20
Example 2: daily gain Shewart control chart, 2-sigma CL Dias 21
Example 2: daily gain Process out of control 8 obs out of 16 Seasonnal variation is to be expected in slaughter pig production If there is an expected pattern: use of other monitoring techniques to take it into account e.g. other classical techniques (presented next) or state space models (chapter 8) If no expected pattern: further analysis / intervention Dias 22
Moving Average Control Charts (1/2) The moving average is the average of the most recent n observations κ + + κ + κ σ K t ≥ 2 n = M n t − n + t − t 1 1 with variance ( ) , t n n E.g. n = 4 M7(n) = 750 M6(n) = 744 M5(n) = 756 M4(n) = 763 Dias 23
Moving Average Control Charts (2/2) Using n=4, a=3 What can we conclude? Dias 24
Exponentially Weighted Moving Average control charts (1/3) The EWMA is a weighted average of all observations until now = λκ + − λ z z ( 1 ) − t t t 1 λ with variance, for large t, σ ≈ σ 2 2 z − λ t 2 The most recent observations are always given highest weights The EWMA control chart is built the same way as the Shewart control chart Dias 25
Exponentially Weighted Moving Average control charts (2/3) First lactation, a=2, λ=0.68 Dias 26
Exponentially Weighted Moving Average control charts (3/3) Choice of lambda: Small values favor detection of small shifts of θ ! Can take time to detect : small lambda = low weight to new obs Shewart control chart is suggested for detecting large shifts Combination of EWMA + Shewart for both small and large shifts Dias 27
Check for autocorrelation - Milk Yield example Present versus previous observation Sample autocorrelation Positive autocorrelation First lactation First lactation milk yields First lactation milk yields Dias 28
A model for autocorrelation Model Predict next obs. Errors = Observed - predicted e e e , ,..., t 1 2 Forecast error Variance Forecast error Control chart! Dias 29
Control chart – correlated data The point of a model: IF “everything is fine” THEN “things progress as expected” Therefore: IF “things progress UN-expectedly” THEN “Something is wrong!” Dias 30
EWMA for autocorrelated data Use EWMA as one-step-ahead predictor for autocorrelated data κ ≈ z ˆ + 1 t t Choose λ by minimizing the sum of the squared forecast errors t ∑ = κ − e z e 2 − t t t 1 i = i 1 The variance of the forecast errors is calculated as ∑ = t e 2 i σ = i 2 1 e t Dias 31
Concluding remarks We have shifted focus from observing a key figure κ at time t to an entire time series (κ 1 , κ 2 ,... κ t ) We tried to detect changes in process (alarms) - Raw data (Shewart control chart) - Averaged data (Moving / Exponentially Moving Average) We observed autocorrelation: model, EWMA We observed seasonality Next time: other, slightly more advanced methods for modelling! Dias 32
Break and exercises, until 5 PM Notice: Exercises at Grønnegårdsvej 7 Room A1-09.01 Dias 33
Recommend
More recommend