Tutorials › Competing Risks and Multi-State Models › Diagnostics for Panel-Data Transition Models

Interval Censoring and Panel Data · Tutorial 529 of 699

Diagnostics for Panel-Data Transition Models

Use observed-versus-expected state-pair frequencies and residual patterns to assess whether a panel transition model describes the data adequately.

Advanced 12 min read

What You'll Learn

  • Define model-implied state-pair frequencies for observations separated by a specified visit gap.
  • Calculate Pearson residuals and a goodness-of-fit statistic from observed and expected counts.
  • Interpret residual patterns across origin states, destination states, and duration groups.
  • Distinguish evidence of duration dependence from differences caused by unequal visit gaps.
  • Recognize when sparse counts, estimated parameters, or repeated observations require simulation-based calibration.

Why Diagnose State-Pair Frequencies?

A transition model summarizes how the state observed at one visit relates to the state observed at a later visit. Its predictions are not just transition rates: for a specified visit gap and starting state, the model implies probabilities for every possible state at the next visit. Those probabilities can be compared with the state-pair frequencies actually observed in the panel.

This comparison is useful because a model can fit an overall summary while systematically missing particular transitions. For example, it may predict too few changes from a state after long periods in that state, or too many returns to an earlier state. Such patterns can flag misspecification, including a failure of the Markov assumption. They do not, on their own, establish which alternative model is correct.

Definition: For a group \(g\) of observed intervals with the same starting state and visit gap, let \(O_{ijg}\) be the number of intervals starting in state \(i\) and ending in state \(j\). If the fitted model implies conditional transition probability \(p_{ijg}\), the model-implied expected frequency is \(E_{ijg}=n_{ig}p_{ijg}\), where \(n_{ig}=\sum_j O_{ijg}\) is the number of intervals in that group. The Pearson residual is \(r_{ijg}=(O_{ijg}-E_{ijg})/\sqrt{E_{ijg}}\), provided \(E_{ijg}>0\).

The group must be defined so that the model assigns the same transition probabilities to its intervals, or so that the expected counts correctly average over their different visit gaps and covariates. In a continuous-time Markov model, for example, the relevant probability is an entry of the transition-probability matrix \(P(\Delta_g)=\exp(Q\Delta_g)\), where \(Q\) is the intensity matrix and \(\Delta_g\) is the gap between visits. In a discrete-time model, use the model-implied probability for the corresponding number of steps. A gap of two time units must not be treated as if it were a gap of one.

Constructing and Reading the Comparison

If intervals in a group are independent and share the same destination-probability vector under the model, the observed counts across destination states have a multinomial distribution, conditional on the group total. With dependent repeated intervals, the expected counts may still be computed from the probabilities when these are the intervals' marginal probabilities, but the multinomial reference distribution need not apply. If the model is correct and its probabilities are known, then \(E_{ijg}=n_{ig}p_{ijg}\). The expected counts in a row sum to that row's observed total, because \(\sum_j p_{ijg}=1\). Expected counts need not be whole numbers.

A Pearson goodness-of-fit statistic aggregates discrepancies across cells:

$$ X^2=\sum_g\sum_i\sum_j\frac{(O_{ijg}-E_{ijg})^2}{E_{ijg}}. $$

When the probabilities are fixed in advance, observations are independent, expected counts are adequate, and the tested cell probabilities have no additional constraints beyond each row summing to one, the reference chi-square degrees of freedom are the number of contributing cells minus the number of row totals minus any other independent constraints. For \(G\) groups, each with \(S\) possible destination states and a separate fixed probability vector, this is \(G(S-1)\), if all cells contribute. If parameters were estimated from the same intervals, that simple reference distribution may not apply: estimating parameters changes the statistic's sampling distribution, and the effect is not always handled by subtracting a parameter count in a small or complex panel data set.

The signed residuals help explain a statistic. A positive residual means more intervals than predicted in that cell; a negative residual means fewer. Large residuals identify where the model's discrepancy lies, while the overall statistic summarizes discrepancies across cells. Cells from the same row are dependent because the row total is fixed, so residuals should be read as a pattern rather than as independent tests. A few large cells can also dominate \(X^2\), making a table or plot of observed counts, expected counts, and residuals essential.

Worked Example: Expected Counts From a Two-State Model

Suppose a hypothetical two-state continuous-time Markov model has transition intensities \(q_{01}=0.20\) and \(q_{10}=0.10\) per year. Consider intervals with a two-year visit gap. The starting state and gap are treated as fixed for this calculation, and the intensities are taken as known rather than estimated from these observations.

For this model, the probability of being in state 0 after a gap \(\Delta\), starting in state 0, is \(p_{00}(\Delta)=\frac{q_{10}}{q_{01}+q_{10}}+\frac{q_{01}}{q_{01}+q_{10}}\exp[-(q_{01}+q_{10})\Delta]\). At \(\Delta=2\), \(\exp[-(0.20+0.10)2]=\exp(-0.6)\approx0.5488\), so \(p_{00}\approx(0.10/0.30)+(0.20/0.30)(0.5488)=0.6992\), and \(p_{01}=1-p_{00}=0.3008\). Starting in state 1, the rates are not symmetric, so its probabilities must be calculated separately. The correct calculation is \(p_{10}=\frac{q_{10}}{q_{01}+q_{10}}(1-\exp(-0.6))=0.1504\), and \(p_{11}=0.8496\). These row probabilities sum to one.

Suppose 100 hypothetical intervals begin in state 0 and 80 begin in state 1. The model-implied expected counts are \((69.92,30.08)\) for the first row and \((12.03,67.97)\) for the second row, using \(80(0.1504)=12.03\) and \(80(0.8496)=67.97\). This calculation illustrates why the destination probabilities must be calculated separately for each starting state; the two rows are not interchangeable.

If the hypothetical observed counts were \((72,28)\) and \((11,69)\), their discrepancies could be assessed by the Pearson formula. For the first row, the contribution is \((72-69.92)^2/69.92+(28-30.08)^2/30.08\approx0.062+0.144=0.206\). For the second, it is \((11-12.03)^2/12.03+(69-67.97)^2/67.97\approx0.088+0.016=0.104\). The total is \(X^2\approx0.310\). This is a small discrepancy, but a formal p-value would need a reference distribution appropriate to how the probabilities were obtained and whether intervals are independent.

A Short Justification for the Pearson Statistic

The Pearson statistic has a direct large-sample justification when probabilities are fixed and the data are independent across subjects. Within one row, the observed count \(O_j\) for destination state \(j\) has mean \(np_j\) and variance \(np_j(1-p_j)\). The binomial standardized discrepancy is \((O_j-np_j)/\sqrt{np_j(1-p_j)}\); the Pearson residual is \((O_j-np_j)/\sqrt{np_j}\). The destination counts are dependent because they sum to \(n\), and the multinomial covariance matrix has rank \(S-1\). Summing the squared Pearson residuals across the row therefore gives an asymptotic chi-square statistic with \(S-1\) degrees of freedom. Independent rows add their degrees of freedom. This approximation becomes unreliable when expected counts are small, probabilities are estimated in a complicated way, or subjects contribute dependent intervals.

A useful practical consequence is that the test statistic and residual display answer different questions. The statistic asks whether the aggregate discrepancy is larger than expected under the reference assumptions. The residuals show which transitions and groups contribute to it. Neither replaces checking whether the groups, visit gaps, and assumed sampling structure match the data collection process.

Worked Example: Testing for a Difference Across Duration Groups

In a hypothetical diagnostic exercise, two groups each contain 200 intervals that start in state A. The groups differ in the time already spent in A at the start of the interval: one is shorter-duration and the other longer-duration. For this illustration, both groups have the same visit gap and covariate profile. The destination is recorded as either remaining in A or being in state B at the next visit.

Duration groupEnds in AEnds in BTotal
Shorter duration14060200
Longer duration17030200
Total31090400

Under the null hypothesis that the two groups have a common destination probability, the pooled proportion ending in A is \(310/400=0.775\), and the pooled proportion ending in B is \(90/400=0.225\). Since each row has 200 intervals, the expected counts in each row are \(200(0.775)=155\) ending in A and \(200(0.225)=45\) ending in B. The expected table is therefore \((155,45)\) for both groups; its row totals are 200, and its column totals are 310 and 90.

The Pearson statistic is \(X^2=(140-155)^2/155+(60-45)^2/45+(170-155)^2/155+(30-45)^2/45\). Thus \(X^2=225/155+225/45+225/155+225/45\approx1.452+5.000+1.452+5.000=12.90\). With two rows and two destination categories, the degrees of freedom are \((2-1)(2-1)=1\), giving a p-value of approximately 0.00033 under the usual chi-square approximation. This is evidence against a common destination probability in this hypothetical comparison.

The direction is also informative: the longer-duration group has more intervals ending in A than expected and fewer ending in B. That pattern is consistent with a lower probability of leaving A among those who have already spent longer in A. It is not by itself proof of duration dependence. The interpretation depends on the groups having comparable visit gaps, covariates, and observation processes, and on the intervals being independent for this calculation.

Duration Patterns, Diagnostics, and Alternatives

A time-homogeneous Markov model in continuous time implies that, conditional on the current state, future transition probabilities depend on the length of the upcoming observation gap, not on how long the process has already occupied that state. A discrete-time Markov model has an analogous one-step property. If state-pair residuals repeatedly show too few departures after short occupancy and too many departures after long occupancy, or the reverse, this can suggest that transition behavior depends on time in state. A semi-Markov model, in which transition behavior may depend on duration in the current state, is one possible alternative to investigate; the residual pattern is a diagnostic clue, not a model-selection result.

The key comparison is conditional: compare intervals with similar starting states, visit gaps, and relevant covariates, while distinguishing their durations in the state at interval start. If longer-duration intervals also have longer gaps between visits, an apparent duration pattern may simply reflect the model's different predictions over those gaps. Calculate expected counts using the appropriate gap-specific probabilities, or define comparison groups with comparable gaps. When gaps vary within a group, calculate each interval's model-implied probabilities and sum them to obtain cell expectations rather than using one unrepresentative probability.

Other useful checks include plotting Pearson residuals against visit gap, calendar time, covariates, and duration in the starting state; checking whether particular origin-destination pairs are repeatedly over- or under-predicted; and comparing predicted and observed state-occupation frequencies. Occupation summaries can reveal broad calibration problems, but they may conceal offsetting errors among particular state pairs. Pair-frequency diagnostics are more local: they identify which observed transitions are not represented well.

These checks have limits. Panel observations reveal states at visits, not necessarily every transition between visits. An observed A-to-A pair does not prove that the process stayed in A throughout; it may have left and returned. The model-implied probability must account for all possible paths between the visits. Likewise, apparent misfit may arise from state misclassification, unmodeled covariate or subject heterogeneity, informative visit timing, or dependence among repeated intervals from the same person. Residuals can flag discrepancies without identifying their cause.

When model probabilities were estimated from the same panel data, treating them as fixed in a chi-square reference calculation can make a p-value inaccurate. A practical alternative is a parametric bootstrap: simulate panels under the fitted model using the observed visit schedule and relevant design features, refit the model to each simulated panel, and recompute the diagnostic statistic. The simulated statistic distribution reflects parameter estimation and the actual observation structure. A graphical residual check is still valuable because a single overall statistic can hide where the model fails.

Common pitfall: Do not divide a pooled expected count by the number of groups unless the target is an average per group. If two groups each contain 200 intervals and the pooled outcome proportions are 0.775 and 0.225, each group's expected counts are \(200(0.775)=155\) and \(200(0.225)=45\), not 77.5 and 22.5. Always verify that expected counts sum to the observed total in every row and preserve the pooled totals under the common-probability null.

How to Conduct the Diagnostic

1
Specify the comparison.
Define starting-state, visit-gap, duration, and covariate groups so the model probabilities are meaningful for each interval or group.
2
Calculate expected frequencies.
For each group, multiply its starting-state total by the model-implied destination probabilities, or sum interval-specific probabilities when schedules vary.
3
Inspect residuals and totals.
Check that expected counts sum to the corresponding group totals; examine signed residuals for repeated patterns and sparse cells.
4
Calibrate the overall evidence.
Use a chi-square approximation only when its independence, expected-count, and parameter assumptions are credible; otherwise consider simulation that repeats the fitting procedure.

Diagnostics matter because a transition model is used to summarize paths that are only partly observed. A model that misses systematic state-pair patterns may give misleading predictions even when its overall state proportions look reasonable. Conversely, a small residual pattern is not a guarantee of correctness: limited sample size can make important departures difficult to detect. Report the observed and expected frequencies, the residual pattern, the assumptions behind any test, and the uncertainty in the diagnostic conclusion.

Check Your Understanding

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

  1. A group has 120 intervals starting in state 1. The model gives destination probabilities 0.70 for state 1 and 0.30 for state 2. What are the expected counts?
  2. In a duration comparison, the shorter-duration group has 90 intervals and the longer-duration group has 110. If their visit gaps differ substantially, why is comparing raw departure proportions potentially misleading?
  3. A cell has observed count 18 and expected count 25. Calculate its Pearson residual and interpret its sign.
  4. Why does an observed A-to-A pair not necessarily imply that the process remained in A throughout the interval?

Solutions. (1) The expected counts are \(120(0.70)=84\) ending in state 1 and \(120(0.30)=36\) ending in state 2; they sum to 120. (2) The transition probability can vary with the gap, so different departure proportions may reflect unequal observation intervals rather than duration dependence. Use gap-specific model predictions or make a suitably adjusted comparison. (3) The Pearson residual is \((18-25)/\sqrt{25}=-7/5=-1.40\); the observed count is 1.40 expected-count standard deviations below its model-implied value, before considering dependence or multiple cells. (4) The process may leave A and return before the next visit. Only the endpoint states are observed, so the model must account for unobserved paths between visits.

Clinical Biostats