This document describes modelling state transitions in dairy cows based on their somatic cell count (SCC). It begins with background on milk recording data collection, including SCC which indicates mastitis levels. States are defined as Low, High, Dry. A multinomial logit model is used to model the transition between states based on previous states. The model is coded in WinBUGS. Validation data from 100 herds is used to test the model.
1. Modelling
State
Transitions
Aur´lien
e
Madouasse
Background
Modelling State Transitions
Milk Recording
Data Example of a Multinomial Logit Model Applied to Somatic
Somatic Cell
Count Cell Count in Dairy Cows
State
Transition
State Definition
State
Transitions
Data
Aur´lien Madouasse
e
A Simple
Model
Model
WinBUGS code
Results 19th April 2010
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
2. Outline
Modelling
State 1 Background
Transitions Milk Recording
Aur´lien
e Data
Madouasse Somatic Cell Count
Background 2 State Transition
Milk Recording State Definition
Data
Somatic Cell State Transitions
Count Data
State
Transition 3 A Simple Model
State Definition Model
State
Transitions WinBUGS code
Data Results
A Simple
Model 4 Adding Complexity
Model SCC Variation
WinBUGS code
Results Model
Adding
WinBUGS code
Complexity Results
SCC Variation
Model 5 Discussion
WinBUGS code
Results
3. Outline
Modelling
State 1 Background
Transitions Milk Recording
Aur´lien
e Data
Madouasse Somatic Cell Count
Background 2 State Transition
Milk Recording State Definition
Data
Somatic Cell State Transitions
Count Data
State
Transition 3 A Simple Model
State Definition Model
State
Transitions WinBUGS code
Data Results
A Simple
Model 4 Adding Complexity
Model SCC Variation
WinBUGS code
Results Model
Adding
WinBUGS code
Complexity Results
SCC Variation
Model 5 Discussion
WinBUGS code
Results
4. What is Milk Recording?
Modelling
State
Transitions
Aur´lien
e
Madouasse
Milk recording is the regular collection of a milk sample
Background from all lactating cows of a dairy herd
Milk Recording
Data What is measured:
Somatic Cell
Count
Milk yield
State
Transition
% butterfat, % protein, % lactose
State Definition Somatic cell count
State
Transitions
Data Information collected
A Simple Date of birth
Model
Model Date of calving
WinBUGS code
Results
Parity
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
5. What is Milk Recording?
Modelling
State
Transitions
Aur´lien
e
Madouasse
Background Farmers pay for milk recording, in order to:
Milk Recording
Data Adapt management
Somatic Cell
Count Identify cows likely to have mastitis
State
Transition
Identify the best producers
State Definition
State
The information is also used for
Transitions
Data Genetic evaluation
A Simple Epidemiologic studies
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
6. Data
Initial Dataset
Modelling
State
Transitions
Aur´lien
e
Madouasse
Background
The National Milk Records: main provider of milk
Milk Recording
Data
recording in England and Wales
Somatic Cell
Count All the data collected by the NMR between January 2004
State and December 2006 were purchased:
Transition
State Definition 19,893,093 recordings
State
Transitions 1,247,427 cows
Data
5,714 herds
A Simple
Model
Model
⇒ Big!!!
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
7. Data
Data Selection
Modelling
State
Transitions Aim: Obtain a homogeneous dataset and discard unreliable
Aur´lien
e
Madouasse
data
Herds recording:
Background
Milk Recording For the 3 complete years
Data
Somatic Cell On a monthly basis
Count
State
At least 80 % of Holstein-Friesian cows
Transition
State Definition
Milk samples collected on 2 consecutive milkings
State
Transitions
Data
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
8. Data
Data Selection
Modelling
State
Transitions Aim: Obtain a homogeneous dataset and discard unreliable
Aur´lien
e
Madouasse
data
Herds recording:
Background
Milk Recording For the 3 complete years
Data
Somatic Cell On a monthly basis
Count
State
At least 80 % of Holstein-Friesian cows
Transition
State Definition
Milk samples collected on 2 consecutive milkings
State
Transitions
Data
A Simple
Final dataset
Model
Model
8,211,988 recordings
WinBUGS code 483,747 cows
Results
Adding
2,128 herds
Complexity
SCC Variation ⇒ Reasonably big!!!
Model
WinBUGS code
Results
9. Somatic Cell Count
Relation to mastitis
Modelling
State
Transitions
Aur´lien
e
Madouasse
Background
Milk Recording
Data
Somatic Cell
Mastitis
Count
One of the biggest health problems in dairy herds
State
Transition Can be clinical or subclinical
State Definition
State
Causes an increase in milk somatic cell count (SCC)
Transitions
Data
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
10. Somatic Cell Count
Relation to mastitis
Modelling
State
Transitions
Aur´lien
e Individual Somatic Cell Count
Madouasse
Threshold of 200,000 cells/mL used to categorise cows as
Background Infected/Uninfected
Milk Recording
Data
Somatic Cell
Count
Bulk Milk Somatic Cell Count
State Reflects herd mastitis prevalence
Transition
State Definition
Penalty on milk price when it is too high
State
Transitions
Data
Aims of the study
A Simple
Model
Model
Can we model the transition between Low/High SCC from
WinBUGS code
Results
individual cow information?
Adding
Complexity
Can we predict BMSCC from the predicted transitions?
SCC Variation
Model
WinBUGS code
Results
11. Outline
Modelling
State 1 Background
Transitions Milk Recording
Aur´lien
e Data
Madouasse Somatic Cell Count
Background 2 State Transition
Milk Recording State Definition
Data
Somatic Cell State Transitions
Count Data
State
Transition 3 A Simple Model
State Definition Model
State
Transitions WinBUGS code
Data Results
A Simple
Model 4 Adding Complexity
Model SCC Variation
WinBUGS code
Results Model
Adding
WinBUGS code
Complexity Results
SCC Variation
Model 5 Discussion
WinBUGS code
Results
12. State transition
Definition of the States
Modelling
State
Transitions
Aur´lien
e
Madouasse
Background
Milk Recording
Data
Somatic Cell
Count
State
Transition
State Definition
First
Low/High
Low/High
Low/High
Low/High
Low/High
Low/High
Low/High
Low/High
Low/High
Low/High
Low/High
Low/High
Last
Dry
Dry
State
Transitions
Data
A Simple
Model
Low Low Low
Model
WinBUGS code
First Dry Last
Results
High High High
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
13. State transition
Transition Matrix
Modelling
State
Transitions
Aur´lien
e
Madouasse
Background
Milk Recording
Current
Data
Somatic Cell
Low High Dry Last
Count
Low π11 π12 π13 π14
Previous
State
Transition High π21 π22 π23 π24
State Definition
State Dry π31 π32 π33 π34
Transitions
Data First π41 π42 π43 π44
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
14. State transition
Transition Matrix
Modelling
State
Transitions
Aur´lien
e
Madouasse
Background
Milk Recording
Current
Data
Somatic Cell
Low High Dry Last
Count
Low π11 π12 π13 π14
Previous
State
Transition High π21 π22 π23 π24
State Definition
State Dry π31 π32 π33 0
Transitions
Data First π41 π42 0 0
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
15. Data
Data Used for the Study
Modelling
State
Transitions
Aur´lien
e
Madouasse
Background Training data
Milk Recording
Data
100 randomly selected herds
Somatic Cell
Count
Dataset 1: 6 consecutive test-days used for parameter
State estimation (70,382 lines)
Transition Dataset 2: 7th test-day for validation (11,895 lines)
State Definition
State
Transitions Validation data (Dataset 3: 14,669 lines)
Data
100 randomly selected herds
A Simple
Model 1 test-day per herd
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
16. Outline
Modelling
State 1 Background
Transitions Milk Recording
Aur´lien
e Data
Madouasse Somatic Cell Count
Background 2 State Transition
Milk Recording State Definition
Data
Somatic Cell State Transitions
Count Data
State
Transition 3 A Simple Model
State Definition Model
State
Transitions WinBUGS code
Data Results
A Simple
Model 4 Adding Complexity
Model SCC Variation
WinBUGS code
Results Model
Adding
WinBUGS code
Complexity Results
SCC Variation
Model 5 Discussion
WinBUGS code
Results
17. State transition
Model
Modelling
State
Transitions
Aur´lien
e
Madouasse
Background
Milk Recording
Data
Somatic Cell
Count Stateij ∼ Multinomial(πij ) State i
State
Transition
Cow-recording j
State Definition
State
Transitions
Data
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
18. State transition
Model
Modelling
State
Transitions
Aur´lien
e
Madouasse
Background
Milk Recording
Data
Somatic Cell
Count Stateij ∼ Multinomial(πij ) State i
4
State
π Cow-recording j
Transition
State Definition
ij
ln( π1j ) = I [Statei(j−1) ]αii
i
State
i =1
Previous State i
Transitions
Data
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
19. State transition
WinBUGS code
Modelling
State
Transitions
Aur´lien
e
Madouasse
model {
Background
Milk Recording
Data
Somatic Cell
Count
State
Transition
State Definition
State
Transitions
Data
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
20. State transition
WinBUGS code
Modelling
State
Transitions
Aur´lien
e
Madouasse
model {
Background
Milk Recording
Data
Somatic Cell for(i in 1:N) {
Count
State
Transition
State Definition
State
Transitions
Data
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
21. State transition
WinBUGS code
Modelling
State
Transitions
Aur´lien
e
Madouasse
model {
Background
Milk Recording
Data
Somatic Cell for(i in 1:N) {
Count
State
Transition resp[i,1:4] ~ dmulti(pi[i,1:4],1)
State Definition
State
Transitions
Data
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
22. State transition
WinBUGS code
Modelling
State
Transitions
Aur´lien
e
Madouasse
model {
Background
Milk Recording
Data
Somatic Cell for(i in 1:N) {
Count
State
Transition resp[i,1:4] ~ dmulti(pi[i,1:4],1)
State Definition
State
Transitions
Data for(m in 1:4){
A Simple
Model
pi[i,m] <- p[i,m]/sum(p[i,])
Model
WinBUGS code
}
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
23. State transition
WinBUGS code
Modelling
State
Transitions p[i,1] <- 1
Aur´lien
e
Madouasse
# Code for 2
Background
log(p[i,2]) <- beta[1, i] + beta[2, i] + beta[3, i] + beta[4, i]
Milk Recording
Data
Somatic Cell beta[1, i] <- pstate[i, 1] * theta[1]
Count
beta[2, i] <- pstate[i, 2] * theta[2]
State
Transition
beta[3, i] <- pstate[i, 3] * theta[3]
State Definition beta[4, i] <- pstate[i, 4] * theta[4]
State
Transitions
Data
# Code for 3
A Simple log(p[i,3]) <- beta[5, i]+beta[6, i]+ beta[7, i] + beta[8, i]
Model
Model
WinBUGS code
Results
beta[5, i] <- pstate[i, 1] * theta[5]
Adding
beta[6, i] <- pstate[i, 2] * theta[6]
Complexity beta[7, i] <- pstate[i, 3] * theta[7]
SCC Variation
Model
beta[8, i] <- pstate[i, 4] * gamma
WinBUGS code
Results
24. State transition
WinBUGS code
Modelling
State
Transitions # Code for 4
Aur´lien
e log(p[i,4]) <- beta[9, i]+ beta[10, i] + beta[11, i] +
Madouasse
beta[12, i]
Background
Milk Recording beta[9, i] <- pstate[i, 1] * theta[8]
Data
Somatic Cell beta[10, i] <- pstate[i, 2] * theta[9]
Count
beta[11, i] <- pstate[i, 3] * gamma
State
Transition
beta[12, i] <- pstate[i, 4] * gamma
State Definition }
State
Transitions
Data
# Priors for fixed effects
A Simple
Model
for(k in 1:9) {
Model theta[k] ~ dnorm(0, .001)
WinBUGS code
Results
}
Adding
Complexity gamma <- -2000
SCC Variation
Model }
WinBUGS code
Results
25. State transition
Results
Modelling
State
Transitions
Aur´lien
e
Madouasse
Background
Milk Recording
Data
Somatic Cell
Count
State
Transition
State Definition
State
Transitions
Data
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
26. State transition
Results
Modelling
State
Transitions
Aur´lien
e
Madouasse
Background
Milk Recording
Data
Somatic Cell
p1 = 1
Count
log (p2 ) = Ipst1 ∗ θ1 + Ipst2 ∗ θ2 + Ipst3 ∗ θ3 + Ipst4 ∗ θ4
State
Transition log (p3 ) = Ipst1 ∗ θ5 + Ipst2 ∗ θ6 + Ipst3 ∗ θ7 + Ipst4 ∗ γ
State Definition
State log (p4 ) = Ipst1 ∗ θ8 + Ipst2 ∗ θ9 + Ipste3 ∗ γ + Ipst4 ∗ γ
Transitions
Data
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
27. State transition
Results
Modelling
State
Transitions
Aur´lien
e
Madouasse Median Ci2.5 Ci97.5
Background theta[1] -2.04 -2.06 -2.00
Milk Recording
Data
theta[2] 0.80 0.76 0.83
Somatic Cell
Count theta[3] -1.27 -1.35 -1.19
State theta[4] -1.52 -1.68 -1.36
Transition
State Definition theta[5] -2.71 -2.75 -2.67
State
Transitions
Data
theta[6] -0.79 -0.84 -0.73
A Simple theta[7] 0.81 0.77 0.86
Model
Model
theta[8] -3.95 -4.02 -3.88
WinBUGS code
Results
theta[9] -1.55 -1.63 -1.48
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
28. State transition
Results
Modelling
State
Transitions
p1 = 1
Aur´lien
e
Madouasse log (p2 ) = Ipst1 ∗−2.04+Ipst2 ∗0.80+Ipst3 ∗−1.27+Ipst4 ∗−1.52
Background
log (p3 ) = Ipst1 ∗−2.71+Ipst2 ∗−0.79+Ipst3 ∗0.81+Ipst4 ∗−2000
Milk Recording
Data
log (p4 ) = Ipst1 ∗ −3.95 + Ipst2 ∗ −1.55 + Ipst3 ∗ γ + Ipst4 ∗ −2000
Somatic Cell
Count
State
Transition
State Definition
State
Transitions
Data
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
29. State transition
Results
Modelling
State
Transitions
Aur´lien
e
Madouasse p1 = 1
Background
log (p2 ) = −2.04
Milk Recording log (p3 ) = −2.71
Data
Somatic Cell
Count
log (p4 ) = −3.95
State
Transition
State Definition
State
Transitions
Data
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
30. State transition
Results
Modelling
State
Transitions
Aur´lien
e
Madouasse p1 = 1
Background
log (p2 ) = −2.04
Milk Recording log (p3 ) = −2.71
Data
Somatic Cell
Count
log (p4 ) = −3.95
State
Transition
State Definition
State
Transitions
Data
Σ p = p1 + p2 + p3 + p4
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
31. State transition
Results
Modelling
State
Transitions
Aur´lien
e
Madouasse p1 = 1
Background
log (p2 ) = −2.04
Milk Recording log (p3 ) = −2.71
Data
Somatic Cell
Count
log (p4 ) = −3.95
State
Transition
State Definition
State
Transitions
Data
Σp = 1 + e −2.04 + e −2.71 + e −3.95
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
32. State transition
Results
Modelling
State
Transitions
Aur´lien
e
Madouasse p1 = 1
Background
log (p2 ) = −2.04
Milk Recording log (p3 ) = −2.71
Data
Somatic Cell
Count
log (p4 ) = −3.95
State
Transition
State Definition
State
Transitions
Data
Σp = 1 + 0.13 + 0.07 + 0.02
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
33. State transition
Results
Modelling
State
Transitions
Aur´lien
e
Madouasse p1 = 1
Background
log (p2 ) = −2.04
Milk Recording log (p3 ) = −2.71
Data
Somatic Cell
Count
log (p4 ) = −3.95
State
Transition
State Definition
State
Transitions
Data
Σp = 1.22
A Simple
Model
Model
WinBUGS code
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
34. State transition
Results
Modelling
State
Transitions
Aur´lien
e
Madouasse
p1 = 1
log (p2 ) = −2.04
Background
Milk Recording log (p3 ) = −2.71
Data
Somatic Cell log (p4 ) = −3.95
Count
State
Transition
State Definition
State
Transitions
Σp = 1.22
Data
A Simple
Model
Model p1 p2 p3 p4
WinBUGS code π1 = Σp π2 = Σp π3 = Σp π4 = Σp
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
35. State transition
Results
Modelling
State
Transitions
Aur´lien
e
Madouasse
p1 = 1
log (p2 ) = −2.04
Background
Milk Recording
log (p3 ) = −2.71
Data
Somatic Cell log (p4 ) = −3.95
Count
State
Transition
State Definition
State
Transitions
Σp = 1.22
Data
A Simple
Model
Model 1 e −2.04 e −2.71 e −3.95
WinBUGS code π1 = 1.22 π2 = 1.22 π3 = 1.22 π4 = 1.22
Results
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
36. State transition
Results
Modelling
State
Transitions
Aur´lien
e
Madouasse p1 = 1
Background
log (p2 ) = −2.04
Milk Recording log (p3 ) = −2.71
Data
Somatic Cell
Count
log (p4 ) = −3.95
State
Transition
State Definition
State
Transitions
Data
Σp = 1.22
A Simple
Model
Model
WinBUGS code
Results π1 = 0.82 π2 = 0.11 π3 = 0.05 π4 = 0.02
Adding
Complexity
SCC Variation
Model
WinBUGS code
Results
37. State transition
Results
Modelling
State
Transitions
State Probability of transition
Aur´lien
e
Previous
Current
Madouasse Credibility
Interval
Background n Observed Median 2.5 % 97.5 %
Milk Recording Low Low 37,259 0.822 0.822 0.819 0.825
Data
Somatic Cell
Low High 4,870 0.107 0.107 0.105 0.110
Count Low dry 2,487 0.055 0.055 0.053 0.057
State Low culled 720 0.016 0.016 0.015 0.017
Transition High Low 3,770 0.258 0.257 0.251 0.264
State Definition
State High High 8,349 0.570 0.570 0.563 0.579
Transitions High dry 1,718 0.117 0.117 0.113 0.123
Data
High culled 798 0.055 0.054 0.051 0.058
A Simple
Model
dry Low 2,647 0.283 0.283 0.274 0.292
Model dry High 745 0.080 0.079 0.075 0.085
WinBUGS code dry dry 5,967 0.638 0.638 0.627 0.646
Results
first Low 863 0.820 0.821 0.797 0.842
Adding first High 189 0.180 0.179 0.158 0.203
Complexity
SCC Variation
Model
WinBUGS code
Results
38. Outline
Modelling
State 1 Background
Transitions Milk Recording
Aur´lien
e Data
Madouasse Somatic Cell Count
Background 2 State Transition
Milk Recording State Definition
Data
Somatic Cell State Transitions
Count Data
State
Transition 3 A Simple Model
State Definition Model
State
Transitions WinBUGS code
Data Results
A Simple
Model 4 Adding Complexity
Model SCC Variation
WinBUGS code
Results Model
Adding
WinBUGS code
Complexity Results
SCC Variation
Model 5 Discussion
WinBUGS code
Results