Tutorials › Marginal Structural Models › Model Selection For Q-Learning

Dynamic Treatment Regimes · Tutorial 423 of 501

Model Selection For Q-Learning

Compare Q-model specifications using stage-specific fit and treatment-effect structure, then assess the resulting decision rules with validation criteria.

Advanced 13 min read

What You'll Learn

  • Compare candidate Q-models separately at each treatment stage.
  • Derive Gaussian AIC- and BIC-style criteria for comparing regression specifications.
  • Explain why treatment-effect structure can matter more than overall prediction error.
  • Calculate and interpret a validation estimate of a rule's value.
  • Identify when fit criteria or validation comparisons are unreliable.

Why Q-Model Selection Needs More Than One Score

Q-learning estimates conditional mean outcomes backward through the treatment stages. At each stage, a candidate Q-model links the history and treatment to the relevant outcome or pseudo-outcome. The selected model therefore affects both fitted values and the treatment rule obtained by maximizing those values. A model that predicts outcomes well on average need not distinguish treatments well enough to produce a useful rule.

For two stages, write \(H_1\) for the first-stage history, \(A_1\) for the first treatment, \(H_2\) for the later history, \(A_2\) for the later treatment, and \(Y\) for the final outcome. The terminal-stage Q-function is \(Q_2(h_2,a_2)=E[Y\mid H_2=h_2,A_2=a_2]\). Its maximized value \( \max_{a_2}Q_2(H_2,a_2) \) is used as the stage-one pseudo-outcome. The stage-one Q-function models the conditional mean of that pseudo-outcome given \(H_1,A_1\). Thus, a change in the terminal-stage specification can change the response that is modeled at stage one.

Definition: A candidate Q-model specification is a proposed set of predictors, functional forms, and treatment-effect terms for a Q-function at a particular stage. A selection criterion is a stated rule for comparing candidate specifications, such as an information criterion, held-out prediction error, or estimated value of the induced treatment rule. These criteria target different properties and need not select the same model.

For a causal interpretation of a learned rule, the usual conditions include consistency, no interference between individuals, sequential exchangeability of each treatment given the measured history, and positivity: every treatment action allowed by the target regime must have positive probability at histories in the target population. Estimation and validation also require independent trajectories, or an appropriate method that accounts for their dependence. Model selection cannot repair a failure of these assumptions.

Compare Specifications Within Each Stage

Begin by defining a plausible candidate set separately for each stage. For example, the set might include a model with history main effects and a model that also allows a history-by-treatment interaction. Include scientifically motivated nonlinear terms when appropriate, but compare models using the same analysis observations and outcome definition. At the terminal stage, the modeled response is \(Y\); at an earlier stage it is a pseudo-outcome, not the original \(Y\).

When a candidate is a Gaussian linear regression with a common variance, an information criterion can summarize the trade-off between fit and the number of mean-model parameters. Let \(SSE\) be the residual sum of squares, \(n\) the number of observations used for that stage, and \(d\) the number of fitted mean parameters, including the intercept. Omitting terms common to all candidate models, the criteria are

$$ C_{\mathrm{AIC}}=n\log(SSE/n)+2d,\qquad C_{\mathrm{BIC}}=n\log(SSE/n)+d\log n. $$

The smaller score is preferred. To derive these expressions, the Gaussian log-likelihood at its maximum over the variance has a model-dependent part \(-\frac{n}{2}\log(SSE/n)\). Therefore \(-2\ell\), after dropping constants common to candidates, is \(n\log(SSE/n)\). Adding \(2d\) gives the AIC comparison and adding \(d\log n\) gives the BIC comparison. The variance parameter is also counted in the full likelihood, but its penalty is the same for every candidate here, so it cancels in the comparison.

Interpretation: These formulas compare Gaussian regression likelihoods for a given stage and response. They do not directly compare a stage-two model with a stage-one model, and a lower score is not a guarantee of a better treatment rule. AIC and BIC also rely on the likelihood being a reasonable description of the fitted data; their usual interpretations do not make them causal value estimators.

Worked Example: AIC and BIC for Two Terminal-Stage Models

Suppose two Gaussian linear models for the same terminal-stage response use \(n=80\) observations. The reduced model has \(d=2\) mean parameters and \(SSE=100\); the expanded model adds two parameters, so \(d=4\), and has \(SSE=80\). Compare their criteria.

For the reduced model, \(SSE/n=100/80=1.25\), and \(\log(1.25)=0.22314355\). Thus

AIC: \(80\log(1.25)+2(2)=17.851484+4=21.851484\), or \(21.85\) to two decimals.

BIC: \(80\log(1.25)+2\log(80)=17.851484+8.764053=26.615537\), or \(26.62\) to two decimals. Rounding the terms first to \(17.85\) and \(8.76\) would give \(26.61\), but that is not the correctly rounded total.

For the expanded model, \(SSE/n=1\), so its log-fit term is zero. Its AIC is \(2(4)=8\). Its BIC is \(4\log(80)=17.528107\), or \(17.53\). Both criteria favor the expanded model in this comparison. That conclusion concerns the specified Gaussian response fit; it does not establish that the added terms improve the induced regime.

Assess the Treatment-Effect Structure

For decision making, the contrast between treatment-specific Q-values is often more directly relevant than overall prediction error. In a binary-treatment model, the blip at history \(h\) is the difference between the fitted Q-value for treatment 1 and that for treatment 0. The estimated rule chooses treatment 1 where that contrast is positive, subject to the allowed action set. A candidate can fit the overall outcome well while imposing a constant blip that misses important variation across histories.

Worked Example: A Treatment Interaction Changes the Rule

Suppose the conditional mean outcomes in two history groups are as follows. Assume the groups are equally common in the target population.

History groupMean outcome if \(A=0\)Mean outcome if \(A=1\)Treatment 1 minus treatment 0
\(H=0\)10122
\(H=1\)85-3

A model allowing treatment effects to vary with \(H\) represents both contrasts: \(2\) for \(H=0\) and \(-3\) for \(H=1\). Its maximizing rule assigns treatment 1 for \(H=0\) and treatment 0 for \(H=1\).

A model with a common treatment effect, fitted to balanced groups, has pooled contrast \((2+(-3))/2=-0.5\). It therefore chooses treatment 0 in both groups. Using the given means, the interaction rule has expected outcome \((12+8)/2=10\). The common-effect rule has expected outcome \((10+8)/2=9\). The difference is \(10-9=1\) outcome unit per individual on average.

This calculation shows why candidate models should be compared for the treatment-effect structure they impose, not only for total residual error. In real data, the group means are estimated rather than known, so this calculation alone does not establish that the interaction rule has higher population value.

At stage two, inspect whether candidate treatment terms allow plausible effect modification by the available history. Then carry the selected terminal-stage model into the construction of the stage-one pseudo-outcome. Compare stage-one candidates on that resulting response, and remember that stage-one fit is conditional on the terminal-stage choices. A useful diagnostic is to check whether modest, scientifically plausible changes in the terminal-stage specification substantially alter the pseudo-outcomes or the earlier-stage treatment contrasts.

Validate the Induced Rule

If the main goal is choosing a treatment rule, a direct comparison should evaluate the rules rather than only their Q-model fits. A validation sample should be separate from the data used to select and fit the models. For a known treatment-assignment probability \(p(a\mid h)\), an inverse-probability estimate of a rule \(d\)'s value is

$$ \widehat V(d)=\frac{1}{n_{\mathrm{val}}}\sum_{i=1}^{n_{\mathrm{val}}} \frac{I\{A_i=d(H_i)\}Y_i}{p(A_i\mid H_i)}. $$

Here \(H_i\) denotes the history at the decision point for a single-stage illustration. With sequential treatments, the corresponding weight involves the probability of following the rule at every stage. The basic justification in the single-stage case is precise: if treatment is randomized with known \(p(a\mid h)>0\), then

$$ E\left[\frac{I\{A=d(H)\}Y}{p(A\mid H)}\middle|H\right] =\frac{p(d(H)\mid H)E[Y\mid H,A=d(H)]}{p(d(H)\mid H)} =E[Y^{d(H)}\mid H]. $$

The first equality uses the observed-data conditional mean, and the second uses randomization and consistency to identify it with the potential outcome mean under the assigned rule. Taking expectation over \(H\) gives \(E[\widehat V(d)]=V(d)\) for an independent validation sample. This argument requires a positive known assignment probability and finite expectations. For observational data, identifying the same value additionally requires consistency and conditional exchangeability, with correctly specified treatment probabilities or another valid identification and estimation strategy. The displayed estimator itself does not make those assumptions true. \(\square\)

Worked Example: Compare Two Rules on Randomized Validation Data

In a validation sample of \(n_{\mathrm{val}}=8\), treatment is randomized with probability \(1/2\) for each action. The records are:

History\(A\)\(Y\)
0112
0010
0111
009
115
108
116
109

Let \(d_{\mathrm{int}}\) treat when \(H=0\) and not treat when \(H=1\). Its matching observations have outcomes \(12,11,8,9\). Each receives weight \(1/(1/2)=2\), so

\(\widehat V(d_{\mathrm{int}})=2(12+11+8+9)/8=80/8=10.\)

Let \(d_0\) always choose treatment 0. Its matching outcomes are \(10,9,8,9\), giving

\(\widehat V(d_0)=2(10+9+8+9)/8=72/8=9.\)

The validation estimates favor \(d_{\mathrm{int}}\) by one unit in this sample. With only eight records, the comparison is imprecise; it is evidence to report with uncertainty, not proof of a population advantage.

Practical Comparisons, Diagnostics, and Limitations

A defensible selection analysis uses the criterion that matches the goal and checks whether conclusions are stable. Stage-specific residual diagnostics can reveal systematic lack of fit, influential observations, or a poor variance model. For treatment decisions, also inspect estimated treatment contrasts across clinically meaningful histories and whether the candidate rules differ in regions with adequate treatment support. If a rule depends on extrapolation into histories with little observed support, apparent gains may be artifacts of the model.

1
Specify candidates by stage.
State each candidate's history terms, treatment terms, and functional forms before comparing their scores.
2
Compare stage-specific fit.
Use likelihood-based criteria only for comparable responses and observations; inspect residual patterns as well as the score.
3
Inspect treatment contrasts.
Check whether added terms alter estimated blips and decisions in supported parts of the history space.
4
Validate the full decision procedure.
Fit the candidate models using training data, construct the regime, and evaluate its value on independent validation data using a valid design or evaluation method.

Information criteria are convenient for comparing regression specifications, but their target is likelihood fit with a complexity penalty. Cross-validation can estimate out-of-sample prediction error, but ordinary prediction error is still not regime value. Policy-value validation is more directly aligned with decision quality, but can be noisy, especially with small validation samples or low treatment probabilities. When several candidates are searched and the best validation result is reported, that same validation set no longer provides an untouched assessment; a separate test sample or an appropriately nested validation procedure is needed.

A further limitation is that the selected candidate is only the best among those considered. If all candidates omit an important feature, or if the treatment and history support is inadequate, selection cannot produce a reliable rule. Nor does a lower AIC or BIC prove that a model is correctly specified. These are model comparison tools, not substitutes for causal assumptions, scientific judgment, or uncertainty assessment.

Common pitfall: Choosing the Q-model with the smallest residual sum of squares and concluding that it must give the best treatment rule. The reasoning fails because residual fit weights errors across all predictions, while the rule depends on treatment contrasts and their signs. Compare treatment-effect structure and, when the goal is decision quality, validate the induced rule's value separately.

Check Your Understanding

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

  1. Two terminal-stage candidates use the same \(n\) observations and response. One has a lower \(SSE\) but more parameters. What does BIC compare?
  2. Why can a model with lower overall prediction error imply a worse treatment rule?
  3. For the randomized validation example, what is the estimated value of the rule that always chooses treatment 1?
  4. Name two reasons a validation estimate of rule value may be unreliable.

Solutions. (1) BIC compares \(n\log(SSE/n)+d\log n\), with smaller values preferred; the fit improvement must offset the additional complexity penalty. (2) Overall error need not reflect treatment contrasts: a model can predict outcomes well on average while misspecifying the contrast's magnitude or sign across histories. (3) The matching outcomes for always choosing treatment 1 are \(12,11,5,6\), so the estimate is \(2(12+11+5+6)/8=68/8=8.5\). (4) For example, a small validation sample gives high sampling variability, and low treatment probabilities create large weights; reuse of the validation data for selection also makes the reported best value optimistic.

Clinical Biostats