]>
nmode's Git Repositories - Rnaught/blob - R/computeLL.R
6acfc786e34401e6f4f43543000f6d76b07a1ec6
1 #' WP method background function computeLL
3 #' This is a background/internal function called by \code{WP}. It computes the log-likelihood.
5 #' @param NT vector of case counts
6 #' @param p discretized version of the serial distribution
7 #' @param R0 basic reproductive ratio
8 #' @return The function returns the variable \code{LL} which is the log-likelihood at the input variables and parameters.
11 computeLL
<- function(p
, NT
, R0
) {
17 Nt
<- NT
[i
:max(1, i
-k
+1)]
18 mu_t
[i
] <- sum(p
[1:min(k
, i
)] * Nt
)
22 LL
<- sum(NT
[-1] * log(mu_t
)) - sum(mu_t
)