|
a |
|
b/R/outbreaker_init_mcmc.R |
|
|
1 |
## #' Initianilizes outputs for outbreaker |
|
|
2 |
## #' |
|
|
3 |
## #' This function creates initial outputs and parameter states for outbreaker. |
|
|
4 |
## #' |
|
|
5 |
## #' @author Thibaut Jombart (\email{thibautjombart@@gmail.com}) |
|
|
6 |
## #' |
|
|
7 |
## #' @param param a list of data items as returned by \code{create_param} |
|
|
8 |
## #' |
|
|
9 |
## #' @param loglike a list of loglikelihood functions with enclosed data as returned by \code{custom_likelihood} |
|
|
10 |
## #' |
|
|
11 |
## #' @param priors a list of prior functions with enclosed parameters as returned by \code{custom_priors} |
|
|
12 |
## #' |
|
|
13 |
## #' @export |
|
|
14 |
## #' |
|
|
15 |
outbreaker_init_mcmc <- function(data, param_current, param_store, loglike, priors, config) { |
|
|
16 |
|
|
|
17 |
## COMPUTE INITIAL LIKE/PRIOR/POST ## |
|
|
18 |
param_store$like[1] <- cpp_ll_all(data, param_current, NULL, loglike) |
|
|
19 |
param_store$prior[1] <- cpp_prior_all(param_current, config, priors) |
|
|
20 |
param_store$post[1] <- param_store$like[1] + param_store$prior[1] |
|
|
21 |
|
|
|
22 |
if(is.infinite(param_store$post[1])) { |
|
|
23 |
stop("Likelihood of initial parameter state is -Inf") |
|
|
24 |
} |
|
|
25 |
|
|
|
26 |
return(param_store) |
|
|
27 |
} |
|
|
28 |
|