# 1. Membaca data
data <- read.csv("bp_before_after.csv")
head(data)
## id before after
## 1 1 140 132
## 2 2 150 145
## 3 3 135 130
## 4 4 142 138
## 5 5 128 125
## 6 6 155 148
summary(data)
## id before after
## Min. : 1.00 Min. :127.0 Min. :124.0
## 1st Qu.: 8.25 1st Qu.:134.2 1st Qu.:130.0
## Median :15.50 Median :139.5 Median :134.5
## Mean :15.50 Mean :139.8 Mean :135.0
## 3rd Qu.:22.75 3rd Qu.:145.8 3rd Qu.:139.8
## Max. :30.00 Max. :155.0 Max. :148.0
# 2. Membuat variabel selisih
data$diff <- data$before - data$after
# Histogram selisih
hist(data$diff, main = "Histogram Selisih (Before - After)", xlab = "Selisih (mmHg)", col = "lightblue")
# Boxplot selisih
boxplot(data$diff, main = "Boxplot Selisih", ylab = "Selisih (mmHg)", col = "pink")
# Scatter plot Before vs After
plot(data$before, data$after, xlab = "Before (mmHg)", ylab = "After (mmHg)", main = "Scatter Plot Before vs After", pch = 19, col = "brown")
abline(0, 1, col = "black", lty = 2) # Garis y = x
#SOAL 3 PEMERIKSAAN ASUMSI(Shapiro-Wilk)
shapiro.test(data$diff)
##
## Shapiro-Wilk normality test
##
## data: data$diff
## W = 0.89942, p-value = 0.008129
#SOAL 4 Uji Hipotesis (Paired t-test & Wilcoxon)
# 1. Paired t-test (Parametrik)
t.test(data$before, data$after, paired = TRUE)
##
## Paired t-test
##
## data: data$before and data$after
## t = 16.826, df = 29, p-value < 2.2e-16
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## 4.216556 5.383444
## sample estimates:
## mean difference
## 4.8
# 2. Wilcoxon signed-rank test (Non-parametrik)
wilcox.test(data$before, data$after, paired = TRUE)
## Warning in wilcox.test.default(data$before, data$after, paired = TRUE): cannot
## compute exact p-value with ties
##
## Wilcoxon signed rank test with continuity correction
##
## data: data$before and data$after
## V = 465, p-value = 1.619e-06
## alternative hypothesis: true location shift is not equal to 0
#Soal 5: Ukuran Efek (Effect Size) dan Interpretasi
mean_diff <- mean(data$diff)
sd_diff <- sd(data$diff)
cohen_d_paired <- mean_diff / sd_diff
cohen_d_paired
## [1] 3.072017
#SOAL 6 Laporan Singkat Hasil Analisis Rata-rata tekanan darah sistolik sebelum intervensi adalah 139.83 mmHg (\(\text{SD} = 7.71\)) dan setelah intervensi adalah 135.03 mmHg (\(\text{SD} = 6.71\)), dengan rata-rata penurunan sebesar 4.80 mmHg (\(\text{SD} = 1.56\)). Uji asumsi normalitas Shapiro-Wilk pada variabel selisih menunjukkan bahwa data tidak berdistribusi normal (\(W = 0.8994, p = 0.0081\)), sehingga acuan utama uji hipotesis menggunakan uji non-parametrik Wilcoxon Signed-Rank Test (\(V = 465, p < 0.001\)). Sebagai pembanding, hasil Paired t-test juga menunjukkan perbedaan yang signifikan (\(t(29) = 16.83, p < 0.001, 95\%\text{ CI} = [4.22, 5.38]\text{ mmHg}\)). Ukuran efek Cohen’s \(d = 3.07\) masuk dalam kategori sangat besar. Kesimpulannya, intervensi edukasi gaya hidup selama 6 minggu secara signifikan dan bermakna klinis efektif menurunkan tekanan darah sistolik pasien.