-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTEMPERATURAS.R
136 lines (109 loc) · 5.36 KB
/
TEMPERATURAS.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#ARCHIVOS PARA CORRELACIÓN ENTRE TEMPERATURA Y MUNICIPIO
#SALTILLO
library(readxl)
#DATOS MENSUALES
saltillo<-read_xlsx("H:/INVESTIGACION/SUICIDIO/TEMPSALTILLO.xlsx")
tempsaltillo<-data.frame(saltillo$Promedio, saltillo$Suicides)
corrsaltillo<-cor(tempsaltillo$saltillo.Promedio,
tempsaltillo$saltillo.Suicides)
torreon<-read_xlsx("H:/INVESTIGACION/SUICIDIO/TEMPTORREON.xlsx")
temptorreon<-data.frame(torreon$Promedio, torreon$Suicides)
corrtorreon<-cor(temptorreon)
#(temptorreon$torreon.Promedio, temptorreon$torreon.Suicides)
ramos<-read_xlsx("H:/INVESTIGACION/SUICIDIO/TEMPRAMOS.xlsx")
tempramos<-data.frame(ramos$Suicides, ramos$Promedio)
corrramos<-cor(tempramos$ramos.Suicides, tempramos$ramos.Promedio)
monclova<-read_xlsx("H:/INVESTIGACION/SUICIDIO/TEMPMONCLOVA.xlsx")
tempmonclova<-data.frame(monclova$Suicides, monclova$Promedio)
corrmonclova<-cor(tempmonclova)
piedras<-read_xlsx("H:/INVESTIGACION/SUICIDIO/TEMPPIEDRAS.xlsx")
temppiedras<-data.frame(piedras$Promedio, piedras$Suicides)
corrpiedras<-cor(temppiedras)
frontera<-read_xlsx("H:/INVESTIGACION/SUICIDIO/TEMPFRONTERA.xlsx")
tempfrontera<-data.frame(frontera$Promedio, frontera$Suicides)
corrfrontera<-cor(tempfrontera)
matamoros<-read_xlsx("H:/INVESTIGACION/SUICIDIO/TEMPMATAMOROS.xlsx")
tempmatamoros<-data.frame(matamoros$Promedio, matamoros$Suicides)
corrmatamoros<-cor(tempmatamoros)
muzquiz<-read_xlsx("H:/INVESTIGACION/SUICIDIO/TEMPMUZQUIZ.xlsx")
tempmuzquz<-data.frame(muzquiz$Promedio, muzquiz$Suicides)
corrmuzquiz<-cor(tempmuzquz)
acuña<-read_xlsx("H:/INVESTIGACION/SUICIDIO/TEMPACUÑA.xlsx")
tempacuña<-data.frame(acuña$Promedio,acuña$Suicides)
corracuña<-cor(tempacuña)
sanpedro<-read_xlsx("H:/INVESTIGACION/SUICIDIO/TEMPSANPEDRO.xlsx")
tempsanpedro<-data.frame(sanpedro$Promedio, sanpedro$Suicides)
cor(tempsanpedro)
corrsanpedro<-cor.test(tempsanpedro$sanpedro.Promedio,
tempsanpedro$sanpedro.Suicides)
coahuila<-read_xlsx("H:/INVESTIGACION/SUICIDIO/TEMPERATURAS.xlsx")
temperaturas<-data.frame(coahuila$Suicides, coahuila$Promedio)
corrgeneral<-cor(temperaturas)
library(lmtest)
#LA NULA ES QUE NO CAUSA
causalidadgeneral<-grangertest(coahuila$Suicides
~ coahuila$Promedio,
data = temperaturas,
order = 2)
#NO CAUSA NI EXAGERANDO LOS REZAGOS
causalidadsaltillo<-grangertest(tempsaltillo$saltillo.Suicides
~tempsaltillo$saltillo.Promedio)
causalidadtorreon<-grangertest(temptorreon$torreon.Suicides
~temptorreon$torreon.Promedio,
order = 4)
causalidadmonclovaa<-grangertest(tempmonclova$monclova.Suicides
~tempmonclova$monclova.Promedio,
order = 4)
#CAUSA CON ORDEN 6 AL 10%
causalidadramos<-grangertest(tempramos$ramos.Suicides
~tempramos$ramos.Promedio,
order = 6)
#CAUSA AL 10 CON ORDEN 4
causalidadpiedras<-grangertest(temppiedras$piedras.Suicides
~temppiedras$piedras.Promedio,
order = 4)
#ESTE CAUSA DESDE EL ORDEN 1
causalidadacuña<-grangertest(tempacuña$acuña.Suicides
~tempacuña$acuña.Promedio,
order = 1)
#causa con orden 10 al 10
causalidadmuzquiz<-grangertest(tempmuzquz$muzquiz.Suicides
~tempmuzquz$muzquiz.Promedio,
order = 10)
#ESTE SIEMPRE CAUSA
causalidadfrontera<-grangertest(tempfrontera$frontera.Suicides
~tempfrontera$frontera.Promedio,
order = 1)
#ESTE CAUSA EN EL ORDEN 5
causalidadmatamoros<-grangertest(tempmatamoros$matamoros.Suicides
~tempmatamoros$matamoros.Promedio,
order = 5)
#este causa desde el 1
causalidadsanpedro<-grangertest(tempsanpedro$sanpedro.Suicides~
tempsanpedro$sanpedro.Promedio,
order = 1)
col <- colorRampPalette(c("#BB4444", "#EE9988", "#FFFFFF", "#77AADD", "#4477AA"))
library(corrplot)
cor(temperaturas)
corrplot(corrgeneral, method="shade",
shade.col = NA, tl.col = "black", tl.srt = 45,
addCoef.col = "black",
cl.pos = "n", order = "AOE")
matrizcorrelaciones<-matrix(c(corracuña, corrfrontera,
corrmatamoros, corrmonclova,
corrmuzquiz, corrpiedras,
corrsanpedro$estimate,
corrtorreon$estimate, corrramos,
corrsaltillo))
nombres<-c("Acuña", "Frontera", "Matamoros",
"Monclova", "Muzquiz", "Piedras Negras",
"San Pedro", "Torreón", "Ramos Arizpe",
"Saltillo")
corrplot(matrizcorrelaciones, method="shade",
type = "lower",
tl.col = "black", tl.srt = 45, diag = FALSE,
cl.pos = "n", addCoef.col = "black",
addCoefasPercent = TRUE, p.mat = NULL,
col = colorRampPalette(c("#FAD4D4", "#F7A3A3", "#FF0000"))(100),
title = "Correlaciones", tl.cex = 0.8, tl.offset = 1,
mar = c(1, 1, 2, 1))