]>
nmode's Git Repositories - Rnaught/blob - R/computeLL.R
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.
12 computeLL
<- function(p
, NT
, R0
){
18 Nt
<- NT
[i
:max(1,i
-k
+1)]
20 # print(p[1:min(k,i)])
21 mu_t
[i
] <- sum(p
[1:min(k
,i
)]*Nt
)
24 LL
<- -sum(mu_t
)+sum(NT
[-1]*log(mu_t
))