From ff1d5fa81a10cc374aa40fa13c697baa6ade136c Mon Sep 17 00:00:00 2001 From: Naeem Model Date: Thu, 29 Jun 2023 21:37:15 +0000 Subject: Group internal functions for WP method --- R/computeLL.R | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 R/computeLL.R (limited to 'R/computeLL.R') diff --git a/R/computeLL.R b/R/computeLL.R deleted file mode 100644 index 01c0d57..0000000 --- a/R/computeLL.R +++ /dev/null @@ -1,26 +0,0 @@ -#' WP method background function computeLL -#' -#' This is a background/internal function called by \code{WP}. It computes the log-likelihood. -#' -#' @param NT Vector of case counts. -#' @param p Discretized version of the serial distribution. -#' @param R0 Basic reproductive ratio. -#' -#' @return This function returns the log-likelihood at the input variables and parameters. -#' -#' @keywords internal -computeLL <- function(p, NT, R0) { - k <- length(p) - TT <- length(NT) - 1 - mu_t <- rep(0, TT) - - for (i in 1:TT) { - Nt <- NT[i:max(1, i-k+1)] - mu_t[i] <- sum(p[1:min(k, i)] * Nt) - } - - mu_t <- R0 * mu_t - LL <- sum(NT[-1] * log(mu_t)) - sum(mu_t) - - return(LL) -} -- cgit v1.2.3