-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimulationsSecondRound.Rmd
120 lines (85 loc) · 3.07 KB
/
SimulationsSecondRound.Rmd
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
---
title: "Simulations II - fixed mixing"
output: html_notebook
---
Different simulations:
```{r}
install.packages("ggplot2")
library("ggplot2")
```
Fixed Parameters:
```{r}
#parameters:
# Recovery rate parameter
r <- 0.8
# Environment virus decay
gamma <- 0.1
# Environment infection parameter
alpha <- ((r*gamma)/(N+1))
# Number of iterations
Iterations <- 20
#size of population
N <- 300
#number of locations
Place <- 3
#contamination levels
contamVec<- c(0.5,1,0.5)
#fix to a medium "mixing level"
probVec <- c(0.3,0.4,0.5)
```
Condition 1: all people distributed over 3 places with no overlap:
```{r}
#vector with probabilities of having additional link to a given location
# Choose the proportion of second degree
# some individuals contact several places;
#probVec[1]: probability of having a second degree at location1; other indices respectivel
beta <- c(1,1,1)
FinalA <- createFinalAMat (N,Place,probVec)
simulationOutputC1_1<- updateFunction (Iterations, FinalA, N, contamVec, r, gamma, beta)
data<- data.frame(Iterations = rep(seq(1,Iterations,1),3),
Vals = c(simulationOutputC1_1 [[1]],simulationOutputC1_1 [[2]],simulationOutputC1_1 [[3]] ),
Type = rep(c("TotalSusceptible", "TotalInfected", "TotalRecovered"), each=20) )
ggplot(data=data, aes(x=Iterations, y=Vals, group=Type)) +
geom_line(aes(linetype=Type, color = Type))+
geom_point()
```
```{r}
beta <- c(0.5,0.4,0.8)
FinalA <- createFinalAMat (N,Place,probVec)
simulationOutputC2_1<- updateFunction (Iterations, FinalA, N, contamVec, r, gamma, beta)
data<- data.frame(Iterations = rep(seq(1,Iterations,1),3),
Vals = c(simulationOutputC2_1 [[1]],simulationOutputC2_1 [[2]],simulationOutputC2_1 [[3]] ),
Type = rep(c("TotalSusceptible", "TotalInfected", "TotalRecovered"), each=20) )
ggplot(data=data, aes(x=Iterations, y=Vals, group=Type)) +
geom_line(aes(linetype=Type, color = Type))+
geom_point()
```
```{r}
```
```{r}
beta <- c(0.1,0.2,0.2)
FinalA <- createFinalAMat (N,Place,probVec)
simulationOutputC3_1<- updateFunction (Iterations, FinalA, N, contamVec, r, gamma,beta)
data<- data.frame(Iterations = rep(seq(1,Iterations,1),3),
Vals = c(simulationOutputC3_1 [[1]],simulationOutputC3_1 [[2]],simulationOutputC3_1 [[3]] ),
Type = rep(c("TotalSusceptible", "TotalInfected", "TotalRecovered"), each=20) )
ggplot(data=data, aes(x=Iterations, y=Vals, group=Type)) +
geom_line(aes(linetype=Type, color = Type))+
geom_point()
```
Plotting the three conditions in one plot. Here only the Total Infected
```{r}
data<- data.frame(Iterations = rep(seq(1,Iterations,1),3),
Vals = c(simulationOutputC1_1 [[2]], simulationOutputC2_1 [[2]], simulationOutputC3_1 [[2]] ),
Type = rep(c("Condition 1", "Condition 2", "Condition3"), each=20) )
ggplot(data=data, aes(x=Iterations, y=Vals, group=Type)) +
geom_line(aes(linetype=Type, color = Type))+
geom_point()
ggsave("SimulationBeta.png")
#Cond1
#beta <- c(1,1,1)
#Cond2
#beta <- c(0.5,0.4,0.8)
#Cond3
#beta <- c(0.1,0.2,0.2)
```