epinowcast
|
Go to the source code of this file.
Functions | |
real | loglogistic_lcdf (real y, real alpha, real beta) |
vector | lcdf_discretised (real mu, real sigma, int u, int dist) |
vector | normalise_lcdf_as_uniform_double_censored (vector lcdf, int u, int max_strat) |
vector | lcdf_to_uniform_double_censored_log_prob (vector lcdf, int u) |
vector | lprob_to_uniform_double_censored_log_hazard (vector lprob, vector lcdf, int u) |
Compute discretised logit hazard. | |
vector | log_hazard_to_logit_hazard (vector lhaz) |
vector | discretised_logit_hazard (real mu, real sigma, int dmax, int dist, int max_strat, int ref_as_p) |
vector discretised_logit_hazard | ( | real | mu, |
real | sigma, | ||
int | dmax, | ||
int | dist, | ||
int | max_strat, | ||
int | ref_as_p | ||
) |
Calculate logit hazard or log probability for discretised delay distribution
Computes logit hazards or log probabilities for a specified discretised parametric distribution up to a maximum possible delay. Employs various normalisation strategies and assumes that delays are double-censored and that the interval width is approximately uniformly distributed.
mu | Location parameter of the parametric distribution. |
sigma | Scale parameter of the parametric distribution. |
dmax | Maximum possible delay. The parametric distribution will be truncated at dmax. |
dist | Distribution type indicator (e.g., exponential, lognormal, ...). |
max_strat | Strategy for normalising LCDF values (e.g., handling probability mass beyond the maximum observed value). |
ref_as_p | Flag indicating whether to return log probabilities directly (1) or to convert to logit hazards (0). |
lcdf_discretised
.normalise_lcdf_as_uniform_double_censored
.lcdf_to_uniform_double_censored_log_prob
.ref_as_p
is 0, further processes these probabilities into logit hazards using lprob_to_uniform_double_censored_log_hazard
and log_hazard_to_logit_hazard
.Dependencies:
lcdf_discretised
normalise_lcdf_as_uniform_double_censored
lcdf_to_uniform_double_censored_log_prob
lprob_to_uniform_double_censored_log_hazard
log_hazard_to_logit_hazard
Definition at line 286 of file discretised_logit_hazard.stan.
vector lcdf_discretised | ( | real | mu, |
real | sigma, | ||
int | u, | ||
int | dist | ||
) |
Compute the discretised LCDF for various distributions
Computes the LCDF at integer points from 1 to u for a selected parametric distribution. Supports exponential, lognormal, gamma, and log-logistic distributions.
mu | Location parameter for the distribution. |
sigma | Scale parameter for the distribution. |
u | Upper bound of the discretised LCDF. |
dist | Integer flag for distribution type (1: exponential, 2: lognormal, 3: gamma, 4: log-logistic). |
loglogistic_lcdf
for the log-logistic distribution. Definition at line 40 of file discretised_logit_hazard.stan.
vector lcdf_to_uniform_double_censored_log_prob | ( | vector | lcdf, |
int | u | ||
) |
Compute LPMF from discretised LCDF under double censoring
Converts LCDF values to log-scale probability mass function (LPMF) assuming double censoring and a uniform interval approximation. Suitable for discretised LCDFs evaluated at integers 1 to u.
lcdf | Vector of LCDF values. |
u | Upper bound of the discretised LCDF / LPMF. |
normalise_lcdf_as_uniform_double_censored
. Definition at line 138 of file discretised_logit_hazard.stan.
vector log_hazard_to_logit_hazard | ( | vector | lhaz | ) |
Convert log hazards to logit hazards efficiently
Transforms log hazards to logit hazards without converting to the natural scale. Used in the final step of converting discretised probability distributions to logit hazards.
lhaz | Vector of log hazards. |
discretised_logit_hazard
. Definition at line 233 of file discretised_logit_hazard.stan.
real loglogistic_lcdf | ( | real | y, |
real | alpha, | ||
real | beta | ||
) |
Compute the log cumulative distribution function (LCDF) for a log-logistic distribution
Calculates the LCDF of a log-logistic distribution for a given value using specified scale and shape parameters.
y | The value at which to compute the LCDF. |
alpha | Scale parameter of the log-logistic distribution (alpha > 0). |
beta | Shape parameter of the log-logistic distribution (beta > 0). |
Definition at line 16 of file discretised_logit_hazard.stan.
vector lprob_to_uniform_double_censored_log_hazard | ( | vector | lprob, |
vector | lcdf, | ||
int | u | ||
) |
Compute discretised logit hazard.
Compute logit hazards from log probabilities.
Derives logit hazards from log probabilities of a delay LPMF, assuming double censoring and a uniform interval approximation for discretised delays.
lprob | Vector of log probabilities from the LPMF. |
lcdf | Vector of corresponding LCDF values for the LMPF. This could also be computed from lprob, but by re-using the precomputed LCDF from elsewhere we reduce overall computation. |
u | Upper bound of discretised LCDF. |
lcdf_to_uniform_double_censored_log_prob
and `normalise_lcdf_as_uniform_double_censored\[ \begin{align*} \text{Let } & h_d = \text{ hazard at delay } d, \\ & p_d = \text{ probability at delay } d, \\ & F_d = \text{ cumulative distribution function (cdf) evaluated at } d, \\ & 1 - F_d = \text{ complementary cumulative distribution function (ccdf) evaluated at } d. \\ \\ % Hazard definition h_d &= \frac{p_d}{1 - \sum_{i=0}^{d-1} p_i} \\ &= \frac{F_{d+1} - F_{d-1}}{1 - \sum_{i=0}^{d-1} (F_{i+1} - F_{i-1})} \\ &= \frac{F_{d+1} - F_{d-1}}{1 - (F_d + F_{d-1})} \\ &= \frac{F_{d+1} - F_{d-1}}{(1 - F_d) - F_{d-1}}. \\ \\ % Log transformation \log(h_d) &= \log(F_{d+1} - F_{d-1}) - \log((1 - F_d) - F_{d-1}). \end{align*} \]
Definition at line 195 of file discretised_logit_hazard.stan.
vector normalise_lcdf_as_uniform_double_censored | ( | vector | lcdf, |
int | u, | ||
int | max_strat | ||
) |
Normalise a discretised LCDF under double censoring
Adjusts LCDF values for the probability mass beyond the upper bound of the discretised LCDF, assuming double censoring and a uniform interval approximation. Different strategies are applied depending on max_strat
.
lcdf | Vector of LCDF values to be adjusted. |
u | Upper bound of the discretised LCDF. |
max_strat | Strategy for handling probability mass beyond upper bound. |
lcdf_discretised
. Definition at line 84 of file discretised_logit_hazard.stan.