]> nmode's Git Repositories - Rnaught/blobdiff - R/WP.R
Add local imports
[Rnaught] / R / WP.R
diff --git a/R/WP.R b/R/WP.R
index 9e44bf9e35b7a02c501e3eddb8d5067bd6d10540..a0290d380b0783a3aee793fac096faf49b6d2df2 100644 (file)
--- a/R/WP.R
+++ b/R/WP.R
@@ -1,3 +1,6 @@
+source("WP_known.R")
+source("WP_unknown.R")
+
 #' WP method
 #'
 #' This function implements an R0 estimation due to White and Pagano (Statistics in Medicine, 2008).
 #' res3        <- WP(NT=NT)    
 #' res3$Rhat
 #' ## find mean of estimated serial distribution
-#' serial      <-      res3$SD
-#' sum(serial$supp*serial$pmf)
+#' serial <- res3$SD
+#' sum(serial$supp * serial$pmf)
 #'
 #' ## ========================================================= ##
 #' ## Compute Rhat using only the first five weeks of data      ##
 #' ## ========================================================= ##
 #' 
-#' res4 <- WP(NT=NT[1:5], mu=5/7, method="known")      # serial distribution has mean of five days
+#' res4 <- WP(NT=NT[1:5], mu=5/7, method="known") # serial distribution has mean of five days
 #' res4$Rhat
 #'
 #' @export
@@ -99,10 +102,10 @@ WP <- function(NT, mu="NA", method="unknown", search=list(B=100, shape.max=10, s
             p <- diff(pexp(0:range.max, 1/mu))
             p <- p / sum(p)
             res <- WP_known(NT=NT, p=p)
-            Rhat <- res$Rhat
+            Rhat <- res
             JJ <- NA
         }
     }
 
-    return(list(Rhat=Rhat, check=length(JJ), SD=list(supp=1:range.max, pmf=p), inputs=list(NT=NT, mu=mu, method=method, search=search, tol=tol)))
+    return(list(Rhat=Rhat, check=length(JJ), SD=list(supp=1:range.max, pmf=p)))
 }