ANÁLISIS ESTADÍSTICO

1. CARGA DE DATOS Y LIBRERÍAS

library(dplyr)
library(knitr)

setwd("C:/Users/HP/Documents/PROYECTO ESTADISTICA/RStudio")
datos <- read.csv("tablap.csv", header = TRUE, dec = ",", sep = ";")
casing_raw <- datos$Complexity.of.the.casing.structure
casing_raw <- casing_raw[!is.na(casing_raw)]

2. TABLA DE DISTRIBUCION DE PROBABILIDAD

Complejidad_Ori <- factor(casing_raw, levels = 0:7, ordered = TRUE)
ni_ori <- table(Complejidad_Ori)
hi_ori <- round(prop.table(ni_ori), 3)

tabla_normal <- data.frame(
  Nivel = names(ni_ori),
  ni    = as.numeric(ni_ori),
  hi    = as.numeric(hi_ori) * 100,
  P     = as.numeric(hi_ori) * 100
)

fila_total_n <- data.frame(Nivel="TOTAL", ni=sum(tabla_normal$ni), hi=100, P=100)
tabla_normal_f <- rbind(tabla_normal, fila_total_n)

kable(tabla_normal_f, format = "markdown", 
      caption = "Tabla N 1. Distribucion de probabilidad de Complejidad de la Estructura de Revestimiento")
Tabla N 1. Distribucion de probabilidad de Complejidad de la Estructura de Revestimiento
Nivel ni hi P
0 2476 19.7 19.7
1 33 0.3 0.3
2 5383 42.9 42.9
3 4138 32.9 32.9
4 503 4.0 4.0
5 25 0.2 0.2
6 2 0.0 0.0
7 1 0.0 0.0
TOTAL 12561 100.0 100.0

3. TABLA DE DISTRIBUCION DE PROBABILIDAD AGRUPADA

Complejidad_G3 <- rep(NA, length(casing_raw))
Complejidad_G3[casing_raw %in% 0:2] <- "Baja"
Complejidad_G3[casing_raw %in% 3:5] <- "Media"
Complejidad_G3[casing_raw %in% 6:7] <- "Alta"

Comp_Factor <- factor(Complejidad_G3, levels = c("Baja", "Media", "Alta"), ordered = TRUE)
ni_ag <- table(Comp_Factor)
hi_ag <- round(prop.table(ni_ag), 3)

tabla_agrupada <- data.frame(
  Nivel = names(ni_ag),
  ni    = as.numeric(ni_ag),
  hi    = as.numeric(hi_ag) * 100,
  P     = as.numeric(hi_ag) * 100,
  Nivel_num = 0:2 
)

fila_total_a <- data.frame(Nivel="TOTAL", ni=sum(tabla_agrupada$ni), hi=100, P=100, Nivel_num=NA)
tabla_agrupada_f <- rbind(tabla_agrupada, fila_total_a)

kable(tabla_agrupada_f[, -5], format = "markdown", 
      caption = "Tabla N 2. Distribucion de probabilidad agrupada de Complejidad de la Estructura de Revestimiento")
Tabla N 2. Distribucion de probabilidad agrupada de Complejidad de la Estructura de Revestimiento
Nivel ni hi P
Baja 7892 62.8 62.8
Media 4666 37.1 37.1
Alta 3 0.0 0.0
TOTAL 12561 100.0 100.0

4. GRAFICO DE DISTRIBUCION DE PROBABILIDAD

barplot(tabla_normal$P, main = "Grafica 1: Distribucion de probabilidad de Complejidad de la 
        Estructura de Revestimiento",
        xlab = "Niveles de Complejidad (0-7)", ylab = "Probabilidad (%)", 
        col = "gray", names.arg = 0:7, ylim = c(0, 100))

barplot(tabla_agrupada$P, main = "Grafica 2: Distribucion de probabilidad de Complejidad de la 
        Estructura de Revestimiento",
        xlab = "Clasificacion", ylab = "Probabilidad (%)", 
        col = "skyblue", names.arg = tabla_agrupada$Nivel, ylim = c(0, 100))

5. CONJETURA DE MODELO

## [1] "n = 12561"
## [1] "Media = 0.3719"

6. TEST DE APROBACIÓN

## [1] "Pearson (%) = 91.12"
## [1] "Chi-Cuadrado (x2) = 21.99"
## [1] "Umbral (vc) = 23.03"
## [1] "APRUEBA TEST: TRUE"
Tabla N 3. Resumen de test de bondad
Variable Test Pearson (%) Chi Cuadrado Umbral de aceptacion
Complejidad Agrupada 91.12 21.99 23.03

7. CALCULO DE PROBABILIDADES

8. CONCLUSION

## La variable complejidad del revestimiento se explica a traves de un modelo geometrico aprobando el test de pearson y chi-cuadrado (x2 = 21.99 < vc = 23.03), de esta manera podemos calcular probabilidades.