[med-svn] [r-cran-epitools] 02/05: New upstream version 0.5-10

Andreas Tille tille at debian.org
Sat Nov 11 14:51:25 UTC 2017


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository r-cran-epitools.

commit 21c2f6e54f8f302288e4ab47bec13b805f20d69e
Author: Andreas Tille <tille at debian.org>
Date:   Sat Nov 11 15:45:22 2017 +0100

    New upstream version 0.5-10
---
 DESCRIPTION        |  8 ++++----
 MD5                |  6 +++---
 R/rateratio.midp.R | 31 ++++++++++++++++++++-----------
 man/rateratio.Rd   | 10 ++++++----
 4 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 6e1bdea..a907e2a 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
 Package: epitools
-Version: 0.5-9
-Date: 2017-04-13
+Version: 0.5-10
+Date: 2017-10-26
 Title: Epidemiology Tools
 Authors at R: c(person("Tomas J.", "Aragon", role = "aut",
         email = "aragon at berkeley.edu"), person("Michael P.",
@@ -12,10 +12,10 @@ Authors at R: c(person("Tomas J.", "Aragon", role = "aut",
 Depends: R (>= 2.1.0)
 Description: Tools for training and practicing epidemiologists including methods for two-way and multi-way contingency tables.
 License: GPL (>= 2)
-Packaged: 2017-04-14 17:48:42 UTC; adam.omidpanah
+Packaged: 2017-10-26 18:25:13 UTC; adam.omidpanah
 Author: Tomas J. Aragon [aut], Michael P. Fay
         [ctb], Daniel Wollschlaeger [ctb], Adam Omidpanah [cre, ctb]
 Maintainer: Adam Omidpanah <adam.omidpanah at wsu.edu>
 Repository: CRAN
-Date/Publication: 2017-04-14 23:04:36 UTC
+Date/Publication: 2017-10-26 20:33:21 UTC
 NeedsCompilation: no
diff --git a/MD5 b/MD5
index e5ee0f4..1f7039d 100644
--- a/MD5
+++ b/MD5
@@ -1,4 +1,4 @@
-abef416cd1c730e7137263f9b1791b4a *DESCRIPTION
+4e327f3e185ceed5c521db691174de78 *DESCRIPTION
 f259c9f26e82e13a8eb777c4f2fbecc7 *NAMESPACE
 2745fc0b8c7dd39e9272b0a8d8d573ae *R/ageadjust.direct.R
 f57b81c6d42888d11c7673aa911aaaa4 *R/ageadjust.indirect.R
@@ -39,7 +39,7 @@ b4af057b9684dd25a204d0fdd07bc490 *R/pois.byar.R
 f55b48d7e8d39764eacac14d02617368 *R/probratio.r
 d963dd2d0fd72e1b1852100d3f3a731c *R/rate2by2.test.R
 23a6d06d89f020f2632c8167a1c5bfb6 *R/rateratio.R
-a3353788495494cfe1701acf61e1296b *R/rateratio.midp.R
+92875d4809c02c2d90b6ce814f08d0bd *R/rateratio.midp.R
 b5a48d34e42c464993cdc31d6f2450af *R/rateratio.wald.R
 da5914dac422077e09bf4ec11bd0bdcb *R/ratetable.R
 7d63605703662d7f708b79875995fafb *R/riskratio.R
@@ -74,7 +74,7 @@ cc44f5cbf9bf742da3fc2812fbb0116d *man/ormidp.test.Rd
 7e4aadfb1419d6707259d2dfbced4ba2 *man/pois.conf.int.Rd
 87bb14cc9f0590b20b9885172e7e8e1a *man/probratio.Rd
 7a6a6a89eda18545c4194f62827dc7b9 *man/rate2by2.test.Rd
-065d02278f69456c17b29793d3273956 *man/rateratio.Rd
+3e78113268282c0e0a3458ef85db6744 *man/rateratio.Rd
 76d5efb56197e4496efe1e8d14b803bf *man/ratetable.Rd
 2ee62232595ea0e0ca866ef586e8a09d *man/riskratio.Rd
 5bda8bae7c61e9fbb874d64d247bcff6 *man/tab2by2.test.Rd
diff --git a/R/rateratio.midp.R b/R/rateratio.midp.R
index 6ff8b27..f034c1f 100644
--- a/R/rateratio.midp.R
+++ b/R/rateratio.midp.R
@@ -1,8 +1,7 @@
-"rateratio.midp" <-
-function(x, y = NULL,
-         conf.level = 0.95,
-         rev = c("neither", "rows", "columns", "both"),
-         verbose = FALSE){
+rateratio.midp <- function(x, y = NULL,
+                           conf.level = 0.95,
+                           rev = c("neither", "rows", "columns", "both"),
+                           verbose = FALSE){
   if(is.matrix(x) && !is.null(y)){stop("y argument should be NULL")}
   if(is.null(y)){
     x <- ratetable(x, rev = rev)
@@ -12,6 +11,16 @@ function(x, y = NULL,
     x <- ratetable(x, y, rev = rev)
     colnames(x) <- c(xn, yn)
   }
+  
+  midprob <- function(p,y,n,lower.tail,offset) dbinom(y,n,p)/2 + pbinom(y-lower.tail, n, p, lower.tail = lower.tail) + offset
+  solve.p <- function(n, y, offset=-0.5, lower.tail=T) {
+    if (lower.tail & !midprob(1, y, n, lower.tail,offset) < 0)
+      return(1)
+    if (!lower.tail & !midprob(0, y, n, lower.tail,offset) < 0)
+      return(0)
+    return(uniroot(midprob, c(0,1),y=y,n=n,lower.tail=lower.tail,offset)$root)
+  }
+  
   tmx <- table.margins(x)[,-3]
   alpha <- 1 - conf.level
   nr <- nrow(x)
@@ -21,11 +30,11 @@ function(x, y = NULL,
     aa <- x[i,1]; bb <- x[1,1]; pt1 <- x[i,2]; pt0 <- x[1,2]
     pt <- pt0 + pt1
     mm <- aa + bb
-    s.irr <- uniroot(function(s) (dbinom(aa, mm, s)/2 + pbinom(aa-1, mm, s)) - 0.5, c(0, 1))$root
+    s.irr <- solve.p(n = mm, y = aa, offset = -0.5, lower.tail = F)
     irr <- (s.irr / (1 - s.irr)) * (pt0 / pt1)
-    s.lower <- uniroot(function(s) 1 - (dbinom(aa, mm, s)/2 + pbinom(aa-1, mm, s)) - alpha/2, c(0,1))$root
+    s.lower <- solve.p(n=mm, y=aa, offset=-alpha/2, lower.tail = F)
     irr.lower <- (s.lower/ (1 - s.lower)) * (pt0 / pt1)
-    s.upper <- uniroot(function(s) dbinom(aa, mm, s)/2 + pbinom(aa-1, mm, s) - alpha/2, c(0,1))$root
+    s.upper <- solve.p(n=mm, y=aa, offset=-alpha/2, lower.tail=T)
     irr.upper <- (s.upper/ (1 - s.upper)) * (pt0 / pt1)
     est[i,] <- c(irr, irr.lower, irr.upper)
   }
@@ -41,14 +50,14 @@ function(x, y = NULL,
              measure = est,
              conf.level = conf.level,
              p.value = pval
-             )
+  )
   rrs <- list(data = tmx,
               measure = est,
               p.value = pval
-              )
+  )
   attr(rr, "method") <- "Median unbiased estimate & mid-p exact CI"
   attr(rrs, "method") <- "Median unbiased estimate & mid-p exact CI"
   if(verbose==FALSE) {
     rrs
   } else rr 
-}
+}
\ No newline at end of file
diff --git a/man/rateratio.Rd b/man/rateratio.Rd
index 6368c1d..f185749 100644
--- a/man/rateratio.Rd
+++ b/man/rateratio.Rd
@@ -94,17 +94,19 @@ rateratio.wald(x, y = NULL,
 }
 
 \references{
-  Kenneth J. Rothman and Sander Greenland (1998), Modern Epidemiology,
+  Kenneth J. Rothman, Sander Greenland, and Timothy Lash (2008), Modern Epidemiology,
   Lippincott-Raven Publishers
 
-  Kenneth J. Rothman (2002), Epidemiology: An Introduction, Oxford
+  Kenneth J. Rothman (2012), Epidemiology: An Introduction, Oxford
   University Press
+  
 } 
 
 \author{Rita Shiau (original author), \email{rita.shiau at sfdph.org};
   Tomas Aragon, \email{aragon at berkeley.edu},
-  \url{http://www.phdata.science}} 
-
+  \url{http://www.phdata.science};
+  Adam Omidpanah, \email{adam.omidpanah at wsu.edu} \url{https://repitools.wordpress.com/}
+}
 
 
 \seealso{

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-epitools.git



More information about the debian-med-commit mailing list