setwd("~/Estadistica")

Calidad del aire de Hermosillo

En el año 2020 la calidad del aire de hersillo era pesima ya que en el 2020 aparecio la pandemia COVID 19, hubo un disminuyo de autos circulando con esto la calidad del aire mejoro.

¿de donde obtenemos datos de NO2 y O3 atmosférico en Hermosillo? ruoa.unam.mx/index.php?page=estaciones&id=6

Importar datos

library(readr)
periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00 <- read_csv("periodo_-2020-04-01-12_00_00-a--2020-04-30-12_00_00.csv")
## 
## -- Column specification --------------------------------------------------------
## cols(
##   FECHA = col_character(),
##   O3 = col_double()
## )
View(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00)
head(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00)
## # A tibble: 6 x 2
##   FECHA               O3
##   <chr>            <dbl>
## 1 2020-04-01 12;47     6
## 2 2020-04-01 13;47    84
## 3 2020-04-01 14;46    73
## 4 2020-04-01 15;47    16
## 5 2020-04-01 16;45     4
## 6 2020-04-01 17;40    72

Medidas de tendencia central

Media

mean(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3, na.rm =TRUE)
## [1] 44.92909

Mediana

median(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3, na.rm =TRUE)
## [1] 44

ordenar datos del menor al mayor

sort(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3)
##   [1]  1  1  1  1  1  1  1  1  1  1  2  2  2  2  2  2  2  2  2  2  2  2  3  3  3
##  [26]  3  3  3  3  3  3  3  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  5  5
##  [51]  5  5  5  5  5  5  5  5  5  5  5  5  6  6  6  6  6  6  6  6  6  6  6  6  6
##  [76]  6  6  6  6  6  6  6  6  7  7  7  7  7  7  7  7  7  7  7  7  7  8  8  8  8
## [101]  8  8  8  8  8  8  8  8  8  8  8  8  8  9  9  9  9  9  9  9  9  9  9  9  9
## [126]  9  9  9  9  9  9  9  9  9  9  9 11 11 12 12 12 12 12 12 12 13 13 13 13 13
## [151] 13 13 13 14 14 14 14 14 14 15 15 15 15 15 15 15 15 15 15 15 16 16 16 16 16
## [176] 16 16 16 16 16 16 17 17 17 17 17 17 17 17 17 18 18 18 18 19 19 19 19 19 19
## [201] 19 21 21 21 21 21 21 21 22 23 23 23 23 23 23 23 23 23 24 24 24 24 24 24 24
## [226] 25 25 25 25 25 25 25 25 25 25 26 26 26 26 26 26 26 26 26 26 26 26 26 26 27
## [251] 27 27 27 27 28 28 28 28 29 29 29 29 31 31 31 31 31 31 31 31 31 31 32 32 33
## [276] 33 33 33 33 34 34 34 34 34 34 34 34 35 35 35 35 35 35 35 35 35 35 35 36 36
## [301] 36 36 36 36 36 36 36 37 37 37 37 37 38 38 38 38 38 38 39 39 39 39 39 41 41
## [326] 41 41 41 41 41 42 42 42 42 42 43 43 43 43 43 43 43 44 44 44 44 45 45 45 45
## [351] 45 45 45 45 45 46 46 46 46 46 46 46 46 46 47 47 47 47 48 48 48 48 48 48 48
## [376] 48 48 49 49 49 49 49 49 49 49 51 51 51 51 51 51 51 51 52 52 52 52 52 53 53
## [401] 53 53 54 54 54 54 54 54 55 55 55 55 55 55 55 56 56 56 56 56 56 56 56 56 57
## [426] 57 57 57 57 57 57 57 58 58 58 58 58 59 59 59 59 59 59 59 59 61 61 61 61 61
## [451] 62 62 62 62 62 62 62 63 63 63 63 63 63 64 64 64 64 64 64 64 64 64 64 64 65
## [476] 65 65 65 65 66 66 66 66 66 66 66 66 66 67 67 67 67 67 68 68 68 68 68 69 69
## [501] 69 69 69 69 71 71 71 71 71 71 71 71 71 71 71 72 72 72 72 72 72 72 72 72 72
## [526] 73 73 74 74 74 74 74 74 74 74 74 74 74 74 74 75 75 75 75 75 75 75 76 76 76
## [551] 76 77 77 77 77 77 77 77 77 77 77 78 78 78 78 78 78 78 79 79 79 79 79 79 79
## [576] 79 79 79 79 79 79 81 81 81 81 82 82 82 82 82 82 82 82 83 83 83 83 83 84 84
## [601] 84 84 84 85 85 85 85 85 86 86 86 86 87 87 87 87 87 88 88 88 88 88 88 88 88
## [626] 89 89 89 89 89 89 89 89 89 89 89 89 91 91 91 91 92 92 92 92 92 92 93 93 93
## [651] 93 93 93 93 93 94 94 94 94 94 94 95 95 95 95 95 95 96 96 96 96 96 96 96 97
## [676] 97 97 97 97 97 97 98 98 98 98 98 98 99 99 99 99

Moda

library(modeest)
mlv(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3, na.rm =TRUE, method ="mfv")
## [1] 9
#most frequent value = valor mas frecuente

Rango

maximo <- max(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3, na.rm =TRUE)
minimo <- min(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3, na.rm =TRUE)
rango  <- (maximo-minimo)
rango
## [1] 98

Cuartiles

summary(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3, na.rm =TRUE)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    1.00   16.00   44.00   44.93   72.00   99.00       5

Rango intercuantil

RIC <- IQR(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3, na.rm =TRUE)
RIC 
## [1] 56
#limite superior
Q3 <- 72.00
limitesuperior <- (Q3+1.5*RIC)
limitesuperior 
## [1] 156
# limite inferior
Q1 <- 16.00 
limiteinferior <- (Q1-1.5*RIC)
limiteinferior
## [1] -68

Gráfico de caja y bigote

boxplot(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3, na.rm =TRUE)

Analisis de frecuencia

library(fdth)
## 
## Attaching package: 'fdth'
## The following object is masked from 'package:modeest':
## 
##     mfv
## The following objects are masked from 'package:stats':
## 
##     sd, var

Frecuencia absolutas, relativas, acumuladas

  • Tabla de frecuencia
dist <- fdt(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3, na.rm =TRUE, breaks = "Sturges")
dist
##   Class limits   f   rf rf(%)  cf  cf(%)
##    [0.99,9.99) 136 0.20 19.68 136  19.68
##   [9.99,18.99)  58 0.08  8.39 194  28.08
##  [18.99,27.99)  60 0.09  8.68 254  36.76
##  [27.99,36.99)  53 0.08  7.67 307  44.43
##  [36.99,45.99)  48 0.07  6.95 355  51.37
##  [45.99,54.99)  53 0.08  7.67 408  59.04
##  [54.99,63.99)  55 0.08  7.96 463  67.00
##  [63.99,72.99)  62 0.09  8.97 525  75.98
##  [72.99,81.99)  60 0.09  8.68 585  84.66
##  [81.99,90.99)  52 0.08  7.53 637  92.19
##  [90.99,99.99)  54 0.08  7.81 691 100.00

Poligonos e histogramas

#absolutos
plot(dist, type="fh", col ="blue")

plot(dist, type="fp", col= "red")

#acumulados
plot(dist, type="cfh", col="blue")

plot(dist, type="cfp", col="red")

#relativos
plot(dist, type="rfh", col="blue")

plot(dist, type="rfp", col="red")

Medidas de dispersion: Rango, Varianza, desviacion estándar

range(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3, na.rm =TRUE)
## [1]  1 99
min(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3, na.rm =TRUE)
## [1] 1
max(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3, na.rm =TRUE)
## [1] 99
max(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3, na.rm =TRUE) - min(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3, na.rm =TRUE)
## [1] 98

Grafico de dispersión

plot(periodo_2020_04_01_12_00_00_a_2020_04_30_12_00_00$O3, col="blue")