File: epi.bohning.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 (14 lines) | stat: -rw-r--r-- 470 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
"epi.bohning" <- function(obs, exp, alpha = 0.05){
   J <- length(obs)
   smr <- obs / exp
   smr.bar <- sum(smr, na.rm = TRUE) / J
   
   # Bohning's test:   
   top <- (1 / (J - 1)) * sum(((obs - (smr.bar * exp))^2 / exp), na.rm = TRUE) - smr.bar
   bottom <- sqrt((2 * smr.bar) / (J - 1))
   bohning <- top / bottom

   p <- 1 - pnorm(q = bohning, mean = 0, sd = 1)
   rval <- as.data.frame(cbind(test.statistic = bohning, p.value = p))
   return(rval)
}