• API
• FAQ
• Tools
• Archive
daily pastebin goal
30%
SHARE
TWEET

# awsd

a guest Mar 26th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. WEEK 6
2. # SOAL 1
3. data<-Nikkei
4. data
5. lowganjil <- numeric()
6. highganjil <- numeric()
7. closegenap <- numeric()
8. opengenap <- numeric()
9. a <- 1
10. b <- 1
11. for(i in 1:500){
12.   if(i%%2==0){
13.     closegenap[a] = Nikkei\$Close[i]
14.     opengenap[a] = Nikkei\$Open[i]
15.     a = a+1
16.   }else{
17.     lowganjil[b] = Nikkei\$Low[i]
18.     highganjil[b] = Nikkei\$High[i]
19.     b = b+1
20.   }
21. }
22.   # 1.1
23. t <- t.test(lowganjil, highganjil, sigma.x=sd(data\$Low), sigma.y=sd(data\$High))
24. t
25.
26.   # 1.2
27. z <- z.test(closegenap, opengenap, sigma.x=sd(data\$Close), sigma.y=sd(data\$Open))
28. z
29.
30.
31.
32. # SOAL 2
33.   # 2.1
34. install.packages(mtcars)
35. data2 <- mtcars
36. View(mtcars)
37.   # 2.3
38. dratprima <- numeric()
39. dratnonprima <- numeric()
40. wtprima <- numeric()
41. wtnonprima <- numeric()
42. a <- 1
43. b <- 1
44.
45. for(i in 1:32){
46.     if(i == 1){
47.       dratnonprima[b] = data2\$drat[i]
48.       wtnonprima[b] = data2\$wt[i]
49.       b = b + 1
50.     }else{
51.       if( i %% 2 == 0 || i %% 3 == 0 || i %% 5 == 0 || i %% 7 == 0 ){
52.         if(i == 2 || i == 3 || i == 5 || i == 7){
53.           dratprima[a] = data2\$drat[i]
54.           wtprima[a] = data2\$wt[i]
55.           a = a + 1
56.         }else{
57.           dratnonprima[b] = data2\$drat[i]
58.           wtnonprima[b] = data2\$wt[i]
59.           b = b + 1
60.         }
61.       }
62.       else{
63.         dratprima[a] = data2\$drat[i]
64.         wtprima[a] = data2\$wt[i]
65.         a = a + 1
66.       }
67.     }
68. }
69.
70.   # 2.2
71. dataframe21 <- data.frame(dratprima, wtprima)
72. dataframe21
73. dataframe22 <- data.frame(dratnonprima, wtnonprima)
74. dataframe22
75.
76.   # 2.4
77. t <- t.test(dataframe21\$dratprima, dataframe21\$wtprima, sigma.x=sd(dataframe21\$dratprima, sigma.y=sd(dataframe21\$wtprima)))
78. t
79.
80. z <- z.test(dataframe22\$dratnonprima, dataframe22\$wtnonprima, sigma.x=sd(dataframe22\$dratnonprima), sigma.y=sd(dataframe22\$wtnonprima))
81. z
82.
83. # SOAL 3
84. data3 <- airquality
85. View(airquality)
86. a <- 1
87. b <- 1
88. ozone <- numeric()
89. solar <- numeric()
90. wind <- numeric()
91. temp <- numeric()
92. for(i in 1:153){
93.   if(i<=50){
94.     ozone[a]=data3\$Ozone[i]
95.     solar[a]=data3\$Solar.R[i]
96.     a = a+1
97.   } else if(i>=104){
98.     wind[b]=data3\$Wind[i]
99.     temp[b]=data3\$Temp[i]
100.     b=b+1
101.   }else{}
102. }
103. t.test(ozone, solar, sigma.x=sd(data3\$Ozone), sigma.y=sd(data3\$Solar.R))
104.
105. z.test(wind, temp, sigma.x=sd(data3\$Wind), sigma.y=sd(data3\$Temp))
106.
107. # SOAL 4
108. set.seed(500)
109. datarandom <- data.frame(replicate(1, sample(1:100, 500, rep = TRUE)))
110. datarandom
111. data4 <- datarandom[1:250, 1]
112. data4
113. data5 <- datarandom[251:500, 1]
114. data5
115. t.test(data4, data5, sigma.x=sd(data4), sigma.y=sd(data5))
116. z.test(data4, data5, sigma.x=sd(data4), sigma.y=sd(data5))
117.
118. # SOAL 5
119. data6 <- 100
120. fibo <- numeric(data6)
121. fibo[1] <- 1
122. fibo[2] <- 1
123. for(i in 3:data6){
124.   fibo[i] <- fibo[i-1] + fibo[i-2]
125. }
126. set.seed(100)
127. datarandom2 <- data.frame(replicate(1, sample(1:100, 100, rep = TRUE)))
128. datarandom2
129. data7 <- data.frame(fibo, datarandom2)
130. data7
131. data8 <- data7[1:50, 1:2]
132. colnames(data8) <- c("fibonacci", "random")
133. data8
134. data9 <- data7[51:100, 1:2]
135. colnames(data9) <- c("fibonacci", "random")
136. data9
137.
138. t.test(data8\$fibonacci, data8\$random, sigma.x=sd(data8\$fibonacci), sigma.y=sd(data8\$random))
139. z.test(data8\$fibonacci, data8\$random, sigma.x=sd(data8\$fibonacci), sigma.y=sd(data8\$random))
140. t.test(data9\$fibonacci, data9\$random, sigma.x=sd(data9\$fibonacci), sigma.y=sd(data9\$random))
141. z.test(data9\$fibonacci, data9\$random, sigma.x=sd(data9\$fibonacci), sigma.y=sd(data9\$random))
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152. WEEK 5
153. a <- c(70,85,76,90,85,60,93,80)
154.
155. View(rivers)
156. data <- rivers
157.
158.
159.
160. #T-Test no. 1
161. hasil <- (((mean(data)-600)*sqrt(141)/sd(data)))
162. hasil
163.
164. View(Orange)
165. data1 <- Orange
166.
167. mean(Orange\$circumference)
168.
169.
170.
171. #Z-Test no. 2
172. z <- ((mean(data1\$circumference)-116)/(sd(data1\$circumference)/sqrt(35)))
173. z
174.
175. #Ho = hipotesa awal = <10.000
176. #Ha = hipotesa alternatif (ekspektasi) = >10.000
177.
178. #Jika Alpha > Z-Test, maka Ha ditolak Ho diterima
179. #kesimpulan: Perusahaan dapat memakai bola lampu lebih dari 10.000 jam
180.
181. #Jika Alpha < Z-Test, maka Ho ditolak Ha diterima
182. #kesimpulan: Perusahaan dapat memakai bola lampu kurang dari 10.000 jam
183.
184.
185.
186. #No. 3
187. alpha <- qnorm(1-.05)
188. alpha
189. -alpha
190.
191. ztest <- (9900-10000)/(120/30)
192. ztest
193.
194. ztest <- (9900-10000)/(120/sqrt(30))
195. ztest
196.
197. a = -z
198. a
199.
200. ztest
201. #Jadi Ha ditolak, dan Ho diterima
202.
203.
204.
205. #No. 4a
206. b <- c(170,156,183,156,187,167,163,179,187,167,174,156,
207.        174,179,159,179,187,179,183,170,179,156,170,174,179)
208. mean4 <- mean(b)
209. mean4
210.
211. #T-Test
212. t4 <- ((mean(b)-170)*(sqrt(25)/sd(b)))
213. t4
214.
215. #Z-Test
216. z4 <- ((mean(b)-170)-(sd(b)/sqrt(25)))
217. z4
218.
219. pval <- 2*pt(-abs(t4), df = 25-1)
220. pval
221.
222. #No. 4b
223. #tvalue = 1.71
224. #kesimpulan Ha diterima dan Ho ditolak
225.
226.
227.
228. #no. 5
229. q <- qnorm(1-.05)
230. a
231. -a
232.
233. x <- ((2.1-2)/(0.25/sqrt(35)))
234. pval1 <- pnorm(x)
235. pval1
236. x.alpha <- qnorm(1-.05)
237. x.alpha
238.
239. w = -z
240. w
241. #Alpha < Z, maka Ha diterima, Ho ditolak
242.
243.
244.
245.
246.
247.
248.
249.
250.
251.
252.
253.
254. WEEK 4
255. mean1 <- mean(FilePendukung\$Umur)
256.
257. med1 <-median(FilePendukung\$Umur)
258.
259. modus1 <- getmode(FilePendukung\$Umur)
260. getmode <- function(v) {
261.   uniqv <- unique(v)
262.   uniqv[which.max(tabulate(match(v, uniqv)))]
263. }
264.
265.
266. hasil <- getmode(FilePendukung\$Umur)
267. hasil
268.
269. max1 <- max(FilePendukung\$Umur)
270.
271. min1 <- min(FilePendukung\$Umur)
272.
273. range1 <- range(FilePendukung\$Umur)
274.
275. var1 <- var(FilePendukung\$Umur)
276.
277. sd1 <- sd(FilePendukung\$Umur)
278.
279. quan1 <- quantile(FilePendukung\$Umur)
280.
281. DataBar1 <- c(mean1, med1, modus1, max1, min1, range1, var1, sd1, quan1)
282. barplot(DataBar1, main = "Barplot Kolom Umur", col = c("tomato", "sienna1", "yellow2", "olivedrab2", "deepskyblue1"))
283.
284.
285.
286.
287.
288. mean2 <- mean(FilePendukung\$Suku)
289. mean3 <- mean(FilePendukung\$Pendidikan)
290.
291. med2 <- median(FilePendukung\$Suku)
292. med3 <- median(FilePendukung\$Pendidikan)
293.
294. modus2 <- getmode(FilePendukung\$Suku)
295. getmode <- function(v) {
296.   uniqv <- unique(v)
297.   uniqv[which.max(tabulate(match(v, uniqv)))]
298. }
299.
300.
301. hasill <- getmode(FilePendukung\$Suku)
302. hasill
303. modus3 <- getmode(FilePendukung\$Pendidikan)
304. getmode <- function(v) {
305.   uniqv <- unique(v)
306.   uniqv[which.max(tabulate(match(v, uniqv)))]
307. }
308.
309.
310. hasilll <- getmode(FilePendukung\$Pendidikan)
311. hasilll
312.
313.
314. DataBar2 <- c(mean2, med2, modus2)
315. DataBar3 <- c(mean3, med3, modus3)
316. barplot(DataBar2, main = "Barplot Kolom Suku", col = c("orangered", "orange", "yellow2", "olivedrab3"))
317. barplot(DataBar3, main = "Barplot Kolom Pendidikan", col = c("gold", "goldenrod1", "goldenrod"))
318.
319.
320.
321.
322.
323.
324. a <- quantile(FilePendukung\$JenisKelamin, c(.61))
325. b <- quantile(FilePendukung\$Status, c(.61))
326. c <- quantile(FilePendukung\$StatusRumah, c(.61))
327. d <- quantile(FilePendukung\$Suku, c(.61))
328. e <- quantile(FilePendukung\$Pendidikan, c(.61))
329. f <- quantile(FilePendukung\$Pekerjaan, c(.61))
330. g <- quantile(FilePendukung\$Umur, c(.61))
331. h <- quantile(FilePendukung\$PengeluaranPerBulan, c(.61))
332. i <- quantile(FilePendukung\$Minat, c(.61))
333.
334. DataBar4 <- c(a, b, c, d, e, f, g, h, i)
335. plot(DataBar4, pch = c(1:9), main = "Plot Lines File Pendukung")
336. lines(DataBar4, col = "darkslateblue")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top