Anda di halaman 1dari 6

binconf(x=3,n=25,method="asymptotic")

PointEst

Lower

Upper

0.12 -0.007382581 0.2473826

> prop.test(x=3,n=25,conf.level=0.95,correct=T)

data: 3 out of 25, null probability 0.5

X-squared = 12.96, df = 1, p-value = 0.0003182
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.03151594 0.32335775
sample estimates:
p
0.12

> library(Hmisc,T)
> binconf(x=3,n=25,alpha=0.05,method="exact")
PointEst

Lower

Upper

0.12 0.0254654 0.3121903

> binom.test(x=3,n=25,conf.level=0.95)

Exact binomial test

data: 3 and 25
number of successes = 3, number of trials = 25, p-value = 0.0001565
alternative hypothesis: true probability of success is not equal to 0.5

95 percent confidence interval:

0.0254654 0.3121903
sample estimates:
probability of success
0.12

> prop.test(x=3,n=25,conf.level=0.95,correct=FALSE)

data: 3 out of 25, null probability 0.5

X-squared = 14.44, df = 1, p-value = 0.0001447
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.04166817 0.29955794
sample estimates:
p
0.12

> local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)

+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
> teh=matrix(c(3,1,1,3),ncol=2)
> fisher.test(teh)

Fisher's Exact Test for Count Data

data: teh

p-value = 0.4857
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.2117329 621.9337505
sample estimates:
odds ratio
6.408309

> fisher.test(teh,alternative="greater")

Fisher's Exact Test for Count Data

data: teh
p-value = 0.2429
alternative hypothesis: true odds ratio is greater than 1
95 percent confidence interval:
0.3135693

Inf

sample estimates:
odds ratio
6.408309

> local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)

+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) :
no packages were specified
> gender=matric(c(762,327,468,484,239,477),byrow=TRUE,nrow=2)

Error: could not find function "matric"

> gender=matrix(c(762,327,468,484,239,477),byrow=TRUE,nrow=2)
> dimnames(gender)=list(Gender=c("Wanita","Laki"),Party=c("Demokrat","Agama","Replubik"))
> chisq.test(gender)

Pearson's Chi-squared test

data: gender
X-squared = 30.0701, df = 2, p-value = 2.954e-07

> chisq.test(gender,simulate.p.value=TRUE,B=10000)

Pearson's Chi-squared test with simulated p-value (based on 10000

replicates)

data: gender
X-squared = 30.0701, df = NA, p-value = 9.999e-05

> local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)

+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) :
no packages were specified
> chooseCRANmirror()
Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) :
no packages were specified

> Fisher.test(gender)
Error: could not find function "Fisher.test"
> chooseCRANmirror()
> dp=c(19,132,0,9,11,52,6,97)
> dp=array(dp,dim=c(2,2,2))
> dimnames(dp)=list(Hukum.Mati=c("ya","tidak"),Korban=c("Suku A","Suku B"),Terdakwa=c("Suku
A","Suku B"))
> mantelhaen.test(dp)

Mantel-Haenszel chi-squared test with continuity correction

data: dp
Mantel-Haenszel X-squared = 5.8062, df = 1, p-value = 0.01597
alternative hypothesis: true common odds ratio is not equal to 1
95 percent confidence interval:
1.397771 11.381078
sample estimates:
common odds ratio
3.988502

> mantelhaen.test(dp,correct=FALSE)

Mantel-Haenszel chi-squared test without continuity correction

data: dp
Mantel-Haenszel X-squared = 6.9964, df = 1, p-value = 0.008168
alternative hypothesis: true common odds ratio is not equal to 1
95 percent confidence interval:

1.397771 11.381078
sample estimates:
common odds ratio
3.988502