Tutorials › Competing Risks and Multi-State Models › Sparse Updates For Large Transition Systems

Transition Intensities and Probabilities · Tutorial 310 of 699

Sparse Updates For Large Transition Systems

Derive and apply sparse product-integral updates, assess their computational savings, and diagnose errors that can undermine the calculation.

Advanced 10 min read

What You'll Learn

  • Express an event-time transition update using transition counts and risk-set sizes.
  • Derive the column-wise sparse update from right multiplication by the increment matrix.
  • Calculate updates for one transition and for several transitions at the same time.
  • Compare sparse-update work with dense matrix multiplication as the state space grows.
  • Check row sums, nonnegativity, event order, and risk-set counts.
  • Recognize when a sparse update offers little computational advantage.

Why sparse updates matter

In a multi-state model with \(S\) states, a transition-probability matrix has \(S^2\) entries. Yet at a particular event time, only a small number of transitions may occur. The corresponding increment matrix is then mostly the identity: most entries do not change. Multiplying the entire probability matrix by that increment using a general dense-matrix routine can do far more arithmetic than the update requires.

The key is to exploit the structure of the event-time increment. Each observed transition moves probability mass from its origin-state column to its destination-state column. The update can therefore be calculated using only the affected columns, while preserving the event-time order of the product integral. This tutorial develops that calculation and shows when it is useful.

Event-time increments and their structure

Use states \(1,\ldots,S\), with rows denoting starting states and columns denoting states at the later time. Let \(P^-\) be the transition-probability matrix immediately before an event time \(u\). For a transition from state \(i\) to a different state \(j\), let \(dN_{ij}(u)\) be its count increment at \(u\), and let \(Y_i(u)\) be the number at risk in state \(i\) just before \(u\). The event-time transition increment has off-diagonal entries \(dN_{ij}(u)/Y_i(u)\), and its diagonal entries are minus the sum of the off-diagonal entries in the same row.

$$ \Delta A_{ij}(u)=\frac{dN_{ij}(u)}{Y_i(u)}\quad(i\ne j), \qquad \Delta A_{ii}(u)=-\sum_{j\ne i}\frac{dN_{ij}(u)}{Y_i(u)}. $$

The event-time update is a right multiplication: \(P^+=P^-(I+\Delta A(u))\), where \(P^+\) is the matrix immediately after \(u\). Thus, chronological event-time updates are applied in their correct matrix order. The earlier material on discrete event-time product integrals establishes this multiplication framework; here the focus is how to compute each multiplication efficiently.

Definition: A sparse update is an event-time matrix update that uses only the nonzero transition increments rather than computing every entry of a general dense matrix product. If \(q_{ij}=dN_{ij}(u)/Y_i(u)\), then the set of edges \(i\to j\) with \(q_{ij}>0\) identifies the transition contributions that need to be processed.

For valid event counts, each \(q_{ij}\) is nonnegative and the total outgoing increment for a source state is \(q_i=\sum_{j\ne i}q_{ij}\). With the risk set defined just before the event time, \(q_i\leq 1\): the total number leaving state \(i\) at that time cannot exceed the number at risk there. The increment matrix has row sums zero, so \(I+\Delta A(u)\) has row sums one. These conditions make the update a probability-matrix update, subject to the usual requirement that the input \(P^-\) is itself a valid probability matrix.

Deriving the sparse column update

Write \(P^-_{ab}\) for the entry in row \(a\), column \(b\). Applying the ordinary rule for matrix multiplication gives

$$ P^+_{ab} =P^-_{ab}+\sum_{i=1}^{S}P^-_{ai}\Delta A_{ib}(u). $$

If no transition increment enters or leaves column \(b\), every term \(\Delta A_{ib}(u)\) in this expression is zero, so that column is unchanged. For any column \(b\), the same expression can be written in terms of the observed transitions:

$$ P^+_{:,b} = P^-_{:,b} +\sum_{i\ne b}q_{ib}P^-_{:,i} -q_bP^-_{:,b}. $$

Here \(P_{:,b}\) denotes the whole \(b\)th column, and \(q_b=\sum_{j\ne b}q_{bj}\) is the total outgoing increment from state \(b\). The positive terms add probability mass arriving in \(b\); the negative term removes mass leaving \(b\). If a state is both a destination and a source at the same event time, both contributions apply to its column.

This formula must use the same pre-event matrix \(P^-\) for every transition increment at \(u\). Updating one tied transition in place and then using that partially changed matrix for another transition would instead impose an arbitrary within-time order. The event-time increment is a single matrix update, so its contributions are computed from the same \(P^-\).

Justification: Each transition \(i\to j\) contributes \(q_{ij}P^-_{:,i}\) to column \(j\), and the diagonal term for source \(i\) contributes \(-q_{ij}P^-_{:,i}\) to column \(i\). Summing those contributions over all transitions gives the column formula. Across all columns, each transition adds and subtracts the same vector, so every row sum is preserved.

Worked Example: One Sparse Transition

Suppose there are three states, and immediately before an event time the transition matrix is

$$ P^-= \begin{pmatrix} 0.60&0.30&0.10\\ 0.20&0.50&0.30\\ 0.10&0.20&0.70 \end{pmatrix}. $$

At the event time, two transitions from state 1 to state 2 are counted among 10 at risk in state 1. Assume there are no other transitions at that time. The increment is \(q_{12}=2/10=0.20\), so state 1 has outgoing increment \(q_1=0.20\). The only changed columns are columns 1 and 2:

$$ P^+_{:,1}=0.80P^-_{:,1} =\begin{pmatrix}0.48\\0.16\\0.08\end{pmatrix}, \qquad P^+_{:,2}=P^-_{:,2}+0.20P^-_{:,1} =\begin{pmatrix}0.42\\0.54\\0.22\end{pmatrix}. $$

Column 3 is unchanged. Therefore \(P^+=\begin{pmatrix}0.48&0.42&0.10\\0.16&0.54&0.30\\0.08&0.22&0.70\end{pmatrix}\). For example, row 2 still sums to \(0.16+0.54+0.30=1.00\). A dense calculation gives the same answer by multiplying \(P^-\) by a matrix whose first row is \((0.80,0.20,0)\) and whose other rows are unchanged identity rows.

Several transitions at the same event time

Sparse calculation is especially useful when a tied event time has multiple observed transitions but only a few active edges. Combine increments by source and destination, then update all affected columns from the same pre-event matrix. Risk-set sizes are evaluated immediately before the event time; counts for different source states use their corresponding risk sets.

Worked Example: Multiple Edges and an Affected Source Column

Suppose the pre-event matrix is

$$ P^-= \begin{pmatrix} 0.50&0.30&0.20\\ 0.20&0.50&0.30\\ 0.10&0.40&0.50 \end{pmatrix}, $$

and the event counts are two transitions \(1\to2\) and one \(1\to3\), with \(Y_1(u)=8\), plus one transition \(2\to3\), with \(Y_2(u)=5\). The increments are \(q_{12}=2/8=0.25\), \(q_{13}=1/8=0.125\), and \(q_{23}=1/5=0.20\). Thus \(q_1=0.375\) and \(q_2=0.20\). All three columns are affected: column 1 loses mass, column 2 both receives and loses mass, and column 3 receives mass.

$$ \begin{aligned} P^+_{:,1}&=(1-0.375)P^-_{:,1} =(0.3125,\;0.125,\;0.0625)^\mathsf{T},\\ P^+_{:,2}&=P^-_{:,2}+0.25P^-_{:,1}-0.20P^-_{:,2} =(0.365,\;0.450,\;0.345)^\mathsf{T},\\ P^+_{:,3}&=P^-_{:,3}+0.125P^-_{:,1}+0.20P^-_{:,2} =(0.3225,\;0.425,\;0.5925)^\mathsf{T}. \end{aligned} $$

For example, the first entry of column 3 is \(0.20+0.125(0.50)+0.20(0.30)=0.3225\). The updated rows each sum to one: \(0.3125+0.365+0.3225=1\), \(0.125+0.450+0.425=1\), and \(0.0625+0.345+0.5925=1\). The largest total outgoing increment is \(0.375\), so both source-state increments are at most one. The arithmetic uses only the three active edges and the pre-event columns; it does not apply the transitions sequentially to a changing matrix.

Computational cost and when sparsity helps

Let \(m\) be the number of nonzero off-diagonal transition increments at the event time, and let \(R\) be the set of source states with positive outgoing increments. A sparse implementation can process each edge by adding \(q_{ij}P^-_{:,i}\) to destination column \(j\), and process each source by subtracting \(q_iP^-_{:,i}\) from its own column. This requires work proportional to \(S(m+|R|)\), rather than recomputing all entries of a general matrix product, which takes order \(S^3\) arithmetic operations. Only columns in the set of sources and destinations need to be written. The probability matrix itself still has \(S^2\) entries if the full matrix is stored.

Worked Example: A Large State Space With Few Event Edges

Consider \(S=2{,}000\) states and an event time with four nonzero transition edges. A generic dense matrix multiplication uses on the order of \(S^3=8{,}000{,}000{,}000\) multiply-add terms. The sparse update instead forms four scaled columns, each of length 2,000, and applies source-column subtractions for at most four source states. That is on the order of \(2{,}000(4+4)=16{,}000\) vector-entry operations, plus small overhead for indexing and accumulation.

This comparison concerns the work for one event-time update, not the cost of storing or initializing the full matrix. It also compares sparse updates with a generic dense product: a matrix library that recognizes the identity-plus-sparse structure can already avoid much of the dense work. The practical gain depends on the implementation and how many edges are active, but the arithmetic difference can be substantial when \(m\) is small relative to \(S\).

Sparsity in the increment does not imply that the transition-probability matrix is sparse. The matrix \(P^-\) may be dense, and each active edge can affect an entire column of length \(S\). The savings come from processing only a few such columns and transitions, not from assuming that most entries of \(P^-\) are zero. If many edges are active, or if almost every state is both a source and destination, the sparse advantage shrinks; a well-optimized dense or sparse-matrix routine may be faster.

Checks, failure modes, and limitations

Useful checks are inexpensive and directly reflect the update formula. Before updating, verify that each source has a positive risk-set size whenever it has a positive transition count, and calculate \(q_i\) from all outgoing edges at that event time. Confirm that \(q_i\leq1\). After the update, check that row sums remain one up to numerical tolerance and that entries are nonnegative up to small rounding error. For a debugging run on a small matrix, compare the sparse result against the explicit product \(P^-(I+\Delta A)\).

A row-sum discrepancy can indicate a missing diagonal subtraction, an omitted destination contribution, or an incorrect event-time increment. A negative probability beyond tiny rounding error can indicate an invalid increment, an incorrectly constructed risk set, or an implementation that applied tied events sequentially. A mismatch with the dense calculation often points to using the wrong column as the source or destination, or to overwriting a column before all contributions based on \(P^-\) have been collected.

The sparse update is an arithmetic strategy, not a remedy for incorrect data or model construction. It relies on valid state coding, appropriate at-risk counts, and transition counts that correspond to the event time being processed. It also does not change the statistical interpretation of the product-integral estimate or provide uncertainty quantification. For an absorbing state with no outgoing transitions, \(q_i=0\); its column can still change if transitions from other states enter it. That distinction is easy to miss if affected columns are identified only by source states.

Common pitfall: It is tempting to process tied transitions one at a time, updating \(P\) after each edge and using the changed matrix for the next edge. That creates an order-dependent result within the same event time. Combine the event-time increments and calculate every contribution from the single pre-event matrix \(P^-\); then apply the resulting update once.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions below.

  1. If \(q_{12}=0.10\) and \(q_{13}=0.15\), what is the total outgoing increment from state 1, and which columns must be considered for changes from these edges?
  2. Why must tied transition contributions use the same pre-event matrix?
  3. If state 4 has no outgoing transitions at an event time but has incoming transitions, can column 4 change? Explain.
  4. For fixed \(S\), what feature of an event time determines whether sparse updates are likely to be advantageous?

Solutions. (1) \(q_1=0.10+0.15=0.25\). Column 1 loses mass and columns 2 and 3 receive mass, so columns 1, 2, and 3 are considered. (2) The event-time increment is one matrix update; using a partially updated matrix makes the result depend on an arbitrary ordering of tied transitions. (3) Yes. Incoming transitions add terms \(q_{i4}P^-_{:,i}\) to column 4, even though its outgoing increment is zero. (4) The number of nonzero transition edges and affected source and destination columns matters: few active edges relative to the state-space size favor sparse updates, while dense event-time increments reduce the advantage.

Clinical Biostats