\(Variable\) \(de\) \(Estudio\): Fecha de Sellado del Pozo (Date Well Plugged).
Antiguas (1884 – 1931): periodo con muy pocos registros.
Medias (1931 – 1979): representación intermedia en el histórico.
Recientes (1979 – 2026): concentra la mayoría de los pozos, con sellados vigentes o recientes.
##### UNIVERSIDAD CENTRAL DEL ECUADOR #####
#### AUTORES: DALLYANA LOZANO ####
### CARRERA: INGENIERÍA EN PETRÓLEOS #####
#### VARIABLE: FECHA DE FINALIZACIÓN DEL POZO ####
suppressPackageStartupMessages({
library(tidyverse)
library(readxl)
library(gt)
library(dplyr)
library(readr)
library(lubridate)
})
Datos <- read_delim("Dataset.csv", delim = ";", escape_double = FALSE, trim_ws = TRUE, show_col_types = FALSE)Extraemos la variable Date Well Plugged, omitimos las celdas en blanco y verificamos el tamaño muestral.
suppressPackageStartupMessages({
library(lubridate)
library(dplyr)
})
fechas_raw_plug <- Datos$`Date Well Plugged`
fechas_validas_plug <- fechas_raw_plug[!is.na(fechas_raw_plug) & fechas_raw_plug != ""]
Fechas_limpias_plug <- mdy(fechas_validas_plug)
Fechas_limpias_plug <- Fechas_limpias_plug[!is.na(Fechas_limpias_plug)]
Fecha_Plug <- cut(as.numeric(Fechas_limpias_plug),
breaks = 3,
labels = c("Antiguas",
"Medias",
"Recientes"),
ordered_result = TRUE)
conteo_plug <- table(Fecha_Plug)
ni_plug <- as.numeric(conteo_plug)
hi_plug <- (ni_plug / sum(ni_plug)) * 100Se extrajo la variable de fecha de sellado del pozo (Date Well Plugged) para determinar su frecuencia absoluta (\(n_i\)) y el porcentaje relativo (\(hi\))respecto al total, agrupando los registros en tres rangos de igual amplitud: Antiguas, Medias y Recientes.
df_plug_final <- data.frame(
Tipo = names(conteo_plug),
ni = as.character(ni_plug),
hi = as.character(round(hi_plug, 2))
)
fila_total_plug <- data.frame(
Tipo = "TOTAL",
ni = as.character(sum(ni_plug)),
hi = as.character(round(sum(hi_plug), 2))
)
df_show_plug_1 <- bind_rows(df_plug_final, fila_total_plug)
df_show_plug_1 %>%
gt() %>%
tab_header(
title = md("**TABLA Nº 1: DISTRIBUCIÓN DE FRECUENCIAS DE LA FECHA DE SELLADO DEL POZO**")
) %>%
cols_label(
Tipo = "Rango de Sellado del Pozo",
ni = "ni",
hi = "hi (%)"
) %>%
cols_align(align = "center", columns = everything()) %>%
tab_style(
style = list(cell_fill(color = "#F2F3F4"), cell_text(weight = "bold", color = "#2E4053")),
locations = cells_column_labels()
) %>%
tab_style(
style = list(cell_fill(color = "#D0ECE7"), cell_text(weight = "bold")),
locations = cells_body(rows = Tipo == "TOTAL")
) %>%
tab_options(
table.width = pct(90),
data_row.padding = px(12),
column_labels.padding = px(15),
table.border.top.style = "solid",
table.border.top.color = "#2E4053",
table.border.bottom.style = "solid",
table.border.bottom.color = "#2E4053"
)| TABLA Nº 1: DISTRIBUCIÓN DE FRECUENCIAS DE LA FECHA DE SELLADO DEL POZO | ||
| Rango de Sellado del Pozo | ni | hi (%) |
|---|---|---|
| Antiguas | 333 | 1.86 |
| Medias | 6256 | 35.03 |
| Recientes | 11271 | 63.11 |
| TOTAL | 17860 | 100 |
Se incorporó una asignación jerárquica ordinal y se consolidó la información en un data frame estructurado para su presentación formal.
conteo_plug_j <- table(Fecha_Plug)
ni_plug_j <- as.numeric(conteo_plug_j)
hi_plug_j <- (ni_plug_j / sum(ni_plug_j)) * 100
df_plug_jerarquia <- data.frame(
Asignacion = as.character(1:length(conteo_plug_j)),
Tipo = names(conteo_plug_j),
ni = as.character(ni_plug_j),
hi = as.character(round(hi_plug_j, 2))
)
fila_total_plug_j <- data.frame(
Asignacion = "TOTAL",
Tipo = "",
ni = as.character(sum(ni_plug_j)),
hi = as.character(round(sum(hi_plug_j), 2))
)
df_show_plug_2 <- bind_rows(df_plug_jerarquia, fila_total_plug_j)
df_show_plug_2 %>%
gt() %>%
tab_header(
title = md("**TABLA Nº 2: ASIGNACIÓN JERÁRQUICA DE LA FECHA DE SELLADO DEL POZO**")
) %>%
cols_label(
Asignacion = "Asignación",
Tipo = "Rango de Fechas",
ni = "ni",
hi = "hi (%)"
) %>%
cols_align(align = "center", columns = everything()) %>%
tab_style(
style = list(cell_fill(color = "#F2F3F4"), cell_text(weight = "bold", color = "#2E4053")),
locations = cells_column_labels()
) %>%
tab_style(
style = list(cell_fill(color = "#D0ECE7"), cell_text(weight = "bold")),
locations = cells_body(rows = Asignacion == "TOTAL")
) %>%
tab_options(
table.width = pct(90),
data_row.padding = px(12),
column_labels.padding = px(15),
table.border.top.style = "solid",
table.border.top.color = "#2E4053",
table.border.bottom.style = "solid",
table.border.bottom.color = "#2E4053"
)| TABLA Nº 2: ASIGNACIÓN JERÁRQUICA DE LA FECHA DE SELLADO DEL POZO | |||
| Asignación | Rango de Fechas | ni | hi (%) |
|---|---|---|---|
| 1 | Antiguas | 333 | 1.86 |
| 2 | Medias | 6256 | 35.03 |
| 3 | Recientes | 11271 | 63.11 |
| TOTAL | 17860 | 100 | |
par(mar = c(7, 4, 4, 2))
barplot(as.numeric(df_plug_final$ni),
main = "GRÁFICO Nº 1: DISTRIBUCIÓN DE LA FECHA DE SELLADO DEL POZO",
ylab = "Cantidad de Pozos",
col = "#B0C4DE",
names.arg = df_plug_final$Tipo,
las = 2,
cex.names = 0.8,
cex.axis = 0.8,
cex.main = 1.1,
ylim = c(0, max(as.numeric(df_plug_final$ni), na.rm = TRUE) + max(as.numeric(df_plug_final$ni), na.rm = TRUE) * 0.1))
mtext("Rango de Fecha de Sellado", side = 1, line = 6)par(mar = c(5, 4, 4, 2))
barplot(as.numeric(df_plug_jerarquia$hi),
main = "GRÁFICO Nº 2: PORCENTAJE DE LA FECHA DE SELLADO DEL POZO",
ylab = "Porcentaje (%)",
col = "#B0C4DE",
names.arg = df_plug_jerarquia$Asignacion,
las = 1,
cex.names = 1.0,
cex.axis = 0.8,
cex.main = 1.1,
ylim = c(0, max(as.numeric(df_plug_jerarquia$hi), na.rm = TRUE) + 10))
mtext("Asignación", side = 1, line = 3)Se validó la fecha de sellado del pozo (Date Well Plugged) mediante una Distribución Binomial\(𝐵(2,p)\), ajustada a la variable ordinal de tres categorías.
n_total_Plug <- sum(as.numeric(df_plug_jerarquia$ni))
size_binom_plug <- 2
X_indices_plug <- 0:2
media_obs_plug <- sum(X_indices_plug * as.numeric(df_plug_jerarquia$ni)) / n_total_Plug
prob_p_plug <- media_obs_plug / size_binom_plug
P_Binomial_Plug <- dbinom(X_indices_plug, size = size_binom_plug, prob = prob_p_plug) * 100
par(mar = c(9, 4, 4, 2))
max_y_plug <- max(max(as.numeric(df_plug_jerarquia$hi)), max(P_Binomial_Plug))
barplot(rbind(as.numeric(df_plug_jerarquia$hi), P_Binomial_Plug),
beside = TRUE,
main = "GRÁFICO Nº 3: Comparado de lo Observado frente a lo Esperado de la Fecha de Sellado del Pozo",
ylab = "Porcentaje (%)",
names.arg = df_plug_jerarquia$Asignacion,
col = c("#B0C4DE", "#AED6F1"),
ylim = c(0, max_y_plug + 25),
las = 1,
cex.names = 0.9,
cex.main = 0.85)
legend("topright",
legend = c("Realidad", "Modelo"),
fill = c("#B0C4DE", "#AED6F1"),
bty = "n", cex = 0.8)
mtext("Rango de Fecha de Sellado", side = 1, line = 6)Fo_Pl <- as.numeric(df_plug_jerarquia$hi)
Fe_Pl <- P_Binomial_Plug
test_correlacion_plug <- cor.test(Fo_Pl, Fe_Pl)
r_valor_plug <- round(test_correlacion_plug$estimate, 4)
par(mar = c(5, 5, 4, 2))
plot(Fo_Pl, Fe_Pl,
main = "GRÁFICO Nº 4: CORRELACIÓN DEL MODELO BINOMIAL - FECHA DE SELLADO DEL POZO",
cex.main = 0.85,
xlab = "Frecuencia Observada (%)",
ylab = "Frecuencia Esperada (%)",
pch = 19,
col = "#2E4053",
cex = 1.5)
abline(lm(Fe_Pl ~ Fo_Pl), col = "red", lwd = 2)
text(x = min(Fo_Pl), y = max(Fe_Pl),
labels = paste("r =", r_valor_plug),
pos = 4, font = 2, col = "#2E4053")## [1] 99.42923
x2_Pl <- sum(((Fo_Pl - Fe_Pl)^2) / Fe_Pl)
gl_Pl <- length(Fo_Pl) - 1
vc_Pl <- qchisq(0.99, gl_Pl)
cat("Estadístico Chi-cuadrado (Calculado):", round(x2_Pl, 4), "\n")## Estadístico Chi-cuadrado (Calculado): 1.4695
## Valor Crítico (Tabla): 9.2103
## ¿Se acepta el modelo? (Calculado < Crítico): TRUE
tabla_resumen_Pl <- data.frame(
Variable = "Fecha de Sellado del Pozo",
Pearson = round(Correlacion_Pl, 2),
Chi2 = round(x2_Pl, 4),
Umbral = round(vc_Pl, 2),
Resultado = ifelse(x2_Pl < vc_Pl, "Modelo Aceptado", "Modelo Rechazado")
)
tabla_resumen_Pl %>%
gt() %>%
tab_header(
title = md("**TABLA Nº 3: RESUMEN DEL TEST DE BONDAD AL MODELO DE PROBABILIDAD**")
) %>%
cols_label(
Variable = "Variable",
Pearson = "Test Pearson (%)",
Chi2 = "Chi Cuadrado",
Umbral = "Umbral de Aceptación",
Resultado = "Resultado Final"
) %>%
tab_source_note(
source_note = "Autor: Dallyana Lozano"
) %>%
cols_align(align = "center", columns = everything()) %>%
tab_style(
style = list(cell_fill(color = "#2E4053"), cell_text(color = "white", weight = "bold")),
locations = cells_title()
) %>%
tab_style(
style = list(cell_fill(color = "#F2F3F4"), cell_text(weight = "bold", color = "#2E4053")),
locations = cells_column_labels()
) %>%
tab_options(
table.width = pct(95),
table.border.top.color = "#2E4053",
table.border.bottom.color = "#2E4053",
column_labels.border.bottom.color = "#2E4053",
data_row.padding = px(10)
)| TABLA Nº 3: RESUMEN DEL TEST DE BONDAD AL MODELO DE PROBABILIDAD | ||||
| Variable | Test Pearson (%) | Chi Cuadrado | Umbral de Aceptación | Resultado Final |
|---|---|---|---|---|
| Fecha de Sellado del Pozo | 99.43 | 1.4695 | 9.21 | Modelo Aceptado |
| Autor: Dallyana Lozano | ||||
## [1] "63.11"
La probabilidad de que un pozo tenga su fecha de sellado en el rango Recientes es de aproximadamente 63.11%.
## [1] "1.86"
La probabilidad de encontrar pozos en el rango Antiguas es de apenas 1.86%.
El modelo Binomial B(2,p) se ajustó adecuadamente a la variable Fecha de Sellado del Pozo, confirmando que la mayoría de los sellados se concentra en el rango Recientes (63.11%), frente a apenas 1.86% en el rango Antiguas.