Skip to content

Commit d3fa6b3

Browse files
committed
Added test-pFinalSizeAndGenSwitch1.R
1 parent 18391e6 commit d3fa6b3

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
test_that("pFinalSizeAndGenSwitch1() matches brute-force calculation", {
2+
pfs1 <- pFinalSizeAndGenSwitch1(g=1, n=1, j=4, R0=1.2, k0=0.33, Rc=0.9, k=0.22)
3+
pfs2 <- pFinalSizeAndGenSwitch1(g=2, n=1, j=4, R0=1.2, k0=0.33, Rc=0.9, k=0.22)
4+
pfs3 <- pFinalSizeAndGenSwitch1(g=3, n=1, j=4, R0=1.2, k0=0.33, Rc=0.9, k=0.22)
5+
6+
d0 <- dnbinom(0:3, mu=1.2, size=0.33)
7+
dc <- dnbinom(0:2, mu=0.9, size=0.22)
8+
dnb1 <- d0[4] * dc[1]^3
9+
dnb2 <- d0[3] * dc[2] * dc[1]^2 * 2 +
10+
d0[2] * dc[3] * dc[1]^2
11+
dnb3 <- d0[2] * dc[2]^2 * dc[1]
12+
13+
expect_equal(pfs1, dnb1, tolerance = sqrt(.Machine$double.eps))
14+
expect_equal(pfs2, dnb2, tolerance = sqrt(.Machine$double.eps))
15+
expect_equal(pfs3, dnb3, tolerance = sqrt(.Machine$double.eps))
16+
})

0 commit comments

Comments
 (0)