23
23
# ' workshops run by Dr. Krishnamurthy.
24
24
# '
25
25
# ' @param population The initial number of persons in the simulation; if
26
- # ' `vitalDynamics = TRUE` and `muB ` and `muD ` are equal, then it is constant.
26
+ # ' `vitalDynamics = TRUE` and `muBirth ` and `muDeath ` are equal, then it is constant.
27
27
# ' @param susceptible The initial number of people who are susceptible to the
28
28
# ' disease (they have no natural immunity to it).
29
29
# ' @param exposed The initial number of people who have been exposed to the
41
41
# ' @param sigma The rate of becoming recovered (no longer infectious).
42
42
# ' @param delta The rate of fatality.
43
43
# ' @param xi The rate of loss of learned immunity.
44
- # ' @param muB The rate of birth.
45
- # ' @param muD The rate of death not due to the disease under consideration.
44
+ # ' @param muBirth The rate of birth.
45
+ # ' @param muDeath The rate of death not due to the disease under consideration.
46
46
# '
47
47
# ' @param vitalDynamics Whether vital dynamics is enabled (if `FALSE`, the
48
- # ' default, implies muB and muD of zero).
48
+ # ' default, implies muBirth and muDeath of zero).
49
49
# ' @param trueMassAction Whether the force of infection is scaled by the
50
50
# ' population or not.
51
51
# '
78
78
population , susceptible , exposed = 0 , infected , recovered , dead = 0 ,
79
79
80
80
# # Parameters (not alphabetically sorted)
81
- beta , gamma , sigma = 0 , delta = 0 , xi = 0 , muB = 0 , muD = 0 ,
81
+ beta , gamma , sigma = 0 , delta = 0 , xi = 0 , muBirth = 0 , muDeath = 0 ,
82
82
83
83
# # Simulation options
84
84
vitalDynamics = FALSE ,
91
91
variables <- c(population , susceptible , exposed , infected , recovered , dead )
92
92
names(variables ) <- c(" N" , " S" , " E" , " I" , " R" , " D" )
93
93
parameters <- c(beta , gamma , sigma , delta , xi ,
94
- muB * vitalDynamics ,
95
- muD * vitalDynamics )
96
- names(parameters ) <- c(" beta" , " gamma" , " sigma" , " delta" , " xi" , " muB " , " muD " )
94
+ muBirth * vitalDynamics ,
95
+ muDeath * vitalDynamics )
96
+ names(parameters ) <- c(" beta" , " gamma" , " sigma" , " delta" , " xi" , " muBirth " , " muDeath " )
97
97
98
98
# # Prevent lsoda from being called with conflicting argument values.
99
99
if (delta == 0 ) stopifnot(dead == 0 )
@@ -121,21 +121,21 @@ epi <-
121
121
122
122
# # Regardless of exposure
123
123
betaSIN <- beta * ((S * I ) / N ^ trueMassAction )
124
- dS <- c(muB * N , - betaSIN , - muD * S )
124
+ dS <- c(muBirth * N , - betaSIN , - muDeath * S )
125
125
dD <- delta * I # Always zero if delta == 0.
126
126
127
127
# # Define the IR compartments with respect to the E compartment.
128
128
if (sigma == 0 ) {
129
129
# # Without exposure, there is no E compartment. γ has its meaning as
130
130
# # in an SI-type model.
131
- compartments <- list (dI = c((betaSIN ), - (gamma * I ), - (muD * I )),
132
- dR = c((gamma * I ), - (muD * R )))
131
+ compartments <- list (dI = c((betaSIN ), - (gamma * I ), - (muDeath * I )),
132
+ dR = c((gamma * I ), - (muDeath * R )))
133
133
} else {
134
134
# # With exposure, there is is an E compartment. γ has its meaning as
135
135
# # in an SEI-type model.
136
- compartments <- list (dE = c((betaSIN ), - (gamma * E ), - (muD * E )),
137
- dI = c((gamma * E ), - (sigma * I ), - (muD * I )),
138
- dR = c((sigma * I ), - (muD * R )))
136
+ compartments <- list (dE = c((betaSIN ), - (gamma * E ), - (muDeath * E )),
137
+ dI = c((gamma * E ), - (sigma * I ), - (muDeath * I )),
138
+ dR = c((sigma * I ), - (muDeath * R )))
139
139
}
140
140
141
141
# # Enable loss of immunity if xi is non-zero.
@@ -149,7 +149,7 @@ epi <-
149
149
if (delta != 0 ) compartments $ dI <- c(compartments $ dI , - dD )
150
150
151
151
# # NOTE: dD is already equal to its sum, and is not part of the
152
- # # calculation of dN. dN is non-zero if muB != muD. Name dS again; it is
152
+ # # calculation of dN. dN is non-zero if muBirth != muD. Name dS again; it is
153
153
# # helpful while debugging and printing the compartmentSums.
154
154
compartmentSums <- lapply(append(list (dS = dS ), compartments ), sum )
155
155
dN <- Reduce(`+` , compartmentSums )
0 commit comments