library(readr)
library(dplyr)
library(gt)
library(ggplot2)
library(scales)
cat("Librerías cargadas correctamente.\n")## Librerías cargadas correctamente.
Se importa el archivo 2023_01_producao_Terra.csv
(delimitado por punto y coma ; y con decimales separados
por coma ,), omitiendo las 3 filas superiores de
encabezados combinados de la ANP para acceder directamente a los
registros operativos de los pozos terrestres.
# Si deseas seleccionarlo manualmente en RStudio, descomenta la siguiente línea:
# ruta_csv <- file.choose()
ruta_csv <- "2023_01_producao_Terra.csv"
datos <- read_delim(
file = ruta_csv,
delim = ";",
skip = 3,
col_names = FALSE,
locale = locale(decimal_mark = ",", encoding = "UTF-8"),
show_col_types = FALSE
)
# Asignar nombres limpios a las columnas principales de interés
colnames(datos)[c(1, 2, 3, 5, 6, 8, 9, 10, 11, 14, 16, 19, 22)] <- c(
"Estado", "Bacia", "Poco_ANP", "Campo", "Operador", "Periodo",
"Oleo_bbl_dia", "Condensado_bbl_dia", "Petroleo_bbl_dia",
"Gas_Total_Mm3_dia", "Agua_bbl_dia", "Tempo_Producao_hs", "Grau_API"
)
cat("Archivo:", basename(ruta_csv), "| Filas:", nrow(datos), "\n")## Archivo: 2023_01_producao_Terra.csv | Filas: 5471
Para el Modelo Log-Normal se selecciona la variable
continua estrictamente positiva
Petroleo_bbl_dia (producción diaria de
petróleo en bbl/día) en pozos productores activos (\(X > 0\)). Los volúmenes de producción de
hidrocarburos abarcan varios órdenes de magnitud con fuerte sesgo
positivo en escala natural, mientras que su logaritmo natural \(Y = \ln(X)\) adopta una distribución
aproximadamente simétrica, propiedad característica del modelo $
ext{Log-Normal}({}, {}^2)$.
datos_ln <- datos %>%
filter(!is.na(Petroleo_bbl_dia), Petroleo_bbl_dia > 0) %>%
mutate(Log_Petroleo = log(Petroleo_bbl_dia))
x <- datos_ln$Petroleo_bbl_dia
y <- datos_ln$Log_Petroleo
n_obs <- length(x)
media_x <- mean(x)
mediana_x <- median(x)
sd_x <- sd(x)
min_x <- min(x)
max_x <- max(x)
mu_log <- mean(y)
sigma_log <- sd(y)
resumen_conteo <- tibble(
Metrica = c(
"Total de pozos activos con Petróleo > 0 (n)",
"Mínimo (bbl/día)",
"Mediana (bbl/día)",
"Media aritmética x̄ (bbl/día)",
"Desviación estándar s (bbl/día)",
"Máximo (bbl/día)",
"Media logarítmica μ_log = mean(ln X)",
"Desviación estándar logarítmica σ_log = sd(ln X)"
),
Valor = c(
format(n_obs, big.mark = ","),
round(min_x, 4),
round(mediana_x, 4),
round(media_x, 4),
round(sd_x, 4),
round(max_x, 4),
round(mu_log, 4),
round(sigma_log, 4)
)
)
resumen_conteo %>%
gt() %>%
tab_header(
title = md("**Resumen de Conteo y Estadísticos en Escala Original y Logarítmica**"),
subtitle = "Variable: Producción Diaria de Petróleo (Petroleo_bbl_dia > 0)"
) %>%
tab_style(
style = list(
cell_fill(color = "#F2C14E"),
cell_text(color = "#0B221E", weight = "bold")
),
locations = cells_column_labels()
) %>%
tab_style(
style = cell_text(color = "#0d2b24"),
locations = cells_title(groups = "title")
) %>%
tab_source_note(source_note = md(paste0(""))) %>%
tab_style(
style = cell_text(color = "#8C6D46"),
locations = cells_source_notes()
) %>%
opt_row_striping() %>%
tab_options(
table.background.color = "#F5F0E6",
row.striping.background_color = "#EDEAE4",
heading.title.font.size = px(16),
heading.subtitle.font.size = px(12),
table.font.size = px(13),
data_row.padding = px(6)
)| Resumen de Conteo y Estadísticos en Escala Original y Logarítmica | |
| Variable: Producción Diaria de Petróleo (Petroleo_bbl_dia > 0) | |
| Metrica | Valor |
|---|---|
| Total de pozos activos con Petróleo > 0 (n) | 5,146 |
| Mínimo (bbl/día) | 2e-04 |
| Mediana (bbl/día) | 4.8973 |
| Media aritmética x̄ (bbl/día) | 12.8319 |
| Desviación estándar s (bbl/día) | 32.3881 |
| Máximo (bbl/día) | 722.7292 |
| Media logarítmica μ_log = mean(ln X) | 1.5063 |
| Desviación estándar logarítmica σ_log = sd(ln X) | 1.504 |
Se agrupan las \(n = 5,146\) observaciones continuas en intervalos de clase mediante la regla de Sturges (\(k = \lceil 1 + 3.322 \log_{10}(n) ceil\)) en el rango operativo principal (\(0\) a \(60 ext{ bbl/día}\), que concentra más del \(96\%\) de los pozos activos), complementado con la tabla de clases por estratos completos para la validación integral, calculando frecuencia absoluta (\(n_i\)), relativa (\(h_i\)), acumulada (\(N_i\)) y relativa acumulada (\(H_i\)).
cortes_ln <- c(0, 1, 2.5, 5, 10, 20, 40, 80, ceiling(max_x / 10) * 10)
intervalos <- cut(x, breaks = cortes_ln, include.lowest = TRUE, right = FALSE)
conteo_clases <- as.data.frame(table(Intervalo = intervalos), stringsAsFactors = FALSE)
tabla_freq <- conteo_clases %>%
mutate(
Clase = row_number(),
Lim_Inf = cortes_ln[-length(cortes_ln)],
Lim_Sup = cortes_ln[-1],
Amplitud = Lim_Sup - Lim_Inf,
Marca_Clase = (Lim_Inf + Lim_Sup) / 2,
ni = Freq,
hi = ni / sum(ni),
Ni = cumsum(ni),
Hi = cumsum(hi),
Porcentaje = hi * 100,
Porc_Acum = Hi * 100,
Densidad = hi / Amplitud
)
tabla_freq %>%
select(
`Clase` = Clase,
`Intervalo (bbl/día)` = Intervalo,
`Marca (Xi)` = Marca_Clase,
`Frec. Abs. (ni)` = ni,
`Frec. Rel. (hi)` = hi,
`Porcentaje (%)` = Porcentaje,
`Frec. Acum. (Ni)` = Ni,
`Porc. Acum. (%)` = Porc_Acum,
`Densidad` = Densidad
) %>%
gt() %>%
tab_header(
title = md("**Tabla de Distribución de Frecuencias — Producción Diaria de Petróleo**"),
subtitle = paste0("Variable: Petroleo_bbl_dia > 0 | Total n = ", format(n_obs, big.mark = ","), " pozos")
) %>%
fmt_number(columns = c(`Marca (Xi)`, `Porcentaje (%)`, `Porc. Acum. (%)`), decimals = 2) %>%
fmt_number(columns = c(`Frec. Abs. (ni)`, `Frec. Acum. (Ni)`), decimals = 0) %>%
fmt_number(columns = c(`Frec. Rel. (hi)`), decimals = 4) %>%
fmt_number(columns = c(`Densidad`), decimals = 6) %>%
grand_summary_rows(
columns = c(`Frec. Abs. (ni)`),
fns = list(Total = ~sum(.)),
fmt = ~fmt_number(., decimals = 0)
) %>%
grand_summary_rows(
columns = c(`Porcentaje (%)`),
fns = list(Total = ~sum(.)),
fmt = ~fmt_number(., decimals = 2)
) %>%
tab_style(
style = list(
cell_fill(color = "#F2C14E"),
cell_text(color = "#0B221E", weight = "bold")
),
locations = cells_column_labels()
) %>%
tab_style(
style = cell_text(color = "#0d2b24"),
locations = cells_title(groups = "title")
) %>%
tab_style(
style = list(
cell_fill(color = "#FBEFC8"),
cell_text(weight = "bold")
),
locations = cells_grand_summary(columns = everything())
) %>%
tab_source_note(source_note = md(paste0(""))) %>%
tab_style(
style = cell_text(color = "#8C6D46"),
locations = cells_source_notes()
) %>%
opt_row_striping() %>%
tab_options(
table.background.color = "#F5F0E6",
row.striping.background_color = "#EDEAE4",
heading.title.font.size = px(16),
heading.subtitle.font.size = px(12),
table.font.size = px(13),
data_row.padding = px(6)
)| Tabla de Distribución de Frecuencias — Producción Diaria de Petróleo | |||||||||
| Variable: Petroleo_bbl_dia > 0 | Total n = 5,146 pozos | |||||||||
| Clase | Intervalo (bbl/día) | Marca (Xi) | Frec. Abs. (ni) | Frec. Rel. (hi) | Porcentaje (%) | Frec. Acum. (Ni) | Porc. Acum. (%) | Densidad | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | [0,1) | 0.50 | 733 | 0.1424 | 14.24 | 733 | 14.24 | 0.142441 | |
| 2 | [1,2.5) | 1.75 | 876 | 0.1702 | 17.02 | 1,609 | 31.27 | 0.113486 | |
| 3 | [2.5,5) | 3.75 | 995 | 0.1934 | 19.34 | 2,604 | 50.60 | 0.077342 | |
| 4 | [5,10) | 7.50 | 1,055 | 0.2050 | 20.50 | 3,659 | 71.10 | 0.041003 | |
| 5 | [10,20) | 15.00 | 786 | 0.1527 | 15.27 | 4,445 | 86.38 | 0.015274 | |
| 6 | [20,40) | 30.00 | 411 | 0.0799 | 7.99 | 4,856 | 94.36 | 0.003993 | |
| 7 | [40,80) | 60.00 | 168 | 0.0326 | 3.26 | 5,024 | 97.63 | 0.000816 | |
| 8 | [80,730] | 405.00 | 122 | 0.0237 | 2.37 | 5,146 | 100.00 | 0.000036 | |
| Total | — | — | — | 5,146 | — | 100.00 | — | — | — |
Se muestra en primer lugar el histograma general empírico de densidad de probabilidad en la zona de mayor concentración operativa (\(0\) a \(60 ext{ bbl/día}\), que reúne más del \(96\%\) de los pozos activos), evidenciando el pico inicial pronunciado y el decaimiento asimétrico hacia la derecha.
cortes_zoom <- seq(0, 60, by = 5)
datos_zoom <- datos_ln %>% filter(Petroleo_bbl_dia <= 60)
ggplot(datos_zoom, aes(x = Petroleo_bbl_dia)) +
geom_histogram(
aes(y = after_stat(density), fill = "Histograma Empírico"),
breaks = cortes_zoom,
color = "#8C6D46",
alpha = 0.85
) +
scale_fill_manual(values = c("Histograma Empírico" = "#EDEAE4")) +
scale_x_continuous(breaks = cortes_zoom) +
labs(
title = "Histograma General Empírico — Producción Diaria de Petróleo",
subtitle = paste0(
"Distribución observada en tramo operativo 0 – 60 bbl/día (n = ",
format(n_obs, big.mark = ","), " pozos activos)"
),
x = "Producción Diaria de Petróleo (bbl/día)",
y = "Densidad de Probabilidad",
fill = NULL
) +
theme_classic(base_size = 13) +
theme(
plot.title = element_text(face = "bold", hjust = 0.5, color = "#0d2b24"),
plot.subtitle = element_text(hjust = 0.5, color = "#8C6D46"),
legend.position = "none"
)En ingeniería de yacimientos, la productividad individual de los pozos responde al producto multiplicativo de factores geológicos (permeabilidad, espesor neto, porosidad y presión de reservorio). Por el teorema del límite central multiplicativo, una variable positiva generada por este mecanismo tiende a seguir una distribución Log-Normal.
Se plantea la siguiente conjetura estadística:
“La producción diaria de petróleo
Petroleo_bbl_dia(\(X > 0\)) se ajusta a un Modelo Log-Normal con parámetros \(\hat{\mu}_{\log} = 1.5063\) y \(\hat{\sigma}_{\log} = 1.504\), de modo que su mediana teórica \(e^{\hat{\mu}_{\log}}\) reproduce adecuadamente el rendimiento típico de los pozos terrestres.”
Formalmente:
mediana_teo_ln <- exp(mu_log)
media_teo_ln <- exp(mu_log + (sigma_log^2) / 2)
moda_teo_ln <- exp(mu_log - sigma_log^2)
tabla_ajuste <- tibble(
Parametro_Metrica = c(
"Parámetro de escala logarítmica (μ̂_log)",
"Parámetro de forma logarítmica (σ̂_log)",
"Mediana teórica exp(μ̂_log) [bbl/día]",
"Moda teórica exp(μ̂_log - σ̂_log²) [bbl/día]",
"Media teórica exp(μ̂_log + σ̂_log² / 2) [bbl/día]"
),
Modelo_LogNormal = c(
round(mu_log, 4),
round(sigma_log, 4),
round(mediana_teo_ln, 4),
round(moda_teo_ln, 4),
round(media_teo_ln, 4)
),
Muestra_Observada = c(
"—",
"—",
paste0(round(mediana_x, 4), " (Mediana empírica)"),
"—",
paste0(round(media_x, 4), " (Media empírica)")
)
)
tabla_ajuste %>%
gt() %>%
tab_header(
title = md("**Parámetros Ajustados por Máxima Verosimilitud — Modelo Log-Normal**"),
subtitle = "Estimación de μ_log y σ_log sobre ln(Petroleo_bbl_dia)"
) %>%
cols_label(
Parametro_Metrica = "Parámetro / Estadístico",
Modelo_LogNormal = "Valor Teórico Log-Normal",
Muestra_Observada = "Referencia Empírica"
) %>%
tab_style(
style = list(
cell_fill(color = "#F2C14E"),
cell_text(color = "#0B221E", weight = "bold")
),
locations = cells_column_labels()
) %>%
tab_style(
style = cell_text(color = "#0d2b24"),
locations = cells_title(groups = "title")
) %>%
tab_source_note(source_note = md(paste0(""))) %>%
tab_style(
style = cell_text(color = "#8C6D46"),
locations = cells_source_notes()
) %>%
opt_row_striping() %>%
tab_options(
table.background.color = "#F5F0E6",
row.striping.background_color = "#EDEAE4",
heading.title.font.size = px(16),
heading.subtitle.font.size = px(12),
table.font.size = px(13),
data_row.padding = px(6)
)| Parámetros Ajustados por Máxima Verosimilitud — Modelo Log-Normal | ||
| Estimación de μ_log y σ_log sobre ln(Petroleo_bbl_dia) | ||
| Parámetro / Estadístico | Valor Teórico Log-Normal | Referencia Empírica |
|---|---|---|
| Parámetro de escala logarítmica (μ̂_log) | 1.5063 | — |
| Parámetro de forma logarítmica (σ̂_log) | 1.5040 | — |
| Mediana teórica exp(μ̂_log) [bbl/día] | 4.5101 | 4.8973 (Mediana empírica) |
| Moda teórica exp(μ̂_log - σ̂_log²) [bbl/día] | 0.4697 | — |
| Media teórica exp(μ̂_log + σ̂_log² / 2) [bbl/día] | 13.9751 | 12.8319 (Media empírica) |
Se superpone sobre el histograma general la función de densidad teórica ajustada del Modelo Log-Normal:
\[f(x) = rac{1}{x\,\hat{\sigma}_{\log}\sqrt{2\pi}} \exp\!\left(-rac{(\ln x - \hat{\mu}_{\log})^2}{2\hat{\sigma}_{\log}^2} ight), \quad x > 0\]
junto con la comprobación en escala logarítmica transformada \(Y = \ln(X) \sim N(\hat{\mu}_{\log}, \hat{\sigma}_{\log}^2)\).
ggplot(datos_zoom, aes(x = Petroleo_bbl_dia)) +
geom_histogram(
aes(y = after_stat(density), fill = "Histograma Empírico"),
breaks = cortes_zoom,
color = "#8C6D46",
alpha = 0.85
) +
stat_function(
fun = dlnorm,
args = list(meanlog = mu_log, sdlog = sigma_log),
aes(color = "Curva Log-Normal Ajustada"),
linewidth = 1.25
) +
scale_fill_manual(values = c("Histograma Empírico" = "#EDEAE4")) +
scale_color_manual(values = c("Curva Log-Normal Ajustada" = "#8C6D46")) +
scale_x_continuous(breaks = cortes_zoom) +
labs(
title = paste0(
"Histograma con Curva Teórica Ajustada — Log-Normal (μ̂_log = ",
round(mu_log, 4), ", σ̂_log = ", round(sigma_log, 4), ")"
),
subtitle = "Densidad empírica vs. densidad teórica Log-Normal (tramo 0 – 60 bbl/día)",
x = "Producción Diaria de Petróleo (bbl/día)",
y = "Densidad de Probabilidad",
fill = NULL,
color = NULL
) +
theme_classic(base_size = 13) +
theme(
plot.title = element_text(face = "bold", hjust = 0.5, color = "#0d2b24"),
plot.subtitle = element_text(hjust = 0.5, color = "#8C6D46"),
legend.position = c(0.76, 0.85)
)ggplot(datos_ln, aes(x = Log_Petroleo)) +
geom_histogram(
aes(y = after_stat(density), fill = "Histograma ln(Petróleo)"),
bins = 20,
color = "#8C6D46",
alpha = 0.82
) +
stat_function(
fun = dnorm,
args = list(mean = mu_log, sd = sigma_log),
aes(color = "Curva Normal N(μ̂_log, σ̂_log²)"),
linewidth = 1.2
) +
scale_fill_manual(values = c("Histograma ln(Petróleo)" = "#EDEAE4")) +
scale_color_manual(values = c("Curva Normal N(μ̂_log, σ̂_log²)" = "#8C6D46")) +
labs(
title = "Comprobación en Escala Logarítmica: ln(Petroleo_bbl_dia)",
subtitle = "Simetría de los datos transformados frente a la distribución Normal asociada",
x = "ln(Producción Diaria de Petróleo)",
y = "Densidad",
fill = NULL,
color = NULL
) +
theme_minimal(base_size = 13) +
theme(
plot.title = element_text(face = "bold", color = "#0d2b24"),
legend.position = c(0.22, 0.85)
)Se valida el ajuste del Modelo Log-Normal
contrastando las frecuencias observadas (\(O_i\)) contra las frecuencias esperadas
(\(E_i = N \cdot [F_{ ext{LN}}(b_i) - F_{
ext{LN}}(a_i)]\)) a través de los intervalos de clase definidos
mediante plnorm(), evaluando las diferencias absolutas,
errores porcentuales y el estadístico de bondad de ajuste \(\chi^2\).
prob_teoricas <- diff(plnorm(cortes_ln, meanlog = mu_log, sdlog = sigma_log))
prob_teoricas <- prob_teoricas / sum(prob_teoricas)
tabla_validacion <- tabla_freq %>%
mutate(
Prob_Obs = hi,
Prob_Teo = prob_teoricas,
Esp_LogNormal = Prob_Teo * n_obs,
Diff_Porcentual = (Prob_Obs - Prob_Teo) * 100,
Aporte_Chi2 = (ni - Esp_LogNormal)^2 / Esp_LogNormal
)
chi2_ln <- sum(tabla_validacion$Aporte_Chi2)
gl_ln <- nrow(tabla_validacion) - 1 - 2
tabla_validacion %>%
select(
`Clase` = Clase,
`Intervalo (bbl/día)` = Intervalo,
`Frec. Obs. (Oi)` = ni,
`Frec. Esp. (Ei)` = Esp_LogNormal,
`Prob. Obs. (%)` = Porcentaje,
`Prob. Log-Normal (%)` = Prob_Teo,
`Diferencia (%)` = Diff_Porcentual,
`Aporte Chi²` = Aporte_Chi2
) %>%
mutate(`Prob. Log-Normal (%)` = `Prob. Log-Normal (%)` * 100) %>%
gt() %>%
tab_header(
title = md("**Tabla de Validación — Frecuencias Observadas vs. Modelo Log-Normal**"),
subtitle = paste0(
"X² = ", round(chi2_ln, 2),
" | gl = ", gl_ln,
" | Error absoluto medio por clase = ",
round(mean(abs(tabla_validacion$Diff_Porcentual)), 2), "%"
)
) %>%
fmt_number(columns = c(`Frec. Obs. (Oi)`), decimals = 0) %>%
fmt_number(columns = c(`Frec. Esp. (Ei)`, `Prob. Obs. (%)`, `Prob. Log-Normal (%)`, `Diferencia (%)`, `Aporte Chi²`), decimals = 2) %>%
grand_summary_rows(
columns = c(`Frec. Obs. (Oi)`, `Frec. Esp. (Ei)`),
fns = list(Total = ~sum(.)),
fmt = ~fmt_number(., decimals = 0)
) %>%
tab_style(
style = list(
cell_fill(color = "#F2C14E"),
cell_text(color = "#0B221E", weight = "bold")
),
locations = cells_column_labels()
) %>%
tab_style(
style = cell_text(color = "#0d2b24"),
locations = cells_title(groups = "title")
) %>%
tab_style(
style = list(
cell_fill(color = "#FBEFC8"),
cell_text(weight = "bold")
),
locations = cells_grand_summary(columns = everything())
) %>%
tab_source_note(source_note = md(paste0(""))) %>%
tab_style(
style = cell_text(color = "#8C6D46"),
locations = cells_source_notes()
) %>%
opt_row_striping() %>%
tab_options(
table.background.color = "#F5F0E6",
row.striping.background_color = "#EDEAE4",
heading.title.font.size = px(16),
heading.subtitle.font.size = px(12),
table.font.size = px(13),
data_row.padding = px(6)
)| Tabla de Validación — Frecuencias Observadas vs. Modelo Log-Normal | ||||||||
| X² = 84.49 | gl = 5 | Error absoluto medio por clase = 1.48% | ||||||||
| Clase | Intervalo (bbl/día) | Frec. Obs. (Oi) | Frec. Esp. (Ei) | Prob. Obs. (%) | Prob. Log-Normal (%) | Diferencia (%) | Aporte Chi² | |
|---|---|---|---|---|---|---|---|---|
| 1 | [0,1) | 733 | 814.80 | 14.24 | 15.83 | −1.59 | 8.21 | |
| 2 | [1,2.5) | 876 | 973.64 | 17.02 | 18.92 | −1.90 | 9.79 | |
| 3 | [2.5,5) | 995 | 926.20 | 19.34 | 18.00 | 1.34 | 5.11 | |
| 4 | [5,10) | 1,055 | 897.88 | 20.50 | 17.45 | 3.05 | 27.49 | |
| 5 | [10,20) | 786 | 706.49 | 15.27 | 13.73 | 1.55 | 8.95 | |
| 6 | [20,40) | 411 | 451.19 | 7.99 | 8.77 | −0.78 | 3.58 | |
| 7 | [40,80) | 168 | 233.86 | 3.26 | 4.54 | −1.28 | 18.55 | |
| 8 | [80,730] | 122 | 141.94 | 2.37 | 2.76 | −0.39 | 2.80 | |
| Total | — | — | 5,146 | 5,146 | — | — | — | — |
ggplot(datos_ln, aes(x = Petroleo_bbl_dia)) +
stat_ecdf(aes(color = "ECDF Empírica"), geom = "step", linewidth = 1.1) +
stat_function(
fun = plnorm,
args = list(meanlog = mu_log, sdlog = sigma_log),
aes(color = "CDF Log-Normal Teórica"),
linewidth = 1.1,
linetype = "dashed"
) +
scale_x_log10(labels = comma) +
scale_color_manual(values = c("ECDF Empírica" = "#0d2b24", "CDF Log-Normal Teórica" = "#8C6D46")) +
labs(
title = "Validación Acumulada (ECDF vs. CDF Log-Normal en Escala Logarítmica)",
subtitle = "Correspondencia acumulada P(X ≤ x) sobre todo el rango productivo",
x = "Producción Diaria de Petróleo (bbl/día — escala log10)",
y = "Probabilidad Acumulada F(x)",
color = "Distribución"
) +
theme_minimal(base_size = 13) +
theme(
plot.title = element_text(face = "bold", color = "#0d2b24"),
legend.position = c(0.22, 0.80)
)Dado que \(Y = \ln(X) \sim N(\mu_{\log}, \sigma_{\log}^2)\), se construyen los intervalos de confianza al \(95\%\) (\(lpha = 0.05\)) para los parámetros logarítmicos y se transforman exponencialmente para obtener el intervalo de confianza exacto de la mediana poblacional (\(e^{\mu_{\log}}\)):
alpha <- 0.05
gl_ln_ic <- n_obs - 1
t_crit <- qt(1 - alpha / 2, df = gl_ln_ic)
ee_log <- sigma_log / sqrt(n_obs)
ic_mulog_inf <- mu_log - t_crit * ee_log
ic_mulog_sup <- mu_log + t_crit * ee_log
ic_med_inf <- exp(ic_mulog_inf)
ic_med_sup <- exp(ic_mulog_sup)
chi2_inf <- qchisq(alpha / 2, df = gl_ln_ic)
chi2_sup <- qchisq(1 - alpha / 2, df = gl_ln_ic)
ic_sigmalog_inf <- sqrt((gl_ln_ic * sigma_log^2) / chi2_sup)
ic_sigmalog_sup <- sqrt((gl_ln_ic * sigma_log^2) / chi2_inf)
tabla_ic <- tibble(
Parametro = c(
"Media logarítmica μ_log",
"Desviación estándar logarítmica σ_log",
"Mediana poblacional exp(μ_log) [bbl/día]"
),
Estimacion_Puntual = c(
round(mu_log, 4),
round(sigma_log, 4),
round(mediana_teo_ln, 4)
),
Limite_Inferior_95 = c(
round(ic_mulog_inf, 4),
round(ic_sigmalog_inf, 4),
round(ic_med_inf, 4)
),
Limite_Superior_95 = c(
round(ic_mulog_sup, 4),
round(ic_sigmalog_sup, 4),
round(ic_med_sup, 4)
),
Amplitud = c(
round(ic_mulog_sup - ic_mulog_inf, 4),
round(ic_sigmalog_sup - ic_sigmalog_inf, 4),
round(ic_med_sup - ic_med_inf, 4)
)
)
tabla_ic %>%
gt() %>%
tab_header(
title = md("**Intervalos de Confianza al 95% — Modelo Log-Normal**"),
subtitle = paste0("Basado en n = ", format(n_obs, big.mark = ","), " pozos productores activos")
) %>%
cols_label(
Parametro = "Parámetro Poblacional",
Estimacion_Puntual = "Estimación Puntual",
Limite_Inferior_95 = "Límite Inferior (2.5%)",
Limite_Superior_95 = "Límite Superior (97.5%)",
Amplitud = "Amplitud del IC"
) %>%
tab_style(
style = list(
cell_fill(color = "#F2C14E"),
cell_text(color = "#0B221E", weight = "bold")
),
locations = cells_column_labels()
) %>%
tab_style(
style = cell_text(color = "#0d2b24"),
locations = cells_title(groups = "title")
) %>%
tab_source_note(source_note = md(paste0(""))) %>%
tab_style(
style = cell_text(color = "#8C6D46"),
locations = cells_source_notes()
) %>%
opt_row_striping() %>%
tab_options(
table.background.color = "#F5F0E6",
row.striping.background_color = "#EDEAE4",
heading.title.font.size = px(16),
heading.subtitle.font.size = px(12),
table.font.size = px(13),
data_row.padding = px(6)
)| Intervalos de Confianza al 95% — Modelo Log-Normal | ||||
| Basado en n = 5,146 pozos productores activos | ||||
| Parámetro Poblacional | Estimación Puntual | Límite Inferior (2.5%) | Límite Superior (97.5%) | Amplitud del IC |
|---|---|---|---|---|
| Media logarítmica μ_log | 1.5063 | 1.4652 | 1.5474 | 0.0822 |
| Desviación estándar logarítmica σ_log | 1.5040 | 1.4755 | 1.5336 | 0.0581 |
| Mediana poblacional exp(μ_log) [bbl/día] | 4.5101 | 4.3285 | 4.6993 | 0.3708 |
df_ic_plot <- tibble(
Parametro = "Mediana Poblacional exp(μ_log) [bbl/día]",
Estimacion = mediana_teo_ln,
LI = ic_med_inf,
LS = ic_med_sup
)
ggplot(df_ic_plot, aes(x = Parametro, y = Estimacion)) +
geom_errorbar(aes(ymin = LI, ymax = LS), width = 0.15, linewidth = 1.2, color = "#8C6D46") +
geom_point(size = 4.5, color = "#0d2b24") +
geom_text(
aes(label = paste0("exp(μ̂_log) = ", round(Estimacion, 3), " bbl/día")),
hjust = -0.22,
fontface = "bold",
color = "#0d2b24"
) +
geom_text(
aes(y = LI, label = paste0("LI 95%: ", round(LI, 3))),
hjust = 1.2,
size = 3.8,
color = "#8C6D46"
) +
geom_text(
aes(y = LS, label = paste0("LS 95%: ", round(LS, 3))),
hjust = 1.2,
size = 3.8,
color = "#8C6D46"
) +
scale_y_continuous(limits = c(ic_med_inf - 0.3, ic_med_sup + 0.3)) +
labs(
title = "Intervalo de Confianza al 95% para la Mediana Poblacional de Producción",
subtitle = "Transformación exponencial bajo el Modelo Log-Normal",
x = NULL,
y = "Producción Mediana de Petróleo (bbl/día)"
) +
theme_minimal(base_size = 13) +
theme(plot.title = element_text(face = "bold", color = "#0d2b24"))Petroleo_bbl_dia > 0), la producción diaria abarca
desde \(0.0002\) hasta \(722.73 ext{ bbl/día}\), ajustándose al
modelo $ ext{Log-Normal}({} = 1.5063,; {} = 1.5040)\(. La mediana teórica resultante
(\)e^{1.5063} = 4.51 ext{ bbl/día}$) coincide estrechamente con
la mediana muestral observada (\(4.90 ext{
bbl/día}\)).