diff options
author | hannajankowski <hkj@yorku.ca> | 2022-06-09 17:57:31 -0400 |
---|---|---|
committer | hannajankowski <hkj@yorku.ca> | 2022-06-09 17:57:31 -0400 |
commit | 14ec98c9bfc49f963e30159dc7db9f554088fb44 (patch) | |
tree | ccdd49f5dd1cda78357bf7c9d0a7c80b25ca3130 /R/computeLL.R |
Testing testing 123
Diffstat (limited to 'R/computeLL.R')
-rw-r--r-- | R/computeLL.R | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/R/computeLL.R b/R/computeLL.R new file mode 100644 index 0000000..0730399 --- /dev/null +++ b/R/computeLL.R @@ -0,0 +1,30 @@ +#' 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 The function returns the variable \code{LL} which is the log-likelihood at the input variables and parameters. + +#' @export +# +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)] +# print(Nt) +# print(p[1:min(k,i)]) + mu_t[i] <- sum(p[1:min(k,i)]*Nt) + } + mu_t <- R0*mu_t + LL <- -sum(mu_t)+sum(NT[-1]*log(mu_t)) + + return(LL) + +} + + |