epinowcast
Loading...
Searching...
No Matches
hazard.stan File Reference

Go to the source code of this file.

Functions

vector prob_to_hazard (vector p)
 
vector cumulative_converse_log_hazard (vector h, int l)
 
vector hazard_to_log_prob (vector h, int l)
 

Function Documentation

◆ cumulative_converse_log_hazard()

vector cumulative_converse_log_hazard ( vector  h,
int  l 
)

Compute the cumulative converse log hazard

Calculates the cumulative sum of the converse of log hazards. This function shifts the hazard vector by one time unit, applies the converse log transformation, and then computes the cumulative sum.

Parameters
hVector of hazards.
lLength of the vector.
Returns
Vector of cumulative converse log hazards.
Note
The cumulative converse log hazard is defined as:

\[ ch_i = \sum_{j=1}^{i} \log(1 - h_{j-1}) \]

where

\[ h_{0} \]

is considered to be 0.

Definition at line 44 of file hazard.stan.

◆ hazard_to_log_prob()

vector hazard_to_log_prob ( vector  h,
int  l 
)

Convert hazards to log probabilities

Transforms a vector of hazards into log probabilities. This function uses the hazards to compute the log probabilities for each time point. Internally it calls cumulative_converse_log_hazard to compute part of the log probability.

Parameters
hVector of hazards.
lLength of the vector.
Returns
Vector of log probabilities corresponding to the input hazards.
Note
The log probability at time i is defined as:

\[ p_i = \log(h_i) + \text{cumulative_converse_log_hazard}(h_i) \]

This function calls cumulative_converse_log_hazard for part of its computation.

Dependencies:

  • cumulative_converse_log_hazard

Definition at line 78 of file hazard.stan.

◆ prob_to_hazard()

vector prob_to_hazard ( vector  p)

Convert probabilities to hazards

Transforms a vector of probabilities into hazards. This function calculates the hazard for each time point based on the given probabilities.

Parameters
pVector of probabilities.
Returns
Vector of hazards corresponding to the input probabilities.
Note
The hazard at time i is defined as:

\[ h_i = \frac{p_i}{1 - \sum_{j=1}^{i-1} p_j} \]

The final hazard (h_l) is set to 1.

Definition at line 15 of file hazard.stan.