acbinomcipv <-
function(x=sum(y),nn=length(y),y=NULL,n=NA,alpha=.05,nullval=.5){
# Compute a p-value when testing the hypothesis that the probability of
# success for a binomial distribution is equal to
# nullval, which defaults to .5
# The Agresti-Coull method is used.
#
# y is a vector of 1s and 0s.
# Or can use the argument
# x = the number of successes observed among
# n=nn trials.
#
res=acbinomci(x=x,nn=nn,y=y,alpha=alpha)
ci=res$ci
alph<-c(1:99)/100
for(i in 1:99){
irem<-i
chkit<-acbinomci(x=x,nn=nn,y=y,alpha=alph[i])$ci
if(chkit[1]>nullval || chkit[2]<nullval)break
}
p.value<-irem/100
if(p.value<=.1){
iup<-(irem+1)/100
alph<-seq(.001,iup,.001)
for(i in 1:length(alph)){
p.value<-alph[i]
chkit<-acbinomci(x=x,nn=nn,y=y,alpha=alph[i])$ci
if(chkit[1]>nullval || chkit[2]<nullval)break
}}
if(p.value<=.001){
alph<-seq(.0001,.001,.0001)
for(i in 1:length(alph)){
p.value<-alph[i]
chkit<-acbinomci(x=x,nn=nn,y=y,alpha=alph[i])$ci
if(chkit[1]>nullval || chkit[2]<nullval)break
}}
list(n=nn,phat=res$phat,ci=res$ci,p.value=p.value)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.