File: rsu.spp.rs.R

package info (click to toggle)
r-cran-epir 2.0.80%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,332 kB
  • sloc: makefile: 5
file content (15 lines) | stat: -rw-r--r-- 482 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
rsu.spp.rs<- function (N = NA, n, c = 1, sp.u){
  
  if (is.na(N)) {
    sph <- stats::pbinom(q = c - 1, size = n, prob = 1 - sp.u)
  }
  else if (!is.na(N) & !is.na(c) & !is.na(sp.u)) {
    # Expected number of test positive animals in the herd:
    EY <- N * (1 - sp.u)
    Y <- floor(EY)
    
    m <- EY - Y
    sph <- m * stats::phyper(q = c - 1, m = Y + 1, n = N - Y - 1, k = n) + (1 - m) * stats::phyper(q = c - 1, m = Y, n = N - Y, k = n)
  }
  return(sph)
}