-
Notifications
You must be signed in to change notification settings - Fork 0
/
TweakedDefault.R
170 lines (118 loc) · 3.69 KB
/
TweakedDefault.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
library(deSolve)
library(rootSolve)
library(tidyverse)
ss_SI_dyn <- function(t, var, par) {
Sc <- var[1]
Sb <- var[2]
Ic <- var[3]
Ib <- var[4]
ss_u = par[[1]]
ss_v = par[[2]]
ss_removal = par[[3]]
beta = par[[4]]
Nc <- Sc + Ic
Nb <- Sb + Ib
S <- matrix(c(Sc, Sb))
I <- matrix(c(Ic, Ib))
Sdiag <- diag(c(Sc, Sb))
IdivN <- matrix(c((Ic/Nc), (Ib/Nb)))
N <- matrix(c(Nc, Nb))
dS <- (ss_u %*% N) + ss_removal %*% I - (Sdiag %*% beta %*% IdivN) - (ss_v %*% S)
dI <- (Sdiag %*% beta %*% IdivN) - ((ss_removal+ss_v) %*% I)
return(list(c(dS, dI)))
}
beta_scenarios = function(scenario) {
if (scenario == 1) {
betaCC <- 0.94*(0.7+vc)
betaBC <- 0.05*(vb)
betaCB <- 0.2*(0.7+vc)
betaBB <- 0.99*(vb)
## default scenario as argued by EBP & Wood (2015)
}
if (scenario == 2) {
betaCC <- 0.99*(0.7+vc)
betaBC <- 0.05*(vb)
betaCB <- 0.05*(0.7+vc)
betaBB <- 1.04*(vb)
## badger reservoir, with low inter-host transmission
}
if (scenario == 3) {
betaCC <- 1.04*(0.7+vc)
betaBC <- 0.05*(vb)
betaCB <- 0.05*(0.7+vc)
betaBB <- 0.99*(vb)
## cattle reservoir, with low inter-host transmission
}
if (scenario == 4) {
betaCC <- 0.94*(0.7+vc)
betaBC <- 0.14*(vb)
betaCB <- 0.07*(0.7+vc)
betaBB <- 0.99*(vb)
## van Tonder scenario
}
beta <- matrix(c(betaCC, betaBC, betaCB, betaBB), 2, 2, byrow = TRUE)
return(beta)
}
init_prevalence = function(scenario) {
#initial prevalence according to steady-state analysis
if (scenario==1) {
# default scenario
I0c = 0.01717
I0b = 0.1064
}
if (scenario==2) {
#badger reservoir scenario
I0c = 0.029
I0b = 0.093
}
if (scenario==3) {
#cattle reservoir scenario
I0c = 0.0576
I0b = 0.0976
}
if (scenario==4) {
#van Tonder scenario
I0c = 0.0324
I0b = 0.0866
}
return(c(I0c, I0b))
}
N0c <- 1
N0b <- 1
scenario = 4
ss_I0c = init_prevalence(scenario)[1]
ss_I0b = init_prevalence(scenario)[2]
uc <- 0.1
## birth rate of cattle = birth rate (constant population size)
ub <- 0.2
## birth rate of badgers = birth rate (constant population size)
vc <- 0.1
## death rate of cattle = birth rate (constant population size)
vb <- 0.2
## death rate of badgers = birth rate (constant population size)
tau <- 0.7
## removal rate of infected cattle
## assumes DIVA test has equal efficacy in vaccinated and unvaccinated cattle
beta <- beta_scenarios(scenario)
## 2x2 matrix for values of beta not including effects of vaccination
ss_u <- diag(c(uc, ub))
ss_v <- diag(c(vc, vb))
ss_removal <- diag(c(tau, 0))
ss_SI.par <- list(ss_u, ss_v, ss_removal, beta)
ss_SI.init <- c(N0c - ss_I0c,
N0b - ss_I0b,
ss_I0c, ss_I0b)
SI.t <- seq(0, 100, by = 1/364)
ss_SI.sol <- lsoda(ss_SI.init, SI.t, ss_SI_dyn, ss_SI.par)[,c(1,4,5)]
colnames(ss_SI.sol) = c("Time", "Cattle", "Badgers")
df_ss_SI.sol = as.data.frame(ss_SI.sol)
df_ss_SI.sol = pivot_longer(df_ss_SI.sol,
cols = c("Cattle","Badgers"),
names_to = "Species",
values_to = "Proportion")
ggplot(df_ss_SI.sol, aes(x=Time, y =Proportion, colour = Species))+
geom_line()+
labs(x= "Time (years)",
y = "Proportion infected")
RS = steady(y=ss_SI.init,func=ss_SI_dyn,parms = ss_SI.par,method='runsteady')
RS$y[c(3,4)]