setwd ("D:/PASCASARJANA/Semester 3/1. ADK/02. Praktikum/02")
Dari Buku Azen and Walker, “Categorical Data Analysis for the Behavioral and Social Sciences”
Suppose that in the general population the proportion of obese men who have heart disease is 10%. In a random sample of 50 obese men who were placed on a low-fat diet, two men were found to have heart disease after 6 months. a. What is the maximum likelihood estimate of heart disease rate in the population of obese men who are on a low-fat diet? b. Is there evidence that heart disease rate is significantly lower in the population of obese men placed on a low-fat diet? State the null and alternative hypotheses and report the p-value of the exact test (binomial distribution).
Diketahui : proporsi lelaki obesitas yang terkena penyakit jantung = 10%, n = jumlah lelak obesitas yang diet rendah lemak = 50 k = jumlah lelaki yang menderita penyakit jantung = 2
bagian a, dengan rumus : p = k/n
p <- 2/50
p
## [1] 0.04
Sehingga MLE-nya adalah 0.04
bagian b : Hipotesisnya : HO : p = 0.1 vs H1 : p < 0.1 sehingga dengan distribusi binomial :
binom.test(2,50, p=0.1, alternative = "less", conf.level = 0.95)
##
## Exact binomial test
##
## data: 2 and 50
## number of successes = 2, number of trials = 50, p-value = 0.1117
## alternative hypothesis: true probability of success is less than 0.1
## 95 percent confidence interval:
## 0.0000000 0.1206142
## sample estimates:
## probability of success
## 0.04
Dengan p-value > alpha 5%, maka keputusan adalah tidak tolak H0. Hal ini menunjukkan bahwa belum cukup bukti untuk menyatakan bahwa proporsi lelaki obesitas dengan melakukan diet rendah lemak lebih kecil daripada yang tidak melakukan diet rendah lemak
prop.test(2,50,p=NULL, alternative = "less", conf.level = 0.95, correct = TRUE)
##
## 1-sample proportions test with continuity correction
##
## data: 2 out of 50, null probability 0.5
## X-squared = 40.5, df = 1, p-value = 9.831e-11
## alternative hypothesis: true p is less than 0.5
## 95 percent confidence interval:
## 0.0000000 0.1276154
## sample estimates:
## p
## 0.04
Diperoleh bahwa nilai p-value < alpha 5% sehingga tolak H0. Hal ini menunjukkan bahwa telah cukup bukti untuk menyatakan bahwa proporsi lelaki obesitas dengan melakukan diet rendah lemak lebih kecil daripada yang tidak melakukan diet rendah lemak.
Use the results of Problems 3.2 and 3.4 to explain why the exact test (based on binomial distribution) is considered to be more conservative than the score test (based on the normal approximation).
Pada hasil Soal 3.2 menggunakan Distribusi Binomial memiliki hasil yang berbeda (Tidak Tolak H0), dengan Soal 3.4 menggunakan Distribusi Normal (Tolak H0). Dimana dengan n yang besar, atau np ≥ 5 (dalam hal ini np = 5) maka dapat didekatkan dengan distribusi normal. Sehingga dalam kasus ini dapat digunakan pendekatan distribusi normal.
In a study on whether voters place different levels of importance on various issues, a random sample of 200 registered voters were asked to rate which of four issues they consider most important. The results obtained are shown in Table 3.5. a. State the null and alternative hypotheses. b. Do the data indicate that voters place the same or different levels of importance on each of these issues? Use the Pearson chi-squared test to answer this question.
bagian a : H0 : p1 = p2 = p3 = p4. Artinya tidak ada perbedaan isu tingkat kepentingan pada pemilih vs H1 : minimal ada 1 p yang berbeda. Artinya ada perbedaan isu tingkat kepentingan pada pemilih
bagian b, dengan masing-masing proporsi adalah sama yaitu sebesar 100/4 = 25%
data3 <- c(80, 40, 65, 15)
res <- chisq.test(data3, p=c(0.25, 0.25, 0.25, 0.25))
res
##
## Chi-squared test for given probabilities
##
## data: data3
## X-squared = 49, df = 3, p-value = 1.304e-10
Diperoleh bahwa nilai p-value < alpha 5% sehingga keputusan adalah tolak Ho. Hal ini menunjukkan bahwa telah cukup bukti untuk menyatakan bahwa ada perbedaan isu tingkat kepentingan pada pemilih
res2 <- c(data3, p=c(50, 50, 50, 50))
DescTools::GTest(res2, correct = "none")
##
## Log likelihood ratio (G-test) goodness of fit test
##
## data: res2
## G = 55.337, X-squared df = 7, p-value = 1.278e-09
Diperoleh bahwa nilai p-value < alpha 5% sehingga keputusan adalah tolak HO Sehingga dapat dikatakan bahwa telah cukup bukti untuk menyatakan bahwa ada perbedaan isu tingkat kepentingan pada pemilih.