library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.5.3
## Warning: package 'ggplot2' was built under R version 4.5.3
## Warning: package 'tidyr' was built under R version 4.5.3
## Warning: package 'readr' was built under R version 4.5.3
## Warning: package 'forcats' was built under R version 4.5.3
## Warning: package 'lubridate' was built under R version 4.5.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.0 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(robustbase)
## Warning: package 'robustbase' was built under R version 4.5.3
library(readxl)
data<-read_xlsx("C:\\Users\\ASUS\\Downloads\\Data Gempa.xlsx")
data
## # A tibble: 167 × 7
## No `Waktu Gempa (UTC)` Lintang Bujur Magnitudo `Kedalaman (Km)` Wilayah
## <dbl> <dttm> <dbl> <dbl> <chr> <dbl> <chr>
## 1 1 2024-02-27 02:28:25 -2.96 130. M3.6 10 Seram, In…
## 2 2 2024-02-26 23:55:36 -7.55 106. M4.3 13 Java, Ind…
## 3 3 2024-02-26 21:08:51 -5.94 130. M3.9 213 Banda Sea
## 4 4 2024-02-26 20:46:13 0.5 126. M4.4 20 Northern …
## 5 5 2024-02-26 20:09:49 -6.76 108. M2.9 12 Java, Ind…
## 6 6 2024-02-26 19:37:16 -5.88 131. M5.1 112 Banda Sea
## 7 7 2024-02-26 18:55:05 -8.8 119. M2.5 10 Sumbawa R…
## 8 8 2024-02-26 18:24:53 -8.39 118. M3.0 162 Sumbawa R…
## 9 9 2024-02-26 17:09:52 -2.95 119. M2.2 13 Sulawesi,…
## 10 10 2024-02-26 13:45:27 -0.68 122. M3.0 10 Minahassa…
## # ℹ 157 more rows
x <- data$`Kedalaman (Km)`
summ <- summary(data$`Kedalaman (Km)`)
IQR <-IQR(data$`Kedalaman (Km)`)
Q <- quantile(x,prob=c(0.25,0.75))
Q1 <- Q[["25%"]]
Q3 <- Q[["75%"]]
summ
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 5.00 10.00 13.00 55.86 45.50 700.00
Q
## 25% 75%
## 10.0 45.5
#medcouple
library(robustbase)
mc<-mc(x)
## The default of 'doScale' is FALSE now for stability;
## set options(mc_doScale_quiet=TRUE) to suppress this (once per session) message
mc
## [1] 0.8504673
frekuensi <- table(x)
frekuensi
## x
## 5 10 11 12 13 14 15 16 17 18 19 20 21 24 26 27 28 29 30 32
## 6 58 4 6 12 3 2 3 3 1 1 2 2 3 1 2 3 1 2 1
## 33 34 37 41 43 44 47 48 68 70 77 81 87 94 97 102 104 106 110 111
## 2 2 2 1 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 1
## 112 116 134 140 150 156 160 162 170 177 187 190 201 213 230 240 251 288 319 368
## 1 1 1 1 2 1 1 2 1 1 1 1 1 2 1 1 1 2 1 1
## 634 700
## 1 1
bb <- Q1-1.5*exp(-4*mc)*IQR
bb
## [1] 8.226192
ba <- Q3+1.5*exp(3*mc)*IQR
ba
## [1] 728.435
boxplot(x)
IQR_normal <- IQR(x)
pagar_bawah <- Q1 - 1.5*IQR_normal
pagar_bawah
## [1] -43.25
pagar_atas <- Q3 + 1.5*IQR_normal
pagar_atas
## [1] 98.75
title(main="Normal Boxplot")

adjboxStats(x)
## $stats
## [1] 10.0 10.0 13.0 45.5 700.0
##
## $n
## [1] 167
##
## $conf
## [1] 8.659625 17.340375
##
## $fence
## [1] 8.226192 728.434991
##
## $out
## [1] 5 5 5 5 5 5
summary(x)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 5.00 10.00 13.00 55.86 45.50 700.00
adjbox(x)

library(psych)
## Warning: package 'psych' was built under R version 4.5.3
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
describe(data$`Kedalaman (Km)`)
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 167 55.86 97.55 13 33.55 4.45 5 700 695 3.68 17.59 7.55
library(ggplot2)
ggplot(data, aes(x = `Kedalaman (Km)`)) +
geom_histogram(aes(y = ..density..), binwidth = 35, fill = "lightyellow", color = "black") +
stat_function(fun = dnorm, args = list(mean = mean(data$`Kedalaman (Km)`), sd = sd(data$`Kedalaman (Km)`)), color = "purple") +
labs(title = "Histogram dan Densitas Kedalaman Gempa", x = "Kedalaman (Km)", y = "Density")+
theme_bw()
## Warning: The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(density)` instead.
## This warning is displayed once per session.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

shapiro.test(data$`Kedalaman (Km)`)
##
## Shapiro-Wilk normality test
##
## data: data$`Kedalaman (Km)`
## W = 0.5332, p-value < 2.2e-16