Skip to content

Commit

Permalink
Test binomial CI for different ns
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Oct 4, 2023
1 parent 975043c commit 2d4deb7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/testthat/test-binomProb.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,32 @@ test_that("test binomProb()", {
expect_equal(binomProbs(x2,na.rm=TRUE), t1)
expect_equal(binomProbs(x2, onlyProbs=FALSE, na.rm=TRUE), t2)


n <- 50
z <- qnorm(1 - 0.025)
z2 <- z * z
c1 <- 2*n*m + z2
c2 <- z*sqrt(z2 - 1.0/n + 4*n*v + (4.0*m-2.0))+1.0
c3 <- 2*(n+z2)
z2.5 <- (c1 + c(-1, 1) * c2) / c3

n <- 50
z <- qnorm(1 - 0.05)
z2 <- z * z
c1 <- 2*n*m + z2
c2 <- z*sqrt(z2 - 1.0/n + 4*n*v + (4.0*m-2.0))+1.0
c3 <- 2*(n+z2)
z5 <- (c1 + c(-1, 1) * c2) / c3


t1 <- c("2.5%"=z2.5[1],
"5%"=z5[1],
"50%"=m,
"95%"=z5[2],
"97.5%"=z2.5[2])

expect_equal(binomProbs(x, n=50), t1)

v ## now get test binomial predictions

})

0 comments on commit 2d4deb7

Please sign in to comment.