Professional Documents
Culture Documents
PROYECTO Estadistica
PROYECTO Estadistica
PROYECTO Estadistica
file.choose()
## # A tibble: 100 x 4
## FECHA CONTAGIOS MUERTES PAIS
## <dttm> <dbl> <dbl> <chr>
## 1 2020-08-01 00:00:00 985 45 Ecuador
## 2 2020-08-02 00:00:00 877 34 Ecuador
## 3 2020-08-03 00:00:00 292 14 Ecuador
## 4 2020-08-04 00:00:00 517 17 Ecuador
## 5 2020-08-05 00:00:00 922 41 Ecuador
## 6 2020-08-06 00:00:00 903 39 Ecuador
## 7 2020-08-07 00:00:00 1671 40 Ecuador
## 8 2020-08-08 00:00:00 1432 10 Ecuador
## 9 2020-08-09 00:00:00 1603 19 Ecuador
## 10 2020-09-01 00:00:00 119 1 Ecuador
## # ... with 90 more rows
#segunda hoja
segunda_hoja=read_excel(ruta_excel,sheet = "Hoja2")
segunda_hoja
## # A tibble: 100 x 4
## FECHA CONTAGIOS MUERTES PAIS
## <dttm> <dbl> <dbl> <chr>
## 1 2020-08-01 00:00:00 7137 195 PERU
## 2 2020-08-02 00:00:00 8466 225 PERU
## 3 2020-08-03 00:00:00 7785 196 PERU
## 4 2020-08-04 00:00:00 7734 221 PERU
## 5 2020-08-05 00:00:00 6790 196 PERU
## 6 2020-08-06 00:00:00 4250 197 PERU
## 7 2020-08-07 00:00:00 6667 206 PERU
## 8 2020-08-08 00:00:00 7448 191 PERU
## 9 2020-08-09 00:00:00 7243 196 PERU
## 10 2020-09-01 00:00:00 3054 72 PERU
## # ... with 90 more rows
#############################################################################
########
#Ecuador
datos_covid_ecu=primera_hoja$CONTAGIOS
datos_covid_ecu
## [1] 985 877 292 517 922 903 1671 1432 1603 119 542 1148 903
815 870
## [16] 261 308 665 1409 1040 1526 1719 2143 317 642 1972 732 1872
1491 799
## [31] 292 932 2249 1254 1329 1506 766 218 784 43 78 62 102
50 34
## [46] 21 41 398 34 13 3 27 17 29 42 51 18 12
8 9
## [61] 49 47 28 14 11 20 15 20 14 10 38 14 8
6 6
## [76] 26 31 54 15 9 10 71 26 31 20 11 8 9
27 21
## [91] 22 44 62 24 39 24 28 42 13 52
prom_contagios_ecu=mean(primera_hoja$CONTAGIOS)
prom_contagios_ecu
## [1] 419.36
prom_muertes_ecu=mean(primera_hoja$MUERTES)
prom_muertes_ecu
## [1] 576.64
median_contagios_ecu=median(primera_hoja$CONTAGIOS)
median_contagios_ecu
## [1] 48
median_muertes_ecu=median(primera_hoja$MUERTES)
median_muertes_ecu
## [1] 467
desv_est_cont_Ecu=sd(primera_hoja$CONTAGIOS)
desv_est_cont_Ecu
## [1] 597.943
desv_est_muerte_Ecu=sd(primera_hoja$MUERTES)
desv_est_muerte_Ecu
## [1] 548.516
cuantil_contag_Ecu= quantile(primera_hoja$CONTAGIOS,c(0.25,0.50,0.75))
cuantil_contag_Ecu
cuantil_muert_Ecu= quantile(primera_hoja$MUERTES,c(0.25,0.50,0.75))
cuantil_muert_Ecu
deciles_contag_Ecu= quantile(primera_hoja$CONTAGIOS,c(0.20,0.40,0.70))
deciles_contag_Ecu
deciles_muert_Ecu= quantile(primera_hoja$MUERTES,c(0.20,0.40,0.70))
deciles_muert_Ecu
histograma_contag_Ecu
## $breaks
## [1] 0 500 1000 1500 2000 2500
##
## $counts
## [1] 68 16 7 7 2
##
## $density
## [1] 0.00136 0.00032 0.00014 0.00014 0.00004
##
## $mids
## [1] 250 750 1250 1750 2250
##
## $xname
## [1] "primera_hoja$CONTAGIOS"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
histograma_muert_Ecu
## $breaks
## [1] 0 200 400 600 800 1000 1200 1400 1600 1800 2000 2200
##
## $counts
## [1] 40 8 6 8 15 6 9 5 1 1 1
##
## $density
## [1] 0.00200 0.00040 0.00030 0.00040 0.00075 0.00030 0.00045 0.00025
0.00005
## [10] 0.00005 0.00005
##
## $mids
## [1] 100 300 500 700 900 1100 1300 1500 1700 1900 2100
##
## $xname
## [1] "primera_hoja$MUERTES"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
cajas_contag_Ecu=boxplot(primera_hoja$CONTAGIOS,horizontal = T,main =
"DIAGRAMA DE CAJAS CONTAGIO ECUADOR",xlab = "CASOS",ylab = "FREQUENCIA")
cajas_contag_Ecu
## $stats
## [,1]
## [1,] 3.0
## [2,] 20.0
## [3,] 48.0
## [4,] 791.5
## [5,] 1872.0
##
## $n
## [1] 100
##
## $conf
## [,1]
## [1,] -73.897
## [2,] 169.897
##
## $out
## [1] 2143 1972 2249
##
## $group
## [1] 1 1 1
##
## $names
## [1] ""
## $stats
## [,1]
## [1,] 1
## [2,] 40
## [3,] 467
## [4,] 979
## [5,] 2021
##
## $n
## [1] 100
##
## $conf
## [,1]
## [1,] 318.638
## [2,] 615.362
##
## $out
## numeric(0)
##
## $group
## numeric(0)
##
## $names
## [1] ""
#tbla_contag_Ecu= nclass.Sturges(primera_hoja$CONTAGIOS)
#tbla_contag_Ecu
#rango_contag_Ecu= range(primera_hoja$CONTAGIOS)
#rango_contag_Ecu
#amplitud_Contag_Ecu=(rango_contag_Ecu[2]-
rango_contag_Ecu[1])/tbla_contag_Ecu
#amplitud_Contag_Ecu
library(fdth)
##
## Attaching package: 'fdth'
tbla_freq_contag_ECU=fdt(primera_hoja$CONTAGIOS,breaks ="Sturges",right = F)
tbla_freq_contag_ECU
tbla_freq_muert_ECU=fdt(primera_hoja$MUERTES,breaks ="Sturges",right = F)
tbla_freq_muert_ECU
tabla_para_barra_contag_ECU<-(tbla_freq_contag_ECU)
tabla_para_barra_contag_ECU
suma_contag_Ecu=primera_hoja$CONTAGIOS
total_contag_Ecu=sum(suma_contag_Ecu)
total_contag_Ecu
## [1] 41936
suma_muert_Ecu=primera_hoja$MUERTES
total_muert_Ecu=sum(suma_muert_Ecu)
total_muert_Ecu
## [1] 57664
poblacion_Ecu=17643060
poblacion_Ecu
## [1] 17643060
proporcion_contag_Ecu=total_contag_Ecu/poblacion_Ecu
proporcion_contag_Ecu
## [1] 0.002376912
proporcion_muert_Ecu=total_muert_Ecu/poblacion_Ecu
proporcion_muert_Ecu
## [1] 0.003268367
tabla_contag_Ecu=table(primera_hoja$CONTAGIOS)
tabla_contag_Ecu
##
## 3 6 8 9 10 11 12 13 14 15 17 18 20 21 22
24
## 1 2 3 3 2 2 1 2 3 2 1 1 3 2 1
2
## 26 27 28 29 31 34 38 39 41 42 43 44 47 49 50
51
## 2 2 2 1 2 2 1 1 1 2 1 1 1 1 1
1
## 52 54 62 71 78 102 119 218 261 292 308 317 398 517 542
642
## 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1
1
## 665 732 766 784 799 815 870 877 903 922 932 985 1040 1148 1254
1329
## 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1
1
## 1409 1432 1491 1506 1526 1603 1671 1719 1872 1972 2143 2249
## 1 1 1 1 1 1 1 1 1 1 1 1
##
## 1 5 6 10 14 15 17 19 23 26 28 29 31 32 33
34
## 2 1 2 1 1 2 1 2 1 1 1 1 1 1 2
1
## 37 39 40 41 42 45 48 50 51 52 74 80 87 134 205
282
## 1 2 2 2 1 2 2 1 1 1 1 1 1 1 1
1
## 301 305 350 362 368 381 428 442 492 543 548 594 668 683 692
717
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1
## 725 763 767 794 803 817 826 845 856 867 883 908 912 919 950
953
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1
## 978 980 996 1002 1014 1036 1045 1146 1161 1208 1277 1298 1299 1323 1344
1375
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1
## 1394 1396 1421 1475 1510 1514 1537 1716 1819 2021
## 1 1 1 1 1 1 1 1 1 1
diagramaB_muert_Ecu=barplot(tabla_muert_Ecu,main ="DIAGRAMA DE BARRAS MUERTES
ECUADOR",xlab = "NUMERO DE MUERTES")
dispersion_Ecu=plot(primera_hoja$MUERTES,primera_hoja$CONTAGIOS,main =
"DIAGRAMA DE DISPERSION ECUADOR",xlab = "MUERTES",ylab = "CONTAGIOS")
#############################################################################
#############################################################################
####################
#Peru
datos_covid_peru=segunda_hoja$CONTAGIOS
datos_covid_peru
## [1] 7137 8466 7785 7734 6790 4250 6667 7448 7243 3054 3412 5160 5558
5654 6235
## [16] 6149 3650 4001 6030 6453 6314 5698 6380 4160 4241 6787 6162 6603
7291 6586
## [31] 4615 1598 6275 6854 6703 6708 6308 5092 4871 3061 3468 3267 3421
3184 1830
## [46] 2930 2733 2952 4741 2733 3283 1800 2803 2977 2789 2677 3132 3126
2201 3242
## [61] 2767 2991 3240 3098 2501 1859 1923 2431 2666 2586 2323 2408 1634
2357 2885
## [76] 2935 2781 2507 2323 1194 1904 2575 2231 2413 2249 2112 1257 1663
2020 1966
## [91] 2170 1994 1589 887 1882 2020 1888 1977 2044 2162
prom_contagios_peru=mean(segunda_hoja$CONTAGIOS)
prom_contagios_peru
## [1] 3788.84
prom_muertes_peru=mean(segunda_hoja$MUERTES)
prom_muertes_peru
## [1] 89.58
median_contagios_peru=median(segunda_hoja$CONTAGIOS)
median_contagios_peru
## [1] 3022.5
median_muertes_peru=median(segunda_hoja$MUERTES)
median_muertes_peru
## [1] 66
desv_est_cont_peru=sd(segunda_hoja$CONTAGIOS)
desv_est_cont_peru
## [1] 1956.623
desv_est_muerte_peru=sd(segunda_hoja$MUERTES)
desv_est_muerte_peru
## [1] 53.40794
cuantil_contag_Peru= quantile(segunda_hoja$CONTAGIOS,c(0.25,0.50,0.75))
cuantil_contag_Peru
cuantil_muert_Peru= quantile(segunda_hoja$MUERTES,c(0.25,0.50,0.75))
cuantil_muert_Peru
deciles_contag_Peru= quantile(segunda_hoja$CONTAGIOS,c(0.20,0.40,0.70))
deciles_contag_Peru
deciles_muert_Peru= quantile(segunda_hoja$MUERTES,c(0.20,0.40,0.70))
deciles_muert_Peru
## $breaks
## [1] 0 1000 2000 3000 4000 5000 6000 7000 8000 9000
##
## $counts
## [1] 1 16 33 14 7 5 17 6 1
##
## $density
## [1] 0.00001 0.00016 0.00033 0.00014 0.00007 0.00005 0.00017 0.00006
0.00001
##
## $mids
## [1] 500 1500 2500 3500 4500 5500 6500 7500 8500
##
## $xname
## [1] "segunda_hoja$CONTAGIOS"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
## $breaks
## [1] 0 50 100 150 200 250 300
##
## $counts
## [1] 23 45 19 9 3 1
##
## $density
## [1] 0.0046 0.0090 0.0038 0.0018 0.0006 0.0002
##
## $mids
## [1] 25 75 125 175 225 275
##
## $xname
## [1] "segunda_hoja$MUERTES"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
cajas_contag_Peru=boxplot(segunda_hoja$CONTAGIOS,horizontal = T,main =
"DIAGRAMA DE CAJAS CONTAGIO PERU",xlab = "CASOS",ylab = "FREQUENCIA")
cajas_contag_Peru
## $stats
## [,1]
## [1,] 887.0
## [2,] 2240.0
## [3,] 3022.5
## [4,] 5676.0
## [5,] 8466.0
##
## $n
## [1] 100
##
## $conf
## [,1]
## [1,] 2479.612
## [2,] 3565.388
##
## $out
## numeric(0)
##
## $group
## numeric(0)
##
## $names
## [1] ""
cajas_muert_Peru=boxplot(segunda_hoja$MUERTES,horizontal = T,main = "DIAGRAMA
DE CAJAS MUERTES PERU",xlab = "MUERTES",ylab = "FREQUENCIA")
cajas_muert_Peru
## $stats
## [,1]
## [1,] 0
## [2,] 53
## [3,] 66
## [4,] 116
## [5,] 206
##
## $n
## [1] 100
##
## $conf
## [,1]
## [1,] 56.046
## [2,] 75.954
##
## $out
## [1] 225 221 284
##
## $group
## [1] 1 1 1
##
## $names
## [1] ""
tbla_freq_contag_Peru=fdt(segunda_hoja$CONTAGIOS,breaks ="Sturges",right = F)
tbla_freq_contag_Peru
tbla_freq_muert_Peru=fdt(segunda_hoja$MUERTES,breaks ="Sturges",right = F)
tbla_freq_muert_Peru
suma_contag_Peru=segunda_hoja$CONTAGIOS
total_contag_Peru=sum(suma_contag_Peru)
total_contag_Peru
## [1] 378884
suma_muert_Peru=segunda_hoja$MUERTES
total_muert_Peru=sum(suma_muert_Peru)
total_muert_Peru
## [1] 8958
poblacion_Peru=32971846
poblacion_Peru
## [1] 32971846
proporcion_Contag_Peru=total_contag_Peru/poblacion_Peru
proporcion_Contag_Peru
## [1] 0.01149114
proporcion_muert_Peru=total_muert_Peru/poblacion_Peru
proporcion_muert_Peru
## [1] 0.0002716863
tabla_contag_PERU=table(segunda_hoja$CONTAGIOS)
tabla_contag_PERU
##
## 887 1194 1257 1589 1598 1634 1663 1800 1830 1859 1882 1888 1904 1923 1966
1977
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1
## 1994 2020 2044 2112 2162 2170 2201 2231 2249 2323 2357 2408 2413 2431 2501
2507
## 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1
1
## 2575 2586 2666 2677 2733 2767 2781 2789 2803 2885 2930 2935 2952 2977 2991
3054
## 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1
1
## 3061 3098 3126 3132 3184 3240 3242 3267 3283 3412 3421 3468 3650 4001 4160
4241
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1
## 4250 4615 4741 4871 5092 5160 5558 5654 5698 6030 6149 6162 6235 6275 6308
6314
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1
## 6380 6453 6586 6603 6667 6703 6708 6787 6790 6854 7137 7243 7291 7448 7734
7785
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1
## 8466
## 1
##
## 0 36 38 39 40 42 44 46 47 48 49 52 53 54 55 56 57 58
59 60
## 1 1 2 3 2 1 3 3 2 2 3 1 2 4 1 2 2 2
1 2
## 61 62 64 65 67 68 71 72 74 77 80 82 85 86 89 92 93 95
99 102
## 1 4 1 4 1 1 2 2 1 1 1 1 1 1 1 1 1 2
1 1
## 105 108 112 113 115 117 120 123 124 126 133 137 138 146 147 149 151 156
191 195
## 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1
2 1
## 196 197 206 221 225 284
## 3 1 1 1 1 1
#segun la base de datos de contagios por COVID en Ecuador en las fechas del 9
de agosto hasta 30 de noviembre
# del 2020, se registraron 100 nuevos contagios por el feriado de Agosto con
una media de 419.36 y la desviacion estandar de 597.943
#obtener el promedio real de contagios con un nivel de confianza del 95%.
total_negativo_E= x-z*o/sqrt(n)
total_negativo_E
## [1] 302.1632
total_positivo_E= x+z*o/sqrt(n)
total_positivo_E
## [1] 536.5568
#segun la base de datos de contagios por COVID en Peru en las fechas del 9 de
agosto hasta 30 de noviembre
# se registraron 100 nuevos contagios por las elecciones presidenciales con
una media de 3788.84 y la desviacion estandar de 1956.623
#determine un intervalo de confianza de 95% para la media de contagiados.
total_negativo_Peru= x-z*o/sqrt(n)
total_negativo_Peru
## [1] 3405.342
total_positivo_Peru= x+z*o/sqrt(n)
total_positivo_Peru
## [1] 4172.338
#PRUEBA DE HIPOTESIS
#de acuerdo al promedio de muerte en Ecuador han llegado a tener un 576.64 de
muertes registradas
#si se sabe por una estadistica anterior,que la desviacion estandar fue de
548.516 y con una muestra de 100 personas
#que fueron diagnosticada, mientras que las muertes en Peru han alcanzado un
promedio de 89.58. pruebe la hipotesis
#de que el promedio de muertes ha disminudo con un nivel de confianza del
95%.
u=576.64
o=548.516
n=100
x=89.58
total=(x-u)/(o/(sqrt(n)))
total
## [1] -8.879595
alfa=0.05
alfa
## [1] 0.05
rechazo=qnorm(alfa)
rechazo
## [1] -1.644854
comprobacion=total<rechazo
comprobacion
## [1] TRUE