Tutorials › Competing Risks and Multi-State Models › Nonlinear Covariate Effects in Fine-Gray Models

Regression: Cause-Specific Cox and Fine-Gray · Tutorial 141 of 699

Nonlinear Covariate Effects in Fine-Gray Models

Use spline terms to model continuous predictors flexibly in Fine-Gray regression and test whether their subdistribution-hazard effects are nonlinear.

Advanced 11 min read

What You'll Learn

  • Specify a spline effect within a Fine-Gray proportional subdistribution-hazards model.
  • Separate the linear component from nonlinear spline components for testing.
  • Interpret a covariate contrast by evaluating the fitted spline at both values.
  • Conduct and report a joint Wald test of the nonlinear terms.
  • Check fit, support, proportionality, and sensitivity to spline choices.

Why Model a Nonlinear Effect?

A continuous predictor need not have a constant effect per unit. In a Fine-Gray model, imposing a single linear coefficient says that each one-unit increase multiplies the subdistribution hazard by the same factor, regardless of the starting value. That may be a poor description if the association bends, levels off, or changes more sharply over part of the predictor’s range.

Spline terms allow the fitted association to curve while retaining a regression model that can be evaluated at particular covariate values. The key is to interpret the resulting function as an effect on the subdistribution-hazard scale, not as a cause-specific hazard effect or as a direct change in event probability.

Fine-Gray Regression With a Spline

Definition: For a chosen event type \(k\), a Fine-Gray proportional subdistribution-hazards model with a continuous predictor \(x\) and other covariates \(z\) is $$ \tilde{\lambda}_k(t\mid x,z) = \tilde{\lambda}_{k0}(t) \exp\{f(x)+z^\mathsf{T}\beta\}. $$ Here \(\tilde{\lambda}_k\) is the subdistribution hazard for event type \(k\), \(\tilde{\lambda}_{k0}(t)\) is its baseline subdistribution hazard, and \(f(x)\) is the modeled covariate effect. A spline represents \(f(x)\) using a linear combination of specified basis functions.

For example, one can write \(f(x)=\beta_x x+\gamma_1B_1(x)+\cdots+\gamma_qB_q(x)\), where the \(B_j(x)\) are nonlinear spline basis functions. This parameterization has a linear component and \(q\) additional terms that allow curvature. In a restricted cubic spline with \(K\) knots, a common parameterization has one linear term and \(K-2\) nonlinear terms. The exact number of terms depends on the chosen spline basis and implementation.

The basis, knot locations, and any centering or scaling should be specified and kept fixed when comparing a linear model with a spline model. Knot choices are typically placed within the observed predictor range, often at prespecified quantiles. A spline should not be treated as a license to estimate a highly irregular curve: the number of terms must be supported by the available information, particularly the number of events of type \(k\).

The model also requires the usual Fine-Gray modeling conditions: the event type and competing events must be classified correctly; the censoring assumptions and weighting procedure used for Fine-Gray estimation must be appropriate; and proportional subdistribution hazards must be a reasonable assumption for the covariate effect. The earlier material on proportional subdistribution hazards and their diagnostics addresses that time-constancy assumption. A spline changes the shape of the covariate effect; it does not by itself fix a time-varying effect.

Contrasts and Tests of Nonlinearity

For two predictor values \(x_1\) and \(x_2\), holding other covariates fixed, the subdistribution-hazard ratio is obtained by subtracting the fitted linear predictors and exponentiating. The baseline subdistribution hazard cancels in this contrast.

$$ \frac{\tilde{\lambda}_k(t\mid x_2,z)} {\tilde{\lambda}_k(t\mid x_1,z)} = \exp\{f(x_2)-f(x_1)\}. $$

Unlike a linear model, a spline model generally has no single subdistribution-hazard ratio “per one-unit increase” that applies across the predictor range. Report a contrast between meaningful values, or show the fitted function relative to a stated reference value. When calculating uncertainty for a contrast, use the estimated covariance matrix of the fitted coefficients; uncertainty in the spline basis coefficients contributes to the interval.

To test whether the association is nonlinear, compare the spline model with its linear submodel. In the parameterization above, the null hypothesis is that all nonlinear coefficients are zero, while the linear coefficient and other covariate effects remain unrestricted:

$$ H_0:\gamma_1=\cdots=\gamma_q=0 \qquad\text{versus}\qquad H_a:\text{at least one }\gamma_j\ne 0. $$

A joint Wald test uses the estimated vector of nonlinear coefficients and its covariance matrix. Under \(H_0\), with the usual large-sample regularity conditions, the statistic is approximately chi-square with \(q\) degrees of freedom. The nonlinearity test is not the same as a test of whether the predictor is associated with the outcome at all: the linear component may be nonzero even when the nonlinear terms are not supported.

$$ W=\hat{\gamma}^{\mathsf T} \widehat{\operatorname{Var}}(\hat{\gamma})^{-1}\hat{\gamma} \ \overset{H_0}{\approx}\ \chi^2_q. $$

This test is meaningful only when the spline model contains the linear model as a nested submodel, with the same observations, adjustment variables, event definition, and censoring-weight setup. Use an inference procedure appropriate to the Fine-Gray estimator and its variance estimate. A weighted partial likelihood is not automatically an ordinary likelihood, so a difference in weighted log partial likelihoods should not be treated as a standard likelihood-ratio test without justification for that procedure.

Worked Example: Interpreting a Spline Contrast

Suppose a hypothetical Fine-Gray analysis models the subdistribution hazard of a particular event type using age in years. The fitted effect is \(f(x)=0.04x+0.30B_1(x)-0.20B_2(x)\). The basis values are \(B_1(50)=0.2\), \(B_2(50)=0.5\), \(B_1(60)=0.6\), and \(B_2(60)=0.3\). Calculate the contrast for age 60 versus age 50, holding the other covariates fixed.

First calculate the difference in fitted linear predictors. The age component changes by \(0.04(60-50)=0.40\). The two spline components change by \(0.30(0.6-0.2)=0.12\) and \(-0.20(0.3-0.5)=0.04\). Thus,

$$ f(60)-f(50)=0.40+0.12+0.04=0.56. $$

Exponentiating gives the subdistribution-hazard ratio:

$$ \exp(0.56)=1.751. $$

In this hypothetical fitted model, the subdistribution hazard at age 60 is estimated to be 1.751 times that at age 50, conditional on the other modeled covariates. This contrast does not say that the event probability is 75.1% higher, and it does not imply a constant ratio for every ten-year age difference.

Testing the Nonlinear Components

Worked Example: A Joint Wald Test for Curvature

In a hypothetical Fine-Gray model, age is represented by a linear term and two nonlinear spline terms. The estimated nonlinear coefficients are \(\hat{\gamma}_1=0.30\) and \(\hat{\gamma}_2=-0.20\). Suppose their estimated covariance matrix is diagonal, with variances \(0.01\) for each coefficient. Test for nonlinearity at \(\alpha=0.05\).

The hypotheses are \(H_0:\gamma_1=\gamma_2=0\) and \(H_a:\) at least one nonlinear coefficient differs from zero. With the stated diagonal covariance matrix, the joint Wald statistic is

$$ W= \frac{0.30^2}{0.01} + \frac{(-0.20)^2}{0.01} = 9+4=13. $$

There are \(q=2\) nonlinear terms, so the reference distribution is \(\chi^2_2\). The p-value is \(P(\chi^2_2\ge13)=\exp(-13/2)=0.00150\). Since \(0.00150<0.05\), reject the joint null hypothesis of no nonlinear terms. The data provide evidence against a purely linear age effect on the subdistribution-hazard scale under this fitted model. The test does not establish that the chosen spline shape is correct, nor does it quantify the effect at any particular age.

Checking the Fit and Choosing a Representation

Worked Example: A Nonlinearity Test That Is Not Significant

A hypothetical analysis of 420 participants estimates the subdistribution hazard of one event type. A linear age model is extended with two nonlinear spline terms, using the same covariates and censoring-weight procedure in both fits. The nonlinear coefficient estimates are \(0.22\) and \(-0.08\); their estimated variances are \(0.0121\) and \(0.0064\), and their covariance is zero. Calculate the joint Wald test and describe the conclusion at \(\alpha=0.05\).

The Wald statistic is

$$ W= \frac{0.22^2}{0.0121} + \frac{(-0.08)^2}{0.0064} = 4+1=5. $$

With two nonlinear terms, the reference distribution is \(\chi^2_2\), giving \(P(\chi^2_2\ge5)=\exp(-2.5)=0.0821\). Since \(0.0821>0.05\), this test does not reject the null of no nonlinear components. It is reasonable to consider the simpler linear representation, but the result does not prove that the true effect is exactly linear. The fitted curve, uncertainty, scientific context, and sensitivity to the spline specification still matter.

In practice, inspect the estimated effect across the observed range, with uncertainty, rather than relying on the p-value alone. Check whether the curve is driven by sparse observations near the extremes, whether there are enough events to support the number of spline terms, and whether modest changes to knot locations materially alter the fitted shape. Large swings in sparsely supported regions are a warning against strong interpretation there. Avoid extrapolating a curved spline beyond the range of the data.

A linear term is simpler and can be adequate when the relationship is approximately straight. A spline is more flexible and can reveal gradual curvature, but uses more degrees of freedom. Categorizing a continuous predictor is another possible approach, but it loses information within categories and makes results depend on arbitrary cut points. A cause-specific Cox model answers a different hazard question; a nonlinear effect on that scale need not match the nonlinear effect in a Fine-Gray model.

Deriving the Contrast and the Test

The contrast formula follows directly from the model. At \(x_2\), the subdistribution hazard is the baseline multiplied by \(\exp\{f(x_2)+z^\mathsf{T}\beta\}\); at \(x_1\), it is the same baseline multiplied by \(\exp\{f(x_1)+z^\mathsf{T}\beta\}\). Dividing cancels the baseline and the fixed covariate contribution, leaving \(\exp\{f(x_2)-f(x_1)\}\).

For the nonlinearity test, write the fitted nonlinear coefficient vector as \(\hat{\gamma}\). Under the null, its large-sample distribution is approximately multivariate normal with mean zero and covariance \(\widehat{\operatorname{Var}}(\hat{\gamma})\). Standardizing this vector by its covariance gives the quadratic form \(W\), which is approximately chi-square with one degree of freedom per independently estimated nonlinear term. This explains why the test is joint and why its degrees of freedom equal \(q\), not the total number of coefficients in the model.

Common Pitfalls and Limitations

  • Reporting one constant ratio for a curved effect. A single coefficient does not summarize all contrasts. Evaluate \(f(x)\) at both values and report the resulting contrast.
  • Testing each spline coefficient separately. Individual tests can miss joint evidence of curvature. Test all nonlinear terms together.
  • Confusing nonlinearity with time variation. A spline models how the effect varies with \(x\); it does not relax proportional subdistribution hazards over time.
  • Reading a nonsignificant test as proof of linearity. Limited information can leave substantial uncertainty. Consider the estimated curve and its interval as well as the test.
  • Overfitting or extrapolating. Too many terms can produce unstable curves, especially near the boundaries. Keep the basis modest and interpret within the observed support.
  • Interpreting a subdistribution-hazard ratio as a risk ratio. It is a relative subdistribution-hazard measure, not a direct percentage change in cumulative incidence.

Spline estimates also depend on basis and knot choices, and sparse data can make the shape weakly identified. A significant nonlinearity test is evidence against the specified linear restriction, not proof of a particular biological mechanism or causal relationship. Report the spline specification, the joint test, and interpretable fitted contrasts so that the modeling choices and their implications are clear.

Key takeaway: In Fine-Gray regression, spline terms model a potentially curved covariate effect on the subdistribution-hazard scale. Interpret contrasts by evaluating the fitted function at both covariate values, and test nonlinearity jointly by testing all nonlinear spline coefficients while retaining the linear component.

Check Your Understanding

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

  1. A spline model has one linear term and three nonlinear terms. What is the null hypothesis for the joint test of nonlinearity, and what are its degrees of freedom?
  2. For two covariate values, the fitted linear predictors differ by \(-0.25\). What is the estimated subdistribution-hazard ratio for the second value versus the first?
  3. A joint test gives \(W=6.0\) on two degrees of freedom. Using \(P(\chi^2_2\ge6)=0.0498\), what is the conclusion at \(\alpha=0.05\)?
  4. Why does adding a spline not address a violation of proportional subdistribution hazards?

Solutions. (1) The null sets all three nonlinear coefficients to zero while leaving the linear effect unrestricted; \(df=3\). (2) The ratio is \(\exp(-0.25)=0.7788\), so the second value has an estimated subdistribution hazard 0.7788 times that at the first, holding other covariates fixed. (3) Since \(0.0498<0.05\), reject the joint null and conclude there is evidence of nonlinearity under the fitted model. (4) The spline allows the effect to curve across covariate values, but proportional subdistribution hazards concerns whether the covariate effect changes over time. These are distinct features of the model.

Clinical Biostats