Functions & Formulae

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

Memoryless transition property of a Markov state and the sojourn-time distribution it implies

Pr(X_(t+1) = j | X_t = i, H_t) = p_ij(t)

Maps the state a person occupies at cycle t, the cycle itself and the path H_t before it to the probability of each next state, under the restriction that the path adds nothing once the current state and cycle are known. With a constant probability p_ii of staying in state i the restriction makes the number of cycles spent in i on one visit geometric, and in continuous time a constant exit rate makes the time spent in i exponential, so in both cases the chance of leaving does not depend on the time already spent in the state. The package gives the geometric distribution of a stay with its median, the residual-stay identity behind memorylessness with a check of a survival curve for time since entry, the exponential residual stay and median, and the gap between the discrete and continuous mean stays at the same rate. Existing records are cited and not restated. The mean episode length 1 divided by 1 minus p_jj is HE-FM-MKCH-002, the cohort update is HE-FM-MM-001 with the trace totals of HE-FN-CSIM-001 and HE-FM-CSIM-001, rate and probability conversion is HE-FN-TP-001 with HE-FM-TP-001 to HE-FM-TP-004 and HE-CF-TP-001 and HE-CF-TP-002, exponential survival and the mean 1 divided by lambda are HE-FM-BTH-003 and HE-FM-CONT-002, the fundamental matrix is HE-FM-ABS-001 with its discounted form HE-FM-MKCH-001 and HE-CF-MKCH-001, the six-month root of an annual matrix is HE-FM-TMAT-001, and relaxing the assumption with tunnel states is HE-FN-TUN-001, HE-FM-TUN-001 to HE-FM-TUN-003 and HE-CF-TUN-001. Notation follows the Markov Assumption article.

  • Geometric distribution of cycles spent in a Markov state on one visit with a constant stay probability

    f_d = p_ii^(d - 1) * (1 - p_ii); G_d = p_ii^(d - 1); F_d = 1 - p_ii^d; d_star = log(0.5) / log(p_ii)

    Gives the probability that one visit to state i lasts exactly d cycles, at least d cycles or at most d cycles, counting the cycle of entry, when the probability of staying for another cycle is the same p_ii in every cycle of the stay. Each cycle acts as a trial in which the person leaves with probability 1 minus p_ii, so the stay ends at the first exit and its length has the geometric distribution of Grinstead and Snell. Its mean, 1 divided by 1 minus p_ii, is the mean episode length L_j of HE-FM-MKCH-002 and is not restated. The median is the smallest whole number of cycles at or above d_star, the first d at which F_d reaches one half; when d_star is itself a whole number F_d equals exactly one half there and that number is the median.

  • Memoryless residual stay and constant per-cycle exit probability of a geometric Markov sojourn

    R_ab = p_ii^(a + b) / p_ii^a; h_d = p_ii^(d - 1) * (1 - p_ii) / p_ii^(d - 1)

    Gives the probability that a stay already longer than a cycles lasts more than a + b cycles, and the probability of leaving in cycle d of the stay among those still in the state in that cycle. Neither depends on the time already spent, since R_ab equals p_ii to the power b whatever a is and h_d equals 1 minus p_ii at every d, which is the memoryless property that Grinstead and Snell derive for the geometric distribution. The first part is the conditional survival ratio of HE-FM-LTR-001 applied to the geometric stay, and the second divides f_d by G_d of HE-FM-MKA-001. Applied to a survival curve for time since entry, the same ratios test the assumption, since only a memoryless curve has the same per-cycle exit probability at every duration; HE-CF-MKA-001 carries out that check, and HE-FM-CUMH-002 gives the per-cycle probabilities of a fitted curve.

  • Exponential residual time and median sojourn in a Markov state with a constant exit rate

    S_res = exp(-lambda * (tau + s)) / exp(-lambda * tau); t_med = log(2) / lambda

    The continuous-time counterpart of HE-FM-MKA-002. With a constant total exit rate lambda the time spent in the state is exponential, with survival exp(minus lambda t) and mean 1 divided by lambda as in HE-FM-BTH-003 and HE-FM-CONT-002, which are not restated. S_res, the conditional survival ratio of HE-FM-LTR-001 applied to exponential survival, is the probability of staying a further time s after a time tau already spent, which equals exp(minus lambda s) whatever tau is, and t_med is the time by which half of all stays have ended. Grinstead and Snell state that the exponential is the only continuous density with the memoryless property, so in continuous time a constant exit rate and a stay that ignores time already spent go together. In a cycle model the stay probability is exp(minus lambda Delta), 1 minus the exit probability of HE-FM-TP-001, and t_med divided by Delta equals d_star of HE-FM-MKA-001.

  • Mean stay of a discrete-cycle Markov state against the exponential mean at the same constant exit rate

    p_ii = exp(-lambda * Delta); D_mean = Delta / (1 - p_ii); T_mean = 1 / lambda; gap_c = (D_mean - T_mean) / Delta

    Compares the mean stay in a cycle model whose stay probability comes from a constant exit rate with the mean time in the state of the continuous process it represents. Here p_ii is 1 minus the exit probability of HE-FM-TP-001, D_mean turns the mean cycles of HE-FM-MKCH-002 into time by multiplying by the cycle length, and T_mean is the exponential mean of HE-FM-CONT-002. The geometric count credits a whole cycle for the cycle of entry and for every cycle begun in the state, so D_mean exceeds T_mean, and the excess gap_c, in cycles, is above one half and below one, and approaches one half as lambda times Delta shrinks. This is the overestimate from counting membership at the start of each cycle that Sonnenberg and Beck describe, a matter of counting that a half-cycle correction addresses, not of memory.