![]() |
primarycensored
|
Helper functions for analytical solutions. More...

Functions | |
| int | check_for_uniform_terms (int dist_id, int primary_id) |
| int | check_for_analytical (int dist_id, int primary_id) |
| real | primarycensored_uniform_lcdf_from_terms (vector terms_d, vector terms_q, data real pwindow) |
| vector | primarycensored_gamma_uniform_terms (real t, array[] real params) |
| vector | primarycensored_lognormal_uniform_terms (real t, array[] real params) |
| real | log_weibull_g (real t, real shape, real scale) |
| vector | primarycensored_weibull_uniform_terms (real t, array[] real params) |
| vector | primarycensored_gengamma_uniform_terms (real t, array[] real params) |
| vector | primarycensored_uniform_terms (real t, data int dist_id, array[] real params) |
| int | check_for_analytical_vectorized (int dist_id, int primary_id, data real pwindow) |
Helper functions for analytical solutions.
| int check_for_analytical | ( | int | dist_id, |
| int | primary_id ) |
Check if an analytical solution exists for the given distribution combination
The non-parametric step (26) and discrete-hazard (27, 28) delays are analytic for every primary primary_lcdf currently supports, the uniform (1) and exponential growth (2). That list is repeated by hand below, so adding a primary to primary_lcdf does not extend the analytic path on its own: without a matching update here the new primary silently falls back to numerical integration.
| dist_id | Distribution identifier for the delay distribution |
| primary_id | Distribution identifier for the primary distribution |
Definition at line 37 of file primarycensored_analytical_cdf.stan.


| int check_for_analytical_vectorized | ( | int | dist_id, |
| int | primary_id, | ||
| data real | pwindow ) |
Check if the analytical solution can be vectorised over integer delays
The analytical uniform primary CDF at d combines terms at d and at q = max(d - pwindow, 0). With an integer pwindow q is an integer delay too, so primarycensored_analytical_lcdf_vectorized() can compute the terms once per delay and share them. This needs the analytical solutions built from primarycensored_uniform_terms(), see check_for_uniform_terms(). The non-parametric delays in check_for_analytical() have no such terms.
| dist_id | Distribution identifier for the delay distribution |
| primary_id | Distribution identifier for the primary distribution |
| pwindow | Primary event window |
Definition at line 455 of file primarycensored_analytical_cdf.stan.


| int check_for_uniform_terms | ( | int | dist_id, |
| int | primary_id ) |
Check if the analytical solution is built from uniform primary terms
These are the delays whose censored CDF with a uniform primary is primarycensored_uniform_lcdf_from_terms() applied to primarycensored_uniform_terms() at d and q.
| dist_id | Distribution identifier for the delay distribution |
| primary_id | Distribution identifier for the primary distribution |
Definition at line 15 of file primarycensored_analytical_cdf.stan.

| real log_weibull_g | ( | real | t, |
| real | shape, | ||
| real | scale ) |
Compute the log of the lower incomplete gamma function
This function is used in the analytical solution for the primary censored Weibull distribution with uniform primary censoring. It corresponds to the g(t; λ, k) function described in the analytic solutions document.
| t | Upper bound of integration |
| shape | Shape parameter (k) of the Weibull distribution |
| scale | Scale parameter (λ) of the Weibull distribution |
Definition at line 153 of file primarycensored_analytical_cdf.stan.

| vector primarycensored_gamma_uniform_terms | ( | real | t, |
| array[]real | params ) |
Compute the uniform primary terms at t for a Gamma delay
| t | Time (d or q) |
| params | Array of Gamma distribution parameters [shape, rate] |
-inf for t <= 0 Definition at line 91 of file primarycensored_analytical_cdf.stan.

| vector primarycensored_gengamma_uniform_terms | ( | real | t, |
| array[]real | params ) |
Compute the uniform primary terms at t for a generalised gamma delay
Uses the Stacy parameterisation of flexsurv::pgengamma.orig(), see gengamma_lcdf. The mean is E = scale * Gamma(k + 1/shape) / Gamma(k) and the partial expectation distribution is the generalised gamma with k replaced by k + 1/shape, so this generalises the Gamma (shape = 1) and Weibull (k = 1) solutions.
| t | Time (d or q) |
| params | Array of generalised gamma distribution parameters [shape, scale, k] |
-inf for t <= 0 Definition at line 201 of file primarycensored_analytical_cdf.stan.

| vector primarycensored_lognormal_uniform_terms | ( | real | t, |
| array[]real | params ) |
Compute the uniform primary terms at t for a Lognormal delay
Each term is formed whole and dropped whole. Adding a -inf log CDF to the parameter-dependent log(t) or log_E first would leave an edge back to the parameters that log_sum_exp differentiates to exp(-inf - -inf). t <= 0 underflows on the same test.
| t | Time (d or q) |
| params | Array of Lognormal distribution parameters [mu, sigma] |
Definition at line 123 of file primarycensored_analytical_cdf.stan.

| real primarycensored_uniform_lcdf_from_terms | ( | vector | terms_d, |
| vector | terms_q, | ||
| data real | pwindow ) |
Combine the uniform primary terms at d and q into the censored log CDF
For a delay T with mean E and a uniform primary over a window of width w_P, the primary event censored CDF at d is F_{S+}(d) = (A - B) / w_P, with A = d * F_T(d) + E * tilde F_T(q), B = q * F_T(q) + E * tilde F_T(d), where q = max(d - w_P, 0) and tilde F_T is the CDF of the partial expectation distribution. Each of A and B is a sum of one term at d and one at q, and those terms depend on d or q alone (see primarycensored_uniform_terms()). Ordering A >= B is guaranteed by F_{S+}(d) >= 0.
| terms_d | Terms at d from primarycensored_uniform_terms() |
| terms_q | Terms at q from primarycensored_uniform_terms() |
| pwindow | Primary event window |
Definition at line 68 of file primarycensored_analytical_cdf.stan.

| vector primarycensored_uniform_terms | ( | real | t, |
| data int | dist_id, | ||
| array[]real | params ) |
Compute the uniform primary terms at t for a delay distribution
| t | Time (d or q) |
| dist_id | Distribution identifier (1: Lognormal, 2: Gamma, 3: Weibull, 5: Generalised gamma), see check_for_uniform_terms() |
| params | Array of distribution parameters |
Definition at line 229 of file primarycensored_analytical_cdf.stan.


| vector primarycensored_weibull_uniform_terms | ( | real | t, |
| array[]real | params ) |
Compute the uniform primary terms at t for a Weibull delay
For Weibull, E = scale (lambda) and tilde F_T(t) = g(t; lambda, k).
| t | Time (d or q) |
| params | Array of Weibull distribution parameters [shape, scale] |
-inf for t <= 0 Definition at line 171 of file primarycensored_analytical_cdf.stan.

