File: pois.daly.R

package info (click to toggle)
r-cran-epitools 1%3A0.5-10-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 596 kB
  • sloc: makefile: 2
file content (29 lines) | stat: -rw-r--r-- 880 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"pois.daly" <-
  function(x, pt = 1, conf.level = 0.95){
    xc <- cbind(x,conf.level,pt)
    pt2 <- xc[,3]
    results <- matrix(NA,nrow(xc),6)
    cipois <-
      function(x, conf.level = 0.95){
        if(x!=0){
          LL <- qgamma((1 - conf.level)/2, x)
          UL <- qgamma((1 + conf.level)/2, x + 1)
        } else {
          if(x==0){
            LL <- 0
            UL <- -log(1 - conf.level)
          }
        }
        data.frame(x = x, lower = LL, upper = UL)
      }
    for(i in 1:nrow(xc)){
      alp <- 1-xc[i,2]
      daly <- cipois(x = xc[i, 1], conf.level = xc[i, 2])
      LCL <- daly$lower/pt2[i]
      UCL <- daly$upper/pt2[i]
      results[i,] <- c(xc[i,1],pt2[i],xc[i,1]/pt2[i],LCL,UCL,xc[i,2]) 
    }
    coln <- c("x","pt","rate","lower","upper","conf.level")
    colnames(results) <- coln
    data.frame(results)
  }