Tutorials › Competing Risks and Multi-State Models › Predicting Competing-Risk Probabilities with riskRegression

Software and Applied Examples · Tutorial 661 of 699

Predicting Competing-Risk Probabilities with riskRegression

Fit a Fine–Gray model in R and use predictRisk to estimate and interpret event-specific absolute risks at clinically chosen time horizons.

Intermediate 10 min read

What You'll Learn

  • Specify the event and censoring codes required for a Fine–Gray prediction.
  • Fit a proportional subdistribution hazards model with riskRegression::FGR.
  • Request cause-specific absolute risk predictions with predictRisk at selected times.
  • Interpret a predicted cumulative incidence in the presence of competing events.
  • Check the range, time ordering, and input coding of predictions.
  • Distinguish Fine–Gray risk predictions from cause-specific hazard predictions.

From a fitted model to an individual risk

A regression coefficient is not itself a patient’s probability of experiencing an event by a clinically meaningful time. For that, an analyst needs an estimate of the event-specific cumulative incidence function (CIF), evaluated at the patient’s covariate values and at a chosen horizon. In R, riskRegression::FGR fits a Fine–Gray model, and predictRisk turns that fit into absolute-risk predictions.

The model targets one event type at a time. For example, a model for relapse estimates the probability of relapse by one year while accounting for the fact that death before relapse prevents relapse from occurring. The prediction is not the probability of “relapse or death”; nor is it a cause-specific hazard.

Definition: For event type \(k\), the cumulative incidence function at time \(t\), conditional on covariates \(z\), is \(F_k(t\mid z)=P(T\leq t,\ J=k\mid z)\), where \(T\) is time to the first event and \(J\) identifies its type. It is the probability of having experienced event \(k\) by \(t\), before any competing event.

A Fine–Gray model specifies the subdistribution hazard for the chosen event type. The subdistribution risk set is constructed so that people who have already experienced a competing event remain represented in a weighted way; the model therefore connects covariates directly to the CIF. This differs from fitting a cause-specific Cox model, which models a cause-specific hazard and requires combining cause-specific hazard estimates to obtain a CIF.

Model: A proportional subdistribution hazards model for cause \(k\) has \(\tilde{\lambda}_k(t\mid z)=\tilde{\lambda}_{k0}(t)\exp(\beta^\mathsf{T}z)\), where \(\tilde{\lambda}_{k0}(t)\) is the baseline subdistribution hazard and \(\beta\) is the coefficient vector. Its CIF is \(F_k(t\mid z)=1-\exp\{-\tilde{\Lambda}_{k0}(t)\exp(\beta^\mathsf{T}z)\}\), with \(\tilde{\Lambda}_{k0}(t)\) the cumulative baseline subdistribution hazard.

The CIF formula follows from the definition of the subdistribution hazard: \(\tilde{\lambda}_k(t\mid z)=f_k(t\mid z)/\{1-F_k(t\mid z)\}\), where \(f_k\) is the corresponding event-specific density. Thus \(dF_k/(1-F_k)=\tilde{\lambda}_k\,dt\). Integrating from zero to \(t\) gives \(-\log\{1-F_k(t\mid z)\}=\tilde{\Lambda}_k(t\mid z)\); solving for \(F_k\) yields the displayed expression. Since \(\tilde{\Lambda}_k(t\mid z)=\tilde{\Lambda}_{k0}(t)\exp(\beta^\mathsf{T}z)\) under proportional subdistribution hazards, the model produces an absolute risk for each covariate profile.

Fit the model and request predictions

Suppose a data frame dat contains one row per patient, follow-up time ftime, event indicator status, age in decades above a reference age as age10, and treatment coded as 0 or 1. Here status is 0 for right censoring, 1 for the event of interest, and 2 for a competing event. The time and status must describe the same first-event follow-up for each person. A Fine–Gray fit for event 1 is:

$$ \texttt{fit <- riskRegression::FGR(}\\ \texttt{\ \ prodlim::Hist(ftime, status) \textasciitilde age10 + treatment,}\\ \texttt{\ \ data = dat, cause = 1)} $$

The line breaks above are for readability; in R, enter the call as a single expression or use ordinary R line breaks. Specify the event of interest with cause; do not recode competing events as censored observations before fitting. For new patients, supply the same covariates, with the same coding and units used in the fitted model:

$$ \texttt{newpatients <- data.frame(age10 = c(0, 0), treatment = c(0, 1))}\\ \texttt{risk <- riskRegression::predictRisk(}\\ \texttt{\ \ fit, newdata = newpatients, times = c(365, 1095), cause = 1)} $$

The requested horizons here are 365 and 1,095 days. The result is a matrix of predicted risks, with one row per new patient and one column per requested time. Index it by row and column position when extracting values, rather than relying on how a software version labels its columns. Each entry estimates the probability of event 1 by that time for the covariate profile in that row. It is a cumulative probability, not the probability of an event occurring exactly on that day.

Worked Example: Predicting Risk for Two Treatment Profiles

Consider a hypothetical fitted Fine–Gray model for event 1 with treatment as the only covariate. The estimated treatment coefficient is \(\hat{\beta}=-0.15\), and the fitted cumulative baseline subdistribution hazards are 0.12 at one year and 0.40 at three years. Patient A is untreated (\(z=0\)); patient B is treated (\(z=1\)). The model assumptions are proportional subdistribution hazards and independent censoring for this analysis; take those as working assumptions for this hypothetical fit.

For patient A, \(\exp(\hat{\beta}z)=\exp(0)=1\). At one year:

$$ \hat{F}_1(1\mid A)=1-\exp(-0.12\times 1)=0.1130796. $$

For patient B, \(\exp(\hat{\beta}z)=\exp(-0.15)=0.860708\). Substituting this factor gives:

$$ \hat{F}_1(1\mid B)=1-\exp\{-0.12\times\exp(-0.15)\} =1-\exp(-0.103285)=0.0981301. $$

The one-year predicted risk is about 11.31% for patient A and 9.813% for patient B. Their difference, calculated before rounding, is \(0.1130796-0.0981301=0.0149495\), or about 1.495 percentage points. This is a model-based contrast, not evidence that treatment causes a reduction in risk.

At three years, the corresponding calculations are:

$$ \hat{F}_1(3\mid A)=1-\exp(-0.40)=0.329680, \qquad \hat{F}_1(3\mid B)=1-\exp\{-0.40\times\exp(-0.15)\}=0.291272. $$

Thus the three-year risks are about 32.97% and 29.13%, respectively, and the unrounded difference is \(0.329680-0.291272=0.038408\), or about 3.841 percentage points. These calculations illustrate how a fitted Fine–Gray model maps its coefficient and baseline cumulative subdistribution hazard to absolute risk. In an actual analysis, use the fitted object and predictRisk; do not substitute an unrelated baseline estimate or coefficients from another fit.

Assumptions and a practical workflow

The prediction is meaningful only if the data and model support it. Before fitting, confirm that follow-up times are positive and correctly measured, status codes identify censoring and every event type consistently, and the cause supplied to FGR is the intended event. Check that each covariate in newdata has the same name, coding, scale, and factor levels as in the fitting data. A binary treatment coded 0/1 cannot be supplied as “control” and “active” text unless the fitted model used that factor coding.

The central model assumption is proportional subdistribution hazards: covariate effects on the subdistribution hazard are constant over follow-up time. The model also needs an adequate covariate specification, including appropriate functional forms and relevant interactions, and independent censoring under the assumptions of the fitting procedure. These assumptions do not follow from successful software execution. Use the earlier material on checking Fine–Gray fits with residuals and time interactions to investigate proportionality and model form. If important time variation remains, a single constant coefficient may give poor predictions at some horizons.

A concise workflow is:

  1. Verify the time, event, and censoring coding, and identify the event type to predict.
  2. Fit FGR using the analysis data and a formula that matches the intended covariate model.
  3. Construct new-patient rows using the exact covariate names, units, and coding from the fit.
  4. Call predictRisk at prespecified, clinically relevant time horizons, giving the target cause.
  5. Check the returned dimensions and values, then report the event, population profile, horizon, and risk together.

Worked Example: Reading Predictions at Two Horizons

Suppose a separate hypothetical model has a treatment coefficient \(\hat{\beta}=\log(0.8)\) and estimated baseline cumulative subdistribution hazards of 0.05 at six months and 0.25 at two years. The intended assumption is proportional subdistribution hazards, and assume censoring is independent for this illustration. For an untreated patient the covariate multiplier is 1; for a treated patient it is \(\exp\{\log(0.8)\}=0.8\).

For untreated patients, the six-month and two-year risks are:

$$ 1-\exp(-0.05)=0.0487706,\qquad 1-\exp(-0.25)=0.221199. $$

For treated patients, multiply each baseline cumulative hazard by 0.8 before applying the risk formula:

$$ 1-\exp(-0.05\times0.8)=1-\exp(-0.04)=0.0392106, $$
$$ 1-\exp(-0.25\times0.8)=1-\exp(-0.20)=0.181269. $$

A call to predictRisk with two new-patient rows and times = c(182, 730) would request these six-month and two-year predictions, if the time unit is days. The untreated risks are approximately 4.877% and 22.12%; the treated risks are approximately 3.921% and 18.13%. The coefficient corresponds to a subdistribution hazard ratio of 0.8, not a risk ratio of 0.8: the absolute risks do not equal 0.8 times the untreated risks.

Checks, alternatives, and limitations

After prediction, confirm that each value lies between 0 and 1. For the same patient and event, estimated CIFs should ordinarily be nondecreasing across increasing horizons; a decrease suggests a time-ordering, extraction, or software-use problem. Check that the requested horizons are expressed in the same units as the fitting times and lie within a follow-up range with adequate information. Predictions far beyond observed follow-up rely heavily on model extrapolation and should not be presented as equally well supported.

Also inspect event counts by cause, missingness, sparse covariate patterns, and whether the new-patient profiles are represented in the fitting data. A valid-looking number can still be unreliable if few people remain informative near that horizon, if a covariate pattern is outside the observed range, or if the proportionality assumption fails. Predictions are conditional on the fitted model and data; software does not establish causality, guarantee calibration, or account automatically for every source of uncertainty in the analysis.

Fine–Gray prediction is useful when the target is an event-specific absolute probability and a direct regression model for the CIF is appropriate. The main alternative in this context is to fit cause-specific Cox models for each event type and combine their estimated hazards to obtain a CIF. The two approaches parameterize covariate effects differently and need not produce identical predictions. Which is preferable depends on the scientific question, model adequacy, and prediction performance; comparing their predictions is a separate analysis.

A frequent mistake is to interpret \(1-\hat{F}_k(t)\) as the probability of remaining alive and event-free. The correction is that \(1-\hat{F}_k(t)\) is the probability of not yet having experienced event \(k\); it can include people who have already experienced a competing event. The probability of remaining free of every event is a different quantity. Likewise, a predicted event-specific CIF is not an individual guarantee or a causal treatment effect.

Key takeaway: Fit the Fine–Gray model for a clearly specified event type, preserve the competing-event coding, and use predictRisk with the intended cause and time units. Interpret each result as an estimated event-specific cumulative incidence for the supplied covariate profile by the stated horizon.

Worked Example: Extracting and Checking a Prediction Matrix

Suppose predictRisk is called for two hypothetical patients at 180 and 365 days. The fitted model assumes proportional subdistribution hazards and, for this illustration, has an estimated baseline cumulative subdistribution hazard of 0.10 at 180 days and 0.22 at 365 days. Patient 1 has reference covariate value \(z=0\); patient 2 has \(z=1\) and estimated coefficient \(\hat{\beta}=\log(1.5)\). The call is:

$$ \texttt{risk <- riskRegression::predictRisk(}\\ \texttt{\ \ fit, newdata = patients, times = c(180, 365), cause = 1)} $$

For patient 2, the covariate multiplier is \(\exp\{\log(1.5)\}=1.5\). The event-1 risks implied by the stated model quantities are:

$$ \hat{F}_1(180\mid z=1)=1-\exp(-0.10\times1.5)=0.139292, $$
$$ \hat{F}_1(365\mid z=1)=1-\exp(-0.22\times1.5) =1-\exp(-0.33)=0.281076. $$

The second patient’s prediction should therefore be about 0.1393 in the first time column and 0.2811 in the second, given these hypothetical fitted quantities. Both are between 0 and 1, and the later-horizon risk exceeds the earlier-horizon risk, as expected for a CIF. In a real call, verify the matrix dimensions before interpretation; for example, dim(risk) should show two rows and two time columns here. A prediction outside the unit interval, a decreasing risk over time, or a mismatch between row order and patient order calls for checking the input and extraction rather than silently reporting the result.

Check Your Understanding

Answer each question using the stated event and time units. Brief solutions follow the questions.

  1. If status is coded 0 for censoring, 1 for relapse, and 2 for death, what cause should be supplied to predict relapse risk?
  2. A fitted model has \(\tilde{\Lambda}_{10}(t)=0.20\), and a patient’s linear predictor multiplier is \(\exp(\hat{\beta}^\mathsf{T}z)=1.5\). Calculate the predicted event-1 CIF.
  3. Does a subdistribution hazard ratio of 0.8 imply that the CIF is 20% lower at every time? Explain.
  4. What does \(1-\hat{F}_1(t)\) represent when event 2 is a competing event?
  5. Name two checks to perform if a predicted CIF decreases between an earlier and a later requested time.

Solutions. (1) Supply cause = 1, because relapse is coded 1; death remains the competing event coded 2. (2) Substitute into the CIF formula: \(1-\exp(-0.20\times1.5)=1-\exp(-0.30)=0.2592\), or about 25.92% by \(t\). (3) No. The hazard ratio applies to the subdistribution hazard under the model, not directly to the CIF; the absolute risk contrast depends on the baseline cumulative subdistribution hazard and time. (4) It is the probability of not yet experiencing event 1 by \(t\); it includes people who may already have experienced event 2. (5) Check that time horizons are ordered and use the correct units, and verify the prediction matrix’s dimensions, patient-row order, and extraction. Also confirm the model and cause passed to predictRisk are the intended ones.

Clinical Biostats