122
Dynamic production monitoring in sow herds Ph.D. Thesis Claudia Bono HERD - Centre for Herd-oriented Education, Research and Development Department of Large Animal Sciences University of Copenhagen July 2013

Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

Dynamic production monitoringin sow herds

Ph.D. Thesis

Claudia Bono

HERD - Centre for Herd-oriented Education,Research and Development

Department of Large Animal SciencesUniversity of Copenhagen

July 2013

Page 2: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic
Page 3: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

PREFACE

This Ph.D. thesis is intended to fulfill the requirements for the Ph.D. degree at theFaculty of Health and Medical Sciences, Department of Large Animal Sciences -Health and Production, HERD - Centre for Herd-oriented Education, Research andDevelopment, University of Copenhagen, Denmark.

I wish to thank the 15 anonymous farmers as well as the Danish Advisory Cen-ter for providing data and the Danish Ministry of Food, Agriculture and Fisheriesfor financial support for this study through a grant entitled: "Development of aManagement System for complete monitoring in Danish and International Pig Pro-duction".

My first day at the Department of Large Animal Sciences was weird, I must say.I met my supervisor for the first time and he started talking about key figures andvariables influencing pig production and things that I had never heard before. I feltseriously in trouble and out of the world. But three years flew and now I can say,that this department became my home.

I owe my deepest gratitude to Anders for his support, guidance and availabilitythrough this project. He was very patient with me and he was able to open anglesof my mind as only a genius can do. Thanks to my co-supervisor, or better say, tomy friend Cécile. She let me discover the world of scientists under another pointof view; she guided me and she had to deal with my written English (which is notthe best I must admit). She supported me when I was weak and she encouragedme a lot with her experience and knowledge and of course patience. Yes, I guesspeople around me have to be patient! But Anders and Cécile were very able to getthe best out of me! It has been an honor to work with them and I will never endsaying: "thank you".

Page 4: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

4

Thanks to my colleagues from the HERD group but also to the ones sitting inthe neighbor building: Population Biology, it was a pleasure working with you.Thanks to my queen, able to solve all the troubles that a PhD student can find inhis/her way! Thanks to my PhD fellow friends, sharing knowledge, ideas, fearsand beers with you has been essential and helpful to make me feel myself in theacademic environment.

Thank you my friends! Being with you for some months or the whole periodin good and bad times, sharing moments, conversations, feelings and adventureswas great and you made this experience one of the best of my entire life.

A special thank to my boyfriend: my past, my present and my future. He hasalways believed in me even when I was not believing in myself. He supported mewith love and patience in every single step of the stairs of my life.

Finally, but not in order of importance, I would like to thank my family: strongfoundation of my heart, bricks of my life, puzzle of my soul. They have alwaysbeen with me, in my decisions, in my actions, in my thoughts and in my heart!

Three years have gone and a mix of feelings is now in my heart. I grew as a personand as a scientist. I feel full of experience, knowledge, smile and life. Thank youfor making me a better person than I was before I met all of you. THANKS - TAK- GRAZIE - GRACIAS !!!

Page 5: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

CONTENTS

1 Summary 9

2 General Introduction 172.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202.2 Limitations of existing MIS . . . . . . . . . . . . . . . . . . . . . 202.3 Requirements needed . . . . . . . . . . . . . . . . . . . . . . . . 212.4 Study context . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.5 Data collection . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.6 Analytic methods . . . . . . . . . . . . . . . . . . . . . . . . . . 22

2.6.1 Dynamic Linear Model . . . . . . . . . . . . . . . . . . . 22Weekly updates for DLM . . . . . . . . . . . . . . . . . . 23

2.6.2 Dynamic Generalized Linear Model . . . . . . . . . . . . 24Weekly updates for DGLM . . . . . . . . . . . . . . . . . 25

2.6.3 Detection methods . . . . . . . . . . . . . . . . . . . . . 25Shewhart control charts . . . . . . . . . . . . . . . . . . . 25V-mask applied on Cumulative Sum . . . . . . . . . . . . 27

2.7 Outline of the thesis . . . . . . . . . . . . . . . . . . . . . . . . . 27

3 I Modeling and monitoring litter size at herd and sow level 333.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343.2 The litter size model proposed by Toft and Jørgensen (2002) . . . 353.3 Sequential estimation of litter size profile and sow effects . . . . . 37

3.3.1 A linear litter size model . . . . . . . . . . . . . . . . . . 373.3.2 Litter size model with time trend . . . . . . . . . . . . . . 383.3.3 A dynamic linear model . . . . . . . . . . . . . . . . . . 38

Observation equation . . . . . . . . . . . . . . . . . . . . 38System equation . . . . . . . . . . . . . . . . . . . . . . 40Weekly update . . . . . . . . . . . . . . . . . . . . . . . 42

Page 6: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

6 CONTENTS

Sow values and their economical consequences . . . . . . 43Initialization . . . . . . . . . . . . . . . . . . . . . . . . 43EM algorithm for estimation of system variance . . . . . . 43

3.4 Detection of impaired litter size results . . . . . . . . . . . . . . . 453.5 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

3.5.1 System variance of herd level parameters . . . . . . . . . 473.5.2 Litter size profiles . . . . . . . . . . . . . . . . . . . . . 473.5.3 Model components . . . . . . . . . . . . . . . . . . . . . 493.5.4 Sow results . . . . . . . . . . . . . . . . . . . . . . . . . 523.5.5 Detection of alarms . . . . . . . . . . . . . . . . . . . . . 53

3.6 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

4 II Modeling and monitoring farrowing rate at herd level 594.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604.2 Explorative data analysis . . . . . . . . . . . . . . . . . . . . . . 614.3 The farrowing rate model . . . . . . . . . . . . . . . . . . . . . . 634.4 Sequential estimation technique . . . . . . . . . . . . . . . . . . 63

4.4.1 Observation Equation . . . . . . . . . . . . . . . . . . . . 644.4.2 System Equation . . . . . . . . . . . . . . . . . . . . . . 644.4.3 Weekly updating . . . . . . . . . . . . . . . . . . . . . . 654.4.4 Initialization . . . . . . . . . . . . . . . . . . . . . . . . 664.4.5 EM-algorithm . . . . . . . . . . . . . . . . . . . . . . . . 66

4.5 Detection of impaired farrowing rate results . . . . . . . . . . . . 664.6 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

4.6.1 System variance . . . . . . . . . . . . . . . . . . . . . . 674.6.2 Farrowing rate profiles . . . . . . . . . . . . . . . . . . . 684.6.3 Model components . . . . . . . . . . . . . . . . . . . . . 694.6.4 Detections of alarms in farrowing rate . . . . . . . . . . . 71

4.7 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734.8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 764.9 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 76

4.9.1 Sequential updating . . . . . . . . . . . . . . . . . . . . . 774.9.2 Dealing with singular variance-covariance matrix . . . . . 784.9.3 Forecast distribution . . . . . . . . . . . . . . . . . . . . 78

5 III Modeling and monitoring mortality rate at herd level 835.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 845.2 Explorative data analysis . . . . . . . . . . . . . . . . . . . . . . 855.3 The mortality model . . . . . . . . . . . . . . . . . . . . . . . . 885.4 Sequential estimation technique . . . . . . . . . . . . . . . . . . 89

5.4.1 A multivariate dynamic generalized linear model . . . . . 89Observation Equation . . . . . . . . . . . . . . . . . . . . 89System Equation . . . . . . . . . . . . . . . . . . . . . . 92

Page 7: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

CONTENTS 7

Weekly updating . . . . . . . . . . . . . . . . . . . . . . 92Initialization . . . . . . . . . . . . . . . . . . . . . . . . 92EM-algorithm . . . . . . . . . . . . . . . . . . . . . . . . 92

5.5 Detection by group of impaired mortality rate results . . . . . . . 935.6 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

5.6.1 System variance . . . . . . . . . . . . . . . . . . . . . . 945.6.2 Model components . . . . . . . . . . . . . . . . . . . . . 965.6.3 Detection of alarms in mortality rate . . . . . . . . . . . . 96

5.7 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 995.8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1015.9 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 101

6 General Discussion 1056.1 Overall idea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1056.2 Data Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

6.2.1 Multivariate Models . . . . . . . . . . . . . . . . . . . . 1066.2.2 Variance estimation . . . . . . . . . . . . . . . . . . . . . 1086.2.3 Model components . . . . . . . . . . . . . . . . . . . . . 109

6.3 Monitoring methods . . . . . . . . . . . . . . . . . . . . . . . . . 1146.3.1 Shewhart Control Chart . . . . . . . . . . . . . . . . . . 1146.3.2 V-mask . . . . . . . . . . . . . . . . . . . . . . . . . . . 1156.3.3 Choice of the monitoring methods . . . . . . . . . . . . . 115

7 Perspectives and Conclusions 121

Page 8: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic
Page 9: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

CHAPTER 1

SUMMARYDynamic production monitoring in sow herds

The concept of management refers to a procedure that includes three essential func-tions: planning, implementation and control. This thesis focuses on the controlaspect. Collection of records and their transformation into information is the prin-cipal aim of any Management Information System (MIS). Therefore, a MIS is acontrol tool used to process information necessary to manage an organization, i.e.farms, effectively. Unfortunately, the existing MISs for livestock productions arestatic, quarterly calculated and retrospective. A new approach is therefore advis-able.

In the last decades the combination of sensors, databases and mathematicalmodels has allowed monitoring activity to be more precise. The development ofdynamic monitoring systems for herd production is closely linked with the amountand the quality of information available on farms. Improvements of modern com-puter technologies at the farm level have been done in the last years; thereforepossibilities of real-time detection of production changes become a challenge forfuture monitoring systems.

Models and methods for dynamic monitoring of sow production on farms aresuggested, implemented and discussed in this thesis. Three models have been suc-cessfully developed: (1) litter size at herd and sow level, (2) farrowing rate and (3)mortality rate for sows and piglets.

The implementation of a litter size model found in literature represents the firststep of the creation of a dynamic monitoring system in sow production. A dynamiclinear model (DLM) is applied for this purpose. Moreover, a Maximum-Likelihoodcombined with Expectation-Maximization algorithm techniques have been used inorder to estimate the variance components of the parameters taken into account.Finally, control tools such as control charts inspired by Shewhart and V-masksapplied on the cumulative sum (Cusum) of the model’s forecast errors have beenused to give warnings in case of impaired litter size results.

Page 10: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

10 Summary

The second step in the creation of the system is the implementation of a far-rowing rate model. Farrowing rate is a binary trait and it is modeled by using aDynamic Generalized Linear Model (DGLM). EM algorithm technique is appliedto pre-estimate the variance components. Insemination and farrowing observationsare included in the analysis. Statistical control tools (control charts and V-mask)are used to give warnings in case of an impaired farrowing rate.

The third step includes the mortality rate model. Mortality, as well as farrow-ing, is a binary trait, therefore, a DGLM is used in order to model this variable.The approach of the third model is a bit different compared to the previous one,because sows and piglets are taken into account at the same time. As in the secondmodel, the EM-algorithm technique is used for the pre-estimation of the variancecomponents. The statistical control tools chosen allow the detection of impairedmortality rate for sows and piglets.

The strength of these new models is the availability of weekly updates thatallow a more real-time monitoring system and therefore, the opportunity to forecastongoing production.

Systems to monitor litter size, farrowing and mortality rate have been devel-oped. They are based on a mixture of DLM, DGLM and control methods to detectsystematic deviations. Forecast of production on a weekly basis is possible andpromising. The combination of the three models and the possibility to link themwith a replacement model from the literature, represent a solid basis for the de-velopment of a new management tool. This tool may be used to create a softwareproduct able to dynamically monitor changes in production systems.

Page 11: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

11

Sammendrag

Dynamisk produktionsmonitorering i sobesætninger

Managementkonceptet referer til en procedure, der indeholder tre essentielle funk-tioner: planlægning, gennemførelse og kontrol. Denne afhandling fokuserer påkontrolaspektet. Indsamling af data og deres transformering til information er detprimære mål for ethvert Management Informations System (MIS). Derfor er etMIS et kontrolværktøj benyttet til at bearbejde information, der behøves når en or-ganisation, fx en besætning, skal drives effektivt. Uheldigvis er eksisterende MISfor svineproduktion statiske, opgjort kvartalsvist og retrospektive. En ny tilgang erderfor tilrådelig.

Inden for de seneste årtier har kombinationen af databaser, sensorer og mate-matiske modeller muliggjort mere præcis monitorering. Udviklingen af dynamiskemonitoreringssystemer til produktionsdyr er tæt forbundet med kvantiteten og kva-liteten af besætningernes data. Der er inden for de seneste år sket forbedringerindenfor moderne computerteknologi. Derfor bliver muligheder inden for realtids-overvågning af ændringer i produktionen en udfordring for fremtidige monitore-ringssystemer.

Denne afhandling foreslår, implementerer og diskuterer modeller og metodertil dynamisk monitorering i sobesætninger. Tre modeller er blevet udviklet: (1)Kuldstørrelse på besætnings- og soniveau, (2) faringsrate og (3) dødelighed forsøer og pattegrise.

Første trin i udviklingen af et dynamisk monitoreringssystem til soproduktioner videreudvikling og implementering af en model for kuldstørrelse fundet i litte-raturen. Til dette formål anvendes en dynamisk lineær model (DLM). Modellensvarianskomponenter er estimeret ved en kombination af en Maximum-Likelihoodmetode i kombination med en Expectation-Maximization (EM) algoritme. Forat skabe et varslingssystem i tilfælde af forringede kuldstørrelsesresultater blevder anvendt Control Charts inspireret af Stewhart og den såkaldte V-maske imple-menteret på den kumulative sum af prædiktionsfejl.

Andet trin er implementeringen af en model for faringsraten. Faring er enbinær egenskab, og raten er modelleret ved hjælp af en Dynamisk GeneraliseretLineær Model (DGLM). EM-algoritmen er igen anvendt til at estimere modellensvarianskomponenter. Analysen er baseret på besætningernes registreringer af alleinsemineringer og faringer. Varslingssystemer for forringede reproduktionsresul-tater blev igen baseret på statistiske kontrolværktøjer (Control Charts og V-maske).

Det tredje trin inkluderer en model for dødelighedsraten. Dødelighed er somfaring en binær egenskab, hvorfor modelleringsmetoden igen var en DGLM. Til-gangen til den tredje model er en anelse anderledes sammenlignet med de tidligere,da der tages højde for søer og pattegrise i samme model. Som i den anden model,

Page 12: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

12 Summary

anvendes EM-algoritmen til estimation af varianskomponenter. Statistiske kon-trolværktøjer muliggør varsling af øget dødelighed for søer og pattegrise.

Styrken i disse nye modeller er brugen af ugentlige opdateringer. Dette kom-mer tættere på realtidsovervågning og dermed også mulighed for bedre at kunnefremskrive produktionen løbende.

Systemer til monitorering af kuldstørrelse, fare- og dødelighedsrate er blevetudviklet. De er baseret på en kombination af DLM, DGLM og statistiske kontrol-metoder til at detektere systematiske afvigelser. Fremskrivning af produktionenpå ugentlig basis er mulig og lovende. Kombinationen af de tre modeller og mu-ligheden for yderligere at kombinere dem med en egentlig udskiftningsmodel fralitteraturen, repræsenterer et solidt grundlag for udviklingen af et nyt managementværktøj. Dette værktøj kan benyttes til at udvikle et softwareprodukt, der dynamiskkan monitorere ændringer i produktionssystemer.

Page 13: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

13

Sommario

Monitoraggio dimamico della produzione in allevamenti di scrofe

Il concetto di management o gestione, si riferisce ad una procedura che includetre funzioni principali: pianificazione, miglioramento e controllo. La tesi si in-centra su quest’ultimo aspetto. La raccolta dei dati e la loro trasformazione ininformazioni rappresenta lo scopo principale di ogni sistema di gestione delle in-formazioni (Management Information System - MIS). MIS é uno strumento di con-trollo usato per processare le informazioni necessarie a gestire un’organizzazione:un’azienda agricola o un’azienda zootecnica, in modo effettivo. Sfortunatamente isistemi di gestione esistenti per le produzioni animali, sono statici, calcolati trime-stralmente e retrospettivi. Un nuovo approccio é consigliabile.

Negli ultimi decenni la combinazione di sensori, databases e modelli mate-matici ha permesso all’attivitá di monitoraggio di essere piú precisa. Lo sviluppodi sistemi di monitoraggio dinamici é strettamente correlato alla quantitá e allaqualitá delle informazioni disponibili nelle aziende zootecniche. Negli ultimi de-cenni, le nuove tecnologie in campo informatico, hanno consentito lo sviluppo distrumenti sempre piú all’avanguardia. La possibilitá di scoprire, in tempo reale, icambiamenti nell’andamento della produzione, diventa quindi una sfida per i futurisistemi di monitoraggio.

Modelli matematici e metodi per il monitoraggio dinamico delle produzioni inallevamenti di scrofe, sono stati suggeriti, attuati e discussi nel corso della tesi.Tre modelli sono stati sviluppati con successo: dimensione della nidiata a livellodell’allevamento e della scrofa; tasso di parto nelle scrofe e tasso di mortalitá inscrofe e suinetti.

Il miglioramento di un precedente modello sulla dimensione della nidiata, tro-vato in letteratura, rappresenta il primo passo per la creazione di un sistema di mon-itoraggio dinamico della produzione suina. Un modello dinamico lineare (DLM) éutilizzato a questo fine. Inoltre la tecnica di Massima verosimiglianza (Maximum-likelihood) é stata combinata con l’algoritmo di tipo EM (Expectation-Maximiza-tion) al fine di stimare le componenti della varianza dei parametri presi in con-siderazione. Infine strumenti quali le carte di controllo ispiarate a Shewhart e lamaschera V (V-mask) applicata alle carte di controllo di tipo cumulativo (Cusum),sono stati usati con lo scopo di fornire allarmi in caso di risultati alterati in meritoalla produzione in termini di dimensioni della prole.

Il secondo passo nella creazione del sistema, é la realizzazione di un modelloche ha per oggetto il tasso di parto delle scrofe. Il tasso di parto é un caratterebinario pertanto é modellato tramite il Modello Dinamico Lineare Generalizzato(DGLM). L’algoritmo di tipo EM é applicato per stimare preventivamente le com-ponenti della varianza. Le osservazioni relative alle inseminazioni e ai parti sono

Page 14: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

14 Summary

state incluse nelle analisi. Strumenti di controllo statistici (carte di controllo e V-mask) sono usati per dare allarmi nel caso di risultati alterati circa il tasso di parto.

Il terzo passo include invece un modello sul tasso di mortalitá. Per il tasso dimortalitá, di carattere binario come quello di parto, é usato il DGLM. L’approccioperó, rispetto al modello precedente, é lievemente differente perché scrofe e suinettisono presi in considerazione contemporaneamente. Come per il modello prece-dente, l’algoritmo di tipo EM é usato per stimare preventivamente le componentidella varianza. Gli strumenti statistici di controllo scelti, consentono il rilevamentodi risultati alterati concernenti il tasso di mortalitá per scrofe e suinetti.

Il punto forte di questi nuovi modelli, é la disponibilitá di aggiornamenti set-timanali che permettono un sistema di monitoraggio dinamico ed in tempo reale equindi l’opportunitá di prevedere la produzione in corso.

Sistemi per il monitoraggio della dimensione della nidiata, del tasso di parto edel tasso di mortalitá, sono stati sviluppati. Questi sono basati su DLM, DGLM emetodi di controllo statistici per rilevare le deviazioni sistematiche. É stato arguitoche la previsione delle produzioni su basi settimanali, é possibilie e promettente.La combinazione dei tre modelli e la possibilitá di collegarli con un modello dirimonta presente in letteratura, rappresenta una solida base per lo sviluppo di unnuovo strumento di gestione. Questo strumento puó essere usato per creare unsoftware capace di monitorare dinamicamente cambi nei sistemi di produzione.

Page 15: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

15

Resumen

Control dinámico de la producción en Cerdas

El concepto de manejo se refiere al procedimiento que incluye tres funciones esen-ciales: Planteamiento, Ejecución y Control. Esta tesis se centra en el aspecto delcontrol. El principal objetivo de cualquier Sistema de Información para la Gestión(MIS) es recopilar datos y transformarlos en información útil. Así pues, un Sis-tema de Información para la Gestión es una herramienta de control utilizada paraprocesar la información necesaria para gestionar una organización o empresa, compor ejemplo, una granja, de manera efectiva. Desafortunadamente, los sistemas deinformación para la gestión existentes en la actualidad para producción ganaderason estáticos, de cálculo trimestral y retrospectivos. Por lo tanto, se necesita unnuevo enfoque.

En las últimas décadas la combinación de detectores, bases de datos y mode-los matemáticos ha permitido que el control de la actividad sea más preciso. Eldesarrollo de sistemas de control dinámico para la producción porcina está es-trechamente vinculado con la cantidad y calidad de información disponible en lasgranjas.

Se han producido notables mejoras en la tecnología informática de la propiagranja en los últimos años, y por lo tanto, la posibilidad de detectar cambios en laproducción en tiempo real se convertirá en un desafío para los futuros sistemas decontrol.

En esta tesis se sugieren, aplican y analizan modelos y métodos para el controldinámico de la producción porcina en granjas. En total, se describen tres mode-los: número de lechones por parto, número de partos y mortalidad de madres ylechones.

La aplicación de un modelo de tamaño de la camada encontrado en la literaturarepresenta el primer paso en la creación de un sistema de control dinámico enproducción porcina. Para este fin se aplica un modelo lineal dinámico (DLM).Para estimar los componentes de la varianza de los parámetros tenidos en cuenta, seutilizaron técnicas algorítmicas de máxima verosimilitud y maximización esperadacombinadas. Finalmente, se utilizaron herramientas de control como las gráficas decontrol inspiradas por Shewhart y la máscara V aplicada a las Sumas acumuladas(Cusum) con el objetivo de proporcionar avisos en caso de tamaños de la camadaimpares.

El segundo paso en la creación del sistema es la aplicación de un modelo denúmero de partos. La tasa de partos es un carácter binario y se modela utilizandoun Modelo Lineal Dinámico Generalizado (DGLM). Para pre-estimar los com-ponentes de la varianza se aplicó el algoritmo de maximización esperada. En elanálisis se incluyeron las observaciones de inseminaciones y partos. Se utilizaron

Page 16: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

16 Summary

herramientas de control estadístico (gráficas de control y máscara V) para dar avi-sos en caso de tamaños de camada impares.

El tercer paso incluye el modelo de la tasa de mortalidad. La mortalidad, comoel índice de partos, es de caracter binario, por lo que también se utilizó el ModeloLineal Dinámico para planear esta variable. El enfoque del tercer modelo resultaun poco diferente comparado con el modelo previo, porque tanto las madres comolos lechones son tenidos en cuenta al mismo tiempo. Aun así, como en el segundomodelo, se utilizó el algoritmo de maximización esperada para la pre-estimaciónde los componentes de la varianza, y con las herramientas de control estadísticoseleccionadas se detectaron los datos impares de mortalidad en cerdas y lechones.

El punto fuerte de estos nuevos modelos es la posibilidad de actualizarlos sema-nalmente, lo que permite un sistema de control más cercano al tiempo real y porconsiguiente, la oportunidad de pronosticar la producción de manera continuada.

Ya se han desarrollado sistemas para controlar el tamaño de la camada, lospartos y la mortalidad. Están basados en una mezcla del Modelo Lineal Dinámico,el Modelo Lineal Dinámico Generalizado y los métodos de control para detectardesviaciones sistemáticas. La predicción de la producción semana tras semana esposible y prometedora. La combinación de los tres modelos y la posibilidad deenlazarlos con un modelo sustituto representa una base sólida para el desarrollode una nueva herramienta de manejo. Esta herramienta podrá ser utilizada paracrear un software capaz de controlar dinámicamente los cambios en un sistema deproducción.

Page 17: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

CHAPTER 2

GENERAL INTRODUCTION

In a situation with increasing herd size and growing competition from countrieswith lower production costs, the profitability of pig herds becomes increasinglysensitive to even small fluctuations in production results (Frost et al., 1997). Goodmanagement will therefore make the difference between success and failure.

During the last decades the rapid evolution of computers and technologies al-lowed many improvements in the agro-zootechnical sector. Around 1950s, whenmathematical models were involved to solve issues within this area, progress be-gan to be more evident (McPhee, 2009; Cornou and Kristensen, 2013). Between1970s and 80s the dynamic aspect of production control has gained more and morespace (Barrett and Nearing, 1998). In the early 90’s Groeneveld and Lacher (1992)described the tasks of Information Systems (IS) in pig production. According tothe authors the use of production data heavily depends on the aim of the IS. IShas been applied in several areas: breeding selection, economic and marketing sys-tems, welfare, health etc. (Groeneveld and Lacher, 1992). Information Technology(IT) has also contributed to the progress of the agro-zootechnical area by enablingthe farmer to collect a large number of records in a quick way. Observation andcollection of relevant figures are the primary steps to begin the process of analysisof production results.

A study on electronic identification of animals on farms, conducted by Geers(1994) underlined the importance of the combination of automatic identificationand sensors. This work also presented a cost-benefit analysis of the effect of theautomation methods adopted. A review by Frost et al. (1997) defined a list of thetools developed in the past decades: the electronic identification of animal identity,weight, behavior, physiological and environmental factors, body conformation andcomposition by using image analysis, electronic odor sensing and acoustic moni-toring. The aim of these tools is to improve the amount and the quality of informa-tion available. To be useful, data need to be processed into information.

Page 18: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

18 General Introduction

In a farm context, the term "information" is used for data which has been pro-cessed to a form that can be used as direct basis for the decision-making process(Boehlje and Eidman, 1984). Therefore, the quality of the underlying data sug-gests, to some extent, the quality of information which, in turn, represents the maintool of any Management Information System (MIS). The concept of managementis complex, but it is possible to recognize three essential parts in it: planning, im-plementation and control (Boehlje and Eidman, 1984). MIS join human knowledgeand organization’s procedures and technologies to support human decision making(Sørensen et al., 2010). The role of any MIS is to facilitate control and reducefuture uncertainty (Beaumont and Beaumont, 1987).

This thesis focuses on the control aspect of the production process. Controlprocesses are based on performance measurements and their comparison with stan-dards. Standards are designed using the aims previously established by the farmmanager (Huirne, 1990). In the livestock area, because the variables taken intoaccount are of biological nature, there is a wide range of uncertainty, therefore,deviations are always present (Frost et al., 1997; Huirne, 1990). Control processesimply not only the assessment of regular patterns in the system, but also the investi-gation of changes (deviations) that may occur during the production (Barnard andNix, 1973). In livestock production, MISs provide the information necessary tomanage animals and make decisions related to their value (Verstegen and Huirne,2001).

In order to process collected data into information, mathematical models areconstantly being developed and implemented. The development of mathematicalmodels in agricultural systems as well as in animal production plays a primaryrole in management systems and represents an important key function (McPhee,2009). Mathematical models are involved in a wide range of applications. A re-view of simulation and optimization models concerning reproduction, replacement,economics, feeding and genetics in a sow herd has been published by Plà (2007).Dumas et al. (2008) provide a centenary review of mathematical modeling in ani-mal nutrition. A sow replacement model based on Bayesian updating and MarkovProcess has been developed by Kristensen and Sollested (2004a), and a follow-ing study also provided the related optimization model (Kristensen and Sollested,2004b). Infectious diseases in slaughter pig fattening units have been modeled byToft et al. (2005). A detailed review of the use of information within the area of de-cision support systems for pig production has recently been carried out by Cornouand Kristensen (2013).

Often, if industries are involved in research projects, the aim to collect andmodel data is addressed through the creation of valuable management tools i.e.software. A list of software packages within the area of pig herd management(feeder and finishing) has been published by Groeneveld and Lacher (1992) and in-cludes PIGCHAMP (University of Minnesota and College of Veterinary Medicine),SWINE GRAPHICS (Swine graphic Inc. Des Moines, Iowa), PIG TALES (Pig Im-provement Company, Franklin, Kentucky), STAGES (Purdue University, Lafayette,Indiana). After twenty years, dozens of similar packages are available and are di-

Page 19: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

19

rectly downloadable from the web. They cover several features of the productionprocess such as farrowing rate, matings, born alive, parity profile, breeding, slaugh-ter weight, mortality, feeding, financial etc.

Unfortunately, most of these management information systems are still static,with quarterly calculated results, and provide retrospective production reports. Thesystems used in pig production are generally based on static statements of selectedkey figures calculated for a specific time interval (from three months to one year).Most often, the results are presented in a table as simple averages over time andanimals. Most systems allow for comparison with the production goals of the herdbut they do not assist the manager in the interpretation of the production results.Another problem with these static systems arises when changes in the productionoccur without possibility for intervention because it is too late to provide effectiveassistance. As a result, enterprisers are subjected to a decrease in productivity andthus financial losses.

A dynamic approach is therefore desirable. The concept of dynamic can beclarified by the meaning of the word. According to OxfordDictionary (2013) theadjective dynamic is defined as: "a process or system characterized by constantchange, activity, or progress". Hence, the term dynamic is related to changes in aprocess through time (West and Harrison, 1997). Dynamic linear models (DLMs)as well as dynamic generalized linear models (DGLMs) belong to the subclass ofdynamic models. A detailed description of these models is depicted in West andHarrison (1997). DLM is applied for normally distributed data, whereas DGLM isgenerally used for categorial data.

Few studies involving these models are found in the swine production sector.Madsen et al. (2005) investigated drinking patterns of young pigs by the use ofa state space model. They applied a univariate dynamic linear model with cycliccomponents in order to observe and predict the diurnal drinking behavior of grow-ing pigs. As a continuation of their previous work, Madsen and Kristensen (2005)created a model for monitoring the condition of pigs by the drinking behavior. Inthis study, the DLM is combined with detection methods such as control chartsand V-masks applied on the cumulative sum of the model forecast errors. Anotherinteresting study in the field of pig production is reported in Cornou et al. (2008).The DLM combined with a Kalman Filter (an algorithm that uses series of data ob-served over time) and control charts (described later in this chapter), was used forautomatic detection of oestrus and health disorders by using data from electronicsow feeders. Furthermore, sows’ activity types have been modeled and monitoredby Cornou et al. (2011), where multivariate dynamic linear models have been ap-plied to classify five types of sows’ activity in the farrowing house using accelera-tion data. By the use of acceleration data Cornou and Lundbye-Christensen (2012)modeled the sows diurnal activity pattern and monitored the onset of the parturi-tion using a dynamic generalized linear binomial model. A dynamic generalizedlinear model with Poisson distributed data has been implemented by Ostersen et al.(2010) in order to detect oestrus by monitoring sows’ visits to a boar.

According to Madsen (2001), monitoring is the activity of recording relevant

Page 20: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

20 General Introduction

parameters and providing immediate data evaluation as soon as they are obtain-able. Monitoring methods are applied in order to detect inadequacies and to give asignal when significant deviations occur (West and Harrison, 1997). Montgomery(2005) has extensively studied statistical control methods for quality control. Hefocused on statistical process control (SPC) and a detailed study on control chartsis available in his book (Montgomery, 2005).

A. de Vries, from University of Florida, has contributed widely to the applica-tion and evaluation of the mentioned detection tools, especially in the dairy sector.Detection of estrus in cows has been the object of study of de Vries and Conlin(2003a,b). A comparison between Shewhart and Cusum control charts has beendepicted by de Vries and Conlin (2005). More recently, a general overview of ap-plication of SPC charts to monitor changes in animal production systems has beenpublished by de Vries and Reneau (2010).

Real time monitoring of unexpected changes in performance would allow in-terpretation of the results in an acceptable range of time and therefore, reduce eco-nomic losses (de Vries and Reneau, 2010).

In this thesis DLMs have been used for modeling and monitoring litter size atherd and sow level, whereas multivariate DGLMs have been applied for modelingand monitoring farrowing and mortality rate at herd level.

2.1 Objective

The objective of this thesis is to develop new and more reliable methods for dy-namic production monitoring. As part of the monitoring, automatic methods fordetection of the systematic deviations from the expected results are implemented.

2.2 Limitations of existing MIS

As previously mentioned, the current production reports are static and several con-cerns emerge from a standard MIS:

• Topicality: Since the production results are calculated retrospectively for agiven period backwards in time they have a topicality problem in the sensethat very often the pigs, that the results are calculated for, have already beenslaughtered. It is therefore too late to take any action in order to improvethe results. This problem can, to some extent, be compensated through morefrequent reports.

• Precision: The results will be influenced by arbitrary random fluctuationswhich are not caused by production failures. Hence, if the reported resultis unfavorable, it is important to know the precision behind the key figures.The precision is necessary for the assessment of whether the deviation issignificant or just coincidental.

Page 21: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

2.3 Requirements needed 21

• Topicality versus precision: There is a built-in conflict between topicalityand precision in the sense that if the time period is long, the precision in-creases (simply because random fluctuations are evened out) whereas thetopicality is impaired.

• Correlations between key figures: Many of the reported key figures are heav-ily correlated. This fact hampers the interpretation of a production report,because the key figures cannot be assessed one by one.

• Auto-correlation: Production reports for consecutive periods cannot be as-sessed in isolation simply because most key figures are auto correlated overtime. They should, therefore, be regarded and analyzed, as time series.

2.3 Requirements needed

The requirements of the methods developed in this thesis can be summarized asfollows:

• Every time new events have been recorded in the herd database, the key fig-ure must be recalculated instantaneously, so that an updated, topical pictureof the production is always at the disposal of the manager.

• The correlation between the key figures must be taken into account.

• Autocorrelation over time must be considered.

• The precision of the key figures should be automatically calculated and con-tinually updated together with the key figure itself.

• The system must provide automatic tests for significant deviations from theexpected results. The tests must be based on multivariate observations sothat correlations are taken into account.

2.4 Study context

The context of this thesis is within the area of herd management and monitoringsystems, development of models and methods that enable the manager to controlthe production and, to some extent, predict failures in the production process.

2.5 Data collection

Data for this study have been provided by the existing DLBR-IT Managementinformation system. The DLBR system for swine (Swine It) is a Danish programfor the effective management of pig farms. It gives the possibility of solving a widerange of tasks in the pig production system. Data were stored in a SQL-database

Page 22: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

22 General Introduction

server, which the primary function is to store and retrieve data as requested and canbe used by other software applications. Data were processed by the free softwareR (R Core Team, 2013) and an apposite package was used to process data, PigMonitor: created by Anders Ringgaard Kristensen (Kristensen, 2012).

Data from 15 anonymous farmers were obtained and used for the present thesis.The time frame of analyzed data per herd ranges between 3 and 9 years. Dataavailable for the study were: sow identity, litter size, parity number, sow effect,insemination number, farrowing events, number of weaned piglets and death ofsows and weaners.

2.6 Analytic methods

The analytical methods applied in this thesis are based on dynamic linear mod-els (DLMs) for normally distributed data and dynamic generalized linear models(DGLMs) for not normally distributed data (i.e. categorial observations).

2.6.1 Dynamic Linear Model

The DLM is generally composed by a set of two equations: an observation equationand a system equation (West and Harrison, 1997). The observation equation (2.1)expresses the distribution of the sample for Yt in the parameter vector θt whereasthe system equation (2.2) describes the evolution of the vector θt over time. Theequations appear as follow:

Yt = F ′tθt + vt, vt ∼ (0, Vt) (2.1)

andθt = Gtθt−1 + wt, wt ∼ (0,Wt) (2.2)

where:

• Yt is an observational vector with n elements

• θt is a parameter vector with m elements

• Ft is an m x n matrix [design matrix]

• vt is an n dimensional random vector

• 0 is a vector of zeros

• Vt is an n x n variance-covariance matrix

• Gt is an m x m matrix [system matrix]

• wt is an m dimensional random vector

• Wt is an m x m variance-covariance matrix.

Page 23: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

2.6 Analytic methods 23

Matrices Ft, Gt, Vt and Wt are assumed to be known at time t. The meaning ofthe model is that the observations are multivariate normally distributed around anunobservable underlying mean F ′tθt where the parameters θt may fluctuate overtime (Kristensen et al., 2010).

Weekly updates for DLM

Before any observations have been made, it is assumed that the initial informa-tion is (µ0|D0) ∼ N(m0, C0) where m0 is a mean vector and C0 is a variance-covariance matrix. When some information become available, the correspondingconditional distribution at time t is (µt|Dt) ∼ N(mt, Ct) (Kristensen et al., 2010).In order to obtain sequential updates of the model components over time, a set ofequations describing the update procedure of the DLM, also called Kalman Filter(KF), has been provided by West and Harrison (1997). For each time step t, thefollowing updating equations are computed:

1. Posterior for θt at time t-1:

(θt−1 | Dt−1) ∼ N (mt−1, Ct−1). (2.3)

2. Prior for θ at time t:(θt | Dt−1) ∼ N (at, Rt), (2.4)

whereat = Gtmt−1 and Rt = GtCt−1G

′t +Wt. (2.5)

3. One step forecast for kt at time t:

(kt | Dt−1) ∼ N (ft, Qt), (2.6)

whereft = F ′tat and Qt = F ′tRtFt + Vt. (2.7)

4. Posterior for θt at time t:

(θt | Dt) ∼ N (mt, Ct), (2.8)

with the updating equations

mt = at +Atet and Ct = Rt −AtQtA′t, (2.9)

whereAt = RtFtQ

−1t and et = kt − ft. (2.10)

Page 24: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

24 General Introduction

2.6.2 Dynamic Generalized Linear Model

A dynamic generalized linear model is used for observations that are not normallydistributed (categorically distributed observations). Farrowing and mortality ratebeing binary traits belong to the binomial distribution which, in turn, belongs tothe exponential family. The general equation for the univariate DGLM (Kristensenet al., 2010) is:

f(Y | η, V ) = exp

(y(Y )η − a(η)

V

)b(Y, V ) (2.11)

where the probability function f of a random variable Y can be written with anatural parameter (η), a scale parameter (V ), and three known functions: a(η),y(Y ) and b(Y, V ). The function a(η) is assumed to be twice differentiable in η(Kristensen et al., 2010). In the binomial distribution β(n, p) the natural parameteris:

η = lnp

1− p, (2.12)

the scale parameter is:

V =1

n, (2.13)

the function y is y(Y ) = Y V , the function a is a(η) = ln(1 + eη) and the functionb is defined as

b(Y, V ) =

(V −1

Y

). (2.14)

In the book "Herd Management Science II. Advanced topics" (Kristensen et al.,2010), a detailed description of the model specification for DGLM is provided.The DGLM, as the DLM, is based on a set of two equations: observation equa-tion and system equation. The first one, observation equation includes, in turn, twoequations. The distribution is only partially specified by its mean and variance. Forobservations kt, the probability function is defined and the influence of an under-lying unobservable parameter vector θt on the natural parameter ηt is expressed asfollow (observation equations):

1.

f(kt | ηt, Vt) = exp

(y(kt)ηy − a(ηt)

Vt

)b(kt, Vt) (2.15)

2.g(ηt) = F ′tθt, (2.16)

and the system equation is defined as follow:

θt = Gtθt−1 + wt, wt ∼ [0,Wt] (2.17)

where:

Page 25: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

2.6 Analytic methods 25

• Yt is the scalar observation at time t

• g(ηt) is a known function mapping ηt to the real line

• Ft is a known m dimensional vector

• g(η) is a linear function of the elements of θt

• wt ∼ [0,Wt] means that wt has zero mean and a known variance-covariancematrix Wt.

Descriptions of univariate DGLM can be found in the literature (West andHarrison, 1997; West et al., 1985) but, at the present time, to the knowledge ofthe authors, no studies on multivariate binomial models have been published. Anextension of the univariate binomial technique is presented in this thesis in order tocover also multivariate models.

Weekly updates for DGLM

A brief description of the updating technique based on Taylor expansion of theconditional probability function of the number of successes of the binomial dis-tribution y given the natural parameter η , is described in Appendix A of Chapter4. The main feature of the technique is that for given ηt, the observations yt areindependent. Therefore, it is possible to achieve weekly updates estimates for θtand hence ηt.

2.6.3 Detection methods

Two detection methods have been applied in order to monitor changes in the pro-duction results. Both are control charts. These charts are particulary suitable tocheck the process and to detect if out of control situations result in small or largeshifts in the monitored parameters. Both are based on the monitoring of the model’sstandardized forecast errors, which are defined as the observation Yt minus themodel forecast ft.

Shewhart control charts

A Shewhart control chart (SCC) is a graphical presentation of observations thathave been collected versus the sample number or time (Montgomery, 2005). It isgenerally composed by a central line or target (CL) (that usually corresponds to themean of the observations taken into account), and two other horizontal lines: uppercontrol limit (UCL) and lower control limit (LCL). An example of SCC is shownin Figure 2.1. The aim of the control limits is to check whether the process is or isnot in control. In order to be dynamic a process is subjected to the time variable.Two general formulas are used to compute these limits:

UCLt = θ′ + aσt (2.18)

Page 26: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

26 General Introduction

Figure 2.1: Shewhart control chart design. The green line corresponds to the centerline (CL) whereas the two red lines represent the upper (UCL) and lower (LCL)control limits. The sample is displayed as plotted points representing, in this study,the difference between observed and expected values i.e. the forecast error.

andLCLt = θ′ − aσt (2.19)

where a, also called distance parameter, is a number (e.g., 1, 2 or 3) reflecting thelevel of significance for the detection of changes in the process (Kristensen et al.,2010).

The breadth of the control limits is inversely proportional to the sample sizefor a given multiple of standard deviation. Therefore, these two lines can be placedat a precise distance, i.e. 1 or 2 standard deviations (it depends on the settingestablished). The value of a for normal distributed data (litter size) is set to 2which means a 5% significance level.

When binomial data are analyzed, it is necessary to consider the beta-binomialdistribution and therefore, adapt the control limits. In this study, when farrowingand mortality rate were investigated, the control limits were defined as integers.The LCL was set as 0.025 quantile of the beta-binomial distribution whereas theUCL was set as 0.925. Being defined as integers, for the UCL the integer wasrounded up, and for LCL, the integer was rounded down. Therefore, for each limit(upper and lower) there is a significance level that corresponds to less than 2.5%.When an observation exceed the mentioned limits (both downwards and upwards)the process is "out-of-control" and an alarm is given.

In the thesis, the target value is set to 0, since in normal situations we expectthat observed values do not differ significantly to the predicted ones. A Shewhartcontrol chart uses information of the last collected sample, which means that noinformation of the entire sequence of observations is available. This is one ofthe major disadvantage of this type of control charts. On the other hand, it is anexcellent tool for detection of small process shifts (Montgomery, 2005).

Page 27: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

2.7 Outline of the thesis 27

d PO

Ψ

(a) V-mask design

0 2 4 6 8 10 12 14 16 18 20 22

−4

−2

0

2

4

Cumulative sum

Observation number

(b) V-mask applied on hypothetical Cusum

Figure 2.2: The V-mask. (a) The V-mask and scaling. The parameters d and Ψdetermine the sensitivity to short term changes and (long term) drifts, respectively.(b) The V-mask applied on a hypothetical Cusum.

V-mask applied on Cumulative Sum

The cumulative sum (Cusum) control chart is an alternative method to detect changesin the process mean. The Cusum includes all the information available and it repre-sents the sum of the accumulated differences between observed and predicted val-ues. If the process is in control, the Cusum should fluctuate stochastically aroundthe 0 level. In this study, a V-mask is applied on the Cusum therefore, no controllimits are used. The mask is a V-shaped lay placed on the chart. A V-mask andan example of application are shown in Figure 2.2. A complete description of theV-mask settings is provided by Barnard (1959) and Montgomery (2005). Thereare basically two parameters to consider when the V-mask is applied: the lead dis-tance d, which reflects the model sensitivity to short term changes, and the angleΨ, which determines how much long term drift can be accepted. If any observationof the Cusum lies outside the arms, the process is considered ’out-of-control’, andthe Cusum is reset to zero.

2.7 Outline of the thesis

The thesis is organized as follow:

• Chapter 2 is a brief description of the context of the PhD project, the datacollection framework, and the applied analytical methods.

• In Chapters 3, 4 and 5, the main key figures are addressed in three separatemanuscripts with the following titles:

Page 28: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

28 General Introduction

1. Dynamic production monitoring in pig herds I: Modeling and moni-toring litter size at herd and sow level. Published in Livestock Science(Bono et al., 2012).

2. Dynamic production monitoring in pig herds II. Modeling and monitor-ing farrowing rate at herd level. Published in Livestock Science (Bonoet al., 2013).

3. Dynamic production monitoring in pig herds III. Modeling and moni-toring mortality rate at herd level (Manuscript).

• In Chapter 6, an overall idea of the thesis and a general discussion on prob-lems and possible solutions identified in Chapters 3, 4, and 5 are discussed.

• In Chapter 7, perspectives for implementation of tools are suggested anda summary of the main conclusions achieved in Chapters 3, 4, 5, and 6 isprovided.

Page 29: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

BIBLIOGRAPHY 29

Bibliography

Barnard, C. S., Nix, J. S., 1973. Farm planning and control. Cambridge, England :University Press.

Barnard, G. A., 1959. Control charts and stochastic processes. Journal of the RoyalStatistical Society. Series B (Methodological) 21 (2), pp. 239–271.

Barrett, J. R., Nearing, M. A., 1998. Humanization of decision support using infor-mation from simulations. Agricultural System Modelling and Simulation. NewYork: Marcel Dekker, 1–17.

Beaumont, J. R., Beaumont, C. D., 1987. Applied management information sys-tems: thoughts on current practice and future potential. Futures 19 (4), 442 –445.

Boehlje, M. D., Eidman, V. R., 1984. Farm Management. John Wiley and Sons,New York.

Bono, C., Cornou, C., Kristensen, A. R., 2012. Dynamic production monitoring inpig herds I. Modelling and monitoring litter size at herd and sow level. LivestockScience 149, 289 – 300.

Bono, C., Cornou, C., Lundbye-Christensen, S., Kristensen, A. R., 2013. Dynamicproduction monitoring in pig herds II. Modeling and monitoring farrowing rateat herd level. Livestock Science 155 (1), 92 – 102.

Cornou, C., Kristensen, A. R., June 2013. Use of information from monitoringand decision support systems in pig production: collection, applications andexpected benefits. Accepted in Livestock Science.

Cornou, C., Lundbye-Christensen, S., 2012. Modeling of sows diurnal activity pat-tern and detection of parturition using acceleration measurements. Computersand Electronics in Agriculture 80 (0), 97 – 104.

Cornou, C., Lundbye-Christensen, S., Kristensen, A. R., 2011. Modelling andmonitoring sows’ activity types in farrowing house using acceleration data.Computers and Electronics in Agriculture 76 (2), 316 – 324.

Cornou, C., Vinther, J., Kristensen, A. R., 2008. Automatic detection of oestrusand health disorders using data from electronic sow feeders. Livestock Science118 (3), 262 – 271.

de Vries, A., Conlin, B., 2003a. Design and performance of statistical processcontrol charts applied to estrous detection efficiency. Journal of Dairy Science86 (6), 1970 – 1984.

Page 30: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

30 BIBLIOGRAPHY

de Vries, A., Conlin, B., 2003b. Economic value of timely determination of un-expected decreases in detection of estrus using control charts. Journal of DairyScience 86 (11), 3516 – 3526.

de Vries, A., Conlin, B., 2005. A comparison of the performance of statisticalquality control charts in a dairy production system through stochastic simulation.Agricultural Systems 84 (3), 317 – 341.

de Vries, A., Reneau, J. K., 2010. Application of statistical process control chartsto monitor changes in animal production systems. Journal of Animal Science88 (13 electronic suppl), E11–E24.

Dumas, A., Dijkstra, J., France, J., 3 2008. Mathematical modelling in animalnutrition: a centenary review. The Journal of Agricultural Science 146, 123–142.

Frost, A., Schofield, C., Beaulah, S., Mottram, T., Lines, J., Wathes, C., 1997. Areview of livestock monitoring and the need for integrated systems. Computersand Electronics in Agriculture 17 (2), 139 – 159.

Geers, R., 1994. Electronic monitoring of farm animals: a review of research anddevelopment requirements and expected benefits. Computers and Electronics inAgriculture 10 (1), 1 – 9.

Groeneveld, E., Lacher, P., july 1992. An open information system for the swineproduction and marketing industry: Its scope, topology and telecommunicationsstrategy. Comput. Electron. Agric. 7 (2), 163–185.

Huirne, R. B. M., 1990. Computerized management support for swine breed-ing farms. Ph.D. thesis, Wageningen Agricoltural University, Wageningen, TheNetherlands.

Kristensen, A., Jørgensen, E., Toft, N., 2010. Herd Management Science. II. Ad-vanced topics. Academic books, Copenhagen.

Kristensen, A. R., 2012. pigMonitor: Monitoring in pig herds. R package version1.0 - Not available on the net, available under request.

Kristensen, A. R., Sollested, T. A., 2004a. A sow replacement model usingbayesian updating in a three-level hierarchic markov process: I. Biologicalmodel. Livestock Production Science 87 (1), 13 – 24.

Kristensen, A. R., Sollested, T. A., 2004b. A sow replacement model usingbayesian updating in a three-level hierarchic markov process: II. Optimizationmodel. Livestock Production Science 87 (1), 25 – 36.

Madsen, T., March 2001. Tools for monitoring growing pigs. Ph.D. thesis, TheRoyal Veterinarian and Agricultural University, Copenhagen, Gronnegaarsvej 2,1870 Frederiksberg C.

Page 31: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

BIBLIOGRAPHY 31

Madsen, T. N., Andersen, S., Kristensen, A. R., 2005. Modelling the drinkingpatterns of young pigs using a state space model. Computers and Electronics inAgriculture 48 (1), 39 – 61.

Madsen, T. N., Kristensen, A. R., 2005. A model for monitoring the condition ofyoung pigs by their drinking behaviour. Computers and Electronics in Agricul-ture 48 (2), 138 – 154.

McPhee, M., July 13-17 2009. Mathematical modelling in agricolutal systems: Acase study of modelling fat deposition in beef cattle for research indudtry. WorldIMACS / MODSIM Congress, Cairns, Australia.

Montgomery, D., 2005. Introduction to statistical quality control, 5th Edition. Wi-ley, Hoboken, NJ.

Ostersen, T., Cornou, C., Kristensen, A., 2010. Detecting oestrus by monitoringsows’ visits to a boar. Computers and Electronics in Agriculture 74 (1), 51 – 58.

OxfordDictionary, July 2013. Online Etymology Dictionary.URL http://dictionary.reference.com/browse/

Plà, L., 2007. Review of mathematical models for sow herd management. Live-stock Science 106 (2-3), 107 – 119.

R Core Team, 2013. R: A Language and Environment for Statistical Computing. RFoundation for Statistical Computing, Vienna, Austria, ISBN 3-900051-07-0.URL http://www.R-project.org/

Sørensen, C., Fountas, S., Nash, E., Pesonen, L., Bochtis, D., Pedersen, S., Basso,B., Blackmore, S., 2010. Conceptual model of a future farm management infor-mation system. Computers and Electronics in Agriculture 72 (1), 37 – 47.

Toft, N., Kristensen, A. R., Jørgensen, E., 2005. A framework for decision sup-port related to infectious diseases in slaughter pig fattening units. AgriculturalSystems 85 (2), 120 – 137.

Verstegen, J., Huirne, R., 2001. The impact of farm management on value of man-agement information systems. Computers and Electronics in Agriculture 30 (1 -3), 51 – 69.

West, M., Harrison, J., January 1997. Bayesian Forecasting and Dynamic Models,2nd Edition. Springer Series in Statistic. Springer, New York.

West, M., Harrison, J. F., Migon, H. S., 1985. Dynamic generalized linear modelsand bayesian forecasting. Journal of the American Statistical Association 80, 73– 83.

Page 32: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic
Page 33: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

CHAPTER 3

DYNAMIC PRODUCTIONMONITORING IN PIG HERDS I:MODELING AND MONITORING

LITTER SIZE AT HERD ANDSOW LEVEL

Claudia Bono, Cécile Cornou and Anders Ringgaard Kristensen

Published in Livestock Science 149 (2012) 289-300. Doi: 10.1016/j.livsci.2012.07.023

Abstract: Monitoring animal production results in real time is a challenge.Existing management information systems (MIS) in pig production are typicallybased on static statements of selected key figures. The objective of this paperis to develop a dynamic monitoring system for litter size at herd and sow level,with weekly updates. For this purpose, a modified litter size model, based onan existing model found in the literature, is implemented using dynamic linearmodels (DLMs). The variance components are pre-estimated from the individ-ual herd database using a maximum-likelihood technique in combination with anExpectation-Maximization (EM) algorithm applied on a larger dataset with ob-servations from 15 herds. The model includes a set of parameters describing theparity-specific mean litter sizes (herd level), a time trend describing the geneticprogress (herd level), and the individual sow effects (sow level). It provides reli-able forecasting with known precision, on a weekly basis, for future production.Individual sow values, useful for the culling strategy, are also computed. In asecond step, statistical control tools are applied. Shewhart Control Charts and V-masks are used to give warnings in case of impaired litter size results. The modelis applied on data from 15 herds, each of them including a period ranging from 150to 800 weeks. For each herd, the litter size profile, the litter size over time, the sow

Page 34: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

34 I Modeling and monitoring litter size at herd and sow level

individual effect and sow economic value, are computed. Perspectives for furtherdevelopment of the model can take into account indices including conception rate,service rate, mortality rate etc. Such a model can be used as a basis for developinga new, dynamic, management tool.

Keywords: Monitoring; Litter size; Dynamic Linear Model; Statistical control

3.1 Introduction

In a situation with increasing herd sizes and growing competition from countrieswith lower production costs, the profitability of pig herds becomes increasinglysensitive to even small fluctuations in production results (Frost et al., 1997). Reli-able monitoring systems therefore become of paramount importance to the farmerwho, as mentioned by Frost et al. (1997), has the full responsibility for all aspects ofhis husbandry including monitoring of feeding, reproduction, health, growth, qual-ity and other key indicators. Performing these tasks become increasingly importantand an appropriate real-time monitoring management system could be desirable.

During the last decades the combination of sensors, databases and mathemati-cal models has allowed the monitoring activity to be more precise, and a MIS joinshuman knowledge, organization’s procedures and technologies, to support humandecision making (Sørensen et al., 2010). Whereas current IT-based managementtools available to pig farmers are well suited for storing data and providing regularto-do list, there is a great potential for improvements when it comes to systematicuse of data for monitoring and forecast.

The problem of existing systems in pig production is that they are based onstatic statements of selected key figures calculated for a specific time interval (typ-ically a quarter or a year). Most systems allow for comparison with the productiongoals of the herd, but, otherwise they don’t assist the manager in any way in theinterpretation of the production results. Through these systems, the advisor mayhelp the farmer to manage his farm and do some forecasts on the future produc-tions. Nevertheless, these systems do not allow farmer intervention in real time andthis may result in decreased productivity and financial loses. Alternative systemsincluding real time monitoring of unexpected changes in performance would allowto control the results in an acceptable range of time and to reduce economic loss(De Vries and Reneau, 2010).

Information systems for supporting the decision-making process have been ap-plied in several fields such as financial (Humphrey, 1994), medical (Doolin, 2004),marketing (Nasir, 2005) etc. MIS is generally composed by different parts or levels(Boehlje and Eidman, 1984). In livestock production for instance, it can be appliedin nutrition, animal herd health, breeding and genetics, animal products processing,animal production and management (Irvin, 2008). A potential problem in livestockindustry is that the factors submitted for analysis, are biological and consequentlyvariable and unpredictable (Frost et al., 1997). Most often the results are presentedin a table as simple averages over time and animals.

Page 35: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

3.2 The litter size model proposed by Toft and Jørgensen (2002) 35

This paper is the first result of a larger project with the overall aim of breakingfundamentally with those traditional principles and, instead, provide monitoringmethods that are proactive and forward looking. These methods should allow themanager to make decisions based on dynamically updated forecasts, so that inter-vention is possible before production failures result in considerable financial lossesor reduced animal health and/or welfare.

The aim of this first paper is to develop a dynamic monitoring system for littersize (total born) at herd and sow level. For accurate predictions of piglet produc-tion, the sow level is needed because individual sow productivity varies system-atically with parity and genetic properties. Since these effects are herd specific,the herd level is needed as well. For this purpose a further developed version ofthe litter size model proposed by Toft and Jørgensen (2002) is implemented in adynamic setting with sequential weekly updating of parameters at herd and sowlevel. In addition, statistical control tools (Shewhart Control Chart and V-mask)are implemented in order to give warnings in case of impaired litter size results.The system developed will be an important step towards creation of a reliable fore-casting system for future production.

3.2 The litter size model proposed by Toft and Jørgensen(2002)

One of the most important measures of productivity in sow herds is the litter size. Asimple average litter size is not suitable for monitoring, because it depends heavilyon the age structure of the herd. A monitoring system for litter size must adjustfor age distribution. In order to do this, the parity specific mean litter size must beknown.

Toft and Jørgensen (2002) proposed the following litter size model for sow i atparity n

Yin = −φ1e(−(n2−1)φ2) + φ3 − φ4n+Mi(n) + εin, (3.1)

where Yin represents the litter size expressed as total born piglets for sow i in parityn; φ1, . . . , φ4 are the parameters describing the curve; and where εin ∼ N (0, τ2)and the sow effect Mi(n) ∼ N (0, σ2) is a first order autoregressive time seriesdescribed as

Mi(n) = e−αMi(n− 1) + ηin, (3.2)

with ηin ∼ N (0, (1 − e−2α)σ2). The parameter α represents the autocorrelationbetween parities of the same sow. Thus, the full litter size model has 7 parameters:φ1, φ2, φ3, φ4, τ, σ, α. Given a large sample of litter size records from a herd, theseseven parameters can be estimated as described by Toft and Jørgensen (2002).

Essential for prediction of litter sizes are the four parameters φ1, . . . , φ4 de-scribing the unselected herd mean (see Figure 3.1(a) for an illustration) and the soweffectsM1(n1), . . . ,MN (nN ) of theN sows in the herd. One approach could be to

Page 36: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

36 I Modeling and monitoring litter size at herd and sow level

0 1 2 3 4 5 6 7 8 9 10 11 1210

12

14

16Litter size

Parity

Intercept=φ3

Slope=φ4

Curve=φ2

φ1

Yn = − φ1e(−(n2−1)φ2) + φ3 − φ4n

(a) Model from Toft and Jørgensen (2002)

0 1 2 3 4 5 6 7 8 9 10 11 1210

12

14

16Litter size

Parity

Slope=φ4µ1

µ2µ3 µ4

(b) Modified model (2012)

Figure 3.1: Differences between the model suggested by Toft and Jørgensen(2002) and the modified one. (a) Original model and corresponding equation. (b)Reparametrization of the previous model. The parameters φ1, φ2 and φ3 are re-placed by the parameters µ1 to µ4, allowing the use of a Dynamic Linear Model.The parameter φ4 remains unchanged.

estimate the litter size profile and the variance components from the herd databaseas described by Toft and Jørgensen (2002), and then, given these estimates, se-quentially update the estimate for the sow effect as described by Kristensen andSøllested (2004a) in the context of a replacement optimization model (i.e. not formonitoring). Such an approach has the following weaknesses for monitoring pur-poses:

• It cannot be applied in new herds, because no (or only very few) litter sizerecords are available.

• The litter size profile may change over time (and is likely to do so). Therecan be several reasons for that, but an obvious example is the genetic trendwhich leads to increasing litter sizes over time.

• The estimates for the litter size profile φ1, . . . , φ4 and the sow effects Mi(n)are mutually dependent.

It is therefore advisable to have a sequential estimation technique which is able,week by week, to simultaneously update the estimates for φ1, . . . , φ4 and the soweffects Mi(n).

Page 37: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

3.3 Sequential estimation of litter size profile and sow effects 37

3.3 Sequential estimation of litter size profile and sow ef-fects

This section presents the process of sequential estimation. A re-parameterizedmodel is suggested. The reason of the re-parametrization is to make the param-eters linear in order to use them in a Dynamic Linear Model. The components ofthe DLM are described and an example illustrates the principle behind the modeldesign.

3.3.1 A linear litter size model

A Dynamic Linear Model as described by West and Harrison (1997) is an obvioustool for sequential estimation. In this case we face the problem that the litter sizeprofile of the herd as suggested by Toft and Jørgensen (2002)

µn = −φ1e(−(n2−1)φ2) + φ3 − φ4n, (3.3)

is not linear. For “large” n, i.e. n > 3 we have nevertheless an approximativelinear expression (cf. Figure 3.1a)

µn ≈ φ3 − φ4n, n > 3, (3.4)

and for n = 1 we haveµ1 = −φ1 + φ3 − φ4. (3.5)

Thus, the only mean litter sizes which are not at least approximately linear inthe parameters are those for parities 2 and 3. As illustrated in Figure 3.1a, it is theparameter φ2 which determines how much to subtract from the linear expression(3.4) in order to obtain µ2 and µ3. We will, therefore, estimate those two meanvalues as

µ2 = −φ22 + φ3 − 2φ4 (3.6)

andµ3 = −φ23 + φ3 − 3φ4. (3.7)

In other words, we use two parameters φ22 and φ23 to model the shape between µ1and µ4 instead of just φ2 in the original model by Toft and Jørgensen (2002). Thebenefit is that we obtain linear expressions for the litter size model, and the cost isthe additional parameter.

When looking at the expressions (3.4 - 3.7) it seems more natural to re-parameterizethe entire model, so that µ1, µ2, µ3 and µ4 (Figure 3.1b) are modeled and estimateddirectly and, for n > 4,

µn = µ4 − (n− 4)φ4, n > 4. (3.8)

That will be the approach used in this study.

Page 38: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

38 I Modeling and monitoring litter size at herd and sow level

3.3.2 Litter size model with time trend

In the Danish breeding system high priority is given to improvement of litter size.An estimated annual genetical improvement of average litter size per parity of 0.45live piglets (at day 5 after farrowing) has been reported (Pig Research Centre,2010). With a sequential (and dynamic) estimation technique, the parameters ofthe litter size model will automatically adapt to the trend, so for pure estimation adirect modeling of the trend is less important. If, however, the model is used forforecasting, a direct modeling of the trend is important in order not to underesti-mate future litter sizes. In the following we shall use the notation µnt to indicateexpected litter size at parity n of a sow farrowing first time at time t.

We shall, therefore, extend the model for average litter size at parity n with alinear time trend δ, so that expected litter size at parity n, µnt, of a sow with firstfarrowing at time t is

µnt = µn + δt, (3.9)

where µn is defined as in Eq. (3.5 - 3.8). Since, however, the trend may also changeover time, the recursive relation

µnt = µn,t−1 + δt−1 (3.10)

will be used to model the development of the general trend. It should be noticedthat µnt for n > 1 does not refer to expected litter size of a parity n sow farrowingat time t. Instead, the index t refers to the time of first farrowing of a parity nsow. A trend of this kind assumes that increased litter size is the result of geneticalimprovement.

3.3.3 A dynamic linear model

A multivariate dynamic linear model consisting of an observation equation and asystem equation as described by West and Harrison (1997) will be applied. Wewill use weekly observations of litter sizes of all farrowing sows to update the herdprofile and the sow effects. The latent parameter vector for week t will be

θt = (µ1t, µ2t, µ3t, µ4t, φ4t , δt,M1(n1t), . . . ,MN (nN t))′. (3.11)

Thus, the size of the parameter vector equals the number of sows, N , in the herdplus the 6 parameters describing the profile.

Observation equation

The observation vector Yt = (yf1t, . . . , yfkt)′ will consist of observed litter sizes of

all k sows farrowing in week t. The observation equation linking the observationsto the parameters has the general form

Yt = F ′tθt + vt, (3.12)

Page 39: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

3.3 Sequential estimation of litter size profile and sow effects 39

where Ft is called the design matrix, and vt ∼ N (0, Iτ2) where 0 is a vector ofzeros and I is the identity matrix. The challenge here is to setup the design matrix.

The content of the matrix depends on the sow number and the parity. Theexpected litter size of a parity n sow farrowing at time t is µnt1 , where t1 ≤ t is thetime of first farrowing. A linear expression for µnt1 is only available if previouslevel estimates are remembered as long time back as the week of first farrowingof the oldest sow in the herd. In other words, we would have to include in theparameter vector also those historical values. Such a solution would, however,drastically increase the complexity of the dynamic linear model (if the oldest sowis a parity 10, the week of first farrowing will be more than 200 weeks back). Wetherefore rely on the following approximation:

µnt1 ≈ µnt − (n− 1)dδt, (3.13)

where d is the average interval (in weeks) between two farrowings of the samesow. A value of d = 23 will be used. The assumptions behind the approximation isthat the intervals between farrowings only vary relatively little and that the currenttrend δt is representative for the entire time interval from t1 to t.

Now assume that k = 5 sows farrow in week t and they are characterized asshown in Table 3.1. The observation vector would then be Yt = (12, 11, 15, 16, 14)′,and the design matrix will then look as follows:

F ′ =

0 0 0 1 −2 −5d . . . 1 . . . 0 . . . 0 . . . 0 . . . 0 . . .0 0 0 1 0 −3d . . . 0 . . . 1 . . . 0 . . . 0 . . . 0 . . .0 0 1 0 0 −2d . . . 0 . . . 0 . . . 1 . . . 0 . . . 0 . . .0 1 0 0 0 −d . . . 0 . . . 0 . . . 0 . . . 1 . . . 0 . . .1 0 0 0 0 0 . . . 0 . . . 0 . . . 0 . . . 0 . . . 1 . . .

(3.14)

Page 40: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

40 I Modeling and monitoring litter size at herd and sow level

Table 3.1: Example of 5 sows farrowing in week t.Sow # Parity Piglets born Sow effect

287 6 12 M287(6)321 4 11 M321(4)356 3 15 M356(3)410 2 16 M410(2)430 1 14 M430(1)

with the corresponding parameter vector

θt =

µ1tµ2tµ3tµ4tφ4tδt...

M287(6t)...

M321(4t)...

M356(3t)...

M410(2t)...

M430(1t)...

.

System equation

The system equation expresses how the parameter values may change over time.The general form of the system equation is

θt = Gtθt−1 + wt, (3.15)

where Gt is called the system matrix, and wt ∼ N (0,W ) where 0 is a vector ofzeros and W is a variance-covariance matrix describing the system variance andcovariance of each of the parameters.

As concerns the sow effect Mi(n), the relation from parity is already given byEq. (3.2), but in this model we need the weekly relation. Since we are only inter-ested in the effect at farrowing we will put α = 0, so that e−α = 1, in weeks where

Page 41: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

3.3 Sequential estimation of litter size profile and sow effects 41

no farrowing takes place for a sow and use the parity to parity value in weeks wherea farrowing actually happens. Thus, the variance component in W correspondingto each sow effect is (1− e−2α)σ2 with α = 0 if no farrowing takes place (makingthe variance component 0 as well). The variance components corresponding to theherd level effects are estimated using the EM-algorithm described in Section 3.3.3.

Including as an example only one multi-parous farrowing sow (number 321,parity 4), one new primiparous farrowing sow (number 430), one not farrowingsow (number 415, parity 2) and a sow (number 356, parity 3) which has beenculled between time t− 1 and time t, the parameter vectors θt−1 and θt become

θt−1 =

µ1,t−1µ2,t−1µ3,t−1µ4,t−1φ4,t−1δt−1

M321(3, t− 1)M356(3, t− 1)M415(2, t− 1)

, θt =

µ1tµ2tµ3tµ4tφ4tδt

M321(4t)M415(2t)M430(1t)

and the system matrix converting θt−1 to θt is

Gt =

1 0 0 0 0 1 0 0 00 1 0 0 0 1 0 0 00 0 1 0 0 1 0 0 00 0 0 1 0 1 0 0 00 0 0 0 1 0 0 0 00 0 0 0 0 1 0 0 00 0 0 0 0 0 e−α 0 00 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0

. (3.16)

As it is seen in the matrix Gt, the culling of Sow 356 is handled by a full columnof zeros at the position of the sow in the parameter vector θt−1. Thus the soweffect M356(3, t− 1) is ignored in the calculation of the new expected value of θt.Insertion of the new Sow 430 is handled by a full row of zeros at the bottom of thematrix corresponding to the index of the sow in the new parameter vector θt. Thus,the expected value of M430(1t) is zero and independent of the previous parametervector which did not contain the sow.

For the variance-covariance matrix Wt the following structure is assumed:

Page 42: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

42 I Modeling and monitoring litter size at herd and sow level

Wt =

W11 W12 W13 W14 0 0 0 0 0W12 W22 W23 W24 0 0 0 0 0W13 W23 W33 W34 0 0 0 0 0W14 W24 W34 W44 0 0 0 0 0

0 0 0 0 W55 0 0 0 00 0 0 0 0 W66 0 0 00 0 0 0 0 0 (1− e−2α)σ2 0 00 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 σ2

.

(3.17)As it is seen, the changes of the level parameters µ1, . . . , µ4 are assumed to bemutually correlated, but independent of changes in other model elements. The sowproperties are assumed to be mutually independent. Sow 321 farrows in week t, soits properties may change according to Eq. (3.2). Sow 415 does not farrow, so itsproperties are constant. The last sow, 430, is a new gilt farrowing, so its propertiesare drawn from N (0, σ2).

Weekly update

In any week, the last week’s estimate for the parameter vector θt−1 ∼ N (mt−1, Ct−1)is available. The vector mt−1 contains the estimates for the 5 litter size profile pa-rameters, the time trend δt−1 and the Nt−1 sows present in the herd.

Based on the sows farrowing in week t, the observation vector Yt, the designmatrix Ft and the system matrix Gt will be defined as described in the previoussections and a new estimate θt ∼ N (mt, Ct) is computed using the updating equa-tions of the Kalman filter (filtering) as described by Kristensen et al. (2010).

As a result of the filtering, we obtain a weekly estimate of:

• The herd specific parameters µ1, µ2, µ3, µ4, φ4, where µn is the mean of asow at parity n and φ4 is the slope of the curve.

• The time trend δ. The trend takes into consideration the sows’ genetic im-provement during the years using Eq. (13) as a "correction" formula.

• The individual property of each sow in the herd, Mi.

Smoothing is a retrospective analysis applicable for those values, where fluc-tuations are evaluated after the events. Data are re-examined starting from the lastupdated, and backwards to the beginning (West and Harrison, 1997). This allowsto have more precise information about the consequences of particular events, suchas employment of new herdsman, disease outbreaks and so on (Kristensen et al.,2010). This retrospective analysis is essential to improve the understanding and toaccelerate the decision process.

Page 43: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

3.3 Sequential estimation of litter size profile and sow effects 43

Sow values and their economical consequences

It is worth mentioning that the described DLM for monitoring complements thesow replacement model described by Kristensen and Søllested (2004a,b) in thesense that it provides a consistent framework for linking the replacement modeldirectly to the data observed in a sow herd. Thus, the herd specific parameters µ1,µ2, µ3, µ4, φ4, are needed as input to model construction and the estimated sowvalue Mi is part of the state definition for individual sows.

It is therefore, by use of the replacement model, possible to provide an eco-nomical value of an individual sow in terms of the so-called future profitabilityoriginally defined by Van Arendonk (1985) for dairy cows and later used for sowsby Huirne et al. (1991) who called it the retention pay-off. The value, which can becalculated by any replacement model based on dynamic programming, expressesthe total extra profit to be expected from keeping a sow until her optimum, com-pared with immediate replacement.

Therefore, the sow value Mi expressing the estimated deviation (in number ofpiglets) of a sow compared to herd level litter size profile expressed by µ2, . . . , µ4,φ4, can by use of the replacement model by Kristensen and Søllested (2004a,b)be associated with a direct economic value in terms of the retention pay-off. Thevalues presented in this study are computed at the time of weaning.

Initialization

In order to have a full specification of the DLM, the initial information θ0 ∼N (m0, C0) before anything has been observed in the herd must be defined. Wewill have to distinguish between two different scenarios:

New herd, no records: The subsets of m0 and C0 referring to the 5 litter sizeprofile parameters (µ1, µ2, µ3, µ4, φ4) will be defined from the populationmean and the population variance-covariance matrix. For the subset of m0

and C0 referring to sow properties, all elements of m0 are set equal to 0, andthe corresponding diagonal elements of C0 are set equal to σ2.

Existing herd, database available: From the herd database, a herd specific lit-ter size profile with variance components τ2, σ2 and α, is estimated as de-scribed by Toft and Jørgensen (2002). Based on the estimated values, thesow effects of the existing sows will be calculated sequentially as describedby Kristensen and Søllested (2004b). Thus, the full m0 is defined.

EM algorithm for estimation of system variance

The EM-algorithm is an iterative algorithm used to estimate unknown parametersby Maximum Likelihood estimation (ML). A free software for statistical comput-ing and graphics was used (R Development Core Team, 2012) for implementationof the algorithm. In ML estimation, we wish to compute the model parameter(s) for

Page 44: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

44 I Modeling and monitoring litter size at herd and sow level

which the observed data are the most likely. The calculation procedure is composedof iterations. The two steps of the EM-algorithm can be formulated as maximizingthe conditional expectation of the log likelihood for the augmented data, given theobserved data and the previous estimate (Dethlefsen, 2001).

The sow related elements of the system variance in Eq. (3.17) are known fromthe herd specific estimation performed by the method described by Toft and Jør-gensen (2002). The herd related elements, i.e. the upper left 6 × 6 sub matrix ofWt, are on the other hand unknown. They are, therefore, estimated by use of theEM algorithm on a collection of herd databases from Danish sow data. Examplesof EM-algorithm applications for estimation of variance components for sow datacan be found in literature, e.g. in Cornou and Lundbye-Christensen (2010) andCornou et al. (2011).

For the estimation procedure, time series from H herds are used. Each timeseries, h = 1, . . . ,H , is observed over Th weeks. Initially, a first guess of theunknown elements of Wt is used. This initial guess is successively improved overa large number of iteration steps until convergence. At each iteration step, m, theKalman filter is applied for t = 1, . . . , Th on each time series to obtain the herdand week specific estimates mht and Cht for the parameter vector θht. Afterwards,smoothing is performed to obtain improved estimates m̃ht and C̃ht for θht. Theseestimates (plain and smoothed) are then used to improve the estimate for Wt fromWmt to Wm+1

t .Inspired by the description provided by Dethlefsen (2001), an iteration step of

the EM algorithm can be described as follows:Let Wm be the current (i.e. iteration m) estimate for the upper left 6 × 6 sub

matrix of Wt. The updated estimate, Wm+1, to be used as estimate at iterationm+ 1 is found as

Wm+1 =1∑H

h=1 Th

H∑h=1

Th∑t=1

(Lht + (m̃ht −Ghtm̃h,t−1)(m̃ht −Ghtm̃h,t−1)

′) ,(3.18)

where

Lht = C̃ht +GhtC̃h,t−1G′ht − C̃htB′h,t−1 −Bh,t−1C̃ ′ht, (3.19)

and

Bh,t−1 = Ch,t−1G′ht(GhtCh,t−1G

′ht +Wm)−1. (3.20)

The equations (3.18), (3.19) and (3.20) are applied block-wise to the system variance-covariance matrix W and only to the herd related elements of the upper left 6× 6sub matrix corresponding to the herd level. In other words, they are applied sep-arately to the upper left 4 × 4 sub matrix, to the diagonal element W55 and thediagonal element W66.

Page 45: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

3.4 Detection of impaired litter size results 45

3.4 Detection of impaired litter size results

After applying the DLM, litter sizes and individual sows’ properties are monitored.Deviations of the observations as compared to the predicted values are monitoredwithin a short- and long term period.

The short term monitoring is a weekly control of the results, where differencesbetween observed and predicted values are monitored using a Control Chart in-spired by Shewhart (Montgomery, 2005). A Control Chart is a statistical tool usedto see, graphically, if observations or time series are running as they should. It is,in general, composed of three elements:

• A central line (CL) corresponding to the target value, θ′,

• An upper control limit (UCL),

• A lower control limit (LCL).

In the current monitoring method, the target value (CL) is set to 0, since weexpect that, in a normal situation, the observed values do not differ significantlyfrom the predicted ones. The control limits are used to see whether or not theprocess is ’out-of-control’ (Kristensen et al., 2010). They are defined as:

UCLt = θ′ + ast (3.21)

and

LCLt = θ′ − ast (3.22)

where a is the distance parameter and st is the standard deviation at week t.The value of a is set to 2, which corresponds to an approximate 5% significancelevel for normally distributed data (Kristensen et al., 2010).

The purpose of the long term monitoring is to detect sudden or gradual changesin level of litter size over time. It is performed over the last three years using a cu-mulative sum (Cusum) Control Chart combined with a V-mask as described byMontgomery (2005). The cumulative sum represents the sum of the accumulateddifferences between observed and predicted values. It incorporates past observa-tions and for this reason, it is also able to detect small shifts in the process (De Vriesand Reneau, 2010). If the process is in control, the Cusum should fluctuate stochas-tically around the 0 level. On the other hand, if data show a trend, the level canshift.

To monitor level shifts, a V-mask is applied on the Cusum Control Chart. Thesetting of the V-mask is defined by Barnard (1959) as the lead distance d, whichreflects the model sensitivity to short term changes, and the angle Ψ, which deter-mines how much long term drift can be accepted. In the present application of themethod, the values d = 10 and a slope of the V-mask of 0.6 (corresponding to anopening of the V-mask, Ψ, of 31 degrees) are used. For detailed information about

Page 46: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

46 I Modeling and monitoring litter size at herd and sow level

d PO

Ψ

(a) V-mask design

0 2 4 6 8 10 12 14 16 18 20 22

−4

−2

0

2

4

Cumulative sum

Observation number

(b) V-mask applied on hypothetical Cusum

Figure 3.2: The V-mask. (a) The V-mask and scaling. The parameters d and Ψdetermine the sensitivity to short term changes and (long term) drifts, respectively.(b) The V-mask applied on a hypothetical Cusum.

the choice of the settings, see Montgomery (2005). If any point of the Cusum liesoutside the arms, the process is considered ’out-of-control’, and the Cusum is resetto zero. Figure 3.2 illustrates the design of the V-mask and its application on aCusum.

For both short and long term monitoring, the following components are ex-tracted from the model: the forecast for the observation vector at time t (West andHarrison, 1997), which is:

ft = F ′tGtmt−1, (3.23)

and its variance

Qt = F ′t(GtCtGt +Wt)Ft + Iτ2. (3.24)

Let 1 = (1,...,1) be a row vector consisting of only elements with value 1. Theforecast for the total number of piglets born in week t is therefore 1ft with variance1Qt1

′ and the observed total number is 1Yt. Thus the weekly forecast error, et, is:

et = 1Yt − 1ft. (3.25)

For the Shewhart Chart, the observation in week t is et and the standard deviationused for control limits, is

st =√

1Qt1′. (3.26)

Thus, the numerical value of st will depend heavily of the number of sows farrow-ing at week t.

Page 47: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

3.5 Results 47

Table 3.2: Upper left matrix of the system variance-covariance W (6 x 6). Valuesof the correlations are shown below the diagonal.

Matrix # 1 2 3 4 5 61 0.00072 0.00071 0.00069 0.00068 0 02 0.90 0.00087 0.00104 0.00121 0 03 0.69 0.95 0.00139 0.00176 0 04 0.53 0.85 0.98 0.00232 0 05 0 0 0 0 1.52e-10 06 0 0 0 0 0 1.48e-10

For the V-mask, the cumulative sum (Cusum) is defined as the sum of thestandardized forecast errors:

Ct =

t∑t=1

etst. (3.27)

3.5 Results

This section presents the results of the system variance estimation, of the modelapplication and of the use of the monitoring methods to detect impaired size results.Data analysis included 15 herds.

3.5.1 System variance of herd level parameters

Convergence of the variance components for each of the six parameters was ob-served after 400 iterations of the EM-algorithm (Figure 3.3). Results began toconverge already after 200 iterations. The inclusion of Herd 12 resulted in conver-gence failure; its variance was much lover than others herds so the EM-algorithmfailed to converge. This herd was therefore excluded from the variance-covarianceestimation procedure. The values of the upper left variance-covariance matrix areshown in Table 3.2. The variances of the model parameters (µ1, µ2, µ3, µ4, φ4) andof the time trend (δt), are in the diagonal. Correlations between parities were alsocomputed and are shown below the diagonal. The highest correlation is observedbetween parity 3 and 4 (0.98), while parity 1 and 4 have the lowest correlation(0.53).

3.5.2 Litter size profiles

The litter size profiles for the 15 herds are shown in Figure 3.4. The profile of mostof the herds appears as expected and confirms the shape of the litter size profile(Figure 3.1): a peak in production is observed around parity three and four andfollowed by a negative slope. At first parity the average (over herds) of the pigletsborn is 14.7 and the peak (around parity four) is 17.89.

Page 48: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

48 I Modeling and monitoring litter size at herd and sow level

0 100 200 300 400

0.0000

0.0005

0.0010

0.0015

0.0020

Iteration

Variance

Parity 1

Parity 2

Parity 3

Parity 4

(a) Convergence of system variance

0 100 200 300 400

0.0

0.2

0.4

0.6

0.8

1.0

Iteration

Correlation

Parities 1 & 2

Parities 1 & 3

Parities 1 & 4

Parities 2 & 3

Parities 2 & 4

Parities 3 & 4

(b) Convergence of system correlation

0 100 200 300 400

0e+00

2e−10

4e−10

6e−10

Iteration

Variance

Slope

(c) Convergence of system variance, slope

0 100 200 300 400

0e+00

2e−10

4e−10

6e−10

Iteration

Variance

Trend

(d) Convergence of system variance, trend

Figure 3.3: Representation of convergence using the EM-algorithm, 400 iterations.(a) Convergence of the system variance in the first four parities. (b) Convergenceof system correlations in the first four parities. (c) Convergence of the systemvariance of the slope and (d) of the trend.

Page 49: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

3.5 Results 49

1 2 3 4 5 6 7 8 9 10 11 12

8

10

12

14

16

18

20

Parity

Piglets

Herd 1Herd 2Herd 3Herd 4Herd 5Herd 6Herd 7Herd 8

Herd 9Herd 10Herd 11Herd 12Herd 13Herd 14Herd 15

Figure 3.4: Litter size profiles (number of total born piglets per parity) in 15 herds.

Exceptions are found for Herds 1, 5 and 7. In Herd 1, the number of pigletsfor Parity 2 increases less than expected, affecting the shape of the curve betweenparities 1 and 3. In Herd 5, an unexpected drop in the number of piglets is observedbetween parities 2 and 3. Finally, Herd 7 shows a very low productivity comparedto the others herds and its slope is less steep.

The values of the model parameters for the 15 herds are shown in Table 3.3.Mean, minimum, maximum and standard deviation are also calculated. The valueof trend, reflecting the genetic improvement during the three years considered,is negative for two herds (Herd 7 and 12) and the maximum value (0.0016) isobserved for Herd 15.

3.5.3 Model components

A detailed analysis of the DLM components for Herd 15, over the last three years,is shown in Figure 3.5. Results of the filtering for the first four parameters ofthe model, corresponding to the first four parities, µ1 to µ4, are shown in Figure3.5(a), and the corresponding smoothed components in Figure 3.5(b). The numberof piglets increases from parity 1 to parity 4. The smoothed values of the slope(Figure 3.5(c)) and trend (Figure 3.5(d)) are almost constant.

Page 50: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

50 I Modeling and monitoring litter size at herd and sow level

Table 3.3: Value of the model parameters for the 15 herds. Mean, minimum, max-imum and standard deviation are shown in the bottom part.

Herd Number µ1 µ2 µ3 µ4 φ4 δ

1 15.07 16.10 17.26 17.12 0.2928 0.001622 15.14 17.78 18.85 19.05 0.3389 0.0009593 13.35 15.89 16.98 17.38 0.2537 0.001514 14.59 17.14 18.30 18.76 0.2595 0.001295 16.07 17.75 17.55 17.87 0.2214 0.002076 14.63 16.77 17.09 17.15 0.4601 0.001257 11.65 13.82 14.95 15.57 0.1179 -0.0001288 14.74 16.69 17.77 18.23 0.33 0.0010429 14.90 17.05 17.88 18.17 0.2769 0.002202

10 15.79 18.06 19.22 19.59 0.2526 0.002311 14.24 16.16 16.84 17.13 0.3694 0.0017312 15.57 17.12 17.42 17.57 0.3471 -0.00061813 15.15 17.75 18.43 18.31 0.2452 0.0014414 14.30 16.43 17.44 17.55 0.2439 0.00040715 15.76 17.55 18.66 19.00 0.1899 0.00642

Mean 14.73 16.80 17.64 17.89 0.2801 0.00157Min 11.65 13.82 14.95 15.57 0.1179 -0.000613Max 16.07 18.06 19.22 19.59 0.4601 0.00642SD 1.10 1.07 1.03 1.01 0.08 0.0016

Page 51: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

3.5 Results 51

50 100 150

14

15

16

17

18

19

20

Week

Piglets

Parity 1

Parity 2

Parity 3

Parity 4

(a) Litter size over time (filtered)

50 100 150

14

15

16

17

18

19

20

Week

Piglets

Parity 1

Parity 2

Parity 3

Parity 4

(b) Litter size over time (smoothed)

50 100 150

0.0

0.1

0.2

0.3

0.4

0.5

Week

Piglets per parity

(c) Slope after parity 4 (smoothed)

50 100 150

0.003

0.004

0.005

0.006

0.007

0.008

0.009

Week

Piglets per week

(d) General trend in litter size (smoothed)

Figure 3.5: Evolution of the model parameters for Herd 15 over the last three years.(a) Filtered parity components: µ1, µ2, µ3, µ4. (b) Smoothed parity components.(c) Smoothed slope (φ4). (d) Smoothed trend (δ).

Page 52: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

52 I Modeling and monitoring litter size at herd and sow level

3.5.4 Sow results

The sows’ properties, Mi(nt), are updated on an individual basis and used forforecasting future litter sizes. These estimates are thereafter combined with aneconomic value (the so-called “retention payoff” or “future profitability”) providedby the sow replacement model by Kristensen and Søllested (2004a,b) as describedin Section 3.3.3.

Table 3.4 shows the results of eight sows from Herd 1. The sow value, Mi(nt),indicates the difference (in number of piglets) between the individual sow resultand the herd mean for the corresponding parity. The first two sows, 2185 and1349, are both at parity 1. The value 1.13 for sow 2185 indicates therefore thatits litter has around 1 piglet more than the general mean, resulting in a positiveretention pay-off of 146.8 EUR. The value of the second sow is negative (-1.65),and this results in a negative retention pay-off implying that the sow should bereplaced. The next two sows, 1820 and 1344, are both at parity 2. Even though bothsow values are positive, a difference of approximately one piglet results in a largedifference in term of retention pay-off. For two sows at parity 4, no economic lossis estimated even if the sow value is slightly negative. This is explained by the factthat parity 4 is just after the peak of production (around parity 3) for Herd 1 (Figure3.4). The low retention pay-off of 2.80 EUR for Sow 2215 with M2215(4t) =−0.36 on the other hand reflects that it can be culled with very low economicalloss. From parity 5, the number of piglets per parity decreases. This has as aconsequence that even if sow has a positive value (Sow 574), the correspondingretention pay-off becomes negative. The same holds for sow 688 at parity 11, ofwhich the negative retention pay-off confirms that it is not profitable to keep a sowfor so long even though the sow value is high. This is simply due to the shape ofthe litter size profile as seen in Figure 3.4.

Table 3.4: Estimated sow value, Mi(nt), and corresponding retention pay-off ofeight selected sows from Herd 1.

Sow number, i Parity, n Sow value, Mi(nt), piglets Retention pay-off, EUR2185 1 1.13 146.801349 1 −1.65 -16.551820 2 0.386 32.081344 2 1.30 152.441549 4 2.25 74.542215 4 −0.36 2.80574 5 0.19 -2.24688 11 1.46 -26.94

Page 53: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

3.6 Discussion 53

150 155 160 165 170 175

−100

−50

0

50

100

Week

Piglets

(a) Observed vs predicted

●●

●●

●●

●●

●●

●●●●●●

●●

●●●●

●●

●●●

●●●●

●●●●

●●

●●●●

●●

●●

●●●

●●

●●●

●●

●●

●●●●

●●

●●●●●●●

●●●●

●●

●●●●

●●

●●●

●●

●●●●●

●●●

●●

●●●●●

●●

●●●●●

●●

●●

●●●

●●●

●●

●●●●

●●●●

●●●

●●

●●●●

●●●●●

●●●

50 100 150−40

−20

0

20

40

Week

Cumulated sum of standardized forecast errors

(b) Cusum with V-mask

Figure 3.6: Monitoring methods applied for Herd 15. (a) Short monitoring period(26 weeks). The central line represents the differences between observed and pre-dicted values. The dotted lines are the upper and lower control limits. (b) Longmonitoring period (156 weeks) using a V-mask applied on a Cusum.

3.5.5 Detection of alarms

Monitoring methods were applied both on short- and long term periods. Figure3.6(a) illustrates the monitoring over a short period (26 weeks) using a ControlChart. Four alarms were observed, at weeks 161, 166, 167 and 168, where thedifferences between observed and predicted values (plain line) exceeded the controllimits (dotted lines). Monitoring over a long period (156 weeks) is performed usinga Cusum combined with a V-mask (Figure 3.6(b)). Here, the Cusum shows a levelshift around Week 76, which is detected by the V-mask.

An overview of the number of alarms obtained over 156 weeks for the 15 herdsis presented in Table 3.5. The total number of alarms using a V-mask is 8. Halfof these alarms (4) are due to a negative trend (VM Decrease), which indicatethat the observed results have been below what was predicted. For the short termmonitoring, 168 alarms are observed, in which 90 of them (CC Decrease) indicatethat the observed results were below what was predicted.

3.6 Discussion

Model parameters were pre-estimated using the EM-algorithm. Convergence of thesystem variance and correlations (Figure 3.3) was obtained when Herd 12 (whichresulted in convergence failure) was left out. Since the weekly error terms are in-dependent (cf. Eq.(3.15)), a coefficient of variation (CV) was calculated to makethe interpretation of the systems variance size more understandable. As an exam-ple, Parity 1, which has a weekly variance of 0.00072 or on annual basis equal to0.03744, has a corresponding CV, equal to 0.013. This value indicates that the herdaverage only varies little over time.

Concerning correlations between parities (see Table 3.2 - below the diagonal),very high values were found between Parity 1 and 2 (0.90), Parity 2 and 3 (0.95),

Page 54: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

54 I Modeling and monitoring litter size at herd and sow level

Table 3.5: Number of alarms in a 156 weeks period according to the detectionmethods: V-mask (VM) and Control Chart (CC).

Herd Number VM Decrease VM Increase CC Decrease CC Increase1 0 0 4 22 0 1 8 63 0 0 1 24 0 1 3 55 0 0 7 36 0 0 4 77 1 0 10 48 1 0 9 89 1 0 7 3

10 0 0 4 411 0 0 7 412 0 0 2 813 0 1 8 914 0 1 4 415 1 0 12 9

Sum 4 4 90 78

and Parity 3 and 4 (0.98). These high correlations indicate that, for instance, if theherd average for Parity 1 increases, the average of Parity 2 will increase as well.Therefore the shape of the litter size profile will be maintained because individualparity averages will not drift independently of each other.

Filtered and smoothed data for Herd 15 were shown in Figure 3.5. The smooth-ing reduced the temporary random fluctuation observed in the filtered data. Thesmoothed data includes all information in the period of time specified, here 156weeks, and is as such the best possible estimate. Whereas the filtered data obtainedfor a given week will not change later on, the corresponding smoothed value willchange in the light of the later observations. Therefore, the two plots are not di-rectly comparable. If, for instance, we decide to interrupt the analysis at Week 50,the smoothed estimate will be the same as the filtered whereas the smoothing valuefor that week after 150 observations, will be different. If these plots should be usedin practice, the dynamic property of the smoothing should be communicated tothe farmer to avoid disorientation in the interpretation of the filtered and smoothedplots.

The value of the slope also contributes to the shape of the herd profile andreflects the persistency of litter size over parities. If the numerical value of theslope is close to zero (cf. Figure 3.5(c)), the productivity of old sows will remain ata high level. If the slope is steep, it reflects a fast decrease in litter size over paritiesfor old sows. The relative value of µ1, as compared to the value of µ2 to µ4 reflectsthe performance of the gilts. A low relative value may indicate problems with this

Page 55: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

3.6 Discussion 55

category of animals.The prior value of the trend used in the paper (0.5 piglet per year) is inspired by

the estimated genetic trend reported by Pig Research Centre (2010). This value wasestimated in the breeding population and based on the number of live piglets at dayfive. The initial weekly value in the setting of this paper (δ0) was therefore set to0.00961 (0.5/52 weeks). As seen in Table 3.3, the obtained values were lower thanexpected. The highest value was found in Herd 15 (0.00642), while Herd 7 and12 had negative values. This tends to indicate that these herds do not exploit thegenetic progress obtained in the breeding population. Even though the breedingvalue may be considered as a upper limit, these results are lower that what mayhave been expected. On the light of these findings, breeding improvement can besuggested to the farmers.

Results were monitored both in short- and long time periods. In the short termperiod (26 weeks), alarms were monitored using a Shewhart Control Chart. ForHerd 15, four points were outside the control limits (Figure 3.6(a)). Alarms atWeeks 166 and 168 indicate that the weekly production is lower than what waspredicted. The farmer may use these alarms to investigate what happened duringthe insemination process, for instance. In Weeks 161 and 167, the alarms are overthe UCL line. The overproduction is positive, therefore these kinds of alarms couldbe ignored unless the farmer wishes to be informed, in real time, of progress interms of productivity. The addition of Warning Limits could be used to indicatewhen results are ’near’ to be ’out-of-control’. These warning limits may be addedon the Shewhart Control Chart by using a smaller value of a, for instance a = 1.5(Montgomery, 2005).

Table 3.5 shows the number of alarms provided by the two monitoring methods.In the course of three years, the level of production (level shift detected by V-mask) rarely changed. There were only 4 decreasing alarms. On the other hand,the Control Chart, monitoring weekly deviations, gave a larger number of alarms.If only the decreasing alarms (90) are taken into consideration, for a total periodof 2340 weeks for the 15 herds, the number of alarms per herd and per year isaround 2, indicating that 3% of the monitored weeks resulted in alarm. This can beconsidered as an acceptable value for practical implementation of this monitoringmethod. Nevertheless, for practical implementation a calibration of the settings,under known production circumstances, should be performed.

An alternative monitoring method is e.g., a Tabular Cusum, for which upperand lower one-side Cusum are calculated separately. The upper Cusum accumu-lates the deviations above the target value, the lower, below it, and an alarm occurswhen a given threshold is exceeded (Kristensen et al., 2010). This method is alsosuitable for the present study, since it automatically distinguishes increasing anddecreasing performances. A detailed description of Tabular Cusum is found inMontgomery (2005).

The monitoring methods may also be applied on parity specific litter sizes,which can be extracted from the model. This model property is very useful if amore detailed analysis, for a given parity, is needed.

Page 56: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

56 I Modeling and monitoring litter size at herd and sow level

The model also estimates the sows’ individual properties, which are used forreliable forecasting of litter sizes. These were in a second step used for comput-ing retention pay-off value. The farmer can therefore combine the obtained in-formation into a decision support model for replacement, as the one proposed byKristensen and Søllested (2004a,b).

The present study forms the basis for the creation of a larger monitoring system.A similar analysis, at herd and sow level, should be performed using informationabout conception rate and mortality rate. This would allow a more precise moni-toring of, for instance, the number of piglets to sell. The new information availablealso gaps the current bridge between the data and the decision support models,and as such, increases to the potentiality of the above mentioned decision supportmodel for replacement.

3.7 Conclusion

A system for monitoring litter size at herd and sow level was developed. It is basedon a combination of Dynamic Linear Models and methods monitoring systematicdeviations, and is as such a useful tool for forecasting and monitoring litter sizes,on a weekly basis. The general profile of litter sizes appear stable and as expected,for most of the 15 herds. The amount of alarms indicating a decreased produc-tion level is, in average, two per herd and per year. This tends to indicate that thechosen settings are appropriate and that the model works properly. However, forpractical implementation a calibration of the settings, under known production cir-cumstances, is desirable. The inclusion of conception rate and mortality rate shouldmake it a fully functional management tool to monitor and predict productions ina dynamic way.

Conflict of interest statement

The authors report that there are not conflicts of interest relevant to this publication.

Acknowledgements

The authors wish to acknowledge the 15 anonymous farmers as well as the Dan-ish Advisory Center for providing data and the Danish Ministry of Food, Agri-culture and Fisheries for financial support for this study through a grant enti-tled:"Development of a Management System for complete monitoring in Danishand International Pig Production".

Page 57: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

BIBLIOGRAPHY 57

Bibliography

Barnard, G. A., 1959. Control charts and stochastic processes. Journal of the RoyalStatistical Society. Series B (Methodological) 21 (2), pp. 239–271.

Boehlje, M. D., Eidman, V. R., 1984. Farm Management. John Wiley and Sons,New York.

Cornou, C., Lundbye-Christensen, S., 2010. Classification of sows activity typesfrom acceleration patterns using univariate and multivariate models. Computersand Electronics in Agriculture 72 (2), 53 – 60.

Cornou, C., Lundbye-Christensen, S., Kristensen, A. R., 2011. Modelling andmonitoring sows activity types in farrowing house using acceleration data. Com-puters and Electronics in Agriculture 76 (2), 316 – 324.

De Vries, A., Reneau, J. K., 2010. Application of statistical process control chartsto monitor changes in animal production systems. Journal of Animal Science88 (13 electronic suppl), E11–E24.

Dethlefsen, C., 2001. Space time problems and application. Ph.D. thesis, AalborgUniversity.

Doolin, B., 2004. Power and resistance in the implementation of a medical man-agement information system. Information Systems Journal 14 (4), 343–362.

Frost, A., Schofield, C., Beaulah, S., Mottram, T., Lines, J., Wathes, C., 1997. Areview of livestock monitoring and the need for integrated systems. Computersand Electronics in Agriculture 17 (2), 139 – 159.

Huirne, R., Dijkhuizen, A., Renkema, J. A., 1991. Economic optimization of sowreplacement decisions on the personal computer by method of stochastic dy-namic programming. Livestock Production Science 28, 331–347.

Humphrey, C., 1994. Reflecting on attempts to develop a financial managementinformation system for the probation service in england and wales: Some ob-servations on the relationship between the claims of accounting and its practice.Accounting, Organizations and Society 19 (2), 147 – 178.

Irvin, M., 2008. Success and failure factors of management information sys-tems in the livestock industry of developing countries. In: Tharakan, J., Trim-ble, J. (Eds.), 3rd International Conference on Appropriate Technology. Kigale,Rwanda., pp. 282–288.

Kristensen, A., Jørgensen, E., Toft, N., 2010. Herd Management Science. II. Ad-vanced topics. Academic books, Copenhagen.

Page 58: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

58 BIBLIOGRAPHY

Kristensen, A. R., Søllested, T. A., 2004a. A sow replacement model usingbayesian updating in a three-level hierarchic markov process: I. biologicalmodel. Livestock Production Science 87 (1), 13 – 24.

Kristensen, A. R., Søllested, T. A., 2004b. A sow replacement model usingbayesian updating in a three-level hierarchic markov process: Ii. optimizationmodel. Livestock Production Science 87 (1), 25 – 36.

Montgomery, D., 2005. Introduction to statistical quality control, 5th Edition. Wi-ley, Hoboken, NJ, USA.

Nasir, S., 2005. The development, change, and trasformation of management in-formation systems (mis): A content analysis of articles published in businessand marketing journals. International Journal of Information Management 25,442–457.

Pig Research Centre, 2010. Annual report 2010. Tech. rep., Danish Agriculture andFood Council, Copenhagen, Denmark.

R Development Core Team, 2012. R: A Language and Environment for StatisticalComputing. R Foundation for Statistical Computing, Vienna, Austria, ISBN 3-900051-07-0.

Sørensen, C., Fountas, S., Nash, E., Pesonen, L., Bochtis, D., Pedersen, S., Basso,B., Blackmore, S., 2010. Conceptual model of a future farm management infor-mation system. Computers and Electronics in Agriculture 72 (1), 37 – 47.

Toft, N., Jørgensen, E., 2002. Estimation of farm specific parameters in a lon-gitudinal model for litter size with variance components and random dropout.Livestock Production Science 77 (2-3), 175 – 185.

Van Arendonk, J. A. M., 1985. Studies on the replacement policies in dairy cattle.II. Optimum policy and influence of changes in production and prices. LivestockProduction Science 13, 101–121.

West, M., Harrison, J., 1997. Bayesian Forecasting and Dynamic Models, 2nd Edi-tion. Springer Series in Statistic. Springer, New York.

Page 59: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

CHAPTER 4

DYNAMIC PRODUCTIONMONITORING IN PIG HERDS II:MODELING AND MONITORING

FARROWING RATE AT HERDLEVEL

Claudia Bono, Cécile Cornou, Søren Lundbye-Christensen andAnders Ringgaard Kristensen

Published in Livestock Science 155 (2013) 92-102. Doi: 10.1016/j.livsci.2013.03.026

Abstract:Good management in animal production systems is becoming ofparamount importance. The aim of this paper was to develop a dynamic moni-toring system for farrowing rate. A farrowing rate model was implemented us-ing a Dynamic Generalized Linear Model (DGLM). Variance components werepre-estimated using an Expectation-Maximization (EM) algorithm applied on adataset containing data from 15 herds, each of them including insemination andfarrowing observations over a period ranging from 150 to 800 weeks. The modelincluded a set of parameters describing the parity-specific farrowing rate and there-insemination effect. It also provided reliable forecasting on weekly basis. Sta-tistical control tools were used to give warnings in case of impaired farrowing rate.For each herd, farrowing rate profile, analysis of model components over time anddetection of alarms were computed. Together with a previous model for litter sizedata and a planned similar model for mortality rate, this model will be an importantbasis for developing a new, dynamic, management tool.

Keywords: Conception rate; Monitoring; Multivariate Dynamic GeneralizedLinear Model; Statistical control

Page 60: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

60 II Modeling and monitoring farrowing rate at herd level

4.1 Introduction

One aspect of paramount importance in the swine industry is reproduction. Ac-cording to Hughes and Varley (1980), reproduction includes different aspects, ofwhich one of them is conception. Conception is conditioned by several factors,such as boar and time of insemination, seasonal effects, feed intake, age and geno-type, artificial insemination, lactation length etc. The measurement of “conceptionrate” is not very precise, since it has to be measured indirectly as the percentage ofsows that do not return to oestrus 21 days after service, or be based on pregnancydiagnosis at about 30 days post-service. The farrowing rate is a more reliable nu-meric indication of the success of the conception: it is defined as the ratio of thetotal number of farrowings divided by the total number of matings, expressed as apercentage (Hughes and Varley, 1980).

The influence of several aspects on reproductive performance has been largelyreported in literature. Several authors have reported an influence of parity on far-rowing rate in sows (Jørgensen and Ali, 1993; Koketsu et al., 1997; Kristensen andSøllested, 2004a; Tummaruk et al., 2010; Hoving et al., 2010; Le Cozler et al.,1998; Hughes, 1998). The general pattern seems to be that first parity sows havea relatively low farrowing rate which increases over the first few parities with amaximum around Parity 3, whereafter it again decreases. In addition, Jørgensenand Ali (1993) estimated a modest reduction in farrowing rate for gilts and sowsreturning to oestrus. The reduction increased with the number of times the sowreturned to oestrus. Lower farrowing rates after insemination 2, 3, and 4 havebeen assumed in several published replacement models, as for instance Jalvinghet al. (1992) and Huirne et al. (1991) (the latter referring to Bisperink, 1979). Eventhough the referred studies agree on reduced farrowing rates for sows returningto oestrus, there are diverging opinions about the magnitude. According to Jør-gensen and Ali (1993) it is only modest (2-3 percentage units per re-insemination),whereas the other authors assume it to be very significant, with 20 percentage unitsless for second insemination and 35 for third (compared to first insemination).

Literature provides detailed studies in many fields concerning the reproductiveperformance of sows. However no information is available on dynamic monitoringof farrowing rate influenced by parity. A simple average of parities is not suit-able for monitoring, because it depends heavily on the age structure and, to someextend, on the number of re-inseminations in the herd. An appropriate monitor-ing system for farrowing rate must adjust for these systematic effects, be able tocapture correlations between categories (parity and insemination number), and todevelop over time.

An attempt to improve the monitoring of pig production has recently been pre-sented by Bono et al. (2012). In that study, the static litter size model proposed byToft and Jørgensen (2002) was re-parameterized and implemented in a DynamicLinear Model. The dynamic setting allowed for sequential weekly updating of pa-rameters at herd and sow level. Furthermore, statistical control tools were appliedand implemented to give warnings in case of impaired litter size results. Also the

Page 61: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

4.2 Explorative data analysis 61

possibility of making predictions was taken into consideration. Nevertheless, otherfactors, such as farrowing rate, need to be included in order to achieve a morecomplete monitoring system.

The aim of this paper is to develop a dynamic monitoring system for farrowingrate. Parity and insemination number are the main effects included in the model.Farrowing being a binary trait is modeled by using a Dynamic Generalized LinearModel (DGLM). To detect systematic deviations, changes or other factors that mayinfluence the farrowing rate, statistical control tools are implemented in order togive warnings in case of impaired farrowing rate results.

This paper is the second step of a larger project with the overall aim of buildinga management tool able to dynamically detect changes in the production process.The development of a similar model for mortality rate will be the next step. Thecombination of the previous model on litter size monitoring (Bono et al., 2012),the present model on farrowing rate and the planned model for mortality will be animportant basis for developing a new, dynamic, management tool.

4.2 Explorative data analysis

Data used in the current study have been provided by the Danish Advisory Center.The dataset consists of 15 herds (also used in Bono et al. (2012)), which are onlyidentified by numbers to ensure the anonymity of the farmers. The traits included inthe study are: sow identity, parity number, inseminations (by date and inseminationnumber) and resulting farrowings (by date).

An explorative data analysis was performed on the data set. Farrowing eventsfor up to eight consecutive parities and up to four inseminations are taken intoaccount for each sow in the explorative analysis. Table 4.1 shows the number ofinseminations per parity, according to the insemination number. For instance, forParity 1, 46266 sows were inseminated for the first time. Out of the 7050 thatfailed to conceive, 4449 were inseminated for the second time. Then out of the4449, 1298 failed to conceive and 453 were inseminated for the third time. Thisprocess is repeated for the four inseminations, for each parity. The difference, innumber of sows, between the empty sows and the re-inseminated ones are likely tobe culled sows.

Table 4.2 presents an overview of the farrowing rate according to parity andinsemination number. For any given parity, the first insemination has a noticeablehigher rate than the following inseminations, even at Parity 8 (0.87). Already fromthe second insemination there is a reduction of the farrowing rate, as comparedto the first insemination (0.87 vs 0.70 on average). Insemination 3 and 4 havelow values and high standard deviations due to a fewer number of observations ascompared to the first and the second inseminations.

The explorative analysis gave an overview of the data and confirmed the influ-ence of the parity number on the farrowing rate, as documented by several authors(Jørgensen and Ali, 1993; Koketsu et al., 1997; Kristensen and Søllested, 2004a;

Page 62: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

62 II Modeling and monitoring farrowing rate at herd level

Table 4.1: Number of farrowings according to parities and inseminationsParity Event Insemination

1 2 3 41 Inseminated 46266 4449 453 90

No farrowing 7050 1298 224 512 Inseminated 34139 2707 218 27

No farrowing 4132 665 84 173 Inseminated 26830 1656 118 13

No farrowing 2787 443 38 74 Inseminated 21206 1321 107 15

No farrowing 2339 357 51 45 Inseminated 16259 1000 85 6

No farrowing 1860 304 34 56 Inseminated 11460 593 53 3

No farrowing 1332 199 26 27 Inseminated 5834 306 34 7

No farrowing 771 122 23 58 Inseminated 2411 111 7 0

No farrowing 318 31 4 0

Table 4.2: Observed farrowing rate according to parities and inseminationsParity Inseminations

1 2 3 41 0.85 0.71 0.51 0.432 0.88 0.75 0.61 0.373 0.90 0.73 0.68 0.464 0.89 0.73 0.52 0.735 0.89 0.70 0.60 0.176 0.88 0.66 0.51 0.337 0.87 0.60 0.32 0.298 0.87 0.72 0.43 -

Mean±SD 0.87±0.015 0.70±0.084 0.50±0.111 0.43±0.177

Page 63: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

4.3 The farrowing rate model 63

Tummaruk et al., 2010; Hoving et al., 2010; Le Cozler et al., 1998; Hughes, 1998).It also confirmed a lower farrowing rate for gilts and sow returning to oestrus, andthat the farrowing rate is further reduced after each consecutive insemination (ex-cept here, for the fourth insemination at Parity 4; the number of sows was only15). The farrowing model applied in this study will therefore reflect the literaturefindings and the patterns observed in this explorative analysis.

4.3 The farrowing rate model

A simple average is not suitable for monitoring farrowing rate, because it dependsheavily on the age structure and, to some extend, on the number of re-inseminationsin the herd. A monitoring system for farrowing rate must adjust for these system-atic effects and be able to capture the correlations between categories (parity andinsemination number) and their development over time.

Since conception is a binary trait it is natural to model the farrowing rate on thelogistic scale. We shall denote the farrowing rate as pnj for parity n inseminationj (where j > 1 corresponds to sows returning to oestrus) and the correspondinglogistic transform as ηnj where

ηnj = logpnj

1− pnj. (4.1)

A simple model for the systematic effects of parity and insemination number couldbe as follows:

ηnj =

{θn − (j − 1)θ7, n ≤ 5θ5 − (n− 5)θ6 − (j − 1)θ7, n > 5.

(4.2)

The model allows the adaptation of the farrowing rate based on the parity num-ber. Thus, the mean farrowing rate of the first five parities (θ1 to θ5) is directlyspecified in the parameter vector θ, whereas the following parities need the con-sideration of the negative slope (θ6). The effect of re-insemination (θ7) is alsoincluded. It reflects the decrease of farrowing rate according to the inseminationnumber for a given reproductive cycle of a sow.

4.4 Sequential estimation technique

A multivariate Dynamic Generalized Linear Model (DGLM) consisting of an ob-servation equation and a system equation will be applied. We will use weeklyobservations of farrowing to update the herd profile as described by Eq. (4.2). Thelatent parameter vector for week t will be

θt = (θ1t, θ2t, θ3t, θ4t, θ5t, θ6t, θ7t)′, (4.3)

Page 64: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

64 II Modeling and monitoring farrowing rate at herd level

where the parameters θ1t to θ5t correspond to the farrowing rate for the first 5parities at week t, θ6t represents the negative slope and θ7t is the effect of there-insemination.

4.4.1 Observation Equation

The observation vector Yt consists of elements, ynjt, corresponding to all combi-nations of parity n and insemination number j. The individual observation ynjtis the number of inseminations resulting in a farrowing no later than week t + 17out of Nnjt inseminated at week t, where 17 weeks correspond to the maximumgestation length of sows. Combinations of n and j where Nnjt = 0 are left out ofthe observation vector.

The observation equations linking the observations to the parameters has thegeneral form

ynjt|θt ∼ B(Nnjt, pnjt), (4.4)

where B denotes the binomial distribution. The farrowing rate pnjt is equal to(exp(−ηnjt) + 1)−1 (cf. Eq. (4.1)), and it depends on the parameter vector θt asfollows:

ηt = F ′tθt, (4.5)

where Ft is called the design matrix. The number of columns corresponds to thesize of θt, and the number of rows corresponds to the number of non-zero valuesof Nnjt.

Now assume that, in week t, Nnjt sows are inseminated and ynjt of them willfarrow no later than week t + 17. Assume for week t that the sows for differentcombinations of parity n and insemination number j are characterized as shownin Table 4.3. The observation vector would then be Yt = (10, 1, 1, 9, . . . , 4, 0, 3)′,and the design matrix will then look as follows (cf. Eq. (4.2)):

F ′ =

1 0 0 0 0 0 01 0 0 0 0 0 −11 0 0 0 0 0 −20 1 0 0 0 0 0...

......

......

......

0 0 0 0 1 −3 00 0 0 0 1 −3 −10 0 0 0 1 −4 0

(4.6)

with the corresponding parameter vector θt = (θ1t, θ2t, θ3t, θ4t, θ5t, θ6t, θ7t)′.

4.4.2 System Equation

The system equation expresses how the parameter values may change over time.The general form of the system equation is

θt = Gtθt−1 + wt, (4.7)

Page 65: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

4.4 Sequential estimation technique 65

Table 4.3: Example of insemination results for sows inseminated in Week tgrouped by parity and insemination number within parity in a herd.

Parity Insemination number Inseminations Resulting farrowingsn j Nnjt ynjt1 1 12 101 2 2 11 3 1 12 1 10 9...

......

...8 1 5 48 2 1 09 1 3 3

where Gt is called the system matrix, and wt ∼ N (0,W ) where 0 is a vector ofzeros and Wt is a variance-covariance matrix describing the evolution variance ofeach of the parameters (and the covariance). Since no particular systematic trendor pattern is expected, we assume that Gt = I , where I is the identity matrix. Forthe variance-covariance matrix Wt the following structure is assumed:

Wt =

W11 W12 W13 W14 W15 0 0W12 W22 W23 W24 W25 0 0W13 W23 W33 W34 W35 0 0W14 W24 W34 W44 W45 0 0W15 W25 W35 W45 W55 0 0

0 0 0 0 0 W66 00 0 0 0 0 0 W77

. (4.8)

As it is seen, the changes of the parameters θ1, . . . , θ5 are assumed to be mutuallycorrelated, but independent of changes in other model elements.

4.4.3 Weekly updating

The concept of univariate DGLM is theoretically well described in the literature(e.g. West and Harrison, 1997; West et al., 1985). For an example of applicationin pig production using binomially distributed data, reference is made to Cornouand Lundbye-Christensen (2012). When it comes to multivariate binomial modelsno applications known to the authors have been published even though Jørgensenet al. (1996) presented a generalized approach for multivariate time series of mixedtypes. However, the method does not allow for binary data to be analyzed. Inthis paper, the univariate binomial technique is extended to cover also multivariatemodels. In Appendix A, an updating technique relying on Taylor expansion ofthe conditional probability function of ynjt given ηnjt is briefly described. A keyproperty of the technique is the fact that, for given ηt, the observations ynjt are

Page 66: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

66 II Modeling and monitoring farrowing rate at herd level

independent. Using the described technique, it is possible to obtain weekly updatedestimates for θt and thus ηt.

4.4.4 Initialization

In order to have a full specification of the DGLM, the initial information θ0 ∼N (m0, C0) before anything has been observed in the herd must be defined. Be-cause a binomial model is considered for farrowing rate, the values are on logisticscale. The initial means based on the results of the explorative data analysis (Table4.2) of the seven parameters are, in order from θ1 to θ7: 1.71, 1.98, 2.15, 2.08, 2.04,0.05 and 1.03. For the variance-covariance matrix it is just assumed, that the sevenstandard deviations correspond to a coefficient of variation of 40% and that theparameters are mutually independent. This crude approach is justified by the factthat as soon as the DGLM is applied to data from a specific herd, the model willautomatically adapt to the conditions of that herd. The initial settings are thereforeof minor importance.

4.4.5 EM-algorithm

System variance (W ) is estimated trough the use of the Expectation-Maximization(EM) algorithm. It is an iterative algorithm based on Maximum Likelihood (ML)estimation. The free software R (R Development Core Team, 2012) was used tocompute the algorithms. The EM technique is described in more details by Bonoet al. (2012).

4.5 Detection of impaired farrowing rate results

Monitoring tools are applied in order to detect any critical changes in the farrowingrate. The deviations between the observations and the predicted values are analyzedin a short and long time period. For the short term control, charts inspired byShewhart (Montgomery, 2005) are used in order to detect alarms on a weekly basis.For the long term, a V-mask applied to the cumulative sum (Cusum) control chartis used to detect level changes in the farrowing rate. For further details about thesemonitoring methods reference is made to Bono et al. (2012).

For both short and long term monitoring, the following components are ex-tracted from the model: the forecast for the observation vector at time t which hasthe mean µt (4.25) and the variance Σt (4.27), shown in Appendix A.

Let 1 = (1,...,1) be a row vector consisting of only elements with value1. The forecast for the total number of farrowings in week t is therefore 1µt withvariance 1Σt1

′ and the observed total number is 1Yt. Thus the weekly forecasterror, et, is:

et = 1Yt − 1µt. (4.9)

Page 67: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

4.6 Results 67

For the control charts, the observation in week t is et and the standard deviationused for control limits, is

st =√

1Σt1′. (4.10)

Thus, the numerical value of st will depend heavily of the number of sows farrow-ing at week t.

Because 1Yt is a sum of several different binomial distributions with unknownvalue of the probability parameter, the distribution of the forecasted number offarrowings is not normal, so a standard Shewhart chart with symmetric controllimits is not well suited. Due to the basically binomially distributed data withunknown probabilities, the control limits must be un-symmetric. In order to adaptthe limits to this kind of data, a beta-binomial distribution was fitted in such a waythat the mean and variance corresponded to the mean, 1µt, and variance, 1Σt1

′, ofthe forecast distribution. The lower control limit was defined as the 0.025 quantileof the beta-binomial distribution, and the upper was defined as the 0.975 quantile.Both the limits were defined as integers: for the upper control limit, the integer wasrounded up, and for the lower control limit, the integer was rounded down. Thisprocedure broadens slightly the control limits, implying that for each limit (upperand lower) there is a significance level that corresponds to less than 2.5%.

For the V-mask, the cumulative sum (Cusum) is defined as the sum of thestandardized forecast errors:

Ct =

t∑t=1

etst. (4.11)

The value of the lead distance of the V-mask was set to d=10 and the slope of thearms of the mask was set to 0.4 in the examples shown in this article. Detaileddescription of the setting and its choice are available in Barnard (1959) and Mont-gomery (2005).

4.6 Results

Results of the system variance estimation, of the model application and of themonitoring methods are shown in this section. All 15 herds are included in theanalysis.

4.6.1 System variance

The values of the variance-covariance matrix converged after 45000 iterations ofthe EM-algorithm. Convergence of the variance components of farrowing rate forthe first five parities and the correlation between them are shown in Figure 4.1(a)and 4.1(b). Convergence of the slope and of the re-insemination effect are shownin Figure 4.1(c) and 4.1(d).

The values of the variance-covariance matrix are presented in Table 4.4. Thevariance of the parities parameters θ1, θ2, θ3, θ4, θ5, the slope θ6 and the effect of

Page 68: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

68 II Modeling and monitoring farrowing rate at herd level

0 10000 20000 30000 40000

0.000

0.005

0.010

0.015

Iteration

Variance

Parity 1

Parity 2

Parity 3

Parity 4

Parity 5

(a) System variance, parities parameters

0 10000 20000 30000 40000

0.0

0.2

0.4

0.6

0.8

1.0

Iteration

Correlation

Parities 1 & 2

Parities 1 & 3

Parities 1 & 4

Parities 1 & 5

Parities 2 & 3

Parities 2 & 4

Parities 2 & 5

Parities 3 & 4

Parities 3 & 5

Parities 4 & 5

(b) System correlation

0 10000 20000 30000 40000

0.0e+00

5.0e−08

1.0e−07

1.5e−07

Iteration

Variance

(c) System variance, slope

0 10000 20000 30000 40000

0.0e+00

5.0e−10

1.0e−09

1.5e−09

2.0e−09

Iteration

Variance

(d) System variance, re-insemination

Figure 4.1: Representation of convergence using the EM-algorithm, 45000 itera-tions. (a) Convergence of the system variance in the first five parities. (b) Conver-gence of system correlations in the first five parities. (c) Convergence of the systemvariance of the slope and (d) of the re-insemination.

the re-insemination θ7 are presented in the diagonal. Correlations between the fiveparities are shown below the diagonal. The highest correlation was found betweenParity 3 and 4 (0.99) and the lowest between Parity 1 and 5 (0.62).

4.6.2 Farrowing rate profiles

Figure 4.2(a) shows the farrowing rate profiles of the 15 herds, for first insemina-tion. The shape of the profiles are not always as expected. A few herds show anincrease of farrowing rate between Parity 4 and 5. This may be explained by alower number of observations at Parity 5 (combined with the considerably higher

Table 4.4: System variance-covariance W (7 x 7). Values of the correlations areshown below the diagonal.W θ1 θ2 θ3 θ4 θ5 θ6 θ7θ1 0.00785 0.00512 0.00462 0.00477 0.00592 0 0θ2 0.88 0.00431 0.00426 0.00428 0.00537 0 0θ3 0.79 0.97 0.00444 0.00451 0.00565 0 0θ4 0.78 0.95 0.99 0.00465 0.00582 0 0θ5 0.62 0.76 0.78 0.79 0.01168 0 0θ6 0 0 0 0 0 5.45e-09 0θ7 0 0 0 0 0 0 4.25e-13

Page 69: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

4.6 Results 69

2 4 6 8 10 12

0.5

0.6

0.7

0.8

0.9

1.0

Parity

Farrowing rate

Herd 1

Herd 2

Herd 3

Herd 4

Herd 5

Herd 6

Herd 7

Herd 8

Herd 9

Herd 10

Herd 11

Herd 12

Herd 13

Herd 14

Herd 15

(a) Farrowing rate profile for first insemina-tion, 15 herds

2 4 6 8 10 12

0.2

0.4

0.6

0.8

1.0

Parity

Farrowing rate

First inseminationSecond inseminationThird inseminationFourth insemination

(b) Farrowing rate profile for the four insem-inations, Herd 8

Figure 4.2: Farrowing rate profiles from the DGLM. (a) For first insemination, 15herds. (b) For four inseminations, Herd 8.

variance for θ5 seen in Table 4.4), as compared to Parity 4. Herds 6 and 7 havea lower profile, as compared to the other herds, and particularly the gilts seem tohave problems with conception in these herds. The farrowing rate at Parity 1 inmost cases confirms that the farrowing rate is lower for gilts than for sows. Onthe other hand Herd 1 shows a high farrowing rate at Parity 1, which subsequentlydecreases at Parity 2. Herd 9 presents the highest farrowing rate’s profile. Figure4.2(b) presents the profile of the first four inseminations for Herd 8. The distancebetween two consecutive inseminations reflects the effect of the re-insemination.

The estimated value of the seven model parameters for the 15 herds, obtainedat the end of the observation period, are available in Table 4.5. In order to havean easier interpretation of the values, the first five parameters are presented in aprobabilistic scale (i.e. pn1 = (exp(−θn) + 1)−1), while the last two (θ6, θ7)remain in the logistic scale. Mean, minimum, maximum and standard deviation areshown in the bottom part. The standard deviations indicate the variation betweenherds, and Parity 1 shows the most variation between herds, as depicted in Figure4.2(a).

4.6.3 Model components

Figure 4.3 shows a detailed analysis of the DGLM components for Herd 8, overthe last three years. Filtered mean for the first five parities, θ1 to θ5, are shown inFigure 4.3(a), and the corresponding smoothed components in Figure 4.3(b). Thesmoothed values of the slope (Figure 4.3(c)) and re-insemination effect (Figure4.3(d)) appear almost constant. The evolution of the means over time (both filteredand smoothed) indicates that the first four parities follow a similar pattern, whereasParity 5 shows a sudden level change at the beginning of the period (around week300). The farrowing rate increases to a peak around week 360 and decreases to alocal minimum around week 390.

Figure 4.4 shows smoothed data of Herds 11 and 14, and illustrates specific

Page 70: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

70 II Modeling and monitoring farrowing rate at herd level

Table 4.5: Estimated values of the model parameters for the 15 herds at the end ofthe observation period. The estimated farrowing rates pnj for first insemination atParities 1-5 are calculated as pn1 = (exp(−θn)+1)−1, n = 1, . . . , 5. Bottom part:mean, minimum, maximum and standard deviation.

Herd Farrowing rates (1st ins.), Par. 1-5 Slope Re-inseminationp11 p21 p31 p41 p51 θ6 θ7

1 0.90 0.85 0.86 0.86 0.84 0.05 0.752 0.87 0.91 0.91 0.89 0.84 0.04 0.963 0.88 0.91 0.92 0.90 0.85 0.05 0.784 0.84 0.88 0.90 0.90 0.93 0.06 0.595 0.88 0.87 0.88 0.87 0.91 0.06 0.596 0.66 0.83 0.85 0.84 0.83 0.05 0.937 0.66 0.71 0.82 0.81 0.79 0.05 0.698 0.88 0.91 0.92 0.90 0.91 0.04 0.889 0.93 0.94 0.95 0.93 0.93 0.05 0.88

10 0.86 0.88 0.90 0.88 0.86 0.06 0.9111 0.85 0.86 0.86 0.85 0.86 0.05 0.6912 0.81 0.89 0.87 0.87 0.86 0.04 0.9313 0.88 0.88 0.90 0.88 0.89 0.06 0.6914 0.80 0.89 0.91 0.91 0.91 0.06 1.1115 0.85 0.84 0.86 0.90 0.89 0.06 0.79

Mean 0.84 0.87 0.89 0.88 0.87 0.05 0.81Min 0.66 0.71 0.82 0.81 0.79 0.04 0.59Max 0.93 0.94 0.95 0.93 0.93 0.06 1.11SD 0.08 0.05 0.03 0.03 0.04 0.01 0.15

Page 71: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

4.6 Results 71

300 350 400

0.75

0.80

0.85

0.90

0.95

Week

Farrowing rate

Parity 1

Parity 2

Parity 3

Parity 4

Parity 5

(a) Farrowing rate over time (filtered)

300 350 400

0.75

0.80

0.85

0.90

0.95

Week

Farrowing rate

Parity 1

Parity 2

Parity 3

Parity 4

Parity 5

(b) Farrowing rate over time (smoothed)

300 350 400

0.020.030.040.050.060.070.08

Week

Slope after parity 5

(c) Slope after parity 5 (smoothed)

300 350 400

0.4

0.6

0.8

1.0

1.2

Week

Effect of re−insemination

(d) Re-insemination effect (smoothed)

Figure 4.3: Evolution of the model parameters for Herd 8 over the last three years.(a) Filtered parity components: θ1, θ2, θ3, θ4 and θ5. (b) Smoothed parity compo-nents. (c) Smoothed slope (θ6). (d) Smoothed re-insemination effect (θ7).

patterns observed over time. Herd 11 shows a very clear seasonal pattern, and Herd14 shows a parity-specific deviation (Parity 1). Whereas Herd 11 was the only herdshowing a clear seasonal variation, parity-specific deviations were observed for 6other herds.

4.6.4 Detections of alarms in farrowing rate

Monitoring methods on the short and the long term period were applied for all 15herds individually. The use of a control chart for weekly monitoring is presentedin Figure 4.5(a). The central line (black plain line) corresponds to the differencesbetween observed and predicted values. The dotted lines are the (asymmetric) con-trol limits. No alarm was observed for the considered time-span (26 weeks). Thelong term monitoring is performed by the use of Cusum combined with V-maskin Figure 4.5(b). During the three years period, two level changes are detected: atweeks 360 and 390.

Table 4.6 shows the number of alarms detected applying the V-masks (leftpanel) and the control charts (right panel). A total of 42 alarms have been foundin a 3 years period using the V-masks, which indicates an average of 0.93 alarmper herd per year. If only the negative alarms are taken into account, the average is0.64 alarm per herd per year. The larger number of negative alarms (29 vs. 13) maybe explained by the fact that the V-mask is set equally sensitive to changes in bothdirections (despite the skew distribution). On the other hand, for the control charts,where asymmetric control limits are used, a total of 49 alarms is reported. This in-

Page 72: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

72 II Modeling and monitoring farrowing rate at herd level

250 300 350 400

0.75

0.80

0.85

0.90

0.95

Week

Farrowing rate

Parity 1

Parity 2

Parity 3

Parity 4

Parity 5

(a) Herd 11 - smoothed

300 350 400

0.75

0.80

0.85

0.90

0.95

Week

Farrowing rate

Parity 1

Parity 2

Parity 3

Parity 4

Parity 5

(b) Herd 14 - smoothed

Figure 4.4: Smoothed data of Herd 11 and Herd 14. (a) Seasonal pattern of Herd11. (b) Parity-specific deviation (Parity 1) of Herd 14.

415 420 425 430 435 440

−6

−4

−2

0

2

4

6

Week

Successful inseminations (observed − predicted)

(a) Observed vs predicted

●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●●●●●

●●

●●

●●

●●

●●●●

●●●

●●●

●●●

300 350 400

−10

−5

0

5

10

Week

Cumulated sum of standardized forecast errors

(b) Cusum with V-mask

Figure 4.5: Monitoring methods applied for Herd 8. (a) Short monitoring period(26 weeks). The central line represents the differences between observed and pre-dicted values. The dotted lines are the upper and lower control limits. (b) Longmonitoring period (156 weeks) using a V-mask applied on a Cusum.

Page 73: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

4.7 Discussion 73

Table 4.6: Number of alarms in a 156 weeks period according to the detectionmethods: V-mask (VM) and Control Chart (CC).

Herd Number VM Decrease VM Increase CC Decrease CC Increase1 1 0 3 22 1 1 1 03 0 0 2 04 2 1 0 15 4 0 1 16 3 2 4 37 5 1 2 38 1 1 2 19 1 1 1 410 2 0 1 011 3 3 0 112 0 0 1 013 3 2 2 414 2 0 2 315 1 1 0 4

Sum 29 13 22 27

dicates an average of 1.08 alarms per herd per year (0.48 for negative alarms only).There the total of positive and negative alarms is more consistent (22 vs. 27).

4.7 Discussion

Variance components were pre-estimated using the EM-algorithm technique. Morethan 40000 iterations were necessary before convergence was obtained. This is farmore than for the normally distributed litter size data in Bono et al. (2012), whereonly 400 iterations were needed. On the other hand, it is clear from Figure 4.1(a)that the changes in values seen after iteration 800 are only small and insignificant.Even though the system variance of the slope and re-insemination effect did notconverge as expected, the size of these values became so small that it was consid-ered irrelevant to carry on with more iterations. High correlations between parities2 and 3 (0.97), parities 3 and 4 (0.99) and parities 2 and 4 (0.95) were found.The lowest value of correlation was found between parities 1 and 5 (0.62). Highcorrelations imply that the farrowing rate profiles will be maintained, i.e. that thefarrowing rate of the first five parities will not drift independently of each other.

Coefficients of Variation (CV) were calculated to improve the comprehensionof the size of the system variance. For instance, the weekly variance of Parity 3(0.00444) indicates a yearly variance of 0.23088. Compared to the average valuefor Parity 3, which is 2.09 (logistic transform of the probability 0.89 of Table 4.5)this implies an annual coefficient of variation of 0.23. This is a far higher value

Page 74: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

74 II Modeling and monitoring farrowing rate at herd level

than seen for litter size profiles in Bono et al. (2012) where a similar coefficient ofvariation was estimated as low as 0.013. Thus, the litter size profile seems to be afar more stable property of a sow herd than the farrowing rate profile.

Herd 8 was used to illustrate the main results (Figure 4.3(a) and 4.3(b)). Thesmoothed mean at a given time includes the knowledge from all observations (pre-vious and future), and is computed backwards. It allows therefore to reduce thetemporary random fluctuation observed in the filtered data. Filtered and smootheddata are not directly comparable. With the filtered data, the farmer is able to seewhat happens in real time. On the other hand smoothed data enables the farmer toidentify and follow up on problems that may have occurred during the productionprocess. See Bono et al. (2012) for further details. For practical application, ifthe smoothed data drift too much, hindering as such the interpretation of results,it can be suggested to reduce the size of the system variance (only for smoothingpurpose).

The farrowing rate profiles for first insemination for the 15 herds do not lookas homogeneous as the litter size profiles from Bono et al. (2012). This is a naturalconsequence of the much higher system variance for the farrowing rate. The peakof the farrowing rate is usually around Parity 3. For Parity 1, Herd 1 showed a highfarrowing rate, likely due to a good quality of gilts. However, already at the secondparity the percentage decreased sharply. Herds 4, 5 and 11 showed an increase ofthe farrowing rate between parities 4 and 5. This may be due to the number ofobservations related to these parities and the high system variance for Parity 5 (cf.Table 4.4).

As it has been described by several authors, the parity number influences thefarrowing rate (Koketsu et al., 1997; Tummaruk et al., 2010; Le Cozler et al., 1998).The negative slope used to describe the decrease in farrowing rate for high paritiesis in this study remarkably small (cf. Table 4.5). If there is a positive repeatability(i.e. a sow effect) in farrowing results as suggested by Jørgensen and Ali (1993), itmeans that data are censored because farmers tend to cull sows returning to oestrus.Sows that survive until high parity numbers will therefore also tend to have a betterfertility resulting in overestimation of farrowing rates for high parities comparedto an unrealistic situation with no culling. This is a possible explanation for thesmall value of the negative slope. A complementary explanation for the unexpectedprofile of herds 4, 5 and 11, could also be the absence of a sow effect in the model.

The value of the slope is an important component of the shape of the profile. Itreflects the trend of the farrowing rate after parity 5. A value of the slope close to 0(Fig.4.3(c)) indicates a persistent farrowing rate after Parity 5. This low reductionof farrowing rate was observed for all herds, and may indicate that farmers adopt,in general, a good culling strategy.

There are divergent opinions among authors about the magnitude of the re-duction of farrowing rate for sows returning to oestrus. Jørgensen and Ali (1993)reported a reduction in percentage units of 2-3 per re-insemination. Other authors(Bisperink, 1979) found a much larger reduction. In this study, the decrease of far-rowing rate per re-insemination is around 10 percentage units (Table 4.5). Again,

Page 75: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

4.7 Discussion 75

an explanation for the larger reduction found in this study compared to Jørgensenand Ali (1993) could be the lack of a sow effect accounting for the repeatability inour model. As described by Jørgensen and Ali (1993), the size of the repeatabilityheavily influences the reduction of farrowing rate for sows returning to oestrus. Ifa sow effect had been included, the percentage of decrease of farrowing rate perre-insemination might approach the one reported by Jørgensen and Ali (1993).

The lowest farrowing rate was observed for Herd 7 and the highest (more than90%) for Herd 9. A seasonal pattern was observed for Herd 11 only. A parity-specific deviation was observed for Parity 1 for Herd 14, and points out a problemspecific to gilts from week 360 until the end of the period analyzed. Deviation ofa single parity during the three years period was seen in almost half of the herds ofthe dataset.

Detection methods were applied to monitor changes in a short (weekly) andlonger time-span. In Herd 8, no alarms were triggered during the period used toillustrate the short term monitoring (26 weeks). Nevertheless, the values observedaround weeks 415, 417, 421, 429 and 435 were at the control limits (Figure 4.5(a)).As mentioned in Section 4.5, the control limits were defined by integer values, forwhich the rounding procedure resulted in broader limits. It can therefore be dis-cussed whether some of these weeks should have been considered as problematic.A potential tool to reduce the uncertainty during the decision process is the additionof “warning limits”, which would narrow the range of allowed deviations before a“warning” alarm is triggered.

As for the long term monitoring, V-masks were applied on the cusums. Ascompared to the previous paper (Bono et al., 2012), the method does not appearentirely satisfactorily. In order to balance the number of negative and positivealarms, a different set up for the two arms of the V-mask could be implemented(one narrower than the other). Furthermore, it has been noticed that the method wasunable to detect changes in the model specific parameters. For instance, in Figure4.3(b), the “drop” of Parity 5 around week 310 was not detected. Similar situationswere noticed in Figure 4.4(b) with a “drop” for Parity 1 after week 370, and forHerds 2 to 6 and 15. A suggestion for improving the monitoring method maytherefore be to implement, concomitantly with the current method, a parity-specificalarm system. Finally, the seasonal pattern observed for Herd 11 triggered bothpositive and negative alarms at each fluctuation. Some monitoring systems maygain from including seasonal components in the model (Madsen and Kristensen,2005), if this feature is inherent to the monitored variable. However, since it isdesirable to keep a stable farrowing rate throughout the year, any cyclic variationshould be detected (so that the farmer becomes aware of the problem), and hencenot modeled.

Results of the total number of alarms were presented in Table 4.6. The per-centage of alarms (positive and negative) for the control charts was, in average,2%. This should be put in perspective with the 95% confidence intervals used inthis study, which then should have resulted in about 5% of false alarms. It was ar-bitrarily decided to round the integers to the higher (upper limit) and lower (lower

Page 76: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

76 II Modeling and monitoring farrowing rate at herd level

limit) values, which resulted in broader control limits. The opposite way to findthe integer values would therefore result in more alarms, which may be closer tothe expected 5%.

Further developments for the suggested monitoring system may include i) theaddition of a parity-specific monitoring system, ii) a modified V-mask, and iii) theinclusion of a sow effect in order to improve its accuracy. This may add value forthe replacement strategy at the farm level (see Kristensen and Søllested, 2004a,b).

The third and final step of this project is the development of a dynamic moni-toring system for the mortality rate of sows and pre-weaned piglets which will bedescribed in a subsequent paper.

4.8 Conclusion

A system to monitor farrowing rate was developed. It is based on a Dynamic Gen-eralized Linear Model, with weekly updates, combined with monitoring methodsfor short (weekly) and long term periods. The farrowing rate profile does not ap-pear as homogeneous as expected, and may be influenced by censoring. For prac-tical implementation, a calibration of the settings of the control chart and V-maskunder known production circumstances needs to be performed. The combination ofthis model with previous work (Bono et al., 2012) and the inclusion of informationabout mortality rate, will help developing a management tool to help the farmersto monitor production, make decision, prevent problems, and reduce economicallosses.

Conflict of interest statement

The authors report that there is no conflict of interest relevant to this publication.

4.9 Acknowledgments

The authors wish to acknowledge the 15 anonymous farmers as well as the Dan-ish Advisory Center for providing data and the Danish Ministry of Food, Agri-culture and Fisheries for financial support for this study through a grant entitled:“Development of a Management System for complete monitoring in Danish andInternational Pig Production”.

Page 77: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

4.9 Acknowledgments 77

Appendix A - A multi variate binomial DGML

4.9.1 Sequential updating

The observation model is as specified in Eqs. (4.4) and (4.5) and the system equa-tion is given by Eq. (4.7). Let Dt = {m0, C0} ∪ {Y1, . . . , Yt} be the full informa-tion set at time t. Denote as

(θt−1|Dt−1) ∼ N (mt−1, Ct−1) (4.12)

the posterior for the parameter vector at time t− 1. It follows from standard argu-ments that the prior for the parameter vector at time t is

(θt|Dt−1) ∼ N (at, Rt) (4.13)

whereat = Gtmt−1 and Rt = GtCt−1G

′t +Wt. (4.14)

Using standard rules in combination with Eq. (4.5) yields

(ηt|Dt−1) ∼ N (ft, Qt) (4.15)

whereft = F ′tat and Qt = F ′tRtFt. (4.16)

We shall denote the farrowing rate corresponding to an individual element fnjt ofthe vector ft as pfijt. Thus

pfijt = (exp(−fnjt) + 1)−1. (4.17)

Since the individual observations ynjt are independent given ηt it follows fromBayes’ theorem that the posterior distribution of ηt after observation of Yt =(y11t, . . . , ynjt, . . . , ynjt)

′ is given as

p(ηt|Dt) ∝ p(ηt|Dt−1)∏n,j

p(ynjt|ηnjt), (4.18)

where p is the probability density function. It can be shown by Taylor expansionof ∂

∂ηnjtlog p(ynjt|ηnjt) around ηnjt = fnjt that Eq. (4.18) can be approximated

by(ηt|Dt) ∼ N (f∗t , Q

∗t ), (4.19)

where

Q∗t = (Q−1t + V̂ −1t )−1 and f∗t = Q∗t (Q−1t ft + V̂ −1t η̂t), (4.20)

withV̂njt =

1

Nnjtpfnjt(1− p

fnjt)

, V̂t = diag(V̂11t, . . . , V̂njt) (4.21)

Page 78: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

78 II Modeling and monitoring farrowing rate at herd level

and

η̂njt = ft +ynjt −Nnjtp

fnjt

Nnjtpfnjt(1− p

fnjt)

, η̂t = (η̂11t, . . . , η̂njt)′. (4.22)

Finally, the posterior for (θt|Dt) ∼ N (mt, Ct) is identified by

mt = at +RtFtQ−1t (f∗t − ft) and Ct = Rt −RtFtQ−1t (Qt −Q∗t )Q−1t F ′tRt.

(4.23)

4.9.2 Dealing with singular variance-covariance matrix

In cases where the rank of F ′t is less than the number of rows, the variance-covariance matrix Qt of Eq. (4.16) becomes singular and cannot be inverted asit must in Eq. (4.20). In those cases the following stepwise updating technique isapplied:

• Denote as F ′t the full design matrix built as described in Section 4.4.1.

• Mark all rows of F ′t as “Not processed”.

• Set k = 0.

• Continue until all rows of F ′t have been marked as “Processed”:

– Increment k by one.

– Build the design matrix F ′kt for Step k row by row by conditionallyadding not processed rows from F ′t . A row is added if, and only if, therank of F ′kt remains equal to the number of rows. If a row is added, itis marked as “Processed” in F ′t and the corresponding observations ofNnjt and ynjt are added to the vectors Nkt and Ykt.

– The matrix F ′kt and the vectors Nkt and Ykt are used for updating tomkt and Ckt as described in 4.9.1.

– Set at = mkt and Rt = Ckt.

• Set mt = mkt and Ct = Ckt.

4.9.3 Forecast distribution

The forecast distribution p(Yt|Dt−1) is deduced from the simultaneous distributionp(Yt, ηt|Dt−1) (where p denotes the probability/density function). We first noticethat (according to standard rules),

p(Yt, ηt|Dt−1) = p(Yt|ηt, Dt−1)p(η|Dt−1) = p(Yt|ηt)p(ηt|Dt−1),

where the last expression follows from the fact that ηt summarizes all previousinformation. Similarly,

p(Yt, ηt|Dt−1) = p(ηt|Yt, Dt−1)p(Yt|Dt−1) = p(ηt|Dt)p(Yt|Dt−1),

Page 79: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

4.9 Acknowledgments 79

where the last term is the requested distribution. Combining the two expressionsfor p(Yt, ηt|Dt−1) yields

p(Yt|ηt)p(ηt|Dt−1) = p(ηt|Dt)p(Yt|Dt−1)

or

p(Yt|Dt−1) = p(Yt|ηt)p(ηt|Dt−1)

p(ηt|Dt). (4.24)

In Eq. (4.24) the probability p(Yt|ηt) is just the product of probabilities from inde-pendent binomial distributions with natural parameters ηnjt. We have,

p(Yt|ηt) =∏nj

(Nnjt

ynjt

)(1− (e−ηnjt + 1)−1)Nnjt−ynjt

(e−ηnjt + 1)ynjt.

The two conditional expressions p(ηt|Dt−1) and p(ηt|Dt) are the multivariate nor-mal density functions for the distributions known from Eqs. (4.15) and (4.19).Thus, for instance,

p(ηt|Dt−1) =1

(2π)|Yt|/2√

detQtexp

(−1

2(ηt − ft)′Q−1t (ηt − ft)

).

For the forecast mean we get

E(Yt|Dt−1) = E(E(Yt|ηt)|Dt−1) ≈ diag(N11t, . . . , Nnjt)pft . (4.25)

For the forecast variance-covariance matrix we use the general rule for randomvariables X and Y that Var(X) = E(Var(X|Y )) + Var(E(X|Y ) and obtain:

Var(Yt|Dt−1) = E(Var(Yt|ηt)|Dt−1) + Var(E(Yt|ηt)|Dt−1). (4.26)

The first term is approximated by the (independent) binomial variances, i.e.

E(Var(Yt|ηt)|Dt−1) ≈ ∆t

where∆t = diag(N11tp

f11t(1− p

f11t), . . . , Nnjtp

f

njt(1− pf

njt)).

For the second term a Taylor expansion around ffjt is used. Denoting the inverseof the logistic transform as the expit function (cf. Eq. (4.17)) we get, element byelement,

E(ynjt|ηnjt) = Nnjtpnjt = Nnjtexpit(ηnjt)

≈ Nnjtexpit(fnjt) +Nnjtexpit′(fnjt)(ηnjt − fnjt)= Nnjtexpit(fnjt) +Nnjtexpit(fnjt)(1− expit(fnjt))(ηnjt − fnjt)= Nnjtp

fnjt +Nnjtp

fnjt(1− p

fnjt)(ηnjt − fnjt)

Page 80: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

80 II Modeling and monitoring farrowing rate at herd level

where the third line follows from the fact that expit′(x) = expit(x)(1−expit(x)).In matrix notation we get

E(Yt|ηt) ≈ diag(N11t, . . . , Nnjt)pft + ∆t(ηt − ft),

and it follows, since Var((ηt − ft)|Dt−1) = Qt, that

Var(E(Yt|ηt)|Dt−1) ≈ ∆tQt∆′t.

With reference to Eq. (4.26) we therefore conclude that

Var(Yt|Dt−1) ≈ ∆t + ∆tQt∆′t. (4.27)

Thus, the partially specified forecast distribution is approximately given by

(Yt|Dt−1) ∼ [µt,Σt],

where

µt = diag(N11t, . . . , Nnjt)pft and Σt = ∆t + ∆tQt∆

′t.

In cases where a stepwise updating is done, the forecasting must be performedstepwise as well.

Page 81: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

BIBLIOGRAPHY 81

Bibliography

Barnard, G., 1959. Control charts and stochastic processes. Journal of the RoyalStatistical Society 21.

Bisperink, H. J., 1979. Economische aspecten van het vervangen van fokzeugen.Bedrijfsontwikkeling 10 (6), 607–610.

Bono, C., Cornou, C., Kristensen, A. R., 2012. Dynamic production monitoring inpig herds I. modelling and monitoring litter size at herd and sow level. LivestockScience 149, 289 – 300.

Cornou, C., Lundbye-Christensen, S., 2012. Modeling of sows diurnal activity pat-tern and detection of parturition using acceleration measurements. Computersand Electronics in Agriculture 80, 97 – 104.

Hoving, L., Soede, N., Graat, E., Feitsma, H., Kemp, B., 2010. Effect of live weightdevelopment and reproduction in first parity on reproductive performance of sec-ond parity sows. Animal Reproduction Science 122 (1 - 2), 82 – 89.

Hughes, P., 1998. Effects of parity, season and boar contact on the reproductiveperformance of weaned sows. Livestock Production Science 54 (2), 151 – 157.

Hughes, P., Varley, M., 1980. Reproduction in the pig. Butterworth and Co, Lon-don, UK.

Huirne, R., Dijkhuizen, A., Renkema, J. A., 1991. Economic optimization of sowreplacement decisions on the personal computer by method of stochastic dy-namic programming. Livestock Production Science 28, 331 – 347.

Jalvingh, A. W., Dijkhuizen, A. A., van Arendonk, J. A. M., Brascamp, E. W.,1992. Dynamic probabilistic modelling of reproductive and replacement in sowherds. general aspects and model description. Agricultural Systems 39, 133 –152.

Jørgensen, E., Ali, N. M., 1993. The repeatability of pregnancy rate in danish sowherds. Unpublished, Biometric Research Unit, Department of Agricultural Sys-tems, Danish Institute of Agricultural Sciences.

Jørgensen, B., Lundbye-Christensen, S., Song, P. X.-K., Sun, L., 1996. State-spacemodels for multivariate longitudinal data of mixed types. Canadian Journal ofStatistics 24 (3), 385–402.

Koketsu, Y., Dial, G. D., King, V. L., 1997. Influence of various factors on farrow-ing rate on farms using early weaning. Journal of Animal Science 75 (10), 2580– 2587.

Page 82: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

82 BIBLIOGRAPHY

Kristensen, A. R., Søllested, T. A., 2004a. A sow replacement model usingbayesian updating in a 3-level hierarchic markov process. I. biological model.Livestock Production Science 87, 13 – 24.

Kristensen, A. R., Søllested, T. A., 2004b. A sow replacement model usingbayesian updating in a 3-level hierarchic markov process. II. optimization model.Livestock Production Science 87, 25–36.

Le Cozler, Y., Dagorn, J., Lindberg, J., Aumaitre, A., Dourmad, J. Y., 1998. Ef-fect of age at first farrowing and herd management on long-term productivity ofsows. Livestock Production Science 53 (2), 135 – 142.

Madsen, T. N., Kristensen, A. R., 2005. A model for monitoring the condition ofyoung pigs by their drinking behaviour. Computers and Electronics in Agricul-ture 48 (2), 138 – 154.

Montgomery, D., 2005. Introduction to statistical quality control, 5th Edition. Wi-ley, Hoboken, NJ, USA.

R Development Core Team, 2012. R: A Language and Environment for StatisticalComputing. R Foundation for Statistical Computing, Vienna, Austria.

Toft, N., Jørgensen, E., 2002. Estimation of farm specific parameters in a lon-gitudinal model for litter size with variance components and random dropout.Livestock Production Science 77 (2-3), 175 – 185.

Tummaruk, P., Tantasuparuk, W., Techakumphu, M., Kunavongkrit, A., 2010. In-fluence of repeat-service and weaning-to-first-service interval on farrowing pro-portion of gilts and sows. Preventive Veterinary Medicine 96 (3 - 4), 194 – 200.

West, M., Harrison, J., 1997. Bayesian Forecasting and Dynamic Models, 2nd Edi-tion. Springer Series in Statistics. Springer, New York, USA.

West, M., Harrison, J. F., Migon, H. S., 1985. Dynamic generalized linear modelsand bayesian forecasting. Journal of the American Statistical Association 80, 73– 83.

Page 83: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

CHAPTER 5

DYNAMIC PRODUCTIONMONITORING IN PIG HERDS

III: MODELING ANDMONITORING MORTALITY

RATE AT HERD LEVELClaudia Bono, Cécile Cornou, Søren Lundbye-Christensen and

Anders Ringgaard Kristensen

Manuscript

Abstract:Management and monitoring systems may enable the farmers to en-hance production results and reduce labor time. The aim of this paper is to de-velop a dynamic monitoring system for mortality rate of sows and piglets. Forthis purpose a mortality rate model is implemented using a Dynamic General-ized Linear Model. Variance components are pre-estimated using an Expectation-Maximization algorithm applied on a dataset containing data from 15 herds, eachof them including observations over a period ranging from three to nine years. Dataare registrations of events for insemination, farrowing (including stillborn and liveborn), number of weaned piglets and death of sows. The model provides reliableforecasting on weekly basis. Detection of impaired mortality rate is performed bystatistical control tools that give warnings when the mortality (rate) shows suddenor gradual changes. For each herd, mortality rate profile, analysis of model compo-nents over time and detection of alarms are computed for two categories, namelysows and piglets. The combination of this model with the previous two on littersize and farrowing rate, represents a significant step into the creation of a new,dynamic, management tool.

Page 84: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

84 III Modeling and monitoring mortality rate at herd level

Keywords: Monitoring; Mortality model; Multivariate Dynamic GeneralizedLinear Model; Statistical control

5.1 Introduction

Mortality in pig farms is a considerable welfare issue, which also affects productiv-ity results. Several studies have been performed on sow mortality (Koketsu, 2000;D’Allaire et al., 1991; López, 2008) as well as on piglet mortality (Weber et al.,2009; Leenhouwers et al., 1999; Marchant et al., 2000). The mortality rate maychange a lot according to the management systems, housing, environment, geno-type, geography, feeding and climate (Duran, 2001). The factors that may influencethe mortality rate in sows and piglets are often different.

Sow annual mortality rate is variable and may depend on the herd size, housingsystem and country (Duran, 2001). According to Sanz et al. (2007), it ranges from7 to 17%. D’Allaire et al. (1991) estimated a rate of 14% whereas Chagnon et al.(1991) reported a range from 0 to 9.2%. Concerning the stages of mortality andaccording to Sanz et al. (2007), 60.6% of sows died during the insemination andgestation periods and 39.4% during the lactation period, whereas Chagnon et al.(1991) reported that 42% of death cases occur in the peripartum period.

For piglets, stillbirth rate ranges between 4.2 and 7.1%, whereas the prewean-ing mortality ranges from 10.8% to 13.2% (KilBride et al., 2012; Marchant et al.,2000; Roehe and Kalm, 2000; Fahmy et al., 1978). The total mortality rate, exclud-ing mummified piglets, is around 18-20% (KilBride et al., 2012; Marchant et al.,2000; Persdotter, 2010), which is considered normal for the reproductive biologyof the pig (Edwards, 2002). Several studies identify that the stage with the majormortality is the preweaning period (Roehe and Kalm, 2000; Wientjes et al., 2012).In particular, KilBride et al. (2012) stated that 84% of all preweaning mortalityoccur within the first 7 days of life.

Different methods have been used to estimate the mortality rates mentionedabove. Several authors used simple Linear Models (Högberg and Rydhmer, 2000;Knol et al., 2002; Lund et al., 2002), others combined Linear Models and ThresholdLinear Models (Grandinson et al., 2002; Arango et al., 2006). Roehe and Kalm(2000) used Generalized Linear Mixed Models.

Literature provides detailed studies concerning sow and piglet mortality. How-ever no information is currently available on dynamic monitoring of mortality rateinfluenced by parity. In fact, a simple average of parities is not suitable for monitor-ing piglet and sow mortality because they depend on the age structure, the insemi-nation and farrowing numbers, and the stage of the reproductive cycle. To the au-thors’ knowledge, no application of Dynamic Generalized Linear Model (DGLM)on mortality rate has been reported. A monitoring system for sow and piglet mor-tality needs to be developed in order to catch correlations between sow and pigletmortality according to the stage of the reproductive cycle, and to monitor changesover time.

Page 85: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

5.2 Explorative data analysis 85

Recent improvements on dynamic monitoring have been done on litter size andon farrowing rate by Bono et al. (2012, 2013). Because mortality is, as farrowing,a binary trait, it is possible to follow the farrowing rate model suggested by Bonoet al. (2013) with the appropriate amendments.

The purpose of this paper is to develop a dynamic monitoring system for mor-tality rate in pig production. The mortality rate is modeled using a Dynamic Gen-eralized Linear Model. Thereafter, statistical control tools are applied in order todetect systematic deviations, changes and other factors that may influence the mor-tality rate.

This paper is the third step of a larger project. The combination of the presentedmodel with the previous two, on litter size and farrowing rate (Bono et al., 2012,2013), represents a solid basis for the development of a new management toolthat may be used to create a software able to dynamically monitor changes in theproduction process.

5.2 Explorative data analysis

Data used in the current study have been provided by the Danish Advisory Center.This dataset is the same as the one used in Bono et al. (2012, 2013). Data are reg-istrations of events for insemination, farrowing (including stillborn and live born),number of weaned piglets and death of sows and weaners, obtained from 15 herdsfor a period ranging from three to nine years.

An explorative data analysis was performed on the dataset. Mortality rate hasbeen calculated for both sow and piglet categories, for eight parities. Sow mortalityhas been furthermore divided into two groups: insemination and gestation periods,and nursing and dry periods. Piglet mortality has been analyzed for three groups:stillborn, pre-weaning and post-weaning mortality.

An overview of the mortality rates for the 15 herds is available in Table 5.1.Stillborn rate ranges from 9.1 to 14 %, pre-weaning mortality is between 10.3 and23.6 % whereas post-weaning mortality is quite low, ranging from 0.03 (suggestingregistration failure) to 3.6 %. It should be noticed that post-weaning mortality dataare not available for Herds 4 and 15 since these farms sell the piglets at weaning.For sows, the mortality in the gestation and insemination periods ranges from 1.4to 3.2 % and in the nursing and dry periods from 1.8 to 5.5 %.

Figure 5.1(a) illustrates the mortality rate for sows according to groups andparities. A sow mortality rate around 2% is observed for the insemination and ges-tation periods at first parity, and the maximum is reached at Parity 8 (around 4%).Higher values are observed in the nursing and dry periods, where the minimumrate is around 2.5% at Parity 1 and the maximum is around 5.5% at Parity 8. Forpiglets, as depicted in Figure 5.1(b), the stillbirth rate increases steadily with theparity number. The minimum rate is observed at Parity 1 (around 9%) whereas themaximum is around 18%, at Parity 8.

Figure 5.2 illustrates the correlation between groups: stillborn, pre-weaning

Page 86: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

86 III Modeling and monitoring mortality rate at herd level

Table 5.1: Average mortality rate of the 15 herds according to categories andgroups

Piglet SowHerd Stillborn Pre-weaning Post-weaning Gestation + Insemination Nursing + Dry

1 11.1 13.4 0.7 3.0 3.32 12.2 15.4 2.3 1.7 3.13 11.3 13.6 3.6 1.7 1.84 11.4 16.5 NA 2.5 3.15 10.1 11.1 1.5 1.4 2.56 13.2 14.4 0.03 3.2 5.57 14.0 23.6 2.2 2.8 4.78 12.5 12.8 1.5 2.1 4.29 10.6 11 2.0 1.7 2.210 13.4 18.4 3.1 2.5 3.211 12.2 14.5 3.1 2.1 4.612 10.3 10.3 1.7 1.4 2.213 13 14.9 1.1 2.3 3.414 12.1 13.1 2.1 3.2 4.215 9.1 16.5 NA 3.1 5.2

Min 9.1 10.3 0.03 1.4 1.8Max 14.0 23.6 3.6 3.2 5.5

Mean ± SD 11.8±1.4 14.6±3.3 1.9±1 2.3±0.6 3.5±1.2

Insemination+Gestation Nursing+Dry

Parity 1

Parity 2

Parity 3

Parity 4

Parity 5

Parity 6

Parity 7

Parity 8

0.00

0.01

0.02

0.03

0.04

0.05

Mortality rate

(a) Mortality rate, all herds

1 2 3 4 5 6 7 8

0.08

0.10

0.12

0.14

0.16

0.18

0.20

Parity

Stillbirth rate

(b) Stillbirth rate, all herds

Figure 5.1: Mortality rate according to categories. (a) Mortality rate of sows in thetwo analyzed periods according to parity number. (b) Stillbirth mortality rate ofpiglets according to parity number.

Page 87: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

5.2 Explorative data analysis 87

stillBorn

0.10 0.14 0.18 0.22 0.015 0.020 0.025 0.030

0.09

0.11

0.13

0.10

0.16

0.22

preWeaningMortality

0.00

0.02

0.01

50.

025

0.09 0.11 0.13 0.00 0.01 0.02 0.03 0.02 0.03 0.04 0.05

0.02

0.04

postWeaningMortality

inseminationGestationMortality

nursingDryMortality

Figure 5.2: Correlations between stillborn, pre-weaning mortality, post-weaningmortality, insemination and gestation mortality, nursing and dry mortality, for allherds

Page 88: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

88 III Modeling and monitoring mortality rate at herd level

mortality, post-weaning mortality, insemination and gestation mortality, and nurs-ing and dry mortality. It is important to note that whereas sow and stillborn mortal-ity can be computed parity wise, pre and post-weaning mortality cannot be groupedby parity due to the litter equalization. In this study, the number of pre-weaningpiglets is indirectly calculated as the difference between weaned and live bornpiglets, at batch level. Visual inspection of Figure 5.2 indicates correlations be-tween stillborn, pre-weaning mortality, insemination and gestation mortality, andnursing and dry mortality. No obvious correlation is found between post-weaningmortality and the other groups.

The sow mortality rate found in this study is lower than the one reported bySanz et al. (2007) and D’Allaire et al. (1991). This can be explained by the dif-ferences in periods taken into account. Whereas the previous authors computedmortality per year, the mortality rate reported in this study is calculated per repro-ductive cycle. Concerning piglets, higher values are found for stillborn piglets ascompared to previous studies (KilBride et al., 2012; Fahmy et al., 1978; Marchantet al., 2000).

In general, it can be observed that sow mortality is highly dependent on paritywith a peak in Parities 2 and 3, which is in accordance with D’Allaire et al. (1991)and Sanz et al. (2007); that sow mortality also depends on the stage of the repro-ductive cycle (Sanz et al., 2007; Chagnon et al., 1991); that stillbirth rate heavilydepends on sow parity with an almost linear increase from Parity 1 to Parity 8(Leenhouwers et al., 1999); that pre-weaning mortality cannot be handled accord-ing to sow parity because of the litter equalization. Finally, it can be suggested that,due to correlations observed between categories, mortality of sows and piglets untilweaning should be handled in the same model.

5.3 The mortality model

Since mortality is a binary trait, it is natural to model the rate on the logistic scaleand use the same multivariate binomial technique for a Dynamic Generalized Lin-ear Model (DGLM) as described by Bono et al. (2013). We shall denote the mor-tality rate as pG for pig group G and the corresponding logistic transform as ηGwhere

ηG = logpG

1− pG. (5.1)

A pig group, G, is described by up to 3 identifiers. The first identifier is either s forsows, b for stillborn or p for piglets before weaning. The second identifier is theparity (if applicable) and the third is stage in the reproductive cycle with the value1 for the insemination/gestation period and 2 for the nursing/dry period. Thus,G = s32 refers to Parity 3 sows in the nursing/weaning period, G = b4 refers topiglets being born by a Parity 4 sow, and G = p refers to suckling piglets.

We first model the sow mortality, and notice that, due to the pattern seen inFigure 5.1(a), we can describe it by the following model for a sow in Parity n,

Page 89: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

5.4 Sequential estimation technique 89

Stage j of the reproductive cycle

ηsnj = µ+ αn + βj , n = 1, . . . , N j = 1, 2. (5.2)

Thus, the mortality is described as a general level, µ, adjusted for effect of parity,αn, and effect of stage of the reproductive cycle βj . In order to ensure uniquenessof the estimates, we will assume in the following that α1 = β1 = 0. Thus, µcorresponds to mortality of Parity 1 sows in the insemination/gestation period. Forstillborn piglets we use the following model for piglets born by a sow in Parity n.

ηbn =

{γn n ≤ 4γ4 + δ(n− 4) n > 4.

(5.3)

In other words, we model the first 4 parities separately and assume a constantslope for parities higher than 4 as seen in Figure 5.1(b). Finally, the pre-weaningmortality will be described simply as

ηp = ζ (5.4)

where the ζ value remains unchanged for all parities.

5.4 Sequential estimation technique

5.4.1 A multivariate dynamic generalized linear model

A multivariate dynamic generalized linear model consisting of an observation equa-tion and a system equation will be applied. We will use weekly observations ofdead sows and piglets to update the herd profile as described by Eqs. (5.2), (5.3)and (5.4). Since α1 = β1 = 0, the latent parameter vector for week t will be

θt = (µt, α2t, . . . , α8t, β2t, γ1t, . . . , γ4t, ζt, δt)′. (5.5)

Observation Equation

The observation vector Yt consists of elements, yGt, corresponding to all pig groups.The individual observation yGt is the number of dead sows or piglets in Group Gout of NGt observed at week t. Groups where NGt = 0 are left out of the observa-tion vector.

The observation equations linking the observations to the parameters have thegeneral form

yGt|θt ∼ B(NGt, pGt), (5.6)

where B denotes the binomial distribution. The mortality rate pGt is equal to(exp(−ηGt) + 1)−1 (cf. Eq. (5.1)), and depends on the parameter vector θt asfollows:

ηt = F ′tθt, (5.7)

Page 90: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

90 III Modeling and monitoring mortality rate at herd level

where Ft is called the design matrix. The number of columns corresponds to thesize of θt, and the number of rows corresponds to the number of non-zero valuesof NGt.

In the observation of yGt and NGt, a constant mortality for the entire stage isused according to the following principles for week t:

Groups snj, sows: The number of dead sows for GroupG = snj in week t is ob-served as yGt. A list of sows present in the herd is maintained week by week.For each sow, the parity n and stage of reproductive cycle, j is maintained.Thus, NGt will be the number of sows (including those that die during theweek) in parity n, stage j. In other words, a common weekly mortality rateis estimated for the entire stage.

Groups bp, stillborn: Here the observation for week t will be the number of totalborn piglets NGt and the number of stillborn piglets yGt.

Group p, suckling piglets: In the database no information is available about deadpiglets before weaning. The pre-weaning mortality is calculated indirectlyas the difference between the number of weaned piglets and the number oflive born. The observation for week t is the total number of live piglets atweaning NWt and the number of piglets originally born alive NGt by thesows having their piglets weaned in week t. The number of dead piglets isthen found as yGt = NGt − NWt. The intensive use of the nursing sowsin farms makes the weekly observation (arbitrary variation) full of noises.Therefore a period of four weeks observation period is suggested for pre-weaning piglets.

Now assume that, in week t, NGt pigs are observed and yGt of them die. As anexample for a herd, we assume for week t that the observed values for a subset ofthe pig groups are as shown in Table 5.2. The observation vector would then be

Yt = (2, 1, 1, . . . , 0, 65, . . . , 52, 45, . . . , 12, 71)′,

and the design matrix will then look as follows (cf. Eqs. (5.2), (5.3) and (5.4)):

Page 91: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

5.4 Sequential estimation technique 91

Table 5.2: Example of mortality results according to pig group for sows and pigletsin week t in a herd.

Pig group Group identifiers Number at risk Number of deadG s/b/p n j NGt yGtSows, Par. 1, Ins.+Gest. s 1 1 150 2Sows, Par. 1, Nursing+Dry s 1 2 75 1Sows, Par. 2, Ins.+Gest. s 2 1 125 1...

......

......

...Sows, Par. 8, Nursing+Dry s 8 2 10 0Stillborn, Par. 1 b 1 - 621 65...

......

......

...Stillborn, Par. 4 b 4 - 398 52Stillborn, Par. 5 b 5 - 289 45...

......

......

...Stillborn, Par. 9 b 9 - 56 12Suckling piglets p - - 654 71

F ′ =

1 0 0 0 0 0 0 0 0 0 0 0 0 0 01 0 0 0 0 0 0 0 1 0 0 0 0 0 01 1 0 0 0 0 0 0 0 0 0 0 0 0 0...

......

......

......

......

......

......

......

1 0 0 0 0 0 0 1 1 0 0 0 0 0 00 0 0 0 0 0 0 0 0 1 0 0 0 0 0...

......

......

......

......

......

......

......

0 0 0 0 0 0 0 0 0 0 0 0 1 0 00 0 0 0 0 0 0 0 0 0 0 0 1 0 1...

......

......

......

......

......

......

......

0 0 0 0 0 0 0 0 0 0 0 0 1 0 50 0 0 0 0 0 0 0 0 0 0 0 0 1 0

(5.8)

where the vertical lines separate sections referring to different parameter groupsof the vector θt. Thus, the leftmost section (first column) refers to the generalherd level for sow mortality (µt). The next section (Columns 2-8) are coefficientsreferring to the parity effects on sow mortality (α2t, . . . α8t) and the third section(Column 9) refers to the effect of stage in the reproductive cycle (β2t). The fourthand fifth section contain the coefficients for the parity specific stillbirth rate forParities 1-4 (γ1t, . . . , γ4t) in Columns 10-13, and in Column 14 the coefficient forthe pre-weaning mortality (ζt). Finally the rightmost section (Column 15) holdsthe coefficient for the slope of stillbirth rates after Parity 4 (δt).

Page 92: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

92 III Modeling and monitoring mortality rate at herd level

System Equation

The system equation expresses how the parameter values may change over time.The general form of the system equation is

θt = Gtθt−1 + wt, (5.9)

where Gt is called the system matrix, and wt ∼ N (0,W ) where 0 is a vector ofzeros and W is a variance-covariance matrix describing the evolution variance ofeach of the parameters (and the covariance), with free structure except for the slopeof stillbirth rate after Parity 4 (δt), which is set independent of the other variables.Since no particular systematic trend or pattern is expected, we assume thatGt = I ,where I is the identity matrix.

Weekly updating

The concept of univariate dynamic generalized linear models is well describedin literature (e.g. West and Harrison, 1997; West et al., 1985). When it comesto multivariate binomial models the only application known to the authors is theprevious work by Bono et al. (2013) where it was shown that the technique ofunivariate binomial models can be extended to also cover multivariate models. Thedeveloped updating technique is described in Appendix A of Bono et al. (2013).It relies on Taylor expansion of the conditional probability function of yGt givenηGt. A key property of the technique is the fact that, for given ηt, the observationsyGt are independent. Using the described technique, it is possible to obtain weeklyupdated estimates for θt and thus ηt.

Initialization

In order to have a full specification of the DGLM, the initial information θ0 ∼N (m0, C0), i.e. before anything has been observed in the herd, must be defined.Because a binomial model is considered for mortality rate, the values are on thelogistic scale. The initial means based on the results of the explorative data analysisare µt: -4.03; α2 to α8: 0.52, 0.48, 0.36, 0.38, 0.34, 0.52, 0.82; β2: 0.36; γ1 to γ4:-2.29, -2.25, -2.07, -1.90; ζt: -1.77; δt: 0.10.

It should be noted that the initial settings are of minor importance since themodel will automatically adapt to the conditions of a specific herd. Therefore,for the variance-covariance matrix, we assumed that the fifteen standard deviationscorrespond to a coefficient of variation of 40% and that the parameters are mutuallyindependent.

EM-algorithm

The Expectation-Maximization (EM) algorithm technique is used in order to esti-mate the system variance (W). The free software R (R Development Core Team,

Page 93: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

5.5 Detection by group of impaired mortality rate results 93

2013) was used to compute the algorithms. The EM technique is an iterative algo-rithm based on Maximum Likelihood (ML) estimation and is described in detailsin Bono et al. (2012).

5.5 Detection by group of impaired mortality rate results

After the application of the DGLM, mortality rate of piglets and sows are mon-itored. In order to explain how the groups are filtered in the parameter vector, apractical example is reported.

Let us consider again the observation vector:

Yt = (2, 1, 1, 1, . . . , 0, 65, . . . , 52, 45, . . . , 12, 71)′.

In order to monitor only the sow mortality, the following filter vector

φs = (1, 1, 1, 1, . . . , 1, 0, . . . , 0, 0, . . . , 0, 0),

will be used. The total number of dead sows in Week t is then φsYt.. This allowsto compute only sow specific results. If instead, the stillborn group is monitored,the following filter vector

φb = (0, 0, 0, 0, . . . , 0, 1, . . . , 1, 1, . . . , 1, 0),

will be used. In this case, the filter vector allows monitoring of the number ofstillbirth only.

For the last group, suckling piglets, the following filter vector

φp = (0, 0, 0, 0, . . . , 0, 0, . . . , 0, 0, . . . , 0, 1),

will be used.Let φ be an arbitrary filter vector. The forecast for the total number in the group

filtered out by the vector of deaths in week t is therefore φµt with variance φΣtφ′

and the observed total number is φYt. Thus the weekly forecast error, et, is

et = φYt − φµt. (5.10)

For each filtered group, the difference between the deviations of the observa-tions and the predicted values, i.e. the forecast errors, are analyzed in a short andlong time period.

For the short term period, control charts inspired by Shewhart (Montgomery,2005) were used in order to detect alarms on a weekly basis. For the ShewhartCharts, the observation in week t is et and the standard deviation used for controllimits, is

st =√φΣtφ′. (5.11)

Thus, the numerical value of st will heavily depend on the number of deaths atweek t. The lower control limit was defined as the 0.025 quantile of the beta-binomial distribution and the upper was defined as the 0.975 quantile. Both the

Page 94: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

94 III Modeling and monitoring mortality rate at herd level

limits were defined as integers (rounded down for the lower quantile and up forthe upper) so that for each limit (upper and lower) there is a significance level thatcorresponds to approximately 2.5%.

For the long term period, a V-mask was applied on the cumulative sum (Cusum)control chart in order to detect sudden or gradual changes of the mortality rate.These monitoring methods are described in details in Bono et al. (2012, 2013).

5.6 Results

Results of the system variance, of the model application and of the monitoringdetection methods are shown in this section. The results are presented accordingto each category, namely the sow and the piglet categories. All the 15 herds wereincluded in the analysis.

5.6.1 System variance

The EM-algorithm was carried out for 22000 iterations. Visual inspection of theplots (not shown) indicates that the variance components for Parity 1 converged,whereas convergence was not reached for Parities 2 to 8, indicating that more itera-tions are needed. The variance components of the stage effect for sows (insemina-tion and gestation, dry and nursing) converged already after 10000 iterations. Forthe stillbirth rate of the first 4 parities, convergence is obtained after less than 1000iterations. A similar pattern is seen for the variance components of pre-weaningmortality (3000 iterations) and the slope of the stillbirth rate after Parity 4 (lessthan 1000). Graphical display of the results are available on request.

The values of the variance-covariance matrix are presented in Table 5.3. Vari-ance of the following components is presented in the diagonal: sow mortality (µt),parity effects (α2t to α8t), effect of stage (β2t), stillbirth rate for the 4 first parities(γ1t to γ4t), pre-weaning mortality (ζt) and slope for stillbirth after Parity 4 (δt).Correlations between all the parameters are shown below the diagonal.

Page 95: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

5.6 Results 95

Tabl

e5.

3:Sy

stem

vari

ance

-cov

aria

nce

W(1

5x

15).

Val

ues

ofth

eco

rrel

atio

nsar

esh

own

belo

wth

edi

agon

al.

µα2

α3

α4

α5

α6

α7

α8

β2

γ1

γ2

γ3

γ4

ζδ

µ0.

019

-0.0

07-0

.004

-0.0

04-0

.008

-0.0

080

-0.0

03-0

.006

0.01

8-0

.007

0.00

2-0

.003

0.02

20

α2

-0.5

70.

008

0.00

50.

005

0.00

70.

006

-0.0

04-0

.001

0.00

4-0

.011

0.00

8-0

.001

0.00

90.

001

0α3

-0.2

60.

510.

010.

011

0.00

90.

008

-0.0

030.

003

0.00

1-0

.006

0.00

10.

018

0.01

70.

002

0α4

-0.2

50.

510.

940.

013

0.01

0.00

9-0

.004

0.00

2-0

.001

-0.0

06-0

.001

0.01

40.

024

0.00

30

α5

-0.5

60.

760.

880.

910.

010.

009

-0.0

040.

002

0.00

2-0

.01

0.00

40.

009

0.01

8-0

.001

0α6

-0.6

0.65

0.88

0.86

0.95

0.00

9-0

.002

0.00

40.

002

-0.0

070.

006

0.01

10.

016

-0.0

030

α7

0.04

-0.7

-0.5

1-0

.61

-0.6

2-0

.37

0.00

40.

002

00.

005

0.00

10

-0.0

09-0

.004

0α8

-0.2

9-0

.08

0.41

0.24

0.25

0.47

0.45

0.00

70.

002

-0.0

03-0

.002

0.01

-0.0

03-0

.002

0β2

-0.5

50.

580.

12-0

.12

0.22

0.29

0.03

0.31

0.00

7-0

.009

0.00

90.

002

-0.0

07-0

.003

0γ1

0.55

-0.5

4-0

.27

-0.2

4-0

.42

-0.3

10.

37-0

.16

-0.4

60.

058

0.02

0.01

10.

008

0.00

60

γ2

-0.2

10.

410.

06-0

.02

0.16

0.26

0.04

-0.0

80.

490.

360.

053

0.00

80.

009

-0.0

080

γ3

0.07

-0.0

50.

050.

460.

330.

440

0.44

0.09

0.16

0.13

0.07

20.

02-0

.006

0γ4

-0.0

90.

420.

70.

850.

760.

67-0

.64

-0.1

3-0

.34

0.14

0.16

0.3

0.06

10.

008

0.65

0.07

0.09

0.13

-0.0

4-0

.12

-0.3

-0.0

9-0

.17

0.1

-0.1

4-0

.09

0.14

0.05

80

δ0

00

00

00

00

00

00

00.

011

Page 96: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

96 III Modeling and monitoring mortality rate at herd level

250 300 350 400

0.000

0.001

0.002

0.003

0.004

0.005

0.006

Week

Weekly mortality rate, insemination + gestation period

Parity 1

Parity 2

Parity 3

Parity 4

Parity 5

(a) Stage 1, smoothed

250 300 350 400

0.000

0.005

0.010

0.015

0.020

Week

Weekly mortality rate, nursing + dry period

Parity 1

Parity 2

Parity 3

Parity 4

Parity 5

(b) Stage 2, smoothed

Figure 5.3: Application of the DGLM for sow mortality over three years in Herd10 for the first five parities. (a) Mortality rate of the insemination and gestationperiod, smoothed. (b) Mortality rate of nursing and dry period, smoothed.

Since full convergence of the system variance was not achieved (for the parityeffects of sow mortality), the results of the following subsections should be con-sidered as preliminary. When convergence has been reached, the analyses must beredone.

5.6.2 Model components

Figures 5.3 and 5.4 show a detailed analysis of the DGLM components for Herd10, over three years. Smoothed means for the first five parities are shown for sowsin the two stages. In both stages, Parity 2 has a higher weekly mortality rate witha peak around week 270 in the insemination and gestation period (Stage 1), andweeks 270 and 340 in the nursing and dry period (Stage 2). The weekly mortalityrate is in general low in Stage 1 (peak at 0.0028) and a bit higher in Stage 2 (peakat 0.010). The evolution of the smoothed means over time indicates that the firstfive parities follow a similar pattern.

Concerning piglets, the smoothed mean of the stillbirth rate for four paritiesand the smoothed pre-weaning rate are shown in Figure 5.4. As compared to sowresults, the stillbirth rates for the first four parities (Figure 5.4(a)) fluctuate more.Parities 1 and 2 have a weekly mortality rate that fluctuates between 0.07 and 0.14,whereas Parities 3 and 4 have a higher weekly mortality rate ranging from 0.09 to0.17. In general, Parity 4 has a higher level and Parity 3 follows a similar patternto Parity 4 until week 320, from which it decreases to approximately 0.10. Pre-weaning piglets mortality (Figure 5.4(b)) ranges between 0.16 to 0.25.

5.6.3 Detection of alarms in mortality rate

Monitoring methods were applied separately for sow and piglet mortality. Fourdifferent filter vectors (Section 5.5) were applied in order to obtain the alarms for

Page 97: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

5.6 Results 97

250 300 350 400

0.00

0.05

0.10

0.15

0.20

Week

Stillbirth rate

Parity 1

Parity 2

Parity 3

Parity 4

(a) Stillbirth, smoothed

250 300 350 400

0.00

0.05

0.10

0.15

0.20

0.25

0.30

Week

Piglets, pre−weaning mortality

(b) Pre-weaning, smoothed

Figure 5.4: Smoothed mortality rate of stillborn and pre-weaning for three years,for Herd 10. (a) Stillbirth rate in the first four parities. (b) Pre-weaning mortalityrate.

the following groups:

1. Sows,

2. Stillbirths,

3. Pre-weaning piglets,

4. All piglets.

The Sow group combines mortality rate of both Stage 1 and 2, and all pigletscombines stillbirth and pre-weaning mortality rates.

Results for sow and stillbirth groups are illustrated for two different time spans:short (26 weeks) for the weekly control, and long (156 weeks) for the long termcontrol. The use of a control chart for weekly monitoring of the mortality rate isillustrated in Figure 5.5(a) for sow and in Figure 5.6(a) for piglet. The central line(black plain line) represents the difference between observed and predicted values.The dotted lines are the control limits, which are asymmetric due to the nature ofthe mortality rate (binomial). The long term monitoring is performed by the useof a Cusum combined with a V-mask, as depicted in Figures 5.5(b) and 5.6(b), forsows and piglets, respectively.

For sows, no alarm is found in the short term monitoring for the illustrated timespan (Figure 5.5(a)). For the long term monitoring, and for the three years takeninto account, two level changes are detected: at weeks 280 and 390 (Figure 5.5(b)).Regarding stillbirth no alarm is found either in the short term (Figure 5.6(a)) or inthe long term monitoring (Figure 5.6(b)) of this example.

Table 5.4 shows the total number of alarms detected applying V-masks andcontrol charts according to the groups. For sow mortality, a total of 35 alarms havebeen found in all herds in a 3 years period using the V-masks, which indicates anaverage of 0.77 alarm per herd per year. If only the increasing alarms, i.e. when

Page 98: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

98 III Modeling and monitoring mortality rate at herd level

370 375 380 385 390 395

−4

−2

0

2

4

Week

Dead animals (observed − predicted)Sows

(a) Observed vs Predicted

250 300 350 400

−20

−10

0

10

20

Week

Cumulated sum of standardized forecast errorsSows

(b) Cusum with V-mask

Figure 5.5: Monitoring methods applied for Herd 10 for sow mortality. (a) Weeklymonitoring (period of 26 weeks). Control Chart where the central line representsthe observed - predicted observations, and the dotted lines are the upper and lowercontrol limits. (b) Long monitoring period (period of 156 weeks). Cusum of stan-dardized forecast errors are reset to 0 when an alarm occurs.

370 375 380 385 390 395

−40

−20

0

20

40

Week

Dead animals (observed − predicted)Stillborn

(a) Observed vs predicted

250 300 350 400

−30

−20

−10

0

10

20

30

Week

Cumulated sum of standardized forecast errorsStillborn

(b) Cusum with V-mask

Figure 5.6: Monitoring methods applied for Herd 10 for stillbirth. (a) Weeklymonitoring (period of 26 weeks). Control Chart where the central line representsthe observed - predicted observations, and the dotted lines are the upper and lowercontrol limits. (b) Long monitoring period (period of 156 weeks).

Page 99: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

5.7 Discussion 99

Table 5.4: Total number of alarms in a 156 weeks period according to the detectionmethods V-mask (VM) and Control Chart (CC) for the four filters applied in the 15herds. I = Increase; D = Decrease. AHY = Alarms per Herd per Year.

Filter VM D VM I CC D CC I Tot VM Tot CC AHY VM AHY CCsow 12 23 0 47 35 47 0.77 1.04

stillbirth 6 3 76 81 9 157 0.2 3.48pre-weaning 0 2 14 13 2 27 0.04 0.6

all piglets 9 6 71 79 15 150 0.33 3.3

the mortality rate significantly increases, are taken into account, the average is 0.51alarm per herd per year. For the control charts, a total of 47 alarms is reported. Thisindicates an average of 1.04 alarms per herd per year. No decreasing alarms havebeen found for sow mortality in the short period.

For the stillbirth rate, a total of 9 alarms were triggered for the long term moni-toring, which corresponds to 0.2 alarm per herd per year. For the control charts 157alarms were found, which corresponds to 3.48 alarms per herd per year. If only theincreasing alarms are taken into account, the mean per herd per year becomes 1.8.

For pre-weaning mortality rate, the V-mask method triggered only 2 alarms,both increasing. Control charts triggered 0.6 alarm per herd per year (total of 27),or 0.28 (total of 13) if only the increasing alarms are taken into account.

Finally, when the mortality rates for all piglets are combined and detected as awhole, 15 alarms are observed using the V-mask (0.33 per herd per year), of which6 of them are increasing (0.13 per herd and per year). A total of 150 alarms weretriggered using control charts (3.3 per herd per year, or 1.75 for increasing alarms).

5.7 Discussion

In the explorative analysis of this study, correlations between stillborn, pre-weaningand post-weaning mortality, insemination and gestation mortality, and nursing anddry mortality, have been investigated (Figure 5.2). On this basis, the model wasdefined to simultaneously analyze mortality rate of sow and piglet.

The EM-algorithm technique was used to pre-estimate the variance compo-nents. At the time being, the number of iterations (22 000) has not been enoughto allow convergence of all parameters. The number of iterations has been con-ditioned by the time available for the project. The time needed for each iterationcorresponds to 1 hour and 6 minutes (on a pc with 64 bit windows and 8 processorcores), which means that the iterations have been carried out for about 96 days.Some of the variance parameters converged already after less than 1000 iterations.The graphical display of the correlations between all parameters resulted in 105curves (available on request), which visual inspection indicated that some of thecorrelations converged.

High correlations, whether negative or positive, indicate that the parametersdo not drift independently and therefore create a pattern, as seen in e.g. Figure

Page 100: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

100 III Modeling and monitoring mortality rate at herd level

5.3. The existence of such a pattern may help to understand the dynamic of themortality rate and predict future patterns.

Herd 10 was used to illustrate the main results (Figure 5.3 and 5.4). Thesmoothing procedure allows to reduce the temporary random fluctuation observ-able in the filtered data (available on request), as it includes, at any given time, theknowledge from all observations (previous and future). For practical application,if the smoothed data drift too much, hindering as such the interpretation of results,it can be suggested, only for smoothing purpose, to reduce the size of the systemvariance.

In Figure 5.3 it can be noticed that the two stages assume similar shape in thethree years period processed. In Stage 2 (nursing and dry periods), the weekly sowmortality rate seems to be a bit higher. Nevertheless, the curves of the five paritiesfollow the same pattern. On the other hand, it is difficult to recognize any pattern inthe stillbirth rate for the first four parities (Figure 5.4(a)). A potential explanation isthe low correlation within the piglets group (Table 5.3). The weekly mortality rateof pre-weaning, of which the variance was not correlated with the other groups,showed more sudden changes and ranged between 16% and 25%.

Detection methods were applied to monitor changes in a short and long time-span. In the example of Herd 10 and for both categories, no alarm was triggeredduring the given period (26 weeks). Nevertheless, the values observed aroundweeks 372 and 387 for sows (Figure 5.5(a)) and 379, 382, 393 and 395 for piglets(Figure 5.6(a)) were just at the control limits. As mentioned in Section 5.5, thecontrol limits were defined by integer values, for which the rounding procedureresulted in broader limits. This was the object of a previous discussion (Bonoet al., 2013) in which it was suggested to add some "warning limits", which wouldnarrow the range of allowed deviations before a "warning" alarm is triggered.

For the long term monitoring, V-masks were applied on the Cusum of the stan-dardized forecast errors. Two alarms were found in Herd 10 for sows (Figure5.5(b)). They occurred at week 270, where an increase of mortality rate is seenfor the first five parities, and week 375 where a decrease of the rate is registered(Figure 5.3). Nevertheless Parity 2 showed a higher level as compared to the otherparities. Concerning piglets, no alarm was triggered (Figure 5.6(b)) even thoughsome clear level changes for Parity 3 around week 330 or for Parity 1 at weeks 310and 370 (Figure 5.4(a)). A suggested improvement for the monitoring method maytherefore be to implement, concomitantly with the current method, a parity-specificalarm system, in the same way that the group-specific alarms are here implemented.Furthermore, in order to balance the number of negative and positive alarms, thetwo arms of the V-mask could be adjusted (one narrower than the other).

Results of the total number of alarms were presented in Table 5.4, where fourfilters were applied to obtain the total number of alarms for four different groups.Because no information was available in the dataset for piglet deaths for a givensow, pre-weaning mortality was computed as the difference between weaned andlive born piglets. An additional filter, based on the total number of dead piglets(stillbirth and pre-weaning) was also implemented. Since a decrease in one group

Page 101: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

5.8 Conclusion 101

may "cancel" a decrease of mortality rate in the other group, an alarm combiningboth groups resulted in a different number of alarms as compared to the sum ofalarms in both groups.

The percentage of alarms (increasing and decreasing) for the control chartswas, in average, 1% for sows and 6% for piglets (all piglets). The percentage ofalarms from the V-mask was, in average, 1% for sows and 0.6% for piglets (allpiglets). Rounding up the integer values used in the control limits would haveresulted in more alarms, closer to the expected 5% (with 95% confidence interval).

Beside a parameter-specific monitoring system and a modified setting of theV-mask, further improvement may consist of splitting the model into two parts,i.e. a sow and a piglet part, which can be combined in a second step. This mayalso allow speeding up the EM-algorithm process. The division of the model intotwo parts may be supported by the low correlation (obtained at the current time)between the parameters of these two categories.

5.8 Conclusion

A system to monitor mortality rate for sows and piglets was developed. It is basedon a Dynamic Generalized Linear Model, with weekly updates, combined withmonitoring methods for short (weekly) and long term periods. The model hasshown to work properly and further improvements are suggested. For practicalimplementation, a calibration of the settings of the control chart and V-mask underknown production circumstances needs to be performed. The combination of thismodel with the previous ones (Bono et al., 2012, 2013), will help developing amanagement tool to help the farmers to monitor production, make decision, preventproblems, and reduce economical losses.

Conflict of interest statement

The authors report that there is no conflict of interest relevant to this publication.

5.9 Acknowledgments

The authors wish to acknowledge the 15 anonymous farmers as well as the Dan-ish Advisory Center for providing data and the Danish Ministry of Food, Agri-culture and Fisheries for financial support for this study through a grant entitled:"Development of a Management System for complete monitoring in Danish andInternational Pig Production".

Page 102: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

102 BIBLIOGRAPHY

Bibliography

Arango, J., Misztal, I., Tsuruta, S., Culbertson, M., Holl, J., Herring, W., 2006.Genetic study of individual preweaning mortality and birth weight in large whitepiglets using threshold-linear models. Livestock Science 101 (1-3), 208 – 218.

Bono, C., Cornou, C., Kristensen, A. R., 2012. Dynamic production monitoring inpig herds I. Modeling and monitoring litter size at herd and sow level. LivestockScience 149 (3), 289 – 300.

Bono, C., Cornou, C., Lundbye-Christensen, S., Kristensen, A. R., 2013. Dynamicproduction monitoring in pig herds II. Modeling and monitoring farrowing rateat herd level. Livestock Science.

Chagnon, M., D’Allaire, S., Drolet, R., April 1991. A prospective study of sowmortality in breeding herds. Canadian Journal Veterinary Research 55 (2), 180–184.

D’Allaire, S., Drolet, R., Chagnon, M., April 1991. The causes of sow mortality:A retrospective study. The Canadian Veterinary Journal 32, 241–243.

Duran, C., August 2001. Sow mortality. Food Animal 23 (8), 76–83.

Edwards, S., 2002. Perinatal mortality in the pig: environmental or physiologicalsolutions? Livestock Production Science 78 (1), 3 – 12.

Fahmy, M. H., Holtmann, W. B., MacIntyre, T. M., Moxley, J. E., 5 1978. Eval-uation of piglet mortality in 28 two-breed crosses among eight breeds of pig.Animal Science 26, 277–285.

Grandinson, K., Lund, M., Rydhmer, L., Strandberg, E., 2002. Genetic parametersfor the piglet mortality traits crushing, stillbirth and total mortality, and theirrelation to birth weight. Acta Agriculturae Scandinavica, Section A - AnimalScience 52 (4), 167–173.

Högberg, A., Rydhmer, L., 2000. A genetic study of piglet growth and survival.Acta Agriculturae Scandinavica, Section A - Animal Science 50 (4), 300–303.

KilBride, A., Mendl, M., Statham, P., Held, S., Harris, M., Cooper, S., Green, L.,2012. A cohort study of preweaning piglet mortality and farrowing accommoda-tion on 112 commercial pig farms in England. Preventive Veterinary Medicine104 (3 - 4), 281 – 291.

Knol, E., Ducro, B., van Arendonk, J., van der Lende, T., 2002. Direct, mater-nal and nurse sow genetic effects on farrowing-, pre-weaning- and total pigletsurvival. Livestock Production Science 73 (2-3), 153 – 164.

Page 103: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

BIBLIOGRAPHY 103

Koketsu, Y., 2000. Retrospective analysis of trends and production factors associ-ated with sow mortality on swine-breeding farms in USA. Preventive VeterinaryMedicine 46 (4), 249 – 256.

Leenhouwers, J. I., van der Lende, T., Knol, E. F., 1999. Analysis of stillbirth indifferent lines of pig. Livestock Production Science 57 (3), 243 – 253.

López, M. A. R., December 2008. Low reproductive performance and high sowmortality in a pig breeding herd: a case study. Irish Veterinary Journal 61 (12),818–826.

Lund, M., Puonti, M., Rydhmer, L., Jensen, J., 2002. Relationship between littersize and perinatal and pre-weaning survival in pigs. Animal Science 74, 217–222.

Marchant, J., Rudd, A., Mendl, M., Broom, D., Meredith, M., Corning, S., Sim-mins, P., 2000. Timing and causes of piglet mortality in alternative and conven-tional farrowing systems. The Veterinary record [Peer Reviewed Journal] 147(8),209–214.

Montgomery, D., 2005. Introduction to statistical quality control, 5th Edition. Wi-ley, Hoboken, NJ, USA.

Persdotter, L., 2010. Piglet mortality in commercial piglet production herds. Mas-ter’s thesis, Swedish University of Agricultural sciences - SLU, Department ofAnimal Breeding and Genetics.

R Development Core Team, 2013. R: A Language and Environment for StatisticalComputing. R Foundation for Statistical Computing, Vienna, Austria.

Roehe, R., Kalm, E., 2000. Estimation of genetic and environmental risk factorsassociated with pre-weaning mortality in piglets using generalized linear mixedmodels. Animal Science 70 (2), 227–240.

Sanz, M., Roberts, J., Perfumo, C., et al., January and February 2007. Assessmentof sow mortality in a large herd. Journal of Swine Health and Production 15 (1),30–36.

Weber, R., Keil, N. M., Fehr, M., Horat, R., 2009. Factors affecting piglet mortalityin loose farrowing systems on commercial farms. Livestock Science 124, 216 –222.

West, M., Harrison, J., 1997. Bayesian Forecasting and Dynamic Models, 2nd Edi-tion. Springer Series in Statistics. Springer, New York, USA.

West, M., Harrison, J. F., Migon, H. S., 1985. Dynamic generalized linear modelsand bayesian forecasting. Journal of the American Statistical Association 80, 73– 83.

Page 104: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

104 BIBLIOGRAPHY

Wientjes, J., Soede, N., van der Peet-Schwering, C., van den Brand, H., Kemp, B.,2012. Piglet uniformity and mortality in large organic litters: Effects of parityand pre-mating diet composition. Livestock Science 144 (3), 218 – 229.

Page 105: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

CHAPTER 6

GENERAL DISCUSSION

6.1 Overall idea

From the management point of view, the general idea of this PhD study can besummarized as depicted in Figure 6.1. Since data were provided by the existingDanish management information system (DLBR-IT) and directly retrieved fromthe SQL-database server, the thesis focuses on phases: 4- Data processing and5- Monitoring methods. Phase 6- Intervention in case of impaired results, is notdeeply treated as it goes more towards the manager decisions related to the farm.Therefore, it is mentioned as "the last phase of the circle". The figure offers thepossibility to have a general framework in which phases 4 and 5 are the main partsanalyzed in this thesis.

The present study is directed towards dynamic management systems devel-oped to support farmers in the decision-making process. The PhD project aimsat developing and implementing mathematical models and monitoring systems insow herds. The core of the project is the dynamic approach suggested. In orderto achieve this goal, Dynamic Linear Models and Dynamic Generalized LinearModels have been used.

The first step was to re-parameterize an existing non-linear litter size model(Toft and Jørgensen, 2002) to ensure the linearity of the parameters (Chapter 3).Linearity is a necessary requirement for standard application of the above men-tioned models (DLM and DGLM). Another fundamental component of the studyis the monitoring part.

The term "monitoring" in a farm context, can be easily misunderstood since theobservation of recorded data (Phase 2 of Figure 6.1) can also be called monitoring.According to OxfordDictionary (2013), one of the meanings of the verb monitoris: "to observe and check the progress or quality of (something) over a period oftime". In this thesis the term is in accordance with its definition. It was intended as

Page 106: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

106 General Discussion

Figure 6.1: Figure depicting the overall idea of the thesis.

the activity of checking the trend of the parameters included in the models (Phase 5- Figure 6.1). Once the models were able to produce weekly reports, it is momen-tous to know if and when the production results are impaired. Real-time monitoringsystems were applied in order to give alarms when changes in the production pro-cess occur. The subjects chosen for the investigation were: litter size (Chapter 3),farrowing rate (Chapter 4) and mortality rate (Chapter 5). The detection methodsadopted and implemented are based on control charts. In the short time horizon,the Shewhart control chart was chosen whereas for the long term one, the V-maskplaced on a Cumulative Sum (Cusum) control chart was preferred.

6.2 Data Processing

In this section, Phase 4 of Figure 6.1 is discussed in detail. Description of thedynamic models implemented, variance and model components is performed forChapters 3, 4 and 5.

6.2.1 Multivariate Models

Properties and applications of Dynamic Linear Models (DLMs) and Dynamic Gen-eralized Linear Models (DGLMs) have been introduced in Chapters 3 to 5. Chapter

Page 107: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

6.2 Data Processing 107

3 is the first step and focuses on modeling quantitative data (Litter size). Chapters4 and 5, due to the binomial nature of the variables, present many similarities onmodeling farrowing and mortality rate. A list of the main characteristics of eachmodel is exposed.

DLM In Chapter 3, litter size is modeled at herd and sow level. The latent pa-rameter vector θt is composed of observed litter size of sows farrowing atweek t for the first four parities (µ1t, . . . , µ4t), the slope after the fourth par-ity (φ4t), the genetic improvement over time i.e. the time trend (δt) and thesow effect (Mit). System variance Wt is estimated by the EM-algorithmtechnique. In order to obtain the weekly updates, the initial information ofthe DLM needs to be defined. Two approaches are presented, new herd-no records: the five litter size parameters are initiated from the populationmean and the population variance-covariance matrix; existing herd-databaseavailable: estimated from herd database (see Toft and Jørgensen (2002) forfurther details). Weekly monitoring is based on the difference between ob-served and expected values.

DGLM 1 In Chapter 4, farrowing rate is modeled at herd level assuming a bino-mial distribution. The latent parameter vector θt is composed of θ1t to θ5tcorresponding to the farrowing rate for the first 5 parities at week t, the neg-ative slope θ6t and the effect of the re-insemination θ7t. Explorative dataanalyses have been performed in order to obtain the initial means of thementioned parameters. The system variance has been estimated through theEM-algorithm technique with the assumption that the first 5 parameters (θ1tto θ5t) are mutually correlated, but independent of changes in the other twomodel parameters (θ6t and θ7t). Being a binary trait, the values of the farrow-ing rate model are presented in a logistic scale. A new sequential updatingprocedure has been created for the multivariate binomial DGLM (availablein Appendix A, end of Chapter 4).

DGLM 2 In Chapter 5, mortality rate of sows and piglets is modeled at herd level.The latent parameter θt is composed of a set of 15 parameters: the gen-eral herd level for sow mortality (µt), the coefficients referring to the parityeffects on sow mortality (α2t, . . . , α8t), effect of stage in the reproductivecycle (β2t), coefficients for the parity specific stillbirth rate for Parities 1-4(γ1t, . . . , γ4t), coefficient for the pre-weaning mortality (ζt) and coefficientfor the slope of stillbirth rates after Parity 4 (δt). The EM-algorithm tech-nique has been used to estimate the variance components. Since mortality, aswell as farrowing is a binary trait, the same multivariate binomial techniquehas been used for updating the weekly results.

As previously mentioned, the choice of dynamic models is related to the in-creasing need of management information systems able to help farmers in the de-cision making process through control and monitoring activities in real time. It

Page 108: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

108 General Discussion

Data D(G)LMControl

Charts

Figure 6.2: Basic assumption of the study

can be discussed whether the use of these models is relevant for the purpose ofthe study. The basic assumption of this project is summarized in Figure 6.2. Assoon as records are available, the suggested dynamic models are used to processthem and, afterwards, control charts are applied to detect changes in the produc-tion process. However, data may be directly displayed in control charts as seen inLeadon (1981); Morrison R.B. and Polson. (1997) and Pleasants et al. (1998). Alogical question may therefore be: why use dynamic linear models? One of theproperties of these models is that data is gathered according to the time evolution,allowing the acquirement of relevant information to forecast future patterns (Westand Harrison, 1997). When an explicit model is applied on observations throughthe system and observation equations, making forecasts become easier (Kristensenet al., 2010). Hence, it is possible to obtain better expected values.

Another advantage of dynamic linear models is the dependence of the parame-ters over time. In fact, in animal production, there are often repeated measurementsof the same animal or similar environmental effects, therefore, it is possible to de-tect autocorrelation. Once the autocorrelation has been identified it is possible tomodel it and to obtain the forecast errors which, assuming that the autocorrelationmodel is correct, are independent (Kristensen et al., 2010). For example, in Chap-ter 5 this assumption was exploited to build the model taking into account sowsand piglets mortality. In Chapters 3 and 4 is also possible to see clear correlationsbetween following parities meaning that individual parity averages (for litter sizeas well as for farrowing rate) will not drift independently of each other. In otherwords, better expected values and dependence over time are the main reasons whydynamic linear models were developed in this study.

6.2.2 Variance estimation

The estimation of the variance components has been performed by using the EM-algorithm technique. The estimation procedure appears faster for continuous data

Page 109: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

6.2 Data Processing 109

(litter size) than binomial data (farrowing and mortality rate). In fact, 400 itera-tions were already enough to obtain the convergence of the variance componentsin the litter size model, whereas for the farrowing rate model 45000 iterations werenecessary. The mortality rate model, being composed of 15 parameters, has led tocomplications in the system variance estimation procedure.

In a preliminary result it was seen that after 22000 iterations, the parity effectson sow mortality (α2t to α8t) did not reach the convergence (7 out of 15 parame-ters). Therefore, the first logical solution was to wait for more iterations. However,due to the long time needed for each iteration (1 hour and 6 minutes per iteration)it was not possible to achieve a desirable result in the time available for the project.Another possible solution is to treat sows and piglets mortality into two separatemodels. In other words, since the convergence for piglets was reached withoutparticular issues, it is also possible to run the EM-algorithm for sow parametersseparately, and combine them afterwards.

Since the convergence of sow mortality parameters has not been reached, anattempt of splitting the model has been initiated. The iteration procedure for sowmortality parameters is faster compared to the full mortality model; however, only2000 iterations have been performed at the present time (June 2013). In Figure 6.3an overview of the variance components of the three models (6.3(a), 6.3(b), 6.3(c),6.3(d)) and the preliminary result of the new partial sow mortality model (6.3(e))are shown.

Therefore, if a weak point is to be considered at this stage, it is the estimationof the variance components in Chapter 5, where the procedure was too long dueto the amount of parameters taken into account simultaneously. On the basis ofthese findings and for future models it would be relevant not to include too manyparameters, keeping in mind that it is always possible include the correlations in asecond estimation procedure. Another possible solution could be to try a differentvariance estimation technique such as MSE (mean square error) proposed by Mad-sen and Kristensen (2005), or simply a method to speed-up the EM-steps for theconvergence process. Jollois and Nadif (2007), in a recent study, proposed an ef-ficient strategy able to speed-up the EM-algorithm iteration process for categorialdata. Therefore, implementations in this area can be indeed of interest.

6.2.3 Model components

In Chapters 3, 4 and 5, filtered and smoothed data of the parameters taken into ac-count were analyzed and discussed. When the model (DLM or DGLM) is applied,the weekly updating procedure provides filtered data. The smoothing techniquecan thereafter be applied on filtered data. The smoothing is a retrospective anal-ysis where the fluctuations are evaluated after the events. It allows to reduce thetemporary random fluctuation observed in the filtered data. It was introduced in or-der to improve the understanding and accelerate the decision process. It should benoticed that filtered and smoothed data are not directly comparable since with theformer, the farmer is able to see the production in real time, whereas with the latter

Page 110: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

110 General Discussion

0 100 200 300 400

0.0000

0.0005

0.0010

0.0015

0.0020

Iteration

Variance

Parity 1

Parity 2

Parity 3

Parity 4

(a) System variance - Litter size

0 10000 20000 30000 40000

0.000

0.005

0.010

0.015

Iteration

Variance

Parity 1

Parity 2

Parity 3

Parity 4

Parity 5

(b) System Variance - Farrowing rate

0 5000 10000 15000

0.000

0.002

0.004

0.006

0.008

0.010

0.012

0.014

Iteration

Variance, Parities 2−8

Parity 2Parity 3Parity 4Parity 5Parity 6Parity 7Parity 8

(c) System Variance - Mortality rate, parityeffect

0 5000 10000 15000

0.00

0.02

0.04

0.06

0.08

Iteration

Variance, Stillbirth rate, Parities 1−4

Parity 1Parity 2Parity 3Parity 4

(d) System Variance - Mortality rate, stillbirth

0 500 1000 1500 2000

0.000

0.005

0.010

0.015

Iteration

Variance, Parities 2−8

Parity 2Parity 3Parity 4Parity 5Parity 6Parity 7Parity 8

(e) System Variance - Mortality rate, parity effect new partial model

Figure 6.3: Representation of convergence of the variance components using theEM-algorithm technique. (a) System variance for the first four parities - Littersize model. (b) System variance for the first five parities - Farrowing rate model.(c) System variance of the parity effects on sow mortality - Mortality model. (d)System variance of stillbirth rate - Mortality model. (e) System variance of theparity effects on sow mortality - New partial sows mortality model

Page 111: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

6.2 Data Processing 111

it is possible to identify problems that may have occurred during the productionprocess.

Chapter 3 In Chapter 3, the choice of the parameters (µ1t to µ4t, φ4t, δt andMi) was a "consequence" of the previous model (Toft and Jørgensen, 2002).On the basis of the sow replacement model described by Kristensen andSollested (2004a,b), it is logical to assume that describing the first four par-ities (µ1t to µ4t) is sufficient to implement the model proposed. These arehowever not the only parities considered in the model. It is simply assumedthat after the fourth parity, the litter size gradually decreases and therefore,a negative slope (φ4t) is considered. In fact, already after the third parity,the litter size begins to decrease, therefore, the farmer may start to considerwhether to replace or not the sow. Time trend (δt) has been included in orderto let the model adapt to the genetic improvement over time. It also allowedto get a measure of this improvement and compare with what was expected.The individual property of sows (Mi) allowed the creation of a frameworkfor linking to the mentioned replacement model (Kristensen and Sollested,2004a,b) which, in turn, allowed the economic evaluation of an individualsow. From the farmer point of view, the economical reward of each sow interms of number of parities and litter size, may be remarkably significant forthe decision-making process.

Chapter 4 In Chapter 4, farrowing events for up to eight consecutive parities andup to four inseminations are taken into account for each sow. To build themodel, the parameters considered were: θ1t to θ5t (farrowing rate for thefirst five parities), a negative slope, θ6t, assumed after the fifth parity, andthe effect of the re-insemination, θ7t. In some of the herds, high farrowingrates for the first insemination have been found between parities 4 and 5.This can be considered odd as after the fourth parity the farrowing rate usu-ally decreases. The explanation for this may lie in the culling strategy andtherefore in censored data: sows that survive until high parity numbers willtend to have a better fertility resulting in overestimation of farrowing ratesfor high parities compared to an unrealistic situation with no culling. Theslope reflects the reduction of the farrowing rate after Parity 5. Since a smallvalue has been found in the 15 herds analyzed, we may assume that, in gen-eral, a good culling strategy has been adopted by the farmers. A decrease of10% of farrowing rate per re-insemination has been found in this study. Thereason for this large reduction can be the lack of sow effect in the model. Ifsow properties are included in this model, the repeatability of the variablecan also be taken into account and a potential reduction of the farrowing rateper re-insemination could occur.

Chapter 5 In Chapter 5, the mortality rate of sows and piglets for eight paritieshas been calculated. Sow mortality has been further divided into two groups:

Page 112: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

112 General Discussion

insemination and gestation periods, and nursing and dry periods. Piglet mor-tality has been analyzed for two groups: stillborn and preweaning mortality.To build the model, 15 parameters have been considered: the general herdlevel for sow mortality (µt), the coefficients referring to the parity effects onsow mortality (α2t to α8t), the effect of stage in the reproductive cycle (β2t),the coefficients for the parity specific stillbirth rate for Parities 1-4 (γ1t toγ4t), the coefficient for the pre-weaning mortality (ζt) and the coefficient forthe slope of stillbirth rates after Parity 4 (δt ). Due to the amount of figuresrelated to the number of the parameters forming the model, only smoothedvalue were shown in this chapter. The weekly mortality rate of the first fiveparities showed a similar pattern in the smoothed data of the two stages men-tioned. On the other hand, the weekly mortality for stillbirth for the first fourparities was difficult to interpret because no pattern was identified. As men-tioned in the previous section, since the optimal system variance was notfound, interpretation of some parameters may have been biased.

The choice of the variables for the three chapters can also be discussed. Since inpig herds productivity heavily depends on the amount of piglets produced per sow,it was logical to assume litter size as the first variable to be included in the model.Another aspect of paramount importance in pig industry is reproduction hence, thevariable chosen for the second model was farrowing rate that includes conceptionrate as well as early abortions. Productivity results are strongly affected by mortal-ity, which in pig farms is also a considerable welfare issue, therefore, this variablewas taken into account for the third study. These variables may be consideredimportant for the economy of the herd (Mertens et al., 2011) nevertheless, othersvariables may be considered for future model applications such as: feed conversionrate, slaughter weight, daily gain etc. As many variables are modeled, as preciseis the information given to the farmer and therefore, it is easier for him/her makechoices. This is basically the aim of the project: to create dynamic models able toconsider all kind of variables (i.e. quantitative and qualitative), and to follow overtime the overall production process of the farm, giving alarms if unexpected resultsare detected.

The use of smoothed data in Chapters 3, 4 and 5 was already discussed; how-ever the general concept has not be explained in practice. In Denmark, the levelof production of farms is usually calculated retrospectively every three months oryearly. Data is presented in tables showing results as simple averages over the pe-riod considered. Variance within farm is generally not shown. These tables arenot able to explain the size of the variance and thus, interpretation of data maynot always be correct. Even if, in this thesis, smoothing data are provided, theprocess may be seen in a different way: every week there is information availableand it is possible to check the process on an ongoing basis so that comparisonsbetween following weeks are easy to obtain and to interpret. Smoothing techniqueon weekly basis can be also used for different purposes such as the evaluation ofthe farm management system. Let us consider that the farmer decided to change

Page 113: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

6.2 Data Processing 113

50 100 150

14

15

16

17

18

19

20

Week

Piglets

Parity 1

Parity 2

Parity 3

Parity 4

(a) Litter size

300 350 400

0.75

0.80

0.85

0.90

0.95

Week

Farrowing rate

Parity 1

Parity 2

Parity 3

Parity 4

Parity 5

(b) Farrowing rate

250 300 350 400

0.000

0.001

0.002

0.003

0.004

0.005

0.006

Week

Weekly mortality rate, insemination + gestation period

Parity 1

Parity 2

Parity 3

Parity 4

Parity 5

(c) Mortality rate, First Stage

250 300 350 400

0.00

0.05

0.10

0.15

0.20

Week

Stillbirth rate

Parity 1

Parity 2

Parity 3

Parity 4

(d) Mortality rate, Stillbirth

Figure 6.4: Evolution of the model parameters in the three models suggested. (a)Smoothed components for the first four parities - Litter size model (Herd 15). (b)Smoothed components for the first five parities - Farrowing rate model (Herd 8).(c) Smoothed components for the first five parities for the insemination/ gestationperiod - Mortality model (Herd 10). (d) Smoothed components for the first fourparities of stillbirth mortality rate - Mortality model (Herd 10).

Page 114: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

114 General Discussion

something in his farm e.g. the management software or simply the managementsystem, weekly smoothed data can help him to understand if the "new" actionscarried out resulted in improvements or deterioration of the production results.

6.3 Monitoring methods

In this section, Phase 5 of Figure 6.1 is treated in detail. The monitoring meth-ods used in Chapters 3, 4 and 5 are discussed. The monitoring methods aim atproviding alarms when impaired results occur. They are able to detect increasingand decreasing changes. In particular, in Chapter 3, the alarms of most interest arewhen litter size decreases; in Chapter 4, when farrowing rate decreases; in Chapter5, when mortality rate increases. Monitoring these states may increase the effi-ciency and the rapidity of the management system and help the farmer to decide ifand when an action may be taken.

To avoid repetitions, for each Chapter, a herd has been selected as illustrationfor the discussion of the results. Chapter 3 = Herd 15; Chapter 4 = Herd 8; Chapter5 = Herd 10.

6.3.1 Shewhart Control Chart

The American Walter Andrew Shewhart, also known as the father of statisticalquality control, while working for a telephone company and collaborating withengineers in 1920s, developed the first production analysis techniques which al-lowed the creation of the statistical process control (Best and Neuhauser, 2006).These techniques aimed at detecting qualitative changes in continuous productionprocesses.

In Chapter 3, 4 and 5, Shewhart control charts are used to check whether theproduction process is in or out-of-control. The method is able to give alarms ifchanges occur in the process. In these Chapters, the observations exceeding thecontrol limits (upper or lower) are considered as alarms whereas when the controllimit line is merely touched by an observation, no alarm is triggered.

In Chapter 3, continuous data were processed. In Herd 15, four alarms havebeen detected. Two of them were found under the lower control limit line, whichmeans that the weekly production was significantly lower than what was predicted.The other two alarms were over the upper control limit line, which indicates that anoverproduction was encountered. On the light of this example, the negative alarmsmay be used by the farmer to investigate, for instance, what happened during theinsemination procedure. On the other hand, positive alarms can be ignored unlessthe farmer wishes to be informed, in real time, of the progress of his/her animals.

In Chapter 4, since binomial data were processed, the control limits were set upin a different way. The control limits were defined as integers. Therefore, for eachlimit (upper and lower) there is a significance level that is less than 2.5%. In Herd8, no alarms were found in the short term period but five observations just touched

Page 115: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

6.3 Monitoring methods 115

the limits. It can therefore be discussed whether some of these weeks should havebeen considered as problematic. A potential tool to reduce the uncertainty duringthe decision process could be the addition of “warning limits”, which would narrowthe range of allowed deviations before a “warning” alarm is triggered.

In Chapter 5, no alarms were triggered for Herd 10 in the given period (26weeks). Since the control limits were set in the same way as in Chapter 4, thetwo observations touching the upper control limit (weeks 372 and 387) for sowmortality and the other two for piglet mortality (weeks 382 and 395) are not con-sidered as alarms. Hence, the possibility of “warning limits” may also be appliedin this context. For piglet mortality, two more observations were touching the limit(weeks 379 and 393) but since it is the lower control limit indicating a decrease ofthe mortality rate, there is no reason to be alarmed.

6.3.2 V-mask

The Cusum, as mentioned in the introduction, is the cumulative sum of the devia-tions of the observations composing the sample. When a V-shaped mask is placedon the chart, it becomes a Cusum control chart and its arms represent the "con-trol limits". If the process is in control, the Cusum should fluctuate stochasticallyaround the 0 level. This method has been used for monitoring long time horizon.

In Chapter 3, one alarm was triggered in week 76 in the 3 years period takeninto account. When an alarm is given, the Cusum is automatically reset to 0. InChapter 4, two alarms were found whereas in Chapter 5 two alarms were triggeredfor sow mortality and none for piglets mortality. In these two Chapters (4 and5), it has been noticed that the method was unable to detect changes in the modelspecific parameters. For instance, in Chapter 4, if smoothed data are comparedwith the V-mask plot, it is possible to see that the “drop” of Parity 5 around week310 was not detected (Figure 6.5) therefore, a parity specific alarm system couldbe implemented concomitantly with the current method. Concerning Chapter 5,maybe due to the absence of a pattern, the V-mask method was not able to givealarms in stillbirth mortality (see Figure 6.6) whereas for the sow mortality themethod appeared satisfactory (see Figure 6.7).

6.3.3 Choice of the monitoring methods

If records are regularly available, it is possible to develop control charts. Accord-ing to Mertens et al. (2011) there are three basic assumptions that allow the properuse of control charts: i) stationarity of in-control state of production process; ii)absence of dependence between records (no autocorrelation) and iii) data must fol-low the statistical distribution function (e.g. normal or binomial) that is associatedwith.

Unfortunately, when dealing with livestock production, variables subjected toanalysis are of biological nature and hence, often unpredictable (Frost et al., 1997)therefore, violation of the aforementioned assumptions can be likely due to the

Page 116: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

116 General Discussion

300 350 400

0.75

0.80

0.85

0.90

0.95

Week

Farrowing rate

Parity 1

Parity 2

Parity 3

Parity 4

Parity 5

(a) Smoothed farrowing rate - Herd 8

●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●●●●●

●●

●●

●●

●●

●●●●

●●●

●●●

●●●

300 350 400

−10

−5

0

5

10

Week

Cumulated sum of standardized forecast errors

(b) V-mask farrowing rate - Herd 8

Figure 6.5: Comparison between Smoothed data and V-mask detection method inthe same three years period. (a) Smoothed components for the first five parities(Herd 8). (b) V-mask applied on Cusum (Herd 8).

250 300 350 400

0.00

0.05

0.10

0.15

0.20

Week

Stillbirth rate

Parity 1

Parity 2

Parity 3

Parity 4

(a) Smoothed stillbirth - Herd 15

250 300 350 400

−30

−20

−10

0

10

20

30

Week

Cumulated sum of standardized forecast errorsStillborn

(b) V-mask stillbirth - Herd 15

Figure 6.6: Comparison between Smoothed data and V-mask detection method forstillbirth mortality, in the same three years period. (a) Smoothed components forthe first four parities (Herd 15). (b) V-mask applied on Cusum stillbirth - (Herd15).

Page 117: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

6.3 Monitoring methods 117

250 300 350 400

0.000

0.001

0.002

0.003

0.004

0.005

0.006

Week

Weekly mortality rate, insemination + gestation period

Parity 1

Parity 2

Parity 3

Parity 4

Parity 5

(a) Smoothed sow mortality - Herd 15

250 300 350 400

−20

−10

0

10

20

Week

Cumulated sum of standardized forecast errorsSows

(b) V-mask sow mortality - Herd 15

Figure 6.7: Comparison between Smoothed data and V-mask detection method forsow mortality in the insemination-gestation stage, in the same three years period.(a) Smoothed components for the first five parities (Herd 15). (b) V-mask appliedon Cusum sow mortality (Herd 15).

dynamic aspects of livestock data (Mertens et al., 2011). Control charts havebeen used in different zootechnical areas such as: dairy management (de Vriesand Conlin, 2003; Lukas et al., 2008; Pastell and Madsen, 2008); poultry produc-tion (Ravindranathan, 1990; Cowen et al., 1994); swine production (Madsen andKristensen, 2005; Ostersen et al., 2010; Cornou et al., 2008; Morrison R.B. andPolson., 1997). In a recent review, Mertens et al. (2011) reported an overview ofpublications about control charts applications in livestock production since 1971.Moreover, detailed differences between control charts, weaknesses and strengthshave been thoroughly analyzed and discussed by the authors. In another reviewstudy, de Vries and Reneau (2010) provided a description of performances evalu-ation and models used in order to preadjust data for using control charts. Controlcharts have been deeply studied in last decades and an extensive literature is avail-able about them.

The choice of the control charts adopted in this thesis can therefore be dis-cussed. According to de Vries and Reneau (2010) and Mertens et al. (2011),Cusum and EWMA (exponentially weighted moving average) charts have com-parable characteristics hence, EWMA can be a plausible alternative to the Cusum.Both charts are used to detect large process shifts but whereas Cusum is fast in de-tecting changes, EWMA reacts slower after a detected change. EWMA charts canbe also applied on deviations. Nevertheless, in Cusum charts, if the process goesout-of-control, there is a quick return to the 0 level and it is possible to recognizenegative and positive deviations.

In this thesis the V-mask has been chosen to detect large process shifts. A V-mask Cusum is a graphical alternative of the common Cusum (Mertens et al., 2011)and despite the fact that Montgomery (2005) does not recommend this method,other authors such as Leadon (1981); Cornou et al. (2008) and Madsen and Kris-tensen (2005) succeeded in its use. An alternative to the V-mask Cusum is the

Page 118: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

118 General Discussion

Tabular Cusum. In a tabular Cusum, upper and lower one-side Cusum are calcu-lated separately. The upper Cusum accumulates the deviations above the targetvalue and, the lower one-side Cusum, below it. Alarms occur when a given thresh-old is exceeded (Montgomery, 2005). This method could also be suitable for thisstudy, since it automatically distinguishes increasing and decreasing performances.

Shewhart chart is recommended for small shifts of the process. Lukas et al.(2009) found that the arrangement of Shewhart and Cusum charts is a profitablecombination to detect both large and small process shifts. This was implementedin Chapters 3, 4 and 5 where the advantages of the aforementioned combinationwere taken into account.

Page 119: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

BIBLIOGRAPHY 119

Bibliography

Best, M., Neuhauser, D., April 2006. Walter a. shewhart, 1924, and the hawthornefactory. Quality and Safety in Health Care 15 (2), 142–143.

Cornou, C., Vinther, J., Kristensen, A. R., 2008. Automatic detection of oestrusand health disorders using data from electronic sow feeders. Livestock Science118 (3), 262 – 271.

Cowen, P., Fernandez, D., Barnes, H., August 1994. Surveillance strategies formonitoring variation in animal health and productivity : the use of statisticalprocess control in the turkey industry.

de Vries, A., Conlin, B., 2003. Design and performance of statistical processcontrol charts applied to estrous detection efficiency. Journal of Dairy Science86 (6), 1970 – 1984.

de Vries, A., Reneau, J. K., 2010. Application of statistical process control chartsto monitor changes in animal production systems. Journal of Animal Science88 (13 electronic suppl), E11–E24.

Frost, A., Schofield, C., Beaulah, S., Mottram, T., Lines, J., Wathes, C., 1997. Areview of livestock monitoring and the need for integrated systems. Computersand Electronics in Agriculture 17 (2), 139 – 159.

Jollois, F.-X., Nadif, M., 2007. Speed-up for the expectation-maximization algo-rithm for clustering categorical data. Journal of Global Optimization 37 (4).

Kristensen, A., Jørgensen, E., Toft, N., 2010. Herd Management Science. II. Ad-vanced topics. Academic books, Copenhagen.

Kristensen, A. R., Sollested, T. A., 2004a. A sow replacement model usingbayesian updating in a three-level hierarchic markov process: I. Biologicalmodel. Livestock Production Science 87 (1), 13 – 24.

Kristensen, A. R., Sollested, T. A., 2004b. A sow replacement model usingbayesian updating in a three-level hierarchic markov process: II. Optimizationmodel. Livestock Production Science 87 (1), 25 – 36.

Leadon, D., 1981. Dealing with data: The practical use of numerical informationby diana sard. Equine Veterinary Journal 13 (2), 126–126.

Lukas, J., Reneau, J., Linn, J., 2008. Water intake and dry matter intake changesas a feeding management tool and indicator of health and estrus status in dairycows. Journal of Dairy Science 91 (9), 3385 – 3394.

Lukas, J., Reneau, J., Wallace, R., Hawkins, D., Munoz-Zanzi, C., 2009. A novelmethod of analyzing daily milk production and electrical conductivity to predictdisease onset. Journal of Dairy Science 92 (12), 5964 – 5976.

Page 120: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

120 BIBLIOGRAPHY

Madsen, T. N., Kristensen, A. R., 2005. A model for monitoring the condition ofyoung pigs by their drinking behaviour. Computers and Electronics in Agricul-ture 48 (2), 138 – 154.

Mertens, K., Decuypere, E., De Baerdemaeker, J., De Ketelaere, B., 6 2011. Statis-tical control charts as a support tool for the management of livestock production.The Journal of Agricultural Science 149, 369–384.

Montgomery, D., 2005. Introduction to statistical quality control, 5th Edition. Wi-ley, Hoboken, NJ.

Morrison R.B., G.D. Dial, P. B. W. M. J., Polson., D., 1997. Current therapy inlarge animal theriogenology. Philadelphia, Pa. : W.B. Sanders, Ch. 116 - Usingstatistical process control to investigate reproductive failure, pp. 323–328.

Ostersen, T., Cornou, C., Kristensen, A., 2010. Detecting oestrus by monitoringsows’ visits to a boar. Computers and Electronics in Agriculture 74 (1), 51 – 58.

OxfordDictionary, July 2013. Online Etymology Dictionary.URL http://dictionary.reference.com/browse/

Pastell, M., Madsen, H., 2008. Application of {CUSUM} charts to detect lamenessin a milking robot. Expert Systems with Applications 35 (4), 2032 – 2040.

Pleasants, A. B., McCall, D. G., Sheath, G. W., 1998. Design and application ofa cusum quality control chart suitable for monitoring effects on ultimate muscleph. New Zealand Journal of Agricultural Research 41 (2), 235–242.

Ravindranathan, N.; Unni, A. K. K., 1990. A study on consistency in body weightsof chicks using shewhart control charts. Cheiron 19 (4), 156–158.

Toft, N., Jørgensen, E., 2002. Estimation of farm specific parameters in a lon-gitudinal model for litter size with variance components and random dropout.Livestock Production Science 77 (2-3), 175 – 185.

West, M., Harrison, J., January 1997. Bayesian Forecasting and Dynamic Models,2nd Edition. Springer Series in Statistic. Springer, New York.

Page 121: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

CHAPTER 7

PERSPECTIVES ANDCONCLUSIONS

In Chapter 6, results of the application of DLM and DGLM and of monitoringsystems for three important measures of production (litter size, farrowing and mor-tality rate) have been largely discussed. Alternatives have also been highlighted.In this section, perspectives regarding the implementation of the developed meth-ods are presented under a practical point of view. What can the farmer use thisresearch for? Why should the farmer change his management system towards thisnew approach?

Let us keep in mind that what has been developed in this thesis aims at helpingfarmers in simplifying the management system by making the decision processas quick as possible, to avoid production losses and to increase earnings. Whendiscussing culling strategies, it has already been mentioned that the combinationof these models with a previous replacement model can be a valuable tool for thefarmer.

Unfortunately, the aforementioned models cannot be used by the farmers asthey currently are. Therefore, the logical following step can be the creation of anappropriate management software able to include all information available in thefarm. This implies that the farmer and the employees need to be very careful andprecise in recording data and in inserting them in the database. Should then thefarmer holds a database or should the system be connected to a central server?The combination of both options is to be preferred. Once the records are regularlyentered into the farm computer, they can be sent to the main database on daily orweekly basis through an internet connection, so that any information is availableat any time. This would also allow farm advisors and veterinarians to access theinformation.

This new approach may require an initial training period for farmers and em-

Page 122: Dynamic production monitoring in sow herdspossibilities of real-time detection of production changes become a challenge for future monitoring systems. Models and methods for dynamic

122 Perspectives and Conclusions

ployees so that they can become familiar with the software. As a consequence, thenew system may imply changes in the daily routine of the farms but, on the otherhand, it also allows to make interventions for improving production or avoid fail-ures. Let us say that the farrowing rate increased in the last month. If records arecollected on daily basis, it is possible to go back in time and look for the productionfactors e.g. a change in nutritional value of feed, that allowed this positive change.Hence, more prepared employees are indeed an advantage.

Once categorial and continuous variables have been modeled as done in thisthesis, any type of variable may be added to create a more complete software.As many variables are modeled, as many can be inserted in the software, and asprecise can be the information obtained on the farm analyzed. The software can bea useful tool also for consultants who, behind the interpretation of results, can helpfarmers in i) comparing methods adopted from farm to farm, ii) identifying thebest strategies and iii) suggesting improvements or interventions in a rather limitedrange of time.

CONCLUSIONS

Systems for monitoring litter size at herd and sow level, and farrowing and mortal-ity rate at herd level have been developed and implemented in this thesis. They arebased on a combination of Dynamic Linear Models, Dynamic Generalized LinearModels and methods for monitoring systematic deviations on weekly basis. Forpractical implementation, a calibration of the settings of the control chart and V-mask under known production circumstances needs to be performed. The combina-tion of the aforementioned models (Chapters 3 to 5), a previous replacement modelfor culling strategy and the inclusion of other production traits will help develop-ing a management tool (i.e. software) to support farmers in monitoring production,making decisions, preventing problems, so that they can reduce economical lossesand hopefully, increase production efficiency.