>
> Hi All:
>
> I am using R to calculate exact 95% confidence interval using Clopper
> Pearson method. I am using the following code but it seems to get into a
> loop and not get out of it, it goes on forever although I am looping it
> only 10 times across 63 sites with 10 observations per site. I was hoping
> to get some help.
>
> Thanks
>
Anamika

> set.seed(111)  #so that you can regenerate the same values
> # another time if you need to
> k<-63
> n<-10
> x<-NULL
> eta<-rnorm(63,-0.085,.990)  # generating data using Binomial Logit Normal
> p<-exp(eta)/(1+exp(eta))
> for(i in 1:k)
> x<-cbind(x,rbinom(10,n,p[i]))
>
> rate<-t(t(x)/n)
>
> # Exact Confidence Interval
>
> for (i in 1:10){
>
> for (j in 1:63)
> {
>
> if (x==0)
> {
> l_cl_exact<-0
> u_cl_exact<-qbeta(.975,x+1,n-x)
> }
> else if (x==n)
> {
> l_cl_exact<-qbeta(.025,x,n-x+1)
> u_cl_exact<-1
> }
> else
> l_cl_exact<-qbeta(.025,x,n-x+1)
> u_cl_exact<-qbeta(.975,x+1,n-x)
>
> }
> }_____________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]

