forked from skissler/nCoV_introduction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
invasion_rates.R
116 lines (111 loc) · 4.2 KB
/
invasion_rates.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
# =============================================================================
# Internal functions
# =============================================================================
beta.val <- function(t, amplitude=1, baseline=1.5, phi.val=-4, gamma.val=1){
gamma.val*(amplitude/2 * cos(2*pi*(t-phi.val)/52) + (amplitude/2 + baseline))
}
p1 <- function(t,kappa.val,importtime1,importlength){
ifelse(t>importtime1 & t<=(importtime1+importlength), kappa.val, 0)
}
p2 <- function(t,kappa.val,importtime2,importlength){
ifelse(t>importtime2 & t<=(importtime2+importlength), kappa.val, 0)
}
# =============================================================================
# State update functions
# =============================================================================
S1S2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
beta.val(t,amplitude,baseline,phi.val,gamma.val)*(I1S2+I1E2+I1I2+I1R2)*S1S2 + p1(t,kappa.val,importtime1,importlength)*S1S2
})}
S1S2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
beta.val(t,amplitude,baseline,phi.val,gamma.val)*(S1I2+E1I2+I1I2+R1I2)*S1S2 + p2(t,kappa.val,importtime2,importlength)*S1S2
})}
E1S2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
nu.val*E1S2
})}
E1S2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
(1-chi12.val)*beta.val(t,amplitude,baseline,phi.val,gamma.val)*(S1I2+E1I2+I1I2+R1I2)*E1S2 + (1-chi12.val)*p2(t,kappa.val,importtime2,importlength)*E1S2
})}
S1E2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
(1-chi21.val)*beta.val(t,amplitude,baseline,phi.val,gamma.val)*(I1S2+I1E2+I1I2+I1R2)*S1E2 + (1-chi21.val)*p1(t,kappa.val,importtime1,importlength)*S1E2
})}
S1E2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
nu.val*S1E2
})}
E1E2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
nu.val*E1E2
})}
E1E2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
nu.val*E1E2
})}
I1S2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
gamma.val*I1S2
})}
I1S2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
(1-chi12.val)*beta.val(t,amplitude,baseline,phi.val,gamma.val)*(S1I2+E1I2+I1I2+R1I2)*I1S2 + (1-chi12.val)*p2(t,kappa.val,importtime2,importlength)*I1S2
})}
S1I2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
(1-chi21.val)*beta.val(t,amplitude,baseline,phi.val,gamma.val)*(I1S2+I1E2+I1I2+I1R2)*S1I2 + (1-chi21.val)*p1(t,kappa.val,importtime1,importlength)*S1I2
})}
S1I2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
gamma.val*S1I2
})}
R1S2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
sigma1.val*R1S2
})}
R1S2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
(1-chi12.val)*beta.val(t,amplitude,baseline,phi.val,gamma.val)*(S1I2+E1I2+I1I2+R1I2)*R1S2 + (1-chi12.val)*p2(t,kappa.val,importtime2,importlength)*R1S2
})}
I1E2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
gamma.val*I1E2
})}
I1E2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
nu.val*I1E2
})}
E1I2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
nu.val*E1I2
})}
E1I2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
gamma.val*E1I2
})}
S1R2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
(1-chi21.val)*beta.val(t,amplitude,baseline,phi.val,gamma.val)*(I1S2+I1E2+I1I2+I1R2)*S1R2 + (1-chi21.val)*p1(t,kappa.val,importtime1,importlength)*S1R2
})}
S1R2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
sigma2.val*S1R2
})}
R1E2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
sigma1.val*R1E2
})}
R1E2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
nu.val*R1E2
})}
I1I2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
gamma.val*I1I2
})}
I1I2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
gamma.val*I1I2
})}
E1R2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
nu.val*E1R2
})}
E1R2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
sigma2.val*E1R2
})}
R1I2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
sigma1.val*R1I2
})}
R1I2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
gamma.val*R1I2
})}
I1R2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
gamma.val*I1R2
})}
I1R2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
sigma2.val*I1R2
})}
R1R2c1 <- function(t,y,parms){with(as.list(c(y,parms)),{
sigma1.val*R1R2
})}
R1R2c2 <- function(t,y,parms){with(as.list(c(y,parms)),{
sigma2.val*R1R2
})}