-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNY.Rmd
115 lines (81 loc) · 3.32 KB
/
NY.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
---
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)
NY_cases <- read_csv("C:/Users/ignac/OneDrive - Universidad de Chile/Escritorio/Modelamietno Matematico/Chaos-Presence-SARS-CoV-II/NY_cases")
NY_deaths <- read_csv("C:/Users/ignac/OneDrive - Universidad de Chile/Escritorio/Modelamietno Matematico/Chaos-Presence-SARS-CoV-II/NY_deaths")
NY_cases = NY_cases[[1]]
NY_deaths = NY_deaths[[1]]
windows()
lm <- 40
mutual_NY_cases = mutual(NY_cases, lag.max=lm)
windows()
lm <- 40
mutual_NY_deaths = mutual(NY_deaths, lag.max=lm)
# Lo pasamos a csv para trabajar en python
df <- data.frame(mutual_NY_cases = as.vector(mutual_NY_cases),
mutual_NY_deaths = as.vector(mutual_NY_deaths))
write.csv(df,"C:\\Users\\ignac\\OneDrive - Universidad de Chile\\Escritorio\\Modelamietno Matematico\\Chaos-Presence-SARS-CoV-II\\data_para_R\\AMI_NY.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=NY_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=NY_deaths,embedding.dim=3,time.lag=9,
time.step=1,number.time.steps=50, numberPercentages=10,do.plot=TRUE,
main="",xlab="Separation in time",ylab="Separation in space")
# da nada claro (usamos 13)
```
```{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<- 12 # Theiler window
rt<- 20 # escape factor
eps<- sd(NY_cases)/12 # neighbourhood diameter
fn_NY_cases <- false.nearest(NY_cases,m.max,d,tw,rt,eps)
fn_NY_cases
plot(fn_NY_cases) # da una dimension de inmersion m = 3
windows()
m.max<- 6 # embedding dimensions: from 1 to m_max
d<- 9 # tentative time delay (see below)
tw<- 13 # Theiler window
rt<- 10 # escape factor
eps<- sd(NY_deaths)/12 # neighbourhood diameter
fn_NY_deaths <- false.nearest(NY_deaths,m.max,d,tw,rt,eps)
fn_NY_deaths
plot(fn_NY_deaths) # da una dimension de inmersion m = 4
```
```{r}
# Calculemos los MCLE
windows()
S_nu_NY_cases <- lyap_k(NY_cases,m=3,d=5,t=12,k=4,ref=250,s=50,eps=0.3)
plot(S_nu_NY_cases,xlab = expression(paste(nu)),ylab=expression(paste("S",(nu))))
S_nu_NY_cases = as.vector(S_nu_NY_cases)
windows()
S_nu_NY_deaths <- lyap_k(NY_deaths,m=3,d=9,t=13,k=2,ref=250,s=50,eps=0.2)
plot(S_nu_NY_deaths,xlab = expression(paste(nu)),ylab=expression(paste("S",(nu))))
S_nu_NY_deaths = as.vector(S_nu_NY_deaths)
```
```{r}
df_S_nu_NY <- data.frame(S_nu_NY_cases = as.vector(S_nu_NY_cases),
S_nu_NY_deaths = as.vector(S_nu_NY_deaths))
write.csv(df_S_nu_NY,"C:\\Users\\ignac\\OneDrive - Universidad de Chile\\Escritorio\\Modelamietno Matematico\\Chaos-Presence-SARS-CoV-II\\data_para_R\\S_nu_NY.csv", row.names = FALSE)
```