Variable cuantitativa continua

Profundidad

1 Extraer la variable continua

datos <- read.csv("~/DATOS_INDIA/Earthquakes (2).csv")
profundidad<-datos$depth
Profundidad<-as.numeric(profundidad)
ValorNulo<- is.na(Profundidad)
Profundidad<- na.omit(Profundidad)

2 Tabla de distribución de frecuencias

2.1 Sturges

Creación de la tabla de distribución de frecuencia

k<-1+(3.3*log10(17805))
k<-floor(k)
min<-min(Profundidad)
max<-max(Profundidad)
R<- max-min
A<-R/k
Li<-round(seq(from=min, to=max-A, by=A),4)
Ls<-round(seq(from=min+A, to=max, by=A), 4)
MC<-round((Li+Ls)/2,2)
ni <- numeric(length(Li))
for (i in 1:length(Li)) {
  ni[i] <- sum(Profundidad >= Li[i] & Profundidad< Ls[i]) 
}
ni[length(Li)] <- sum(Profundidad >= Li[length(Li)] & Profundidad<= max)
sum(ni)
## [1] 17805
hi<-ni/sum(ni)*100
sum(hi)
## [1] 100
Niasc<-cumsum(ni)
Nidsc<-rev(cumsum(rev(ni)))
Hiasc<-round(cumsum(hi))
Hidsc<-round(rev(cumsum(rev(hi))))
TDFProfundidad<-data.frame(Li, Ls, MC, ni, hi, Niasc, Nidsc, Hiasc, Hidsc)
TDFProfundidad

Tabla de distribución

total_ni<-sum(ni)
total_hi<-100
TDFProfundidadCompleto<-rbind(TDFProfundidad, data.frame(Li=" Total", Ls=" ",MC=" ",
                                ni=total_ni, hi=total_hi, Niasc=" ", Nidsc=" ", 
                                                 Hiasc=" ", Hidsc=" "))
library(gt)
## Warning: package 'gt' was built under R version 4.4.3
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.4.3
## 
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
tabla_Profundidad<-TDFProfundidadCompleto %>%
  gt() %>%
  tab_header(
    title = md("*Tabla Nº:15*"),
    subtitle = md("**Tabla de distribucion de Frecuencias simples y acumuladas
                  de la Profundidad de los Sismos en el Subcontinente Indio (2000-2024)")
  ) %>%
  tab_source_note(
    source_note = md("Autor: GRUPO1")
  ) %>%
  tab_options(
    table.border.top.color = "black",
    table.border.bottom.color = "black",
    table.border.top.style = "solid",
    table.border.bottom.style = "solid",
    column_labels.border.top.color = "black",
    column_labels.border.bottom.color = "black",
    column_labels.border.bottom.width = px(2),
    row.striping.include_table_body = TRUE,
    heading.border.bottom.color = "black",
    heading.border.bottom.width = px(2),
    table_body.hlines.color = "gray",
    table_body.border.bottom.color = "black"
  )  %>%
  tab_style(
    style = cell_text(weight = "bold"),
    locations = cells_body(
      rows = Li == "Total"
    )
  ) 
tabla_Profundidad
Tabla Nº:15
**Tabla de distribucion de Frecuencias simples y acumuladas de la Profundidad de los Sismos en el Subcontinente Indio (2000-2024)
Li Ls MC ni hi Niasc Nidsc Hiasc Hidsc
0.6 18.16 9.38 7000 39.3147992 7000 17805 39 100
18.16 35.72 26.94 7078 39.7528784 14078 10805 79 61
35.72 53.28 44.5 1669 9.3737714 15747 3727 88 21
53.28 70.84 62.06 754 4.2347655 16501 2058 93 12
70.84 88.4 79.62 416 2.3364224 16917 1304 95 7
88.4 105.96 97.18 348 1.9545072 17265 888 97 5
105.96 123.52 114.74 203 1.1401292 17468 540 98 3
123.52 141.08 132.3 131 0.7357484 17599 337 99 2
141.08 158.64 149.86 81 0.4549284 17680 206 99 1
158.64 176.2 167.42 59 0.3313676 17739 125 100 1
176.2 193.76 184.98 19 0.1067116 17758 66 100 0
193.76 211.32 202.54 19 0.1067116 17777 47 100 0
211.32 228.88 220.1 16 0.0898624 17793 28 100 0
228.88 246.44 237.66 5 0.0280820 17798 12 100 0
246.44 264 255.22 7 0.0393148 17805 7 100 0
Total 17805 100.0000000
Autor: GRUPO1

2.2 Intervalos con R

Histograma de la variable

histoP<-hist(Profundidad,
                    main= "Grafica Nº47:Distribución de Profundidad
              de los sismos en el Subcontiente Indio (2000-2024)",
                    xlab= " Error Magnitud", 
                    ylab= "Cantidad", col="blue",
                    las=2)

Creación de la tabla de distribución de frecuencia

Limites<-histoP$breaks
LimInf<-Limites[1:14]
LimSup<-Limites[2:15]
Mc<-histoP$mids
ni<-histoP$counts
sum(ni)
## [1] 17805
hi<-ni/sum(ni)*100
sum(hi)
## [1] 100
Ni_asc <- cumsum(ni)
Ni_dsc <- rev(cumsum(rev(ni)))
Hi_asc <- round(cumsum(hi), 2) 
Hi_dsc <- round(rev(cumsum(rev(hi))), 2)
TDFP<-data.frame(LimInf, LimSup, Mc, ni, hi, Ni_asc, Ni_dsc, Hi_asc, Hi_dsc)
TDFP

Tabla de distribución

totalni <- sum(ni)
totalhi <- 100  
TDFEPCompleto<-rbind(TDFP, data.frame(LimInf="Total",
                                                   LimSup=" ", Mc=" ",ni=totalni,
                                      hi=totalhi, Ni_asc=" ", Ni_dsc=" ", 
                                                   Hi_asc=" ", Hi_dsc=" "))
library(gt)
library(dplyr)
# Crear la tabla 
tablaProf<-TDFEPCompleto %>%
  gt() %>%
  tab_header(
    title = md("*Tabla Nº:16*"),
    subtitle = md("**Tabla de distribucion de Frecuencias simples y acumuladas
                  Profundidad de los Sismos en el 
                  Subcontinente Indio (2000-2024)")
  ) %>%
  tab_source_note(
    source_note = md("Autor:Grupo1")
  ) %>%
  tab_options(
    table.border.top.color = "black",
    table.border.bottom.color = "black",
    table.border.top.style = "solid",
    table.border.bottom.style = "solid",
    column_labels.border.top.color = "black",
    column_labels.border.bottom.color = "black",
    column_labels.border.bottom.width = px(2),
    row.striping.include_table_body = TRUE,
    heading.border.bottom.color = "black",
    heading.border.bottom.width = px(2),
    table_body.hlines.color = "gray",
    table_body.border.bottom.color = "black"
  )  %>%
  tab_style(
    style = cell_text(weight = "bold"),
    locations = cells_body(
      rows = LimInf == "Total"
    )
  ) 

tablaProf
Tabla Nº:16
**Tabla de distribucion de Frecuencias simples y acumuladas Profundidad de los Sismos en el Subcontinente Indio (2000-2024)
LimInf LimSup Mc ni hi Ni_asc Ni_dsc Hi_asc Hi_dsc
0 20 10 7213 40.5110924 7213 17805 40.51 100
20 40 30 7361 41.3423196 14574 10592 81.85 59.49
40 60 50 1539 8.6436394 16113 3231 90.5 18.15
60 80 70 630 3.5383319 16743 1692 94.04 9.5
80 100 90 419 2.3532716 17162 1062 96.39 5.96
100 120 110 255 1.4321820 17417 643 97.82 3.61
120 140 130 175 0.9828700 17592 388 98.8 2.18
140 160 150 95 0.5335580 17687 213 99.34 1.2
160 180 170 60 0.3369840 17747 118 99.67 0.66
180 200 190 21 0.1179444 17768 58 99.79 0.33
200 220 210 17 0.0954788 17785 37 99.89 0.21
220 240 230 13 0.0730132 17798 20 99.96 0.11
240 260 250 5 0.0280820 17803 7 99.99 0.04
260 280 270 2 0.0112328 17805 2 100 0.01
Total 17805 100.0000000
Autor:Grupo1

3 Histogramas

3.1 Histograma de frecuencia absoluta local (ni)

hist(Profundidad, breaks=seq(min, max, A), main="Grafica Nº48: Frecuencia de la Profundidad
     los Sismos en el subcontinente (Local)",
     col="blue", 
     xlab="Profundidad (km)", ylab="Cantidad")

3.2 Histograma de frecuencia absoluta global (ni)

hist(Profundidad, breaks=seq(min, max, A), main="Grafica Nº49: Frecuencia de la Profundidad 
     los Sismos en el subcontinente (Global)",col="blue", 
     xlab="Profundidad (km)", ylab="Cantidad", ylim=c(0,17805))

3.3 Histograma de porcentaje local (hi)

barplot(TDFProfundidad$hi, space=0, main="Grafica Nº50: Porcentaje de la profundidad 
        de los Sismos en el subcontinente Indio (Local)",
        col="blue", 
        xlab="Profundidad ", ylab="Porcentaje (%)", names.arg=TDFProfundidad$MC)

3.4 Histograma de porcentaje global (hi)

barplot(TDFProfundidad$hi, space=0, main="Grafica Nº51: Porcentaje de la profundidad
      de los Sismos en el Subcontinente Indio (Global)",col="blue", 
        xlab="Profundidad", ylab="Porcentaje (%)",
        names.arg=TDFProfundidad$MC, ylim=c(0,100))

4 Diagramas

4.1 Ojivas

4.1.1 Ojivas combinadas (ni)

plot(Ls, Nidsc, type="o", xlim=c(0,max),
     main="Grafiaca Nº52: Ojivas combinadas de la Profundidad 
     de los Sismos del Subcontinente Indio"
     , ylab="Frecuencia", col="blue", xlab="Profundidad")

lines(Li, Niasc, col="black", add=TRUE, type="b")
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "add" es un parámetro
## gráfico inválido
legend("right",legend = c("Ojiva descendente", "Ojiva ascendente"),
       col = c("blue", "black"), pch = 1, lty = 1,cex = 0.7)

4.1.2 Ojivas combinadas (hi)

plot(Ls, Hidsc, type="o", xlim=c(0,max),
     main="Grafiaca Nº53: Ojivas combinadas de la profundidad 
     de los sismos del Subcontinente Indio"
     , ylab="Frecuencia", col="blue", xlab="Profunidad")

lines(Li, Hiasc, col="black", add=TRUE, type="b")
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "add" es un parámetro
## gráfico inválido
legend("right",legend = c("Ojiva descendente", "Ojiva ascendente"),
       col = c("blue", "black"), pch = 1, lty = 1,cex = 0.7)

4.2 Diagrama de caja

boxplot(Profundidad, horizontal = T, col="blue", main="Grafiaca Nº54: Distribución
de Profundidad de los Sismos del Subcontinente Indio",
        xlab="Profundidad")

summary(Profundidad)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.60   10.00   29.72   30.56   35.00  264.00

Identificar los valores atípicos

outliers<-boxplot.stats(Profundidad)$out 
num_outliers <- length(outliers) 
minoutliers<-min(outliers)
maxoutliers<-max(outliers)

5 Indicadores estadísticos

5.1 Posición

Media aritmética

x<-mean(Profundidad)

Mediana

Me <-median(MC)
Me<-median(Profundidad)
ri<-min(Profundidad)
rs<-max(Profundidad)

5.2 Dispersión

Varianza

var(Profundidad)
## [1] 771.4176

Desviación estándar

s<-sd(Profundidad)

Coeficiente de variación

CV <- ((s / x) * 100)

5.3 Forma

Coeficiente de asimetría

library(e1071)
## Warning: package 'e1071' was built under R version 4.4.3
As<-skewness(Profundidad)

Coeficiente de kurtosis

k<-kurtosis(Profundidad)

6 Tabla resumen

6.1 Indicadores estadisticos

Variable<-c("Profundidad")
TablaIndicadores<-data.frame(Variable,ri,rs,round(x,2),Me,round(s,2), round(CV,2), round(As,2),round(k,2))
colnames(TablaIndicadores)<-c("Variable","minimo","máximo","x","Me","sd","Cv (%)","As","K")

library(knitr)
## Warning: package 'knitr' was built under R version 4.4.3
kable(TablaIndicadores, format = "markdown", caption = "Tabla 17. Indicadores
      estadíticos de la variable Profundidad")
Tabla 17. Indicadores estadíticos de la variable Profundidad
Variable minimo máximo x Me sd Cv (%) As K
Profundidad 0.6 264 30.56 29.72 27.77 90.88 2.78 10.84

6.2 Ouliers

TablaOutliers<-data.frame(num_outliers,minoutliers,maxoutliers)
colnames(TablaOutliers)<-c("Outliers","Mínimo","Máximo")
library(knitr)
kable(TablaOutliers, format = "markdown", caption = "Tabla No.18: Outliers de la variable Profundidad)")
Tabla No.18: Outliers de la variable Profundidad)
Outliers Mínimo Máximo
1250 72.62 264

7 Conclusión

La variable profundidad medida en (km), sus valores fluctúan entre 0.6 y 264 sus valores están en torno a 30.56, con una desviación estándar de 27.77 siendo un conjunto muy heterogéneo cuyos valores atípicos están entre 72 mínimo de ouliers. La acumulación de valores está en la parte baja de manera fuerte. Por todo lo anterior el comportamiento es medianamente perjudicial ya que las profundidades se centran en parte superficial e intermedia de la corteza terrestre.