Functions & Formulae

Each applied formula has its own function page, with a signature, implementations, and tests.

Continuous-time transition probabilities and expected state occupancy from transition intensities

P(t) = exp(t * Q); d occ(t) / dt = occ(t) * Q

Maps a matrix of constant transition rates (intensities) between health states to the probability of being in each state after any interval, by the matrix exponential, and to the expected, optionally discounted, time spent in each state. A fixed-cycle Markov model approximates this continuous process; the exact interval probabilities show what the approximation should reproduce. The notation follows the Continuous Model article and its illness-death example.

  • Exact interval probabilities in a progressive illness-death model with constant rates

    p_WW = exp(-(q_WS + q_WD) * t); p_WS = q_WS / (q_SD - q_WS - q_WD) * (exp(-(q_WS + q_WD) * t) - exp(-q_SD * t)); p_WD = 1 - p_WW - p_WS

    Gives the closed-form matrix exponential for a three-state model in which Well people can fall Sick or die and Sick people can die, with no recovery. Staying Well depends on the total exit rate; being Sick at the end of the interval allows for people who fall Sick and then die within it; the remainder is death by either route. The single-rate conversion is HE-FM-TP-001 and the competing-risk split HE-FM-TP-004; neither includes the two-step path through Sick.

  • Expected undiscounted time in the Well and Sick states with constant rates

    L_W = 1 / (q_WS + q_WD); L_S = q_WS / (q_WS + q_WD) / q_SD; LE = L_W + L_S

    Gives life expectancy in a progressive illness-death model directly from the rates. A stay in a state with constant total exit rate lasts 1 over that rate on average (the mean sojourn time); the share of people leaving Well who go to Sick is q_WS over the total Well exit rate, and each spends on average 1 / q_SD in Sick. The sum is life expectancy, the value a cycle model of the same process should reproduce.

  • Continuous discount rate equivalent to an annual discount rate

    rho = log(1 + d); DF_t = exp(-rho * t)

    Converts an annual (discrete) discount rate d into the continuous rate rho that gives the same discount factor at every time, so that exp(minus rho t) equals (1 plus d) to the power minus t. Continuous-time models integrate costs and QALYs against exp(minus rho t), so rho, not d, belongs in the exponent.

  • Discounted QALYs in a progressive illness-death model with continuous discounting

    QALY_d = u_W / (q_WS + q_WD + rho) + u_S * q_WS / ((q_WS + q_WD + rho) * (q_SD + rho))

    Solves the article's integral of state utilities times state occupancy times exp(minus rho t) in closed form when rates are constant: discounting adds rho to every exit rate, so discounted time Well is 1 / (q_WS plus q_WD plus rho) and discounted time Sick is q_WS / (q_WS plus q_WD plus rho) / (q_SD plus rho). Weighting by utilities gives discounted QALYs; state costs in place of utilities give discounted costs.