#Buat Tabel Kontingensi
data_mat <- matrix(c(15, 5, 12, 8), nrow = 2, byrow = TRUE)
colnames(data_mat) <- c("Sesudah_Tertarik", "Sesudah_Tidak")
rownames(data_mat) <- c("Sebelum_Tertarik", "Sebelum_Tidak")
data_mat <- as.table(data_mat)
print(data_mat)
## Sesudah_Tertarik Sesudah_Tidak
## Sebelum_Tertarik 15 5
## Sebelum_Tidak 12 8
#Uji McNemar dengan Continuity Correction
mcnemar.test(data_mat, correct = T)
##
## McNemar's Chi-squared test with continuity correction
##
## data: data_mat
## McNemar's chi-squared = 2.1176, df = 1, p-value = 0.1456
#Uji Tanda (Sign test)
library(DescTools)
## Warning: package 'DescTools' was built under R version 4.5.3
data = read.table(file.choose(), header=TRUE)
data
## Sebelum Sesudah
## 1 4 6
## 2 7 5
## 3 5 8
## 4 6 7
## 5 8 6
## 6 3 5
## 7 6 6
## 8 5 7
## 9 7 8
## 10 4 3
## 11 6 8
## 12 5 4
## 13 7 9
## 14 3 6
## 15 8 8
SignTest(data$Sesudah, data$Sebelum, alternative = "two.sided")
##
## Dependent-samples Sign-Test
##
## data: data$Sesudah and data$Sebelum
## S = 9, number of differences = 13, p-value = 0.2668
## alternative hypothesis: true median difference is not equal to 0
## 96.5 percent confidence interval:
## -1 2
## sample estimates:
## median of the differences
## 1
#Uji Wilcoxon
data=read.table(file.choose(), header = TRUE)
data
## Sebelum Sesudah
## 1 120 121
## 2 145 146
## 3 98 99
## 4 175 174
## 5 132 133
## 6 210 211
## 7 156 155
## 8 187 186
## 9 115 116
## 10 165 164
## 11 138 139
## 12 195 194
y = data$Sebelum
x = data$Sesudah
wilcox.test(x, y, paired = TRUE, correct = FALSE)
## Warning in wilcox.test.default(x, y, paired = TRUE, correct = FALSE): cannot
## compute exact p-value with ties
##
## Wilcoxon signed rank test
##
## data: x and y
## V = 45.5, p-value = 0.5637
## alternative hypothesis: true location shift is not equal to 0