El presente informe estadístico analiza la variable Profundidad de Perforación de pozos petroleros de Brasil.
# 1. LIBRERÍAS Y CARGA DE DATOS
library(readxl)
library(dplyr)
library(gt)
library(e1071)
# Carga de datos
Datos_Brutos <- read_excel("tabela_de_pocos_janeiro_2018.xlsx", sheet = 1)
vars_to_keep <- c("POCO", "OPERADOR", "ESTADO", "BACIA", "DIRECAO",
"TIPO", "SITUACAO", "PROFUNDIDADE_SONDADOR_M", "LAMINA_D_AGUA_M")
Datos <- Datos_Brutos %>%
select(any_of(vars_to_keep)) %>%
mutate(PROFUNDIDADE_SONDADOR_M = as.numeric(gsub(",", ".", as.character(PROFUNDIDADE_SONDADOR_M))))
Variable <- na.omit(Datos$PROFUNDIDADE_SONDADOR_M)
Variable <- Variable[Variable > 0 & Variable < 15000]
if(length(Variable) == 0) stop("ERROR")
# 2. CÁLCULOS MATEMÁTICOS (STURGES)
N <- length(Variable)
min_val <- min(Variable)
max_val <- max(Variable)
Rango <- max_val - min_val
K <- floor(1 + 3.322 * log10(N))
Amplitud <- Rango / K
breaks_raw <- seq(min_val, max_val, length.out = K + 1)
breaks_raw[length(breaks_raw)] <- max_val + 0.0001
lim_inf_raw <- breaks_raw[1:K]
lim_sup_raw <- breaks_raw[2:(K+1)]
MC <- (lim_inf_raw + lim_sup_raw) / 2
ni <- numeric(K)
for (i in 1:K) {
if (i < K) {
ni[i] <- length(Variable[Variable >= lim_inf_raw[i] & Variable < lim_sup_raw[i]])
} else {
ni[i] <- length(Variable[Variable >= lim_inf_raw[i] & Variable <= lim_sup_raw[i]])
}
}
hi <- (ni / sum(ni)) * 100
Ni_asc <- cumsum(ni)
Ni_desc <- rev(cumsum(rev(ni)))
Hi_asc <- cumsum(hi)
Hi_desc <- rev(cumsum(rev(hi)))
TDF_Profundidad <- data.frame(
Li = round(lim_inf_raw, 2),
Ls = round(lim_sup_raw, 2),
MC = round(MC, 2),
ni = ni,
hi = round(hi, 2),
Ni_asc = Ni_asc,
Ni_desc = Ni_desc,
Hi_asc = round(Hi_asc, 2),
Hi_desc = round(Hi_desc, 2)
)A continuación se presenta la tabla de distribución de frecuencias obtenida.
# Totales
totales <- c("TOTAL", "-", "-", sum(ni), round(sum(hi), 2), "-", "-", "-", "-")
TDF_Char <- TDF_Profundidad %>% mutate(across(everything(), as.character))
TDF_Final <- rbind(TDF_Char, totales)
TDF_Final %>%
gt() %>%
tab_header(
title = md("**DISTRIBUCIÓN DE FRECUENCIAS DE POZOS PETROLEROS DE BRASIL**"),
subtitle = md("Variable: **Profundidad de Perforación (m)**")
) %>%
tab_source_note(source_note = "Fuente: Datos ANP 2018") %>%
cols_label(
Li = "Lím. Inf", Ls = "Lím. Sup", MC = "Marca Clase (Xi)",
ni = "ni", hi = "hi (%)",
Ni_asc = "Ni (Asc)", Ni_desc = "Ni (Desc)",
Hi_asc = "Hi (Asc)", Hi_desc = "Hi (Desc)"
) %>%
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.border.top.color = "#2E4053",
table.border.bottom.color = "#2E4053",
column_labels.border.bottom.color = "#2E4053",
data_row.padding = px(6)
)| DISTRIBUCIÓN DE FRECUENCIAS DE POZOS PETROLEROS DE BRASIL | ||||||||
| Variable: Profundidad de Perforación (m) | ||||||||
| Lím. Inf | Lím. Sup | Marca Clase (Xi) | ni | hi (%) | Ni (Asc) | Ni (Desc) | Hi (Asc) | Hi (Desc) |
|---|---|---|---|---|---|---|---|---|
| 5 | 543.35 | 274.17 | 6150 | 23.37 | 6150 | 26312 | 23.37 | 100 |
| 543.35 | 1081.69 | 812.52 | 6823 | 25.93 | 12973 | 20162 | 49.3 | 76.63 |
| 1081.69 | 1620.04 | 1350.87 | 4181 | 15.89 | 17154 | 13339 | 65.19 | 50.7 |
| 1620.04 | 2158.39 | 1889.21 | 2117 | 8.05 | 19271 | 9158 | 73.24 | 34.81 |
| 2158.39 | 2696.73 | 2427.56 | 1684 | 6.4 | 20955 | 7041 | 79.64 | 26.76 |
| 2696.73 | 3235.08 | 2965.91 | 2131 | 8.1 | 23086 | 5357 | 87.74 | 20.36 |
| 3235.08 | 3773.43 | 3504.25 | 1512 | 5.75 | 24598 | 3226 | 93.49 | 12.26 |
| 3773.43 | 4311.77 | 4042.6 | 687 | 2.61 | 25285 | 1714 | 96.1 | 6.51 |
| 4311.77 | 4850.12 | 4580.95 | 397 | 1.51 | 25682 | 1027 | 97.61 | 3.9 |
| 4850.12 | 5388.47 | 5119.29 | 290 | 1.1 | 25972 | 630 | 98.71 | 2.39 |
| 5388.47 | 5926.81 | 5657.64 | 221 | 0.84 | 26193 | 340 | 99.55 | 1.29 |
| 5926.81 | 6465.16 | 6195.99 | 80 | 0.3 | 26273 | 119 | 99.85 | 0.45 |
| 6465.16 | 7003.51 | 6734.33 | 27 | 0.1 | 26300 | 39 | 99.95 | 0.15 |
| 7003.51 | 7541.85 | 7272.68 | 9 | 0.03 | 26309 | 12 | 99.99 | 0.05 |
| 7541.85 | 8080.2 | 7811.03 | 3 | 0.01 | 26312 | 3 | 100 | 0.01 |
| TOTAL | - | - | 26312 | 100 | - | - | - | - |
| Fuente: Datos ANP 2018 | ||||||||
Esta sección presenta la visualización de la distribución de los datos.
col_gris_azulado <- "#5D6D7E"
col_ejes <- "#2E4053"
h_base <- hist(Variable, breaks = "Sturges", plot = FALSE)
ylim_max <- max(h_base$counts) * 1.1
# GRÁFICO 1: Histograma Absoluto (Local)
par(mar = c(8, 5, 4, 2))
plot(h_base,
main = "Gráfica No.1: Distribución de Profundidad de Perforación de Pozos Petroleros de Brasil",
xlab = "Profundidad de Perforación (m)",
ylab = "Frecuencia Absoluta",
col = col_gris_azulado, border = "white", axes = FALSE,
ylim = c(0, ylim_max))
axis(1, at = round(h_base$breaks, 0), labels = format(round(h_base$breaks, 0), scientific = FALSE), las = 2, cex.axis = 0.7)
axis(2)
grid(nx=NA, ny=NULL, col="#D7DBDD", lty="dotted") # GRÁFICO 2: Histograma Global
par(mar = c(8, 5, 4, 2))
plot(h_base,
main = "Gráfica N°2: Distribución de Profundidad de Perforación de Pozos Petroleros de Brasil",
xlab = "Profundidad de Perforación (m)",
ylab = "Total Pozos",
col = col_gris_azulado, border = "white", axes = FALSE,
ylim = c(0, sum(h_base$counts)))
axis(1, at = round(h_base$breaks, 0), labels = format(round(h_base$breaks, 0), scientific = FALSE), las = 2, cex.axis = 0.7)
axis(2)
grid(nx=NA, ny=NULL, col="#D7DBDD", lty="dotted")h_porc <- h_base
h_porc$counts <- (h_porc$counts / sum(h_porc$counts)) * 100
h_porc$density <- h_porc$counts
ylim_porc <- max(h_porc$counts) * 1.2
# GRÁFICO 3: Porcentajes (Local)
par(mar = c(8, 5, 4, 2))
plot(h_porc,
main = "Gráfica N°3: Distribución Porcentual de Profundidad de Perforación de Pozos Petroleros de Brasil",
xlab = " Profundidad de Perforación (m)",
ylab = "Porcentaje (%)",
col = col_gris_azulado, border = "white", axes = FALSE, freq = TRUE,
ylim = c(0, ylim_porc))
axis(1, at = round(h_base$breaks, 0), labels = format(round(h_base$breaks, 0), scientific = FALSE), las = 2, cex.axis = 0.7)
axis(2)
text(x = h_base$mids, y = h_porc$counts, label = paste0(round(h_porc$counts, 1), "%"), pos = 3, cex = 0.6, col = col_ejes)
grid(nx=NA, ny=NULL, col="#D7DBDD", lty="dotted") # GRÁFICO 4: Global Porcentual
par(mar = c(8, 5, 4, 2))
plot(h_porc,
main = "Gráfica No.4: Distribución Porcentual de Profundidad de Perforación de Pozos Petroleros de Brasil",
xlab = "Profundidad de Perforación (m)",
ylab = "% del Total",
col = col_gris_azulado, border = "white", axes = FALSE, freq = TRUE,
ylim = c(0, 100))
axis(1, at = round(h_base$breaks, 0), labels = format(round(h_base$breaks, 0), scientific = FALSE), las = 2, cex.axis = 0.7)
axis(2)
text(x = h_base$mids, y = h_porc$counts, label = paste0(round(h_porc$counts, 1), "%"), pos = 3, cex = 0.6, col = col_ejes)
abline(h=seq(0,100,20), col="#D7DBDD", lty="dotted")# GRÁFICO 5: Boxplot
par(mar = c(5, 5, 4, 2))
boxplot(Variable, horizontal = TRUE, col = col_gris_azulado,
main = "Gráfica No.5: Diagrama de Caja de Profundidad de Perforación de Pozos Petroleros de Brasil (Boxplot)",
xlab = "Profundidad (m)", outline = TRUE, outpch = 19, outcol = "#C0392B",
boxwex = 0.5, frame.plot = FALSE, xaxt = "n", cex.main=0.97)
eje_x_detallado <- pretty(Variable, n = 20)
axis(1, at = eje_x_detallado, labels = format(eje_x_detallado, scientific = FALSE), cex.axis=0.7, las=2)
grid(nx=NULL, ny=NA, col="lightgray", lty="dotted")# GRÁFICO 6: Ojivas
par(mar = c(5, 5, 4, 8), xpd = TRUE)
x_asc <- c(min(breaks_raw), breaks_raw[2:length(breaks_raw)])
y_asc <- c(0, Ni_asc)
x_desc <- c(min(breaks_raw), breaks_raw[2:length(breaks_raw)])
y_desc <- c(Ni_desc, 0)
x_range <- range(c(x_asc, x_desc))
y_range <- c(0, max(c(y_asc, y_desc)))
col_azul <- "#2E4053"
col_rojo <- "#C0392B"
plot(x_asc, y_asc, type = "o", col = col_azul, lwd=2, pch=19,
main = "Gráfica No.6: Ojivas Ascendente y Descendente de Profundidad de Perforación de Pozos Petroleros de Brasil",
xlab = "Profundidad de Perforación (m)", ylab = "Frecuencia acumulada",
xlim = x_range, ylim = y_range, axes = FALSE, frame.plot = FALSE, cex.main=0.9, line=3)
axis(1, at = round(breaks_raw,0), labels = format(round(breaks_raw,0), scientific = FALSE), las=2, cex.axis=0.6)
axis(2, at = pretty(y_asc), labels = format(pretty(y_asc), scientific = FALSE))
lines(x_desc, y_desc, type = "o", col = col_rojo, lwd=2, pch=19)
legend("right", legend = c("Ascendente", "Descendente"),
col = c(col_azul, col_rojo), lty = 1, pch = 19, cex = 0.7, lwd=2,
inset = c(-0.15, 0), bty="n")
grid()# CÁLCULO DE INDICADORES
media_val <- mean(Variable)
mediana_val <- median(Variable)
freq_max <- max(TDF_Profundidad$ni)
modas_calc <- TDF_Profundidad$MC[TDF_Profundidad$ni == freq_max]
moda_txt <- paste(round(modas_calc, 2), collapse = ", ")
rango_txt <- paste0("[", round(min(Variable), 2), "; ", round(max(Variable), 2), "]")
varianza_val <- var(Variable)
sd_val <- sd(Variable)
cv_val <- (sd_val / abs(media_val)) * 100
asimetria_val <- skewness(Variable, type = 2)
curtosis_val <- kurtosis(Variable, type = 2)
vals_atipicos <- boxplot.stats(Variable)$out
num_atipicos <- length(vals_atipicos)
status_atipicos <- if(num_atipicos > 0) {
min_out <- min(vals_atipicos)
max_out <- max(vals_atipicos)
paste0(num_atipicos, " [", round(min_out, 2), "; ", round(max_out, 2), "]")
} else {
"0 (Sin atípicos)"
}
df_resumen <- data.frame(
"Variable" = "Profundidad de Perforación (m)",
"Rango" = rango_txt,
"Media" = media_val,
"Mediana" = mediana_val,
"Moda" = moda_txt,
"Varianza" = varianza_val,
"Desv_Std" = sd_val,
"CV_Porc" = cv_val,
"Asimetria" = asimetria_val,
"Curtosis" = curtosis_val,
"Atipicos" = status_atipicos
)
df_resumen %>%
gt() %>%
tab_header(
title = md("**CONCLUSIONES Y ESTADÍSTICOS**"),
subtitle = "Resumen de Indicadores de Profundidad de Perforación de Pozos Petroleros de Brasil"
) %>%
tab_source_note(source_note = "Autor: Grupo 3") %>%
fmt_number(columns = c(Media, Mediana, Varianza, Desv_Std, CV_Porc, Curtosis), decimals = 2) %>%
fmt_number(columns = c(Asimetria), decimals = 4) %>%
cols_label(
Variable = "Variable",
Rango = "Rango [Min; Max]",
Media = "Media (X̄)",
Mediana = "Mediana (Me)",
Moda = "Moda (Mo)",
Varianza = "Varianza (S²)",
Desv_Std = "Desv. Est. (S)",
CV_Porc = "C.V. (%)",
Asimetria = "Asimetría (As)",
Curtosis = "Curtosis (K)",
Atipicos = "Outliers [Intervalo]"
) %>%
tab_options(
column_labels.background.color = "#2E4053",
table.border.top.color = "black",
table.border.bottom.color = "#2E4053",
column_labels.border.bottom.color = "#2E4053",
data_row.padding = px(8)
) %>%
tab_style(
style = list(cell_text(weight = "bold", color = "white")),
locations = cells_column_labels()
)| CONCLUSIONES Y ESTADÍSTICOS | ||||||||||
| Resumen de Indicadores de Profundidad de Perforación de Pozos Petroleros de Brasil | ||||||||||
| Variable | Rango [Min; Max] | Media (X̄) | Mediana (Me) | Moda (Mo) | Varianza (S²) | Desv. Est. (S) | C.V. (%) | Asimetría (As) | Curtosis (K) | Outliers [Intervalo] |
|---|---|---|---|---|---|---|---|---|---|---|
| Profundidad de Perforación (m) | [5; 8080.2] | 1,557.01 | 1,119.00 | 812.52 | 1,615,037.78 | 1,270.84 | 81.62 | 1.2423 | 1.10 | 586 [4931; 8080.2] |
| Autor: Grupo 3 | ||||||||||
min_txt <- format(min(Variable), scientific = FALSE)
max_txt <- format(max(Variable), scientific = FALSE)
asimetria_val <- skewness(Variable, type = 2)
if (abs(asimetria_val) > 0.5) {
centro_valor <- format(round(median(Variable), 2), scientific = FALSE)
valor_referencia <- median(Variable)
} else {
centro_valor <- format(round(mean(Variable), 2), scientific = FALSE)
valor_referencia <- mean(Variable)
}
sd_txt <- format(round(sd(Variable), 4), scientific = FALSE)
cv_calc <- (sd(Variable) / abs(mean(Variable))) * 100
tipo_homogeneidad <- if(cv_calc > 30) "heterogénea" else "homogénea"
donde_se_concentra <- if(asimetria_val > 0) "parte media baja (valores menores)" else "parte media alta (valores mayores)"
outliers_lista <- boxplot.stats(Variable)$out
num_outliers <- length(outliers_lista)
texto_outliers <- if(num_outliers > 0) {
paste0("con la presencia de **", num_outliers, " valores atípicos**")
} else {
"sin la agregación de valores atípicos significativos"
}
umbral_profundidad <- 3500
juicio_comportamiento <- if(valor_referencia < umbral_profundidad) {
"favorable en términos de rentabilidad operativa, ya que los registros evidencian profundidades contenidas que reducen drásticamente los costos métricos de perforación (menor tiempo de taladro y consumo de materiales), sugiriendo yacimientos ubicados en horizontes estratigráficos accesibles que no requieren una inversión de capital (CAPEX) excesiva"
} else {
"intensivo en términos de inversión (Alto CAPEX), dado que las grandes profundidades de perforación registradas implican mayores desafíos técnicos (presión/temperatura) y costos operativos elevados, característicos de la exploración de horizontes profundos o estructuras geológicas complejas"
}
cat(paste0(
"## Análisis Descriptivo y Económico\n\n",
"La variable **Profundidad de Perforación** fluctúa entre **", min_txt, "** y **", max_txt, "** metros, ",
"y sus valores se encuentran alrededor de **", centro_valor, "** metros. ",
"Presenta una desviación estándar de **", sd_txt, "**, siendo una variable **", tipo_homogeneidad, "** ",
"(CV: ", round(cv_calc, 2), "%), ",
"cuyos valores se concentran en la **", donde_se_concentra, "** de la distribución ",
texto_outliers, "; ",
"**por todo lo anterior, el comportamiento de la variable se considera ", juicio_comportamiento, ".**"
))La variable Profundidad de Perforación fluctúa entre 5 y 8080.2 metros, y sus valores se encuentran alrededor de 1119 metros. Presenta una desviación estándar de 1270.841, siendo una variable heterogénea (CV: 81.62%), cuyos valores se concentran en la parte media baja (valores menores) de la distribución con la presencia de 586 valores atípicos; por todo lo anterior, el comportamiento de la variable se considera favorable en términos de rentabilidad operativa, ya que los registros evidencian profundidades contenidas que reducen drásticamente los costos métricos de perforación (menor tiempo de taladro y consumo de materiales), sugiriendo yacimientos ubicados en horizontes estratigráficos accesibles que no requieren una inversión de capital (CAPEX) excesiva.