-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoba_coba.R
161 lines (93 loc) · 3.96 KB
/
coba_coba.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
## Latihan 1 PPT Hal. 16
sebelum1 <- rep(1,12)
sebelum2 <- rep(2,9)
sebelum <- c(sebelum1, sebelum2)
setelah1 <- c(rep(1,3), rep(2,9))
setelah2 <- c(rep(1,4), rep(2,5))
setelah <- c(setelah1, setelah2)
data<- data.frame(sebelum, setelah)
table(data)
mcnemar.test(table(data))
## HEHEHEHEHEHEHHEHE
sebelum1 <- rep(1,7)
sebelum2 <- rep(2,17)
sebelum <- c(sebelum1, sebelum2)
setelah1 <- c(rep(1,9), rep(2,3))
setelah2 <- c(rep(1,5), rep(2,4))
setelah <- c(setelah1, setelah2)
data<- data.frame(sebelum, setelah)
table(data)
mcnemar.test(table(data))
sebelum1 <- rep(1,10)
sebelum2 <- rep(2,20)
sebelum <- c(sebelum1, sebelum2)
setelah1 <- c(rep(1,9), rep(2,1))
setelah2 <- c(rep(1,14), rep(2,6))
setelah <- c(setelah1, setelah2)
data<- data.frame(sebelum, setelah)
table(data)
mcnemar.test(table(data))
## Contoh 2 PPT Hal. 35
sebelum <- c(5,4,3,4,4,3,3,4,4,3,4,3,3,2,4,3,3,5,2,2,3,3,4,4,3,4,4,4,3,2,4,4,5,5,4,3,2,3,2,3)
sesudah <- c(5,5,4,3,3,4,4,5,5,5,3,4,4,3,4,3,4,4,3,3,4,4,5,3,3,3,5,5,4,3,3,4,4,4,4,4,3,4,3,5)
diff <- sesudah - sebelum
data <- data.frame(Sebelum = sebelum, Sesudah = sesudah, Diff = diff)
data
library(BSDA)
SIGN.test(x = diff, alternative = "two.sided", conf.level = 0.95)
SIGN.test(x=data$diff, alternative="two.sided", conf.level=0.95)
## Contoh 1 PPT Hal. 27
istri<- c(4,5,4,4,5,4,4,2,1,4,3,2,4,4,3,2,4,1,5,5)
suami<- c(1,4,5,5,4,3,3,1,3,5,2,3,1,2,2,1,5,2,4,4)
data<- data.frame(istri, suami, diff=suami-istri)
data
library(BSDA)
#SIGN.test(x=data$diff, alternative="less", conf.level=0.95)
SIGN.test(x = diff, alternative = "less", conf.level = 0.95)
## Latihan 1 PPT Hal. 40
sendiri <- c(80, 82, 84, 86, 80, 84, 83, 81, 82, 80, 83, 84, 82, 81, 80, 79, 75)
kelompok <- c(78, 85, 82, 78, 84, 89, 83, 81, 90, 78, 85, 82, 86, 91, 80, 89, 79)
beda <- kelompok - sendiri
data <- data.frame(Sendiri = sendiri, Kelompok = kelompok, Beda = beda)
print(data)
data_analisis <- data[data$Beda != 0, ]
library(BSDA)
SIGN.test(x = data_analisis$Beda, alternative = "two.sided", conf.level = 0.95)
##HUHUHUHUHUHUHUHUHUHUHHUHU
sendiri <- c(80, 82, 84, 86, 80, 84, 83, 81, 82, 80, 83, 84, 82, 81, 80, 79, 75)
kelompok <- c(78, 85, 82, 78, 84, 89, 83, 81, 90, 78, 85, 82, 86, 91, 80, 89, 79)
data <- data.frame(Sendiri = sendiri, Kelompok = kelompok, Beda = kelompok-sendiri)
data
library(BSDA)
SIGN.test(x = diff, alternative="two.sided", conf.level=0.95)
# contoh 1 uji tanda
beda <- c(-3,-1,1,1,-1,-1,-1,-1,2,1,-1,1,-3,-2,-1,-1,1,1,-1,-1)
library(BSDA)
SIGN.test(beda, alternative = "less")
# contoh 2 uji tanda
beda <- c(0,1,1,-1,-1,1,1,1,1,2,-1,1,1,1,0,0,1,-1,1,1,1,1,1,-1,0,-1,1,1,1,1,-1,0,-1,-1,0,1,1,1,1,2)
library(BSDA)
SIGN.test(beda, alternative = "two.sided")
## Contoh 𝑛 < 25 PPT Hal. 46
sebelum<- c(76, 58, 62, 67, 66, 81, 85, 72, 71, 75)
sesudah<- c(80, 60, 68, 72, 79, 80, 82, 80, 81, 79)
pelatihan<- data.frame(sebelum, sesudah)
pelatihan
wilcox.test(sebelum, sesudah, paired=TRUE, data=pelatihan)
## HEHEHEHEHEHEHHEHEHHEHEHEHEH
wilcox.test(sebelum, sesudah, paired=TRUE)
## HUHUHUHUHUHUHU
wilcox.test(pelatihan$sebelum, pelatihan$sesudah, paired=TRUE)
## Latihan 3 PPT Hal. 61
sebelum <- c(75, 50, 77, 80, 30, 68, 55, 72, 33, 70, 64, 40, 90, 35, 87, 75, 35, 60, 55, 82, 37, 66, 73, 65, 73, 45, 74, 76, 70, 60)
sesudah <- c(77, 60, 70, 81, 60, 70, 70, 75, 55, 70, 64, 50, 80, 45, 80, 67, 60, 60, 70, 80, 65, 65, 73, 60, 70, 50, 80, 75, 67, 70)
pertanian <- data.frame(sebelum, sesudah)
pertanian
wilcox.test(sebelum, sesudah, paired = TRUE, data=pertanian)
wilcox.test(sebelum, sesudah, paired = TRUE, conf.int = 0.975)
## Contoh 2 PPT Pertemuan 4,5 Hal 17
Kanker<- matrix(c(3, 1, 0, 3), nrow=2, dimnames=list(c("Merokok", "Tidak Merokok"), c("Kanker Paru", "Tidak Kanker Paru")))
Kanker
fisher.test(Kanker, alternative="greater")
fisher.test(Kanker, alternative="two.sided")
fisher.test(Kanker)