Why Use a Spline for the Baseline Time Pattern?
A survival MSM needs to represent how the event rate changes over follow-up, as well as how it depends on the treatment regime. A straight-line time term may be too restrictive: risk can rise, fall, or change curvature. A separate parameter for every time point or interval is more flexible, but can be unstable when events are sparse. A spline offers a middle ground: it uses a modest number of coefficients to describe a smooth, potentially nonlinear time pattern.
The earlier material on choosing the time scale addresses what time variable is being modeled. Here, take that time scale as chosen and focus on its functional form. The spline concerns the baseline part of the hazard or discrete-time event model. By itself, it does not make the treatment effect vary over time.
Model Forms and Their Interpretation
For a continuous-time proportional-hazards MSM, let \(A_i\) denote the regime or treatment contrast in the MSM, \(N_i(t)\) the event counting process, and \(Y_i(t)\) the at-risk indicator. One flexible-baseline model is
The baseline hazard is \(\lambda_0(t)=\exp\{B(t)^\top\gamma\}\). Its log is a spline, while the hazard itself is the exponential of that spline. Because the same baseline term appears for both treatment values, the model’s hazard ratio comparing \(A_i=1\) with \(A_i=0\) is \(\exp(\beta)\), constant over time. A spline baseline is not a time-varying treatment effect; that would require a treatment-by-time term, such as \(A_iB(t)^\top\delta\).
A weighted pooled logistic MSM for intervals \(k\) instead models the conditional event probability in an at-risk interval. With interval time \(t_k\), one form is
Here the spline describes the baseline log odds, not the continuous-time log hazard. The coefficient \(\beta\) gives a conditional odds ratio \(\exp(\beta)\), not in general a hazard ratio or risk ratio. The complementary log-log formulation has a different interpretation; the link should be chosen to match the intended model.
A common basis choice is a restricted cubic spline, which is cubic between knots and constrained to be linear beyond the boundary knots. Other valid choices include ordinary cubic splines and B-splines. The basis and knot locations determine the functions \(B_j(t)\); the coefficients \(\gamma\) are estimated from the weighted data. Knots should lie within the observed time support, and their number should be modest relative to the available event information. Boundary behavior matters: predictions far beyond observed follow-up depend strongly on the chosen spline constraints.
Worked Example: Reading a Cubic-Spline Baseline Hazard
Consider the valid cubic-spline basis \(B(t)=(1,t,t^2,t^3,(t-5)_+^3)^\top\), where \(x_+=\max(x,0)\), with time measured in years. Suppose the fitted coefficients are \(\gamma=(\log(0.02),0.03,-0.004,0.0002,-0.0004)^\top\). The model has a knot at year 5 and baseline hazard \(\lambda_0(t)=\exp\{B(t)^\top\gamma\}\).
At \(t=0\), all time terms are zero, so \(\log\lambda_0(0)=\log(0.02)\), giving \(\lambda_0(0)=0.0200\) per year.
At \(t=5\), the truncated term is zero. Thus \(\log\lambda_0(5)=\log(0.02)+0.15-0.10+0.025=-3.837\), and \(\lambda_0(5)=\exp(-3.837)\approx0.0216\) per year.
At \(t=10\), the terms beyond the intercept contribute \(0.30-0.40+0.20-0.05=0.05\), so \(\log\lambda_0(10)=-3.9120+0.05=-3.8620\). Therefore, \(\lambda_0(10)\approx0.0210\) per year. These are instantaneous hazard values, not probabilities of an event over a year.
If the fitted treatment coefficient is \(\beta=-0.4\), the model-implied hazard ratio is \(\exp(-0.4)\approx0.670\) at each of these times. The baseline can vary flexibly with time even though this treatment contrast is constant.
Worked Example: A Spline in a Pooled Logistic MSM
Let \(B(t)=(1,t/5,((t-5)_+/5)^2)^\top\), with \(t\) in years, and suppose the fitted logit model has coefficients \((-4,0.2,-0.05)^\top\) for the baseline spline and \(\beta=-0.3\) for treatment. This basis is a piecewise quadratic spline with a join at year 5.
For the reference regime \(A=0\), the linear predictors at years 0, 5, and 10 are respectively \(-4\), \(-4+0.2=-3.8\), and \(-4+0.4-0.05=-3.65\). Applying the logistic function \(p=\exp(\eta)/(1+\exp(\eta))\) gives interval event probabilities about \(0.0180\), \(0.0219\), and \(0.0253\).
For \(A=1\), subtract \(0.3\) from each linear predictor. The corresponding probabilities are approximately \(0.0134\), \(0.0163\), and \(0.0189\). The treatment odds ratio is \(\exp(-0.3)\approx0.741\) at every time, but the risk difference is not fixed: it is about \(-0.0046\) at year 0 and \(-0.0064\) at year 10. Thus the time-varying baseline changes the event probabilities even with a constant treatment odds ratio.
Weighted Fitting and a Score-Equation Result
In an MSM, weights create a pseudo-population in which the treatment histories have the target distribution under the assumptions supporting the weighting procedure. For pooled logistic fitting, the weighted log-likelihood contribution has the form
where the sum is over at-risk person-interval records, \(W_{ik}\geq0\) is the record’s weight, and \(X_{ik}\) includes the spline basis and treatment terms. This is a weighted estimating criterion, not generally an ordinary likelihood for independent observations. In continuous time, a spline baseline can likewise be fit in a weighted proportional-hazards model using the event and at-risk contributions. A spline baseline is not estimated by the usual Cox partial likelihood alone: that likelihood leaves the baseline unspecified. Estimating spline-baseline coefficients requires a full likelihood or an appropriate counting-process/Poisson likelihood formulation.
The condition behind the weighted pooled-logistic score is important. Correct specification of a conditional event probability in the unweighted population is not enough if weights depend on the outcome in ways not represented in the design. A precise sufficient condition is that the model is correctly specified in the weighted target distribution.
\(\displaystyle E_P[W X\{Y-p_{\theta_0}(X)\}]=E_P[W]E_Q[X\{Y-p_{\theta_0}(X)\}]\)
\(\displaystyle =E_P[W]E_Q\!\left[X\,E_Q\{Y-p_{\theta_0}(X)\mid X\}\right]=0.\)
The first equality is the definition of \(Q\); the second uses that \(X\) is measurable with respect to itself and the stated conditional mean under \(Q\). In a correctly specified pooled logistic MSM, \(X\) contains the spline basis and treatment terms, and this argument applies to the relevant weighted record distribution. It does not justify the same conclusion by conditioning under \(P\) when the weight depends on outcome information.
Two Consequences of the Model Form
\(\displaystyle \frac{\lambda(t\mid A=1)}{\lambda(t\mid A=0)} =\frac{\exp\{B(t)^\top\gamma+\beta\}}{\exp\{B(t)^\top\gamma\}} =\exp(\beta).\)
The common spline term cancels exactly. Consequently, a flexible baseline can repair misspecification of the shared time pattern, but cannot represent a treatment effect that changes over time. To allow that change, the model must include an interaction, for example \(\beta A+A B(t)^\top\delta\), and the resulting hazard ratio becomes \(\exp\{\beta+B(t)^\top\delta\}\).
For pooled logistic models the same cancellation gives a constant conditional odds ratio, not a constant risk ratio. In either model, interpretation depends on the link and the exact terms included. A plotted spline baseline is a description of the model’s time pattern, conditional on its specification; it is not proof that the chosen shape is correct.
Worked Example: Weighted Events and Sparse Information
Suppose one interval has four at-risk records with weights \(1,1,2,4\) and event indicators \(0,1,1,0\). In a model with only an interval-specific intercept, the weighted event total is \(1(0)+1(1)+2(1)+4(0)=3\), and the total weight at risk is \(1+1+2+4=8\). The weighted fitted event probability is therefore \(3/8=0.375\), with fitted log odds \(\log(3/5)\approx-0.511\). The unweighted event fraction is \(2/4=0.5\), illustrating that the weighted fit describes the weighted target rather than the raw record distribution.
The weight effective sample size for these records is \((\sum W_i)^2/\sum W_i^2=8^2/(1+1+4+16)=64/22\approx2.91\), smaller than the four observed records. If a spline has many coefficients but only this much effective information in a time region, its local shape will be unstable. Adding knots cannot create event information.
Choosing Knots, Checking Fit, and Comparing Alternatives
Choose the time basis before interpreting the fitted curve. Knot placement can be based on clinically meaningful times or quantiles of the event-time distribution, subject to adequate information near each knot. In weighted analyses, inspect the distribution of weighted events and weighted risk-set support, not only the raw sample size. Avoid placing several knots in a region with few events or very low effective sample size. The weighted example above illustrates why raw counts alone can be reassuring when the effective information is not.
Useful checks include plotting the estimated baseline log hazard or hazard over the observed support, checking whether the curve changes sharply at a knot, and comparing a modest alternative knot specification. For pooled logistic fits, examine fitted interval probabilities and look for implausible probabilities or abrupt changes between adjacent intervals. Also inspect whether influential weights are concentrated at particular times. Robust variance estimation addresses dependence and some uncertainty in weighted estimating equations, but it does not correct a badly specified spline or restore information lost to extreme weights.
A few alternatives clarify what the spline buys:
| Time specification | Advantage | Limitation |
|---|---|---|
| Linear time term | Simple, parsimonious, easy to interpret | Can force an unrealistic straight-line trend on the modeled scale |
| Separate indicators for intervals | Allows an unrestricted pattern across the chosen intervals | Uses many parameters and can be noisy with sparse weighted events |
| Spline basis | Captures smooth nonlinear patterns with fewer parameters than a fully saturated time model | Shape depends on basis, knot placement, and boundary behavior |
| Unspecified Cox baseline | Avoids specifying a parametric baseline shape for estimating treatment coefficients | Does not estimate spline-baseline coefficients; it is a different modeling choice |
No baseline-time specification solves every model problem. In particular, a common baseline spline does not address nonproportional treatment effects, incorrect treatment weights, positivity violations, or informative censoring that has not been handled by the analysis. Extrapolating beyond observed follow-up is especially fragile because the spline’s boundary behavior, rather than data, may dominate.
Common Mistakes
- Calling a spline baseline a time-varying treatment effect. With a common \(B(t)^\top\gamma\), the treatment hazard ratio or odds ratio remains constant. Add and assess a treatment-by-time term if the scientific model requires a changing contrast.
- Reading a logit-model probability as a hazard. The pooled logistic model specifies an interval probability; its spline is on the log-odds scale. It is not the continuous-time hazard.
- Using the ordinary Cox partial likelihood to estimate spline baseline coefficients. The standard partial likelihood does not parameterize the baseline hazard. Use a fitting approach that includes the spline baseline if those coefficients are to be estimated.
- Assuming a weighted score is unbiased merely because the unweighted outcome model is correct. The score condition must hold under the weighted target distribution, or an appropriate equivalent condition must be established. Weights depending on outcome information cannot simply be pulled outside a conditional expectation.
- Adding knots to fix sparse or unstable data. More flexibility may amplify noise, particularly where weighted risk-set support is low. Check support and weight concentration before interpreting local curvature.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- In a Cox MSM with \(\log\lambda(t\mid A)=B(t)^\top\gamma+\beta A\), what does \(\exp(\beta)\) represent, and what does the spline represent?
- Why does a spline in a pooled logistic model not directly specify the continuous-time hazard?
- State a sufficient weighted-distribution condition under which the expected weighted logistic score is zero.
- Four records have weights \(1,1,2,4\) and outcomes \(0,1,1,0\). What is their weighted event fraction and weight effective sample size?
- Name one way to allow a treatment effect to vary over time, and explain why adding baseline spline knots alone does not do this.
Solutions. (1) \(\exp(\beta)\) is the constant hazard ratio; \(B(t)^\top\gamma\) models the baseline log hazard pattern. (2) The pooled logistic link models conditional interval event odds; a hazard is a continuous-time rate, so the scales and links differ. (3) Define \(Q\) by \(dQ/dP=W/E_P[W]\), require \(0<E_P[W]<\infty\), and assume \(E_Q[Y\mid X]=p_{\theta_0}(X)\); then \(E_P[WX(Y-p_{\theta_0})]=E_P[W]E_Q[X(Y-p_{\theta_0})]=0\). (4) The weighted event fraction is \(3/8=0.375\), and effective sample size is \(64/22\approx2.91\). (5) Include a treatment-by-time spline term \(A B(t)^\top\delta\); baseline knots modify the common time pattern, which cancels in the treatment contrast.