EpiNow2 Stan Functions
pmfs.stan
Go to the documentation of this file.
1/**
2 * Probability Mass Function (PMF) Utilities
3 *
4 * This file contains functions for creating and manipulating probability mass
5 * functions, particularly for discretizing continuous distributions for use in
6 * delay modeling.
7 *
8 * @ingroup pmf_handlers
9 */
10
11/**
12 * Discretise a continuous distribution using primary censoring
13 *
14 * Computes a properly primary-censored PMF using the vendored
15 * primarycensored Stan functions. Assumes uniform primary event
16 * distribution within a window of width 1.
17 *
18 * @param params Distribution parameters as a vector
19 * @param n Number of days to calculate PMF for (max_delay + 1)
20 * @param dist Distribution type using primarycensored convention
21 * (1: lognormal, 2: gamma, 3: weibull, 4: exponential)
22 * @param L Left truncation point (0 for no truncation)
23 * @return A vector of length n containing the discretised PMF
24 *
25 * @ingroup pmf_handlers
26 */
28 vector params, data int n, int dist, data int L
29) {
30 int n_params = num_elements(params);
31 array[n_params] real params_array;
32 for (i in 1:n_params) {
33 params_array[i] = params[i];
34 }
35 array[0] real primary_params;
37 n - 1, L * 1.0, n * 1.0, dist,
38 params_array, 1.0, 1, primary_params
39 );
40}
vector discretised_pmf(vector params, data int n, int dist, data int L)
Definition pmfs.stan:27
vector primarycensored_sone_pmf_vectorized(int max_delay, data real L, data real D, int dist_id, array[] real params, data real pwindow, int primary_id, array[] real primary_params)