2. TABLA DE DISTRIBUCIÓN DE CANTIDAD POR
STURGES
latitud_pozos <- as.numeric(datos$Latitude.of.well.pad)
latitud_pozos <- na.omit(latitud_pozos)
n <- length(latitud_pozos)
# REGLA DE STURGES
k <- floor(1 + 3.322 * log10(n))
k
## [1] 14
minimo <- min(latitud_pozos)
maximo <- max(latitud_pozos)
R <- maximo - minimo
R
## [1] 4.998391
#Amplitud
A <- R / k
A
## [1] 0.3570279
Li_s <- round(seq(from = minimo, to = maximo - A, by = A), 2)
Ls_s <- round(seq(from = minimo + A, to = maximo, by = A), 2)
MC_s <- round((Li_s + Ls_s) / 2, 2)
ni_s <- numeric(length(Li_s))
for (i in 1:length(Li_s)) {
ni_s[i] <- sum(latitud_pozos >= Li_s[i] & latitud_pozos < Ls_s[i])
}
ni_s[length(Li_s)] <- sum(latitud_pozos >= Li_s[length(Li_s)] & latitud_pozos <= maximo)
TDF_Sturges <- data.frame(Li=Li_s, Ls=Ls_s, MC=MC_s, ni=ni_s, hi=round((ni_s/n)*100, 2))
TDF_Sturges_P <- rbind(TDF_Sturges, data.frame(Li="TOTAL", Ls="", MC="", ni=sum(ni_s), hi=100))
| Tabla N°1. Tabla de distribucion de cantidad de
latitud de los pozos de gas natural en Nuevo México |
| Li |
Ls |
MC |
ni |
hi |
| 32 |
32.36 |
32.18 |
707 |
5.63 |
| 32.36 |
32.71 |
32.53 |
1290 |
10.27 |
| 32.71 |
33.07 |
32.89 |
638 |
5.08 |
| 33.07 |
33.43 |
33.25 |
74 |
0.59 |
| 33.43 |
33.79 |
33.61 |
413 |
3.29 |
| 33.79 |
34.14 |
33.97 |
155 |
1.23 |
| 34.14 |
34.5 |
34.32 |
0 |
0.00 |
| 34.5 |
34.86 |
34.68 |
0 |
0.00 |
| 34.86 |
35.21 |
35.03 |
0 |
0.00 |
| 35.21 |
35.57 |
35.39 |
0 |
0.00 |
| 35.57 |
35.93 |
35.75 |
0 |
0.00 |
| 35.93 |
36.28 |
36.11 |
303 |
2.41 |
| 36.28 |
36.64 |
36.46 |
3563 |
28.37 |
| 36.64 |
37 |
36.82 |
5418 |
43.13 |
| TOTAL |
|
|
12561 |
100.00 |
| Tabla 1 de 4 |
3. TABLA DE DISTRIBUCIÓN DE CANTIDAD AGRUPADA
Debido a que la Tabla conteniene valores con
decimales complejos, la vamos a simplificar
h_f <- hist(latitud_pozos, breaks = seq(32, 37, by = 0.5), plot = FALSE)
lis <- h_f$breaks[1:(length(h_f$breaks)-1)]
lss <- h_f$breaks[2:length(h_f$breaks)]
MC_f <- h_f$mids
ni_f <- h_f$counts
hi_f <- (ni_f / sum(ni_f)) * 100
Niasc <- cumsum(ni_f); Nidsc <- rev(cumsum(rev(ni_f)))
Hiasc <- round(cumsum(hi_f), 2); Hidsc <- round(rev(cumsum(rev(hi_f))), 2)
TDF_Simp <- data.frame(Li=lis, Ls=lss, MC=MC_f, ni=ni_f, hi=round(hi_f, 2),
Niasc, Nidsc, Hiasc, Hidsc)
TDF_Simp_P <- rbind(TDF_Simp, data.frame(Li="TOTAL", Ls=" ", MC=" ", ni=sum(ni_f), hi=100,Niasc=" ", Nidsc=" ", Hiasc=" ", Hidsc=" "))
| TABLA°2: Tabla de distribución de cantidad
de la latitud en pozos de gas natural en Nuevo México |
| Li |
Ls |
MC |
ni |
hi |
Niasc |
Nidsc |
Hiasc |
Hidsc |
| 32 |
32.5 |
32.25 |
1296 |
10.32 |
1296 |
12561 |
10.32 |
100 |
| 32.5 |
33 |
32.75 |
1306 |
10.40 |
2602 |
11265 |
20.71 |
89.68 |
| 33 |
33.5 |
33.25 |
184 |
1.46 |
2786 |
9959 |
22.18 |
79.29 |
| 33.5 |
34 |
33.75 |
486 |
3.87 |
3272 |
9775 |
26.05 |
77.82 |
| 34 |
34.5 |
34.25 |
5 |
0.04 |
3277 |
9289 |
26.09 |
73.95 |
| 34.5 |
35 |
34.75 |
0 |
0.00 |
3277 |
9284 |
26.09 |
73.91 |
| 35 |
35.5 |
35.25 |
0 |
0.00 |
3277 |
9284 |
26.09 |
73.91 |
| 35.5 |
36 |
35.75 |
3 |
0.02 |
3280 |
9284 |
26.11 |
73.91 |
| 36 |
36.5 |
36.25 |
1868 |
14.87 |
5148 |
9281 |
40.98 |
73.89 |
| 36.5 |
37 |
36.75 |
7413 |
59.02 |
12561 |
7413 |
100 |
59.02 |
| TOTAL |
|
|
12561 |
100.00 |
|
|
|
|
| Tabla 2 de 4 |
4. GRÁFICAS DE DISTRIBUCIÓN
par(oma = c(1, 1, 1, 1))
par(mfrow=c(1,1))
par(mar = c(6, 5, 4, 2) + 0.1)
colores <- gray.colors(length(ni_f), start = 0.3, end = 0.9)
#LÍMITES INFERIOR Y SUPERIOR
h_datos23 <- hist(latitud_pozos, plot = FALSE)
limite_inferior <- h_datos23$breaks[1]
limite_superior <- tail(h_datos23$breaks, 1)
x_cant <- c(limite_inferior, h_datos23$mids, limite_superior)
y_cant <- c(0, h_datos23$counts, 0)
#GRAFICA 1
hist(latitud_pozos, col = colores, xlab = "Latitud", ylab = "Cantidad",
main = "Grafica N°1: Distribución de cantidad de la latitud en pozos
de gas natural en Nuevo México")
lines(x_cant, y_cant, type = "b", col = "red", pch = 19, lwd = 2)
box(which = "outer", col = "black")

#GRAFICA 2
hist(latitud_pozos, col = colores, xlab = "Latitud", ylab = "Cantidad",
ylim = c(0, 12561),
main = "Grafica N°2: Distribución de cantidad de la latitud en pozos
de gas natural en Nuevo México")
box(which = "outer", col = "black")

#GRAFICA 3
h_porcentaje <- hist(latitud_pozos, plot = FALSE)
h_porcentaje$counts <- (h_porcentaje$counts / sum(h_porcentaje$counts)) * 100
plot(h_porcentaje, col = colores, xlab = "Latitud", ylab = "Porcentaje (%)",
main = "Grafica N°3: Distribución de cantidad en porcentaje
de la latitud en pozos de gas natural en Nuevo México")
box(which = "outer", col = "black")

#GRAFICA 4
plot(h_porcentaje, col = colores, xlab = "Latitud", ylab = "Porcentaje (%)",
ylim = c(0, 100),
main = "Grafica N°4: Distribución de cantidad en porcentaje
de la latitud en pozos de gas natural en Nuevo México")
box(which = "outer", col = "black")

#GRAFICA 5
plot(lss, Nidsc, type="b", col="blue", pch=19, bg="white", xlab="Latitud", ylab="Cant. Acumulada",
main="Grafica N°5: Ojivas combinadas de cantidad acumulada de la
latitud en pozos de gas natural en Nuevo México")
lines(lis, Niasc, col="black", type="b", pch=19)
legend("top", legend=c("Descendente", "Ascendente"), col=c("blue", "black"), pch=c(19, 19), pt.bg="white", bty="n")
box(which = "outer", col = "black")

#GRAFICA 7
plot(lss, Hidsc, type="b", col="blue", pch=19, bg="white", ylim=c(0, 100),
xlab="Latitud", ylab="Porcentaje Acumulado",
main="Grafica N°6: Ojivas combinadas de porcentaje acumulado de la
latitud en pozos de gas natural en Nuevo México")
lines(lis, Hiasc, col="black", type="b", pch=19)
legend("bottomright", legend=c("Descendente", "Ascendente"), col=c("blue", "black"), pch=c(19, 19), pt.bg="white", bty="n")
box(which = "outer", col = "black")

#GRAFICA 8
boxplot(latitud_pozos, horizontal = TRUE, col = "skyblue", xlab = "Latitud",
main = "Grafica N°7: Distribución de cantidad de la latitud
en pozos de gas natural en Nuevo México")
box(which = "outer", col = "black")

summary(latitud_pozos)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 32.00 33.80 36.58 35.65 36.79 37.00
#GRAFICA N°9: SUPERPOSICIÓN DE BOXPLOT SOBRE HISTOGRAMA
hist(latitud_pozos, prob = TRUE,
col = colores, xlab = "Latitud", ylab = "Densidad",
main = "Grafica N°8: Distribución de cantidad de la latitud
en pozos de gas natural en Nuevo México")
par(new = TRUE)
boxplot(latitud_pozos, horizontal = TRUE, axes = FALSE,
col = rgb(0, 0.8, 1, alpha = 0.5))
box(which = "outer", col = "black")

5. INDICADORES ESTADÍSTICOS Y OUTLIERS
TablaInd <- data.frame(Variable="Latitud", min=min(latitud_pozos), max=max(latitud_pozos),
x=round(mean(latitud_pozos),2), Me=median(latitud_pozos),
sd=round(sd(latitud_pozos),2), Cv=round((sd(latitud_pozos)/mean(latitud_pozos))*100,2),
As=round(skewness(latitud_pozos),2), K=round(kurtosis(latitud_pozos),2))
#media
media_val <- mean(latitud_pozos)
media_val
## [1] 35.65062
#desviacion estandar
desv_val <- sd(latitud_pozos)
desv_val
## [1] 1.757531
#minimo
min_val <- min(latitud_pozos)
min_val
## [1] 32.00058
#maximo
max_val <- max(latitud_pozos)
max_val
## [1] 36.99897
cv_analisis <- (desv_val / media_val) * 100
cv_analisis
## [1] 4.929873
tipo_datos <- if(cv_analisis > 30) "heterogeneos" else "homogeneos"
conteo_atipicos <- length(boxplot.stats(latitud_pozos)$out)
# TABLA 3 CON GT
TablaInd %>%
gt() %>%
tab_header(title = md("Tabla Nº3: Indicadores estadisticos de la variable
latitud en pozos de gas natural en Nuevo México")) %>%
tab_style(
style = list(cell_fill(color = "lightgray"), cell_text(weight = "bold")),
locations = cells_title(groups = "title")
) %>%
tab_options(
column_labels.font.weight = "bold"
) %>%
tab_source_note(
source_note = md("**Tabla 3 de 4**"))
| Tabla Nº3: Indicadores estadisticos de la variable
latitud en pozos de gas natural en Nuevo México |
| Variable |
min |
max |
x |
Me |
sd |
Cv |
As |
K |
| Latitud |
32.00058 |
36.99897 |
35.65 |
36.58063 |
1.76 |
4.93 |
-1.12 |
-0.61 |
| Tabla 3 de 4 |
valores_atipicos <- boxplot.stats(latitud_pozos)$out
n_atipicos <- length(valores_atipicos)
min_atipico <- if(n_atipicos > 0) min(valores_atipicos) else 0
max_atipico <- if(n_atipicos > 0) max(valores_atipicos) else 0
TablaOutliers <- data.frame(Cantidad = n_atipicos, Mínimo = min_atipico, Máximo = max_atipico)
| TABLA N°4: Valores atípicos de la variable Latitud |
| Cantidad |
Mínimo |
Máximo |
| 0 |
0 |
0 |
| Tabla 4 de 4 |