options(scipen=999)
options(digits=9)

n=500
x=160
pcap=x/n;pcap
standard_error=sqrt((pcap*(1-pcap))/n)
standard_error
alpha=0.05
ztable=qnorm(1-alpha/2,0,1);ztable
confi_level=ztable*standard_error;confi_level
lower_limit=pcap-confi_level;lower_limit
upper_limit=pcap+confi_level;upper_limit




library("TeachingDemos")
prop.test(160,500,correct=FALSE)


library("TeachingDemos")
prop.test(160,500,correct=FALSE)





prop.test(x,500,correct=TRUE)
prop.test(x,500,p=0.32,correct=TRUE)



smokers  <- c( 83, 90, 129, 70 )
patients <- c( 86, 93, 136, 82 )
prop.test(smokers, patients)


binom.test(160, 500, p = 0.5,
           alternative = c("two.sided", "less", "greater"),
           conf.level = 0.95)


binom.test(160,500,conf.level=0.95)




library(Hmisc)
binconf(x=160,n=500,method="asymptotic")

library(Hmisc)
binconf(x=160,n=500,method="wilson")

library(Hmisc)
binconf(x=160,n=500)

library(Hmisc)
binconf(x=160,n=500,method="all")
