1. Cargar Librerías

library(readr); library(dplyr); library(gt); library(MASS)
cat("Librerías cargadas correctamente.\n")
## Librerías cargadas correctamente.

2. Cargar Datos

ruta_csv <- file.choose()
datos    <- read_csv(ruta_csv, show_col_types = FALSE)
cat("Archivo:", basename(ruta_csv), "| Filas:", nrow(datos), "\n")
## Archivo: oil_and_gas_leases_data (2).csv | Filas: 47757

3. Conteo

x_raw <- datos %>%
  mutate(SEC = suppressWarnings(as.integer(SECTION))) %>%
  filter(!is.na(SEC), SEC >= 1, SEC <= 36) %>%
  pull(SEC)

n_conteo  <- length(x_raw)
k_sturges <- ceiling(1 + 3.322 * log10(n_conteo))

cat("Observaciones válidas:", n_conteo, "\n")
## Observaciones válidas: 47757
cat("Clases (Regla de Sturges):", k_sturges, "\n")
## Clases (Regla de Sturges): 17
cat("Mínimo:", min(x_raw), "| Máximo:", max(x_raw), "\n")
## Mínimo: 1 | Máximo: 36

4. Tabla de Distribución de Frecuencias

Se calcula la distribución de frecuencias absolutas y relativas para la variable cuantitativa discreta agrupada Sección, correspondiente a los arrendamientos de hidrocarburos registrados en Kansas, EE.UU.

x_min_st   <- min(x_raw); x_max_st <- max(x_raw)
rango_st   <- x_max_st - x_min_st
c_amp_st   <- ceiling(rango_st / k_sturges)
k_st       <- ceiling((rango_st + 1) / c_amp_st)
lim_inf_st <- x_min_st + (0:(k_st - 1)) * c_amp_st
lim_sup_st <- lim_inf_st + c_amp_st
lim_sup_st[k_st] <- x_max_st + 1
mc_st      <- floor((lim_inf_st + lim_sup_st) / 2)
breaks_st  <- c(lim_inf_st, lim_sup_st[k_st])

intervalos_cut_st <- cut(x_raw, breaks = breaks_st, right = FALSE, include.lowest = TRUE)
freq_abs_st       <- as.integer(table(intervalos_cut_st))

li_st <- lim_inf_st
ls_st <- lim_sup_st

hi_dec_st  <- freq_abs_st / n_conteo
Ni_asc_st  <- cumsum(freq_abs_st)
Hi_asc_st  <- cumsum(hi_dec_st)
Ni_desc_st <- n_conteo - c(0, head(Ni_asc_st, -1))
Hi_desc_st <- 1 - c(0, head(Hi_asc_st, -1))

etiq_st        <- paste0("[", li_st, " – ", ls_st, ")")
etiq_st[k_st]  <- paste0("[", li_st[k_st], " – ", ls_st[k_st] - 1, "]")

tabla_st_df <- data.frame(
  Intervalo = etiq_st,
  MC        = as.integer(mc_st),
  ni        = freq_abs_st,
  hi_pct    = round(hi_dec_st * 100, 2),
  hi_real   = round(hi_dec_st, 4),
  Ni_a      = Ni_asc_st,
  Hi_a      = round(Hi_asc_st, 4),
  Ni_d      = Ni_desc_st,
  Hi_d      = round(Hi_desc_st, 4),
  stringsAsFactors = FALSE
)

total_st_row <- data.frame(
  Intervalo = "TOTAL",
  MC        = NA_integer_,
  ni        = sum(freq_abs_st),
  hi_pct    = round(sum(hi_dec_st) * 100, 2),
  hi_real   = round(sum(hi_dec_st), 4),
  Ni_a      = max(Ni_asc_st),
  Hi_a      = round(max(Hi_asc_st), 4),
  Ni_d      = max(Ni_desc_st),
  Hi_d      = round(max(Hi_desc_st), 4),
  stringsAsFactors = FALSE
)

tabla_sturges_final <- bind_rows(tabla_st_df, total_st_row)

tabla_sturges_final %>%
  gt() %>%
  tab_header(
    title    = md("**Distribución de Frecuencias — Regla de Sturges (referencial)**"),
    subtitle = md(paste0(
      "*Sección, Kansas, EE.UU. (n = ",
      format(n_conteo, big.mark = ","), ", k = ", k_st, " intervalos)*"
    ))
  ) %>%
  cols_label(
    Intervalo = md("**Intervalo [Li – Ls)**"),
    MC        = md("**Marca de Clase**"),
    ni        = md("**ni (FA)**"),
    hi_pct    = md("**hi %**"),
    hi_real   = md("**hi (decimal)**"),
    Ni_a      = md("**Ni ↑ (FAAa)**"),
    Hi_a      = md("**Hi ↑ (FRAa)**"),
    Ni_d      = md("**Ni ↓ (FAAd)**"),
    Hi_d      = md("**Hi ↓ (FRAd)**")
  ) %>%
  tab_style(
    style = list(cell_fill(color = "#2C2C2C"), cell_text(color = "white", weight = "bold")),
    locations = cells_column_labels()
  ) %>%
  tab_style(
    style = cell_fill(color = "#F5F5F5"),
    locations = cells_body(rows = seq(1, nrow(tabla_sturges_final), by = 2))
  ) %>%
  tab_style(
    style = list(cell_fill(color = "#D6D6D6"), cell_text(weight = "bold")),
    locations = cells_body(rows = Intervalo == "TOTAL", columns = everything())
  ) %>%
  fmt_missing(columns = everything(), missing_text = "—") %>%
  tab_source_note(source_note = md("*Autor: Leslye Quinchiguango*")) %>%
  tab_options(
    table.width                = pct(100),
    heading.title.font.size    = px(15),
    heading.subtitle.font.size = px(11),
    table.font.size            = px(12),
    data_row.padding           = px(4)
  )
Distribución de Frecuencias — Regla de Sturges (referencial)
Sección, Kansas, EE.UU. (n = 47,757, k = 12 intervalos)
Intervalo [Li – Ls) Marca de Clase ni (FA) hi % hi (decimal) Ni ↑ (FAAa) Hi ↑ (FRAa) Ni ↓ (FAAd) Hi ↓ (FRAd)
[1 – 4) 2 4036 8.45 0.0845 4036 0.0845 47757 1.0000
[4 – 7) 5 3976 8.33 0.0833 8012 0.1678 43721 0.9155
[7 – 10) 8 4008 8.39 0.0839 12020 0.2517 39745 0.8322
[10 – 13) 11 4042 8.46 0.0846 16062 0.3363 35737 0.7483
[13 – 16) 14 4081 8.55 0.0855 20143 0.4218 31695 0.6637
[16 – 19) 17 4078 8.54 0.0854 24221 0.5072 27614 0.5782
[19 – 22) 20 3927 8.22 0.0822 28148 0.5894 23536 0.4928
[22 – 25) 23 3989 8.35 0.0835 32137 0.6729 19609 0.4106
[25 – 28) 26 3913 8.19 0.0819 36050 0.7549 15620 0.3271
[28 – 31) 29 3900 8.17 0.0817 39950 0.8365 11707 0.2451
[31 – 34) 32 3823 8.01 0.0801 43773 0.9166 7807 0.1635
[34 – 36] 35 3984 8.34 0.0834 47757 1.0000 3984 0.0834
TOTAL 47757 100.00 1.0000 47757 1.0000 47757 1.0000
Autor: Leslye Quinchiguango

Aplicando la Regla de Sturges, con 47,757 observaciones corresponderían 12 intervalos de clase. Sin embargo, un desglose tan fino dificulta la lectura visual y el ajuste de los indicadores sobre la distribución. Por ello, se simplifica el análisis a una tabla de máximo 10 intervalos de clase, criterio que conserva representatividad estadística sin sacrificar claridad interpretativa.

Justificación del agrupamiento. Sección es discreta, pero al tomar 36 valores únicos posibles (del 1 al 36, según el sistema PLSS), una tabla de frecuencia simple resultaría extensa y poco legible. Por ello se agrupa en intervalos de clase, como se hace con variables continuas, únicamente como recurso para resumir la información; su naturaleza discreta se conserva en los límites e indicadores, que siguen siendo enteros.

intervalos_cut <- cut(x, breaks = breaks_vec, right = FALSE, include.lowest = TRUE)
freq_abs       <- as.integer(table(intervalos_cut))
hi_dec         <- freq_abs / n
Ni_asc         <- cumsum(freq_abs); Hi_asc  <- cumsum(hi_dec)
Ni_desc        <- n - c(0, head(Ni_asc,-1)); Hi_desc <- 1 - c(0, head(Hi_asc,-1))
etiq           <- paste0("[", lim_inf, " - ", lim_sup, ")")
etiq[k]        <- paste0("[", lim_inf[k], " - ", lim_sup[k]-1, "]")

bind_rows(
  data.frame(Intervalo=etiq, MC=as.integer(mc), ni=freq_abs,
             hi_pct=round(hi_dec*100,2), hi_real=round(hi_dec,4),
             Ni_a=Ni_asc, Hi_a=round(Hi_asc,4),
             Ni_d=Ni_desc, Hi_d=round(Hi_desc,4), stringsAsFactors=FALSE),
  data.frame(Intervalo="TOTAL", MC=NA_integer_, ni=sum(freq_abs),
             hi_pct=round(sum(hi_dec)*100,2), hi_real=round(sum(hi_dec),4),
             Ni_a=max(Ni_asc), Hi_a=round(max(Hi_asc),4),
             Ni_d=max(Ni_desc), Hi_d=round(max(Hi_desc),4), stringsAsFactors=FALSE)
) %>%
  gt() %>%
  tab_header(title    = md("**Tabla N\u00b01: Distribución de Frecuencias**"),
             subtitle = md(paste0("*Variable Cuantitativa Discreta Agrupada: Secci\u00f3n, ",
                                  "Kansas (n = ", format(n, big.mark=","), ")*"))) %>%
  cols_label(Intervalo=md("**Intervalo**"), MC=md("**MC**"), ni=md("**ni**"),
             hi_pct=md("**hi%**"), hi_real=md("**hi**"),
             Ni_a=md("**Ni (asc)**"), Hi_a=md("**Hi (asc)**"),
             Ni_d=md("**Ni (desc)**"), Hi_d=md("**Hi (desc)**")) %>%
  tab_style(style=list(cell_fill(color="#2C2C2C"),cell_text(color="white",weight="bold")),
            locations=cells_column_labels()) %>%
  tab_style(style=cell_fill(color="#F5F5F5"), locations=cells_body(rows=seq(1,k+1,by=2))) %>%
  tab_style(style=list(cell_fill(color="#D6D6D6"),cell_text(weight="bold")),
            locations=cells_body(rows=Intervalo=="TOTAL")) %>%
  fmt_missing(columns=everything(), missing_text="-") %>%
  tab_source_note(source_note=md("*Autor: Leslye Quinchiguango*")) %>%
  tab_options(table.width=pct(100), table.font.size=px(13), data_row.padding=px(6))
Tabla N°1: Distribución de Frecuencias
Variable Cuantitativa Discreta Agrupada: Sección, Kansas (n = 47,757)
Intervalo MC ni hi% hi Ni (asc) Hi (asc) Ni (desc) Hi (desc)
[1 - 5) 3 5445 11.40 0.1140 5445 0.1140 47757 1.0000
[5 - 9) 7 5254 11.00 0.1100 10699 0.2240 42312 0.8860
[9 - 13) 11 5363 11.23 0.1123 16062 0.3363 37058 0.7760
[13 - 17) 15 5454 11.42 0.1142 21516 0.4505 31695 0.6637
[17 - 21) 19 5349 11.20 0.1120 26865 0.5625 26241 0.5495
[21 - 25) 23 5272 11.04 0.1104 32137 0.6729 20892 0.4375
[25 - 29) 27 5226 10.94 0.1094 37363 0.7824 15620 0.3271
[29 - 33) 31 5110 10.70 0.1070 42473 0.8894 10394 0.2176
[33 - 36] 35 5284 11.06 0.1106 47757 1.0000 5284 0.1106
TOTAL - 47757 100.00 1.0000 47757 1.0000 47757 1.0000
Autor: Leslye Quinchiguango

5. Gráfico Histograma General

grises        <- gray(seq(0.25, 0.80, length.out=k))
h_obj         <- hist(x, breaks=breaks_vec, plot=FALSE)
h_obj$density <- hi_dec

par(mar=c(5,6,6,2))
plot(h_obj, col=grises, border="black", freq=FALSE,
     main="", xlab="", ylab="", las=1, xaxt="n")
axis(1, at=breaks_vec, labels=breaks_vec, las=1, cex.axis=0.9)
mtext("Densidad de Probabilidad", side=2, line=4.5, cex=1)
mtext("Secci\u00f3n",            side=1, line=3.5, cex=1)
mtext("Histograma General \u2014 Secci\u00f3n, arrendamientos de hidrocarburos, Kansas, EE.UU.",
      side=3, line=3, cex=0.95, font=2)

6. Conjetura

El histograma de la variable Sección muestra barras de altura prácticamente idéntica en todos los intervalos, sin concentración ni cola en ningún extremo. Este comportamiento es la característica definitoria de una distribución Uniforme Continua, donde todos los valores tienen la misma probabilidad de ocurrencia. Se ajusta un único modelo Uniforme sobre toda la distribución con parámetros \(\hat{a} = \min(x)\) y \(\hat{b} = \max(x)\).

\[f(x) = \frac{1}{\hat{b} - \hat{a}}, \qquad \hat{a} \leq x \leq \hat{b}\]

a_hat <- x_min
b_hat <- x_max

densidad_unif <- 1 / (b_hat - a_hat)

cat("=== Modelo Uniforme Continua ===\n")
## === Modelo Uniforme Continua ===
cat("\u00e2 (mínimo) :", a_hat, "\n")
## â (mínimo) : 1
cat("b\u0302 (máximo) :", b_hat, "\n")
## b̂ (máximo) : 36
cat("f(x) = 1/(b\u0302 - \u00e2) :", round(densidad_unif, 6), "\n")
## f(x) = 1/(b̂ - â) : 0.028571
h_plot        <- hist(x, breaks=breaks_vec, plot=FALSE)
h_plot$density <- hi_dec

xs <- seq(a_hat - 1, b_hat + 1, length.out=500)
ys <- dunif(xs, min=a_hat, max=b_hat) * c_amp

par(mar=c(5,6,6,2))
plot(h_plot, col=grises, border="black", freq=FALSE,
     ylim=c(0, max(c(hi_dec, ys)) * 1.30),
     main="", xlab="", ylab="", las=1, xaxt="n")
axis(1, at=breaks_vec, labels=breaks_vec, las=1, cex.axis=0.9)
lines(xs, ys, col="black", lwd=2.5)
mtext("Densidad de Probabilidad", side=2, line=4.5, cex=1)
mtext("Secci\u00f3n",            side=1, line=3.5, cex=1)
mtext(paste0("Gráfica N\u00b02: Histograma con Curva Uniforme",
             " (\u00e2 = ", a_hat, ", b\u0302 = ", b_hat, ") \u2014 Secci\u00f3n"),
      side=3, line=3, cex=0.9, font=2)
legend("topright",
       legend=c("Histograma",
                paste0("Uniforme(\u00e2=", a_hat, ", b\u0302=", b_hat, ")")),
       fill=c("gray55",NA), border=c("black",NA),
       lty=c(NA,1), lwd=c(NA,2.5), bty="n", cex=0.85)

7. Cálculo de Parámetros y Probabilidades

# ── Parámetros de la Uniforme ─────────────────────────────────────────────────
media_teo <- (a_hat + b_hat) / 2
var_teo   <- (b_hat - a_hat)^2 / 12
sd_teo    <- sqrt(var_teo)

cat("=== Parámetros Uniforme Continua ===\n")
## === Parámetros Uniforme Continua ===
cat("\u00e2 (mínimo)          :", a_hat, "\n")
## â (mínimo)          : 1
cat("b\u0302 (máximo)          :", b_hat, "\n")
## b̂ (máximo)          : 36
cat("f(x) = 1/(b\u0302-\u00e2)  :", round(densidad_unif, 6), "\n")
## f(x) = 1/(b̂-â)  : 0.028571
cat("E[X] = (a+b)/2      :", round(media_teo, 4), "\n")
## E[X] = (a+b)/2      : 18.5
cat("V[X] = (b-a)²/12    :", round(var_teo,   4), "\n")
## V[X] = (b-a)²/12    : 102.0833
cat("\u03c3  = \u221a(V[X])         :", round(sd_teo,    4), "\n")
## σ  = √(V[X])         : 10.1036
# ── Tabla de parámetros ───────────────────────────────────────────────────────
data.frame(
  Parametro = c(
    "\u00e2 = mínimo de la variable",
    "b\u0302 = máximo de la variable",
    "f(x) = 1 / (b\u0302 \u2212 \u00e2)",
    "E[X] = (\u00e2 + b\u0302) / 2",
    "V[X] = (b\u0302 \u2212 \u00e2)\u00b2 / 12",
    "\u03c3 = \u221a(V[X])"
  ),
  Valor = c(
    as.character(a_hat),
    as.character(b_hat),
    round(densidad_unif, 6),
    round(media_teo,     4),
    round(var_teo,       4),
    round(sd_teo,        4)
  )
) %>%
  gt() %>%
  tab_header(
    title    = md("**Tabla N\u00b02: Parámetros del Modelo Uniforme Continua**"),
    subtitle = md("*Variable Secci\u00f3n \u2014 Kansas, EE.UU.*")
  ) %>%
  cols_label(Parametro=md("**Parámetro**"), Valor=md("**Valor**")) %>%
  tab_style(style=list(cell_fill(color="#2C2C2C"),cell_text(color="white",weight="bold")),
            locations=cells_column_labels()) %>%
  tab_style(style=cell_fill(color="#F5F5F5"),
            locations=cells_body(rows=seq(1,6,by=2))) %>%
  tab_source_note(source_note=md("*Autor: Leslye Quinchiguango*")) %>%
  tab_options(table.width=pct(75), heading.title.font.size=px(15),
              heading.subtitle.font.size=px(11), table.font.size=px(13),
              data_row.padding=px(6))
Tabla N°2: Parámetros del Modelo Uniforme Continua
Variable Sección — Kansas, EE.UU.
Parámetro Valor
â = mínimo de la variable 1
b̂ = máximo de la variable 36
f(x) = 1 / (b̂ − â) 0.028571
E[X] = (â + b̂) / 2 18.5
V[X] = (b̂ − â)² / 12 102.0833
σ = √(V[X]) 10.1036
Autor: Leslye Quinchiguango
# ── Probabilidades bajo Uniforme(a, b) ───────────────────────────────────────
# P(X < 9): secciones en el primer cuarto del rango
p_a <- punif(9,  min=a_hat, max=b_hat)

# P(9 ≤ X < 25): secciones en el tramo central
p_b <- punif(25, min=a_hat, max=b_hat) - punif(9, min=a_hat, max=b_hat)

# P(X ≥ 25): secciones en el último cuarto del rango
p_c <- punif(25, min=a_hat, max=b_hat, lower.tail=FALSE)

# P(13 ≤ X < 21): intervalo alrededor de la mediana
p_d <- punif(21, min=a_hat, max=b_hat) - punif(13, min=a_hat, max=b_hat)

data.frame(
  Evento = c(
    "P(X < 9)",
    "P(9 \u2264 X < 25)",
    "P(X \u2265 25)",
    "P(13 \u2264 X < 21)"
  ),
  Descripcion = c(
    "Sección en el primer cuarto del rango territorial",
    "Sección en el tramo central del rango",
    "Sección en el último cuarto del rango territorial",
    "Sección alrededor de la mediana del rango"
  ),
  Probabilidad = round(c(p_a, p_b, p_c, p_d), 4)
) %>%
  gt() %>%
  tab_header(
    title    = md("**Tabla N\u00b03: Cálculo de Probabilidades**"),
    subtitle = md("*La probabilidad es el área bajo la curva del modelo teórico \u2014 Variable Secci\u00f3n*")
  ) %>%
  cols_label(Evento=md("**Evento**"), Descripcion=md("**Descripción**"),
             Probabilidad=md("**Probabilidad**")) %>%
  tab_style(style=list(cell_fill(color="#2C2C2C"),cell_text(color="white",weight="bold")),
            locations=cells_column_labels()) %>%
  tab_style(style=cell_fill(color="#F5F5F5"),
            locations=cells_body(rows=seq(1,4,by=2))) %>%
  tab_source_note(source_note=md("*Autor: Leslye Quinchiguango*")) %>%
  tab_options(table.width=pct(92), table.font.size=px(13),
              heading.title.font.size=px(15), heading.subtitle.font.size=px(11),
              data_row.padding=px(6))
Tabla N°3: Cálculo de Probabilidades
La probabilidad es el área bajo la curva del modelo teórico — Variable Sección
Evento Descripción Probabilidad
P(X < 9) Sección en el primer cuarto del rango territorial 0.2286
P(9 ≤ X < 25) Sección en el tramo central del rango 0.4571
P(X ≥ 25) Sección en el último cuarto del rango territorial 0.3143
P(13 ≤ X < 21) Sección alrededor de la mediana del rango 0.2286
Autor: Leslye Quinchiguango
set.seed(42)

# ── Pearson ───────────────────────────────────────────────────────────────────
mc_vals  <- (head(breaks_vec,-1) + tail(breaks_vec,-1)) / 2
hi_teo   <- rep(1/k, k)   # uniforme: cada intervalo tiene la misma proporcion
hi_obs   <- freq_abs / n
pearson  <- round(cor(hi_obs, hi_teo) * 100, 2)

# ── Kolmogorov-Smirnov ────────────────────────────────────────────────────────
samp     <- sample(x, size=min(400, n), replace=FALSE)
ks_res   <- ks.test(samp, "punif", min=a_hat, max=b_hat)
ks_pval  <- round(ks_res$p.value, 4)
val      <- ifelse(pearson > 70, "APROBADO", "RECHAZADO")

cat("Pearson R%  :", pearson, "%\n")
## Pearson R%  : NA %
cat("KS p-valor  :", ks_pval, "\n")
## KS p-valor  : 0.5912
cat("Validación  :", val, "\n")
## Validación  : NA
data.frame(
  Modelo     = "Uniforme Continua",
  Pearson_R  = pearson,
  KS_pvalor  = ks_pval,
  Validacion = val
) %>%
  gt() %>%
  tab_header(
    title    = md("**Tabla N\u00b04: Resumen de Validación del Modelo**"),
    subtitle = md("*Pearson (R%) y Kolmogorov-Smirnov (p-valor) \u2014 Variable Secci\u00f3n*")
  ) %>%
  cols_label(Modelo=md("**Modelo**"), Pearson_R=md("**Pearson (R %)**"),
             KS_pvalor=md("**K-S (p-valor)**"), Validacion=md("**Validación**")) %>%
  tab_style(style=list(cell_fill(color="#2C2C2C"),cell_text(color="white",weight="bold")),
            locations=cells_column_labels()) %>%
  tab_style(style=list(cell_fill(color="#2C2C2C"),cell_text(color="white",weight="bold")),
            locations=cells_title(groups="title")) %>%
  tab_style(style=cell_text(color="darkgreen",weight="bold"),
            locations=cells_body(columns=Validacion, rows=Validacion=="APROBADO")) %>%
  tab_style(style=cell_text(color="darkred",weight="bold"),
            locations=cells_body(columns=Validacion, rows=Validacion=="RECHAZADO")) %>%
  tab_style(style=cell_borders(sides="bottom",color="#E0E0E0",weight=px(1)),
            locations=cells_body(rows=everything())) %>%
  cols_align(align="center", columns=c(Pearson_R, KS_pvalor, Validacion)) %>%
  cols_align(align="left",   columns=Modelo) %>%
  fmt_number(columns=Pearson_R, decimals=2) %>%
  fmt_number(columns=KS_pvalor, decimals=4) %>%
  tab_source_note(source_note=md("*Autor: Leslye Quinchiguango*")) %>%
  tab_options(table.width=pct(80), table.font.size=px(13),
              heading.title.font.size=px(15), heading.subtitle.font.size=px(11),
              data_row.padding=px(6),
              column_labels.border.top.width=px(2),
              column_labels.border.bottom.width=px(2),
              table_body.border.bottom.width=px(2),
              table.border.top.style="hidden", table.border.bottom.style="hidden")
Tabla N°4: Resumen de Validación del Modelo
Pearson (R%) y Kolmogorov-Smirnov (p-valor) — Variable Sección
Modelo Pearson (R %) K-S (p-valor) Validación
Uniforme Continua NA 0.5912 NA
Autor: Leslye Quinchiguango

8. Intervalo de Confianza

El Intervalo de Confianza estima el rango dentro del cual se encuentra la verdadera media poblacional de Sección con un nivel de confianza del 95%. El Teorema Central del Límite garantiza que la distribución de las medias muestrales tiende a la normalidad dado el volumen de datos (\(n=\) 47,757).

\[E = \frac{\sigma}{\sqrt{n}}\]

media_muestral <- mean(x)
desv_est       <- sd(x)
n_total        <- length(x)
z_95           <- 1.96
error_est      <- desv_est / sqrt(n_total)
margen         <- z_95 * error_est
lim_inf_ic     <- media_muestral - margen
lim_sup_ic     <- media_muestral + margen

data.frame(
  Parametro      = "Secci\u00f3n Promedio Kansas",
  Lim_Inferior   = round(lim_inf_ic,    4),
  Media_Muestral = round(media_muestral, 4),
  Lim_Superior   = round(lim_sup_ic,    4),
  Error_Estandar = paste0("+/- ", round(margen, 4)),
  Confianza      = "95% (Z = 1.96)",
  stringsAsFactors = FALSE
) %>%
  gt() %>%
  tab_header(
    title    = md("**TABLA N\u00b0 5: ESTIMACIÓN DE LA MEDIA POBLACIONAL**"),
    subtitle = md("*Inferencia Estadística para la Variable Secci\u00f3n*")
  ) %>%
  cols_label(
    Parametro      = md("**Parámetro**"),
    Lim_Inferior   = md("**Lim_Inferior**"),
    Media_Muestral = md("**Media_Muestral**"),
    Lim_Superior   = md("**Lim_Superior**"),
    Error_Estandar = md("**Error_Estándar**"),
    Confianza      = md("**Confianza**")
  ) %>%
  tab_style(style=list(cell_fill(color="#2C2C2C"),cell_text(color="white",weight="bold")),
            locations=cells_column_labels()) %>%
  tab_style(style=list(cell_fill(color="#2C2C2C"),cell_text(color="white",weight="bold")),
            locations=cells_title(groups="title")) %>%
  tab_style(style=list(cell_fill(color="#C8E6C9"),cell_text(weight="bold")),
            locations=cells_body(columns=Media_Muestral)) %>%
  tab_style(style=cell_borders(sides="bottom",color="#E0E0E0",weight=px(1)),
            locations=cells_body(rows=everything())) %>%
  cols_align(align="center",
             columns=c(Lim_Inferior,Media_Muestral,Lim_Superior,
                       Error_Estandar,Confianza)) %>%
  cols_align(align="left", columns=Parametro) %>%
  tab_source_note(source_note=md("*Autor: Leslye Quinchiguango*")) %>%
  tab_options(table.width=pct(100), table.font.size=px(13),
              heading.title.font.size=px(16), heading.subtitle.font.size=px(12),
              data_row.padding=px(6),
              column_labels.border.top.width=px(2),
              column_labels.border.bottom.width=px(2),
              table_body.border.bottom.width=px(2),
              table.border.top.style="hidden", table.border.bottom.style="hidden")
TABLA N° 5: ESTIMACIÓN DE LA MEDIA POBLACIONAL
Inferencia Estadística para la Variable Sección
Parámetro Lim_Inferior Media_Muestral Lim_Superior Error_Estándar Confianza
Sección Promedio Kansas 18.2898 18.3828 18.4757 +/- 0.093 95% (Z = 1.96)
Autor: Leslye Quinchiguango

9. Conclusiones

El comportamiento de Sección se explica con un modelo Uniforme Continua de parámetros â = 1, b̂ = 36. Podemos afirmar con un 95% de confianza que la media aritmética real de Sección se encuentra entre 18.2898 y 18.4757, con una desviación estándar de 10.3662.


Autor: Leslye Quinchiguango — Análisis Estadístico, Kansas Hydrocarbon Leases Dataset