AZEN 4.1-4.4 DAN 4.6
Odds Ratio:
Salah satu ukuran asosiasi lain yang dapat digunakan untuk tabel 2 x 2 adalah odds ratio. Odds ratio biasanya muncul disebagian besar model yang melibatkan data kategorik. Pada suatu tabel 2×2, dengan odds pada baris-1 dan baris-2 masing-masing odds1= π1/(1− π1)dan odds2= π2/(1− π2), nisbah odds baris-1 atas odds baris-2 adalah: θ =\(\frac{odds1}{odds1}\) = \(\frac{π1/(1− π1)}{π2/(1− π2)}\)
Uji Kebebasan Antar Peubah:
Uji kebebasan yang biasa digunakan adalah uji Khi-Kuadrat (Chi-Square Test for Independence). Hipotesis: H_0: Dua peubah saling bebas H_1: Dua peubah tidak saling bebas Statistic ini akan mendekati sebaran χ2 dengan derajat bebas (r-1)(c-1) dalam hal ini r adalah banyaknya baris (row) dan c adalah banyaknya kolom (column) pada tabel kontingensi.
#setwd("D:/#S2 IPB STATISTIKA/SEMESTER 3/STK654 ANALISIS DATA KATEGORIK/RESPONSI/UTS/adk_prak34")
#Library yang digunakan
library("epiR")
## Loading required package: survival
## Package epiR 2.0.19 is loaded
## Type help(epi.about) for summary information
## Type browseVignettes(package = 'epiR') to learn how to use epiR for applied epidemiological analyses
##
library("epitools")
##
## Attaching package: 'epitools'
## The following object is masked from 'package:survival':
##
## ratetable
library("DescTools")
library("fmsb")
##
## Attaching package: 'fmsb'
## The following objects are masked from 'package:DescTools':
##
## CronbachAlpha, VIF
## The following objects are masked from 'package:epitools':
##
## oddsratio, rateratio, riskratio
Latihan Odds Ratio dan Uji Kebebasan antar Peubah
Soal Latihan dari Buku Azen Bab 4
ilustrasi
Soal 4.1 (Penghitungan Manual)
ilustrasi
ilustrasi
Soal 4.1 (dengan Program)
#----INPUT TABLE 4.8----#
Proficiency<-matrix(c(35,5,93,67), nrow=2,byrow=TRUE)
colnames(Proficiency)<-c("Prof_No","Prof_Yes")
rownames(Proficiency)<-c("NES_No","NES_Yes")
tabelProficiency<-as.table(Proficiency)
tabelProficiency
## Prof_No Prof_Yes
## NES_No 35 5
## NES_Yes 93 67
dataProficiency<-as.data.frame(Proficiency)
dataProficiency
## Prof_No Prof_Yes
## NES_No 35 5
## NES_Yes 93 67
addmargins(tabelProficiency)
## Prof_No Prof_Yes Sum
## NES_No 35 5 40
## NES_Yes 93 67 160
## Sum 128 72 200
prop.table(tabelProficiency)
## Prof_No Prof_Yes
## NES_No 0.175 0.025
## NES_Yes 0.465 0.335
prop.table(tabelProficiency,margin=1)
## Prof_No Prof_Yes
## NES_No 0.87500 0.12500
## NES_Yes 0.58125 0.41875
#bagian a
#Odds of Proficiency
# Odds of Proficiency NO untuk Status NES NO
prop.out <- prop.table(tabelProficiency,margin=1)
prop.out[1,1]/prop.out[1,2]
## [1] 7
# Odds of Proficiency NO untuk Status NES YES
prop.out[2,1]/prop.out[2,2]
## [1] 1.38806
Odds of Proficiency NO untuk Status NES NO diperoleh angka 7, yang berarti bahwa peluang siswa yang berstatus BUKAN NES (NES NO) tidak terampil/handal matematik adalah 7 kali dari peluang yang berstatus BUKAN NES (NES NO) terampil/handal dalam matematik.
Sedangkan Odds of Proficiency NO untuk Status NES YES diperoleh angka 1.38806, yang berarti bahwa peluang siswa yang berstatus NES (NES YES) tidak terampil/handal matematik adalah 1.38806 kali dari peluang yang berstatus bNES (NES YES) terampil/handal dalam matematik.
#bagian b
# Odds Ratio of Proficiency
oddsratio(tabelProficiency)
## Disease Nondisease Total
## Exposed 35 5 40
## Nonexposed 93 67 160
## Total 128 72 200
##
## Odds ratio estimate and its significance probability
##
## data: tabelProficiency
## p-value = 0.000554
## 95 percent confidence interval:
## 1.877099 13.548543
## sample estimates:
## [1] 5.043011
Interpretasi: Odds siswa berstatus BUKAN NES (NES NO) adalah 5 kali dari odds siswa berstatus NES (NES YES).
Soal 4.2: Find the 95% confidence interval for the odds ratio in Problem 4.1 and interpret the result (Penghitungan Manual)
ilustrasi
Soal 4.2: Find the 95% confidence interval for the odds ratio in Problem 4.1 and interpret the result (dengan Program)
##soal nomor 4.2
oddsratio(tabelProficiency)
## Disease Nondisease Total
## Exposed 35 5 40
## Nonexposed 93 67 160
## Total 128 72 200
##
## Odds ratio estimate and its significance probability
##
## data: tabelProficiency
## p-value = 0.000554
## 95 percent confidence interval:
## 1.877099 13.548543
## sample estimates:
## [1] 5.043011
Interpretasi: Selang kepercayaan 95% untuk soal nomor 4.1 yaitu nilai θ berada dalam selang nilai 1.877099 hingga 13.548543. Berdasarkan nilai dari rasio odds terdapat hubungan antara mathematics proficiency dan status NES karena nilai 1 tidak masuk pada selang kepercayaan θ pada α=5%.
Soal 4.3: Is there an association between proficiency and NES status based on the data in Problem 4.1? State the null hypothesis and interpret the results of the hypothesis test (Penghitungan Manual)
ilustrasi
ilustrasi
Soal 4.3: Is there an association between proficiency and NES status based on the data in Problem 4.1? State the null hypothesis and interpret the results of the hypothesis test (dengan Program)
Hipotesis: H_0: Status NES dan Mathematics Proficiency saling bebas H_1: Status NES dan Mathematics Proficiency tidak saling bebas
chisq.test(tabelProficiency,correct=FALSE)
##
## Pearson's Chi-squared test
##
## data: tabelProficiency
## X-squared = 11.985, df = 1, p-value = 0.0005364
Keputusan: nilai p-value= 0.0005364 < α= 0.05 sehingga tolak H0. Kesimpulan: dengan kata lain hubungan Status NES dan Mathematics Proficiency tidak saling bebas pada α=5%.
Soal 4.6
ilustrasi
#----INPUT TABLE 4.9----#
VitC<-matrix(c(32,16,13,27,5,7), nrow=3,byrow=TRUE)
colnames(VitC)<-c("Yes","No")
rownames(VitC)<-c("Few","Some","Many")
tabelVitC<-as.table(VitC)
tabelVitC
## Yes No
## Few 32 16
## Some 13 27
## Many 5 7
#Hipotesis:
#H_0: Colds incidence dan penggunaan vitamin C saling bebas
#H_1: Colds incidence dan penggunaan vitamin C tidak saling
##bagian a : Pearson Chi-squared Test
chisq.test(tabelVitC,correct=FALSE)
##
## Pearson's Chi-squared test
##
## data: tabelVitC
## X-squared = 10.567, df = 2, p-value = 0.005075
##bagian b : Likelihood Ratio Test
GTest(tabelVitC, correct = "none")
##
## Log likelihood ratio (G-test) test of independence without correction
##
## data: tabelVitC
## G = 10.777, X-squared df = 2, p-value = 0.004569
##bagian c : Kesimpulan
Keputusan: Pada pearson chi-square test p-value yang dihasilkan adalah sebesar 0.005075 dan p-value yang dihasilkan pada Likelihood Ratio test adalah sebesar 0.004569. Sehingga kedua p-value yang dihasilkan < α=0.05 maka keputusannya adalah tolak H0.
Kesimpulan: dengan kata lain hubungan Colds incidence dan penggunaan vitamin C tidak saling bebas pada α=5%.