Hello,
Anamika Chaudhuri-2 wrote > >> >> 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@ 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]] > > ______________________________________________ > R-help@ mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > See package 'binom'. Function 'binom.confint' gives a choice of 8 different methods, Clopper-Pearson is the 'exact', and function 'binom.test' also uses it. Hope this helps, Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/Exact-Confidence-Interval-tp4454603p4455178.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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 and provide commented, minimal, self-contained, reproducible code.