-
Notifications
You must be signed in to change notification settings - Fork 0
/
FR.Rmd
231 lines (152 loc) · 6.72 KB
/
FR.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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
---
title: "R Notebook"
output: html_notebook
---
```{r}
library("tseriesChaos", lib.loc="C:/Users/ignac/anaconda3/envs/rstudio/lib/R/library")
require(scatterplot3d)
library("dplyr", lib.loc="C:/Users/ignac/anaconda3/envs/rstudio/lib/R/library")
library("dplyr", lib.loc="C:/Users/ignac/anaconda3/envs/rstudio/lib/R/library")
library(readr)
```
```{r}
library(readr)
FR_cases <- read_csv("C:/Users/ignac/OneDrive - Universidad de Chile/Escritorio/Modelamietno Matematico/Chaos-Presence-SARS-CoV-II/FR_cases")
FR_deaths <- read_csv("C:/Users/ignac/OneDrive - Universidad de Chile/Escritorio/Modelamietno Matematico/Chaos-Presence-SARS-CoV-II/FR_deaths")
FR_cases = FR_cases[[1]]
FR_deaths = FR_deaths[[1]]
windows()
lm <- 40
mutual_BE_cases = mutual(FR_cases, lag.max=lm)
windows()
lm <- 40
mutual_BE_deaths = mutual(FR_deaths, lag.max=lm)
# Lo pasamos a csv para trabajar en python
df <- data.frame(mutual_FR_cases = as.vector(mutual_FR_cases),
mutual_FR_deaths = as.vector(mutual_FR_deaths))
write.csv(df,"C:\\Users\\ignac\\OneDrive - Universidad de Chile\\Escritorio\\Modelamietno Matematico\\Chaos-Presence-SARS-CoV-II\\data_para_R\\AMI_FR.csv", row.names = FALSE)
```
```{r}
# Veamos una estimacion de la Theiler Window
library("nonlinearTseries", lib.loc="C:/Users/ignac/anaconda3/envs/rstudio/lib/R/library")
windows()
require(nonlinearTseries)
spaceTimePlot(time.series=FR_cases,embedding.dim=3,time.lag=5,
time.step=1,number.time.steps=50, numberPercentages=10,do.plot=TRUE,
main="",xlab="Separation in time",ylab="Separation in space")
# da 12
windows()
require(nonlinearTseries)
spaceTimePlot(time.series=FR_deaths,embedding.dim=3,time.lag=8,
time.step=1,number.time.steps=50, numberPercentages=10,do.plot=TRUE,
main="",xlab="Separation in time",ylab="Separation in space")
# da 12
```
```{r}
# Calculamos la dimension con FNN
windows()
m.max<- 6 # embedding dimensions: from 1 to m_max
d<- 5 # tentative time delay (see below)
tw<- 13 # Theiler window
rt<- 20 # escape factor
eps<- sd(FR_cases)/12 # neighbourhood diameter
fn_FR_cases <- false.nearest(FR_cases,m.max,d,tw,rt,eps)
fn_FR_cases
plot(fn_FR_cases) # da una dimension de inmersion m = 3
windows()
m.max<- 6 # embedding dimensions: from 1 to m_max
d<- 8 # tentative time delay (see below)
tw<- 13 # Theiler window
rt<- 10 # escape factor
eps<- sd(FR_deaths)/4 # neighbourhood diameter
fn_FR_deaths <- false.nearest(FR_deaths,m.max,d,tw,rt,eps)
fn_FR_deaths
plot(fn_FR_deaths) # da una dimension de inmersion m = 4
```
```{r}
# Calculemos los MCLE
windows()
S_nu_FR_cases <- lyap_k(FR_cases,m=3,d=5,t=12,k=4,ref=250,s=50,eps=0.3)
plot(S_nu_FR_cases,xlab = expression(paste(nu)),ylab=expression(paste("S",(nu))))
S_nu_FR_cases = as.vector(S_nu_FR_cases)
windows()
S_nu_FR_deaths <- lyap_k(FR_deaths,m=3,d=5,t=12,k=4,ref=250,s=50,eps=0.3)
plot(S_nu_FR_deaths,xlab = expression(paste(nu)),ylab=expression(paste("S",(nu))))
S_nu_FR_deaths = as.vector(S_nu_FR_deaths)
```
```{r}
df_S_nu_FR <- data.frame(S_nu_FR_cases = as.vector(S_nu_FR_cases),
S_nu_FR_deaths = as.vector(S_nu_FR_deaths))
write.csv(df_S_nu_FR,"C:\\Users\\ignac\\OneDrive - Universidad de Chile\\Escritorio\\Modelamietno Matematico\\Chaos-Presence-SARS-CoV-II\\data_para_R\\S_nu_FR.csv", row.names = FALSE)
```
```{r}
ssa_FR_cases <- read_csv("C:/Users/ignac/OneDrive - Universidad de Chile/Escritorio/Modelamietno Matematico/Chaos-Presence-SARS-CoV-II/ssa_FR_cases")
#SCL_cases = SCL_cases[[1]]
#CL_cases = CL_cases[[1]]
#SCL_cases_icovid = SCL_cases_icovid[[1]]
#SFR_cases = SFR_cases[[1]]
ssa_FR_cases = ssa_FR_cases[[1]]
```
```{r}
# Calculemos los MCLE de SSA
windows()
S_nu_ssa_FR_cases <- lyap_k(ssa_FR_cases,m=3,d=5,t=12,k=4,ref=250,s=50,eps=0.3)
plot(S_nu_ssa_FR_cases,xlab = expression(paste(nu)),ylab=expression(paste("S",(nu))))
S_nu_ssa_FR_cases = as.vector(S_nu_ssa_FR_cases)
```
```{r}
ssa_FR_deaths <- read_csv("C:/Users/ignac/OneDrive - Universidad de Chile/Escritorio/Modelamietno Matematico/Chaos-Presence-SARS-CoV-II/ssa_FR_deaths")
#SFR_cases = SFR_cases[[1]]
#FR_cases = FR_cases[[1]]
#SFR_cases_icovid = SFR_cases_icovid[[1]]
#SFR_deaths = SFR_deaths[[1]]
ssa_FR_deaths = ssa_FR_deaths[[1]]
```
```{r}
# Calculemos los MCLE de SSA
windows()
S_nu_ssa_FR_deaths <- lyap_k(ssa_FR_deaths,m=3,d=5,t=12,k=4,ref=250,s=50,eps=0.3)
plot(S_nu_ssa_FR_deaths,xlab = expression(paste(nu)),ylab=expression(paste("S",(nu))))
S_nu_ssa_FR_deaths = as.vector(S_nu_ssa_FR_deaths)
```
```{r}
df_S_nu_ssa_FR <- data.frame(#S_nu_SFR_cases = as.vector(S_nu_SFR_cases),
S_nu_ssa_FR_cases = as.vector(S_nu_ssa_FR_cases),
#S_nu_SFR_cases_icovid = as.vector(S_nu_SFR_cases_icovid),
#S_nu_SFR_deaths = as.vector(S_nu_SFR_deaths),
S_nu_ssa_FR_deaths = as.vector(S_nu_ssa_FR_deaths))
write.csv(df_S_nu_ssa_FR,"C:\\Users\\ignac\\OneDrive - Universidad de Chile\\Escritorio\\Modelamietno Matematico\\Chaos-Presence-SARS-CoV-II\\data_para_R\\S_nu_ssa_FR.csv", row.names = FALSE)
```
```{r}
trend_FR_cases <- read_csv("C:/Users/ignac/OneDrive - Universidad de Chile/Escritorio/Modelamietno Matematico/Chaos-Presence-SARS-CoV-II/trend_FR_cases")
#SCL_cases = SCL_cases[[1]]
#CL_cases = CL_cases[[1]]
#SCL_cases_icovid = SCL_cases_icovid[[1]]
#SFR_cases = SFR_cases[[1]]
trend_FR_cases = trend_FR_cases[[1]]
```
```{r}
# Obtenemos el MCLE de la tendencia obtenida mediante Hodrick–Prescott decomposition
# Calculemos los MCLE de SSA
windows()
S_nu_trend_FR_cases <- lyap_k(trend_FR_cases,m=3,d=5,t=12,k=4,ref=250,s=50,eps=0.3)
plot(S_nu_trend_FR_cases,xlab = expression(paste(nu)),ylab=expression(paste("S",(nu))))
S_nu_trend_FR_cases = as.vector(S_nu_trend_FR_cases)
trend_FR_deaths <- read_csv("C:/Users/ignac/OneDrive - Universidad de Chile/Escritorio/Modelamietno Matematico/Chaos-Presence-SARS-CoV-II/trend_FR_deaths")
trend_FR_deaths = trend_FR_deaths[[1]]
```
```{r}
# Calculemos los MCLE de SSA
windows()
S_nu_trend_FR_deaths <- lyap_k(trend_FR_deaths,m=3,d=5,t=12,k=4,ref=250,s=50,eps=0.3)
plot(S_nu_trend_FR_deaths,xlab = expression(paste(nu)),ylab=expression(paste("S",(nu))))
S_nu_trend_FR_deaths = as.vector(S_nu_trend_FR_deaths)
```
```{r}
df_S_nu_trend_FR <- data.frame(#S_nu_SFR_cases = as.vector(S_nu_SFR_cases),
S_nu_trend_FR_cases = as.vector(S_nu_trend_FR_cases),
#S_nu_SFR_cases_icovid = as.vector(S_nu_SFR_cases_icovid),
#S_nu_SFR_deaths = as.vector(S_nu_SFR_deaths),
S_nu_trend_FR_deaths = as.vector(S_nu_trend_FR_deaths))
write.csv(df_S_nu_ssa_FR,"C:\\Users\\ignac\\OneDrive - Universidad de Chile\\Escritorio\\Modelamietno Matematico\\Chaos-Presence-SARS-CoV-II\\data_para_R\\S_nu_trend_FR.csv", row.names = FALSE)
```