ANÁLISIS ESTADÍSTICO

CARGA DE DATOS Y LIBRERÍAS

CARGA DE DATOS

#Carga de datos
setwd("~/UNI/ESTADISTICA")
datos  <- read.csv("Datos_Depurados.csv", sep = ";", dec = ".", header = TRUE)

CARGA DE LIBRERIAS

#Carga de librerias
library(dplyr)
library(knitr)
library(gt)

TABLA PARES DE VALORES

# Extraer variables numéricas
profundidad  <- as.numeric(datos$cover)
cobre <-as.numeric(datos$cugrd)

TPV <- data.frame( profundidad,cobre/100)

#TABLA DE PARES DE VALORES
TPV <- na.omit(TPV) #OMITIR NA
TPV <- TPV[TPV$profundidad > 0 & TPV$cobre > 0, ] #OMITIR VALORES NEGATIVOS Y CEROS
TPV
##     profundidad cobre.100
## 1             1    0.1500
## 2             1    0.1200
## 3             1    0.1100
## 4             1    0.2000
## 5             3    0.2356
## 6             4    0.2374
## 7             6    0.2444
## 8             8    0.2695
## 9             9    0.2935
## 10           10    0.2641
## 11           10    0.2800
## 12           10    0.3000
## 13           10    0.2641
## 14           10    0.1500
## 15           10    0.2000
## 16            3    0.2600
## 17           17    0.5979
## 18           18    0.3455
## 19           19    0.4853
## 20           21    0.5289
## 21           22    0.4876
## 22           23    0.7132
## 23           25    0.4675
## 24           27    0.4076
## 25           28    0.5854
## 26           29    0.4420
## 27           30    0.5632
## 28           31    0.4087
## 29           32    0.3258
## 30           33    0.4657
## 31           34    0.4179
## 32           36    0.5036
## 33           37    0.4785
## 34           38    0.6922
## 35           40    0.6528
## 36           41    0.4946
## 37           42    0.6706
## 38            4    0.2600
## 39            4    0.3200
## 40            5    0.2300
## 41            6    0.3000
## 42            6    0.3100
## 43            9    0.3400
## 44            9    0.5000
## 45            9    0.4500
## 46           30    0.5000
## 47           30    0.6600
## 48           30    0.2800
## 49           17    0.2500
## 50           59    0.7906
## 51           60    0.6874
## 52           61    0.6622
## 53           62    0.8095
## 54           63    0.6288
## 57           80    0.7500
## 58           86    0.8800
## 59           74    0.8095
## 60           92    0.6288
## 61           25    0.5000
## 62           27    0.6600
## 63           28    0.5500
## 64           29    0.6400
## 65           30    0.3900
## 66           31    0.4900
## 68           21    0.2000
## 69           22    0.3500
## 70           23    0.4000
## 71           25    0.8000
## 72           27    0.6600
## 73           28    0.4500
## 74           29    0.9000
## 75           30    0.2400
## 76           31    0.6000
## 77           32    0.4500
## 78           33    0.3000
## 81           99    1.0647
## 82          100    1.0902
## 83           99    0.8000
## 84          100    1.5000
## 85           99    1.0000
## 86          100    1.1900
## 87          112    1.1120
## 88          114    0.8423
## 92          112    1.1533
## 93          114    0.9913
## 94          115    1.4344
## 96          150    0.6000
## 98          119    1.2723
## 99          120    1.1960
## 100         121    1.3534
## 101         122    1.3047
## 102         123    1.4100
## 103         124    1.5640
## 105          59    0.3500
## 106          60    0.9000
## 107          61    1.1000
## 108          62    0.9800
## 109          63    0.2000
## 113         135    1.5775
## 114         139    1.2275
## 115         140    1.0460
## 116         141    1.8102
## 117         142    1.4976
## 120         135    1.1000
## 121         139    1.6000
## 122         140    1.2000
## 123         141    0.8000
## 124         142    0.9000
## 126          19    0.2000
## 127          21    1.1000
## 128          22    0.5200
## 129          23    0.6800
## 130          25    0.3900
## 131          27    0.5800
## 132          28    0.7400
## 133          29    0.8800
## 134          30    0.9200
## 135          31    0.2400
## 136          32    0.1500
## 137          33    0.7800
## 161         188    2.0022
## 163         160    0.6000
## 164         200    1.6470
## 165         300    3.6600
TPV <- TPV[order(TPV$profundidad), ] #DAR ORDEN A LA TABLA
TPV
##     profundidad cobre.100
## 1             1    0.1500
## 2             1    0.1200
## 3             1    0.1100
## 4             1    0.2000
## 5             3    0.2356
## 16            3    0.2600
## 6             4    0.2374
## 38            4    0.2600
## 39            4    0.3200
## 40            5    0.2300
## 7             6    0.2444
## 41            6    0.3000
## 42            6    0.3100
## 8             8    0.2695
## 9             9    0.2935
## 43            9    0.3400
## 44            9    0.5000
## 45            9    0.4500
## 10           10    0.2641
## 11           10    0.2800
## 12           10    0.3000
## 13           10    0.2641
## 14           10    0.1500
## 15           10    0.2000
## 17           17    0.5979
## 49           17    0.2500
## 18           18    0.3455
## 19           19    0.4853
## 126          19    0.2000
## 20           21    0.5289
## 68           21    0.2000
## 127          21    1.1000
## 21           22    0.4876
## 69           22    0.3500
## 128          22    0.5200
## 22           23    0.7132
## 70           23    0.4000
## 129          23    0.6800
## 23           25    0.4675
## 61           25    0.5000
## 71           25    0.8000
## 130          25    0.3900
## 24           27    0.4076
## 62           27    0.6600
## 72           27    0.6600
## 131          27    0.5800
## 25           28    0.5854
## 63           28    0.5500
## 73           28    0.4500
## 132          28    0.7400
## 26           29    0.4420
## 64           29    0.6400
## 74           29    0.9000
## 133          29    0.8800
## 27           30    0.5632
## 46           30    0.5000
## 47           30    0.6600
## 48           30    0.2800
## 65           30    0.3900
## 75           30    0.2400
## 134          30    0.9200
## 28           31    0.4087
## 66           31    0.4900
## 76           31    0.6000
## 135          31    0.2400
## 29           32    0.3258
## 77           32    0.4500
## 136          32    0.1500
## 30           33    0.4657
## 78           33    0.3000
## 137          33    0.7800
## 31           34    0.4179
## 32           36    0.5036
## 33           37    0.4785
## 34           38    0.6922
## 35           40    0.6528
## 36           41    0.4946
## 37           42    0.6706
## 50           59    0.7906
## 105          59    0.3500
## 51           60    0.6874
## 106          60    0.9000
## 52           61    0.6622
## 107          61    1.1000
## 53           62    0.8095
## 108          62    0.9800
## 54           63    0.6288
## 109          63    0.2000
## 59           74    0.8095
## 57           80    0.7500
## 58           86    0.8800
## 60           92    0.6288
## 81           99    1.0647
## 83           99    0.8000
## 85           99    1.0000
## 82          100    1.0902
## 84          100    1.5000
## 86          100    1.1900
## 87          112    1.1120
## 92          112    1.1533
## 88          114    0.8423
## 93          114    0.9913
## 94          115    1.4344
## 98          119    1.2723
## 99          120    1.1960
## 100         121    1.3534
## 101         122    1.3047
## 102         123    1.4100
## 103         124    1.5640
## 113         135    1.5775
## 120         135    1.1000
## 114         139    1.2275
## 121         139    1.6000
## 115         140    1.0460
## 122         140    1.2000
## 116         141    1.8102
## 123         141    0.8000
## 117         142    1.4976
## 124         142    0.9000
## 96          150    0.6000
## 163         160    0.6000
## 161         188    2.0022
## 164         200    1.6470
## 165         300    3.6600

DIAGRAMA DE DISPERSIÓN

#Extraer Variables de la tabla

x<-TPV$profundidad #Variable independiente
y<-TPV$cobre #Variable dependiente

#Diagrama de dispersión
plot(x,y,
     pch = 16,
     col = "blue",
     main = "Grafica N°1 : Diagrama de dispersión entre la profundidad y 
     la cantidad de cobre en los depositos de sulfuros masivos
     volcanicos",
     xlab = "Profundidad (m)",
     ylab = " Cobre (%)")

CONJETURA DEL MODELO

Debido a la similitud de la nube de puntos conjeturamos a un modelo lineal

Diagrama de dispersión

#Extraer Variables de la tabla

x<-TPV$profundidad #Variable independiente
y<-TPV$cobre #Variable dependiente

#Diagrama de dispersión

plot(x,y,
     pch = 16,
     col = "blue",
     main = "Grafica N°2 : Comparación de la realidad con el modelo lineal
     entre la profundidad y el contenido de oro de los depositos masivos 
     de sulfuros volcánicos",
     xlab = "Profundidad (m)",
     ylab = "Cobre (%)")


# Parámetros lineales

regresion_lineal<-lm(y~x)
regresion_lineal
## 
## Call:
## lm(formula = y ~ x)
## 
## Coefficients:
## (Intercept)            x  
##    0.250587     0.007992
#Crear la recta
abline(regresion_lineal)

#Formamos la ecuación
plot(1, type = "n", axes = FALSE, xlab = "", ylab = "") # Crear un gráfico vacío
text(x = 1, y = 1,
     labels = " Ecuación lineal \n Y = ax+b \n Y = 0.0082x+0.2443",
     cex = 2, # Tamaño del texto (ajustable)
     col = "blue", # Color del texto
     font =6) #tipo

TEST DE APROBACIÓN Y RESTRICCIONES

TEST DE PEARSON

#TEST DE PEARSON
r<-cor(x,y)
r*100
## [1] 86.1567

APRUEBA EL TEST PEARSON

#Coeficiente de determinación
r2<-r^2
r2*100
## [1] 74.22976

RESTRICCIONES

# 100 = 0.0082x+0.2443
# x= 12165

Sí existe restricción, ya que el cobre en porcentaje solo puede tomar valores entre 0% y 100%. Al reemplazar valores de profundidad mayores a 12165.33 m, el modelo predice valores de cobre mayores al 100%, lo cual está fuera del dominio de la variable dependiente.

CÁLCULO DE PRONOSTICOS

¿Que porcentaje de cobre se espera a una profundidad de 100m?

#Cálculo de Pronosticos
C_Esp <- 0.0082*100+0.2443
C_Esp
## [1] 1.0643
plot(1, type = "n", axes = FALSE, xlab = "", ylab = "") # Crear un gráfico vacío
text(x = 1, y = 1,
     labels = "¿Que porcentaje de cobre se espera
     a una profundidad de 100 m ?
     \n R= 1.0643 % ",
     cex = 2, # Tamaño del texto (ajustable)
     col = "blue", # Color del texto
     font = 6)

CONCLUSIÓN

Entre la profundidad y el porcentaje de cobre existe una relación tipo lineal donde el modelo f(x)=0.0082x+0.2443 siendo “x” la profundidad y “y” el porcentaje de cobre donde si existe restricciones y el porcentaje de cobre esta influenciada por 76.72 % por la profundidad y el resto se debe a otros factores.

Ejemplo: Cuando la profundidad es de 100 m se espera un porcentaje de cobre del 1.06 %