Control charts applied to pig farming data

Statistical control charts are effective tools to reveal changes in a production process. The CUSUM (cumulative sum) and the EWMA (exponentially weighted moving average) control chart are used to detect small deviations in a process. Data from two sow herds, herd A and herd B, were collected from 1999 to 2004. Farm A had an average number of 530 breeding sows, Farm B had an average of 370 breeding sows. Both herds were diagnosed with Porcine Reproductive and Respiratory Syndrome (PRRS). The weekly means of the number of piglets weaned (NPW), the pre-weaning mortality (PWM) and return to service rate (RSR) were analysed with different settings of the CUSUM as well as the EWMA control chart to reveal a shift in the production process. For the pre-weaning mortality and the number of piglets weaned, the two charts detected a change in the process 4 weeks (Farm A) and 2 weeks before (Farm B) PRRS was diagnosed. The CUSUM and the EWMA chart revealed a shift in the return to service rate on Farm A 3.5 months before PRRS was detected. On Farm B, the signal occurred 6 weeks before the infection was detected. The CUSUM and the EWMA control charts were effective tools for detecting small deviations in sow herd data. Compared with EWMA, the use of the CUSUM chart is more straightforward and the settings are more easily handled. The CUSUM chart is therefore the preferred option for use in practice.


Introduction
Structural change in pig production is characterised by larger sow herd sizes and a decrease in time spent on dealing with each individual sow.Sow farm managers are trying to create high productivity production systems with low variance, which coordinates all facets of production, thus the overall production is optimised.This includes the coordination of information regarding health, genetics, facilities, and nutrition with management.This development requires management information systems to record and analyse data.Special add-on tools that are able to assist the decision-making of the farmer are becoming more and more important.Timely signalling of an unwanted change in performance is important to keep desired results within a predefined acceptable range to reduce economic loss (HUIRNE et al. 1997).Statistical control charts are widely used for statistical process control (SPC) in manufacturing industries (MONTGOMERY 1997).But only few investigations have been made using this technique on agricultural datasets.DE VRIES andCONLIN (2003, 2005) analysed the oestrous detection efficiency of dairy cows.PLEASANTS et al. (1998) surveyed the monitored effects on the muscle pH on Hereford steers.QUIMBY et al. (2001) used SPC charts to predict the morbidity of newly received calves in a commercial feedlot.In the most recent study, the CUSUM technique was used by MADSEN and KRISTENSEN (2005) to monitor the condition of young pigs with regard to their drinking behaviour.Another area where the use of control charts is becoming more frequent is the medical sector.CUSUM (cumulative sum) and EWMA (exponentially weighted moving average) are often used to improve clinical processes (BENNYAN 2001, MORTON et al. 2001).Data arising from clinical investigations are comparable to the data in animal production.This means that variable sample sizes, higher variability in process and less data than in industrial processes are available.SVOLBA (1999) mentions another important difference: the fact that clinical trials often contain unequal subgroup sizes as well as different time intervals.In sow production processes on the other hand, the number of observations per time unit compared to industrial processes may be smaller.KRIETER et al. (2009) presented a simulation study to test the performance of the CUSUM chart as well as the EWMA chart applied to sow farm datasets.Both charts were able to detect differential shifts in a timely manner depending on the setting of the charts.In the present study, the CUSUM and the EWMA control charts were both applied to actual sow farm data in order to show the efficiency of the control charts for practical use.

Data
The control charts were tested on two sow farms located in Northern Germany.Data from January 1999 until December 2004 were available.Farm A had an average number of 530 breeding sows with 24 sows farrowing each week.Farm B had 370 sows with 16 sows farrowing each week.The data were separated into weeks and the weekly means of the traits were calculated.The two farms differed in the percentage of pre-weaning mortality.Farm A showed very low piglet losses of only 5.3 % but a higher return to service rate (23.4 %) whereas farm B showed a return to service rate of 12.6 % and the percentage of piglet losses was 12.4 %.Further characteristics of both farms are presented in Table 1.Farm A and Farm B were both diagnosed with PRRS (Porcine Reproductive and Respiratory Syndrome), at the end of February 2004 and at the end of September 2004, respectively.

SPC charts
The consistency of production processes can be monitored by statistical process control charts (MONTGOMERY 1997).Statistical control charts are time plots of process data to improve processes.They are used as a tool for the detection of particular causes of variation that might be covered in the variation of common causes (WIERINGA 1999).
A control chart is constructed from a centre line (μ0) which represents the average value or the target specification of the process.Two other lines, the upper control limit (UCL) and the lower control limit (LCL), define the range of the natural variation of the plotted values.A shift in the process beyond control limits indicates a change in the production process.More variation is present than can be assigned to the effect of a common cause.A signal occurs and investigations are required to improve the process.The chart does not give information about the problem that caused the shift in the process.
Several types of control charts have been developed for different types of process data that have to be monitored.When the detection of small deviations is of interest, two effective charts may be used: CUSUM control chart and the EWMA control chart (MONTGOMERY 1997).

CUSUM Charts
Control charts based on cumulative sums were first introduced by PAGE (1954PAGE ( , 1961)).The CUSUM chart incorporates all the information in the sequence of sample values and plots the cumulative sums of the deviations from a target value using information from all prior weeks.The memory of the CUSUM chart is relatively long due to the fact that the sum of all prior observations is taken into account.
This CUSUM works by accumulating deviations from xi − μ0 that are above the target with one statistic Ci + called the one-sided-upper CUSUM and accumulating deviations from μ0 that are below the target value with another statistic Ci − called one-sided-lower CUSUM.
Computed as follows: 0 1 max 0, ( ) The starting values for the CUSUM are zero.The CUSUM chart can be adjusted with the reference value k.The k-value needs to be chosen relative to the size of the shift that is to be detected (MONTGOMERY 1997, HAWKINS andOLWELL 1998).MONTGOMERY (1997), HAWKINS and OLWELL (1998) recommended a k-value that is chosen to be half the size of the shift that needs to be detected.The upper (UCL) and the lower control limit (LCL) are determined by the choice of h.The h-value expresses the factor of σ0 (standard deviation of the process) defining the distance between μ0 and the control limits (UCL, LCL).
When either the Ci + or the Ci − exceeds the control limits (LCL, UCL), an alarm signal is given.

EWMA Charts
In 1959, ROBERTS was the first who proposed the EWMA chart.ROBERTS (1959) suggested calculating the geometric moving averages and plotting them in a control chart.This is a very common control chart technique, known as the EWMA control chart.In these charts, the process is monitored using a weighted moving average of the foregoing observations.
The EWMA is defined by: 1 (1 ) The smoothing constant λ is a constant satisfying λ∈(0,1).The weight that is given to the foregoing observation is influenced by λ.If λ =1, the most recent observation receives all of the weight.If λ → 0, the most recent observation receives small weight, as a result, the weight only marginally declines as the age of the observations increases.An alarm signal is given when zi exceeds the upper or lower control limit.The control limits are specified as: The L-value is a constant and has the greatest impact on defining the distance of the control limits to the mean (μ0).As i becomes larger, the term [1−(1−λ) 2i ] approaches unity.This indicates that after the EWMA control chart has been running for several time periods, the control limits approach a steady-state.

Performance
Statistical control charts are classified by their average run length (ARL).The ARL of a chart is the expected number of samples to be taken (in the case of this study the expected number of weeks) before the chart indicates that a shift in the process level has occurred.The ARL should be large when there has been no change in the process and small when the process has undergone a change.Typically ARLs are evaluated for zero shift in the process level: the so-called in-control ARL.To minimise the Type I error, the ARL should be high (MONTGOMERY 1997).When the ARL is small, the chance of a Type I error increases (an out-of-control signal is given while the process is in-control), but the time until the chart detects a shift in the process will be short.A high ARL results in a higher chance of a Type II error.This is the risk of an observation falling within the control limits when an actual change in the process occurs.If samples are taken at fixed time intervals (weeks), the performance of a control chart may be expressed in terms of average time to signal (ATS) (MONTGOMERY 1997).
A period of 52 weeks before PRRS diagnosis was used to calculate the CUSUM and the EWMA charts.
To test the performance of the EWMA and the CUSUM control charts, the calculated ATS as well as the setting of the constants were chosen according to the results of the foregoing simulation study (KRIETER et al. 2009).
For the CUSUM chart, h-values of 1, 1.5 and 2 in combination with k-values of 0.25, 0.50 and 0.75 were tested and the EWMA chart was set up with the L-values of 1.0, 1.5 and 2.0 combined with a λ of 0.2, 0.4, 0.6, and 0.8.

Traits
In order to detect deviations caused by PRRS, the weekly means of the return to service rate (RSR) as well as the pre-weaning mortality (PWM) and the number of piglets weaned (NPW) were used to test the CUSUM and the EWMA charts on actual farm data.The standard deviation, the target values of the process that were needed to establish the charts as well as the control limits were calculated out of the means of the foregoing 12 months of the observed period.For the RSR, PWM and the NPW a time period of 52 weeks to calculate the charts was chosen.This was done to be able to monitor the production process over a distinct time period and to make a comparison of the results of the simulation study (KRIETER et al. 2009) with the actual data possible by choosing the same length of investigation time.

Litter size
The CUSUM chart applied to the trait number of piglets weaned to the data of Farm A led to the earliest signal in week 2/2004 with a setting of h=1.5; k=0.25.In Figure 1, the CUSUM with a setting of h=2 and k=0.5 is presented.This setting of the constants resulted in a signal 1 week later, in week 3/2004.The CUSUM also crossed the LCL in week 22/2003.Other alarm signals were no longer given.The gradual decrease in the weekly means also became apparent by analysis of the weekly means.On Farm B, the signal was given in week 37/2004 (all h-values [1, 1.5, 2] combined with all k-values [0.25, 0.5, 0.75]), this was two weeks before the detection of PRRS.Another alarm was given in week 23/2003 (h=1, k=0.25).
The EWMA chart showed similar results to the CUSUM chart (Table 2).On Farm A, detection of the shift in the NPW (L=1, λ=0.4,0.6) took place one week later in the EWMA chart compared to the CUSUM.When an L-value higher than 1 was chosen, the chart signalled in week 5/2004.

Pre-weaning mortality
The results of the PWM are comparable to the results of the NPW (Table 2 ).Analysing pre-weaning mortality for Farm A, the CUSUM chart gave a signal in week 4/2004, 4 weeks before detection of PRRS.Another signal was given in week 35/2003 and 36/2003 (h=2).For Farm B, the signal was given in week 37 (h=1, k=0.5 and h=1.5, k=0.25), this was three weeks before PRRS diagnosis.A higher h-value (h=2) resulted in a later signal (week 38/2004).A lower k-value combined with a low h-value led to two other alarm signals (week 23/2004 and week 31/2004).
On Farm A, using the EWMA chart, the earliest detection of a shift in pre-weaning mortality was obtained in week 4/2004 (L=1, 1.5, 2, λ=0.6, 0.8), a alarm was also given in week 35/2003.Other settings resulted in more alarms and the same time until detection.On Farm B, a shift in pre-weaning mortality was revealed by the EWMA chart in week 38/2004 (L=1, λ=0.4, 0.6).This shift was detected one week later than in the CUSUM chart and only one week before detection of PRRS.

Return to service rate
The third observed trait was the return to service rate (RS).In Figure 3, the CUSUM control chart for the RSR is established for the 12 months before PRRS was detected on Farm A.
The chart signalled in week 19/2003 and until week 24/2003.This observation was also made with other settings of the constants within the CUSUM chart.In week 42/2003, the CUSUM crossed the UCL again remaining above the UCL until week 46/2003.However, in week 1/2004, the CUSUM dropped below the UCL.In week 2/2004, the CUSUM crossed the UCL once more and reached a high level.
The same peaks could be seen in the EWMA chart in Figure 3  In Figure 4, the CUSUM and the EWMA chart are presented for Farm B. The same setting of constants used for Farm A were chosen for this chart (CUSUM h=2, k=0.5).The CUSUM chart crossed the UCL in week 29/2004 and remained at a very high level until the end of the observed period.

Discussion
Both the CUSUM and the EWMA statistical control charts revealed a change in the process before PRRS was diagnosed.The litter size attributes NPW and PWM showed a very distinct shift.This shift could also be clearly recognized without the control charts.
The CUSUM chart and the EWMA chart signalled almost at the same time, but due to the fact that the CUSUM can be set up for a downward shift as well as for an upward shift, its visualization is much clearer than the EWMA chart.The charts applied to the two observed litter size traits NPW and the PWM gave an alarm signal 4 weeks before detection of PRRS on Farm A and 2 weeks on Farm B. The application of the control charts to the RSR resulted in an early alarm signal on both farms.
The early shift in the return to oestrus rate might be caused by an infection of PRRS.The early alarm signal could have given a hint for arising problems, nevertheless possible reasons for an increase in the RSR are complex.An increasing return to service rate can also be a signal of problems in mating and insemination management, the wrong time of insemination or problems with sperm fertility.An infection of PRRS will affect the reproductive efficiency of a sow herd.The reproductive efficiency is mainly characterised by the number of unproductive days.The number of return to service days is a reasonable indicator for reproductive problems, but it is not a useful trait for investigation using the control chart.The number of the return to service days depends on the number of sows in a herd at a particular time.To be independent from the number of breeding sows, it appears to be more reasonable to examine proportional data with the control charts.For example, the investigation of the proportion of return to service days in relation to reproductive days, the proportion of productive days in relation to reproductive days or the proportion of unproductive days in relation to reproductive days works well to assist the observer in becoming aware of a change in the system.
It has to be kept in mind that there may be a delay between the change in the system and the time when the observation becomes available (FETROW et al. 1997).For example, the result of an insemination is not known until a return to oestrus or a pregnancy diagnosis is performed.The change in the probability of conception cannot be signalled immediately.Therefore, the specific variability and dynamics of a production system affect the performance of the control chart (DE VRIES and CONLIN 2005).
Once a signal has emerged, the potential cause has to be investigated.An alarm does not give information about the problem that caused the shift in the process.DE VRIES (2001) mentioned that for the farmer it might be unsatisfying that signals on a SPC chart cannot always be traced back to the sources of variation.This might due to the lack of good data.Further analysis is needed to reveal the reason of a problem that is detected by the control chart.The decision tree technique could be a possibility to obtain more information about the changes in the process (KIRCHNER et al. 2004) The CUSUM and the EWMA control charts may be used for various different traits that emerge from the data that is provided by the management information system.Processing the recorded data in order to achieve as much information as possible is important to provide the farm manager with assistance to manage decisions.Since the charts are set up with an upper as well as a lower control limit, it is possible to not only give an alarm signal when the process turns in the unfavourable direction, but also to give a positive signal when the process shifts in the desired direction.
The correct setting of the chart depends on the willingness of the farm manager to accept false alarms or a delay in signalling.MADSEN and KRISTENSEN (2005) state that alarms for which no explanation can be found should not be regarded as poor performance by the model but they rather denote a problem which was not realised by the caretaker.If the farm manager is of the opinion that the system produces too many alarms, it can easily be adjusted.The costs of false alarms are usually difficult to determine (DE VRIES 2001).However, too many false alarm signals will result in a loss of confidence in the system.

Conclusion
The CUSUM as well as the EWMA chart revealed changes in the process at an early stage.However, the CUSUM chart shows several advantages over the EWMA chart.Shifts are displayed in a graphically distinct manner.The upper-and lower-sided CUSUM can be observed separately.The k-value is chosen equal to the size of the shift that is to be detected.The control limits can easily be adjusted by the choice of h.The implementation to a management information system is suggestive, because data which is needed to perform a CUSUM has already been recorded.Control charts based on weekly means should not be applied to small sow herds because of a small amount of information that can be provided each week.

Figure 2
Figure 2 shows the EWMA control chart (L=1.5, λ= 0.6) for farm A. The control limits were set very close to the mean.Two alerts were found in week 22/2003 and week 25/2003.Compared to the CUSUM chart, the EWMA control chart shifts in two directions.The upper control limit is exceeded in six different weeks.The shift in the NPW was detected in week 4/2004; further signals were not given.

Figure 3
Figure 3 Farm A, CUSUM control chart set up with h=2, k= 0.5 and a EWMA control chart set up with L=1.5, λ= 0.6 applied to the return to service rate (RS), March 2003-February 2004 Betrieb A, CUSUM und EWMA Control Charts für die Umrauschquote, März 2003-Februar 2004

Figure 4
Figure 4 Farm B, CUSUM control chart set up with h=2, k=0.5 and the EWMA control chart set up with L=1.5, λ= 0.6, applied to the return to service rate (RS), October 2003-September 2004 Betrieb B, CUSUM und EWMA Control Charts für die Umrauschquote, Oktober 2003-September 2004

Table 2
Setting for fastest detection combined with the lowest number of other alarm signals of the CUSUM and the EWMA charts and the time of the signal for Farm A and Farm B for the traits pre-weaning mortality and number of piglets weaned Einstellung der Control Charts bei einem möglichst frühzeitigen Signal und einer geringen Anzahl weiterer Alarmmeldungen für die Saugferkelsterblichkeit und die abgesetzten Ferkel je Wurf