CalibrationPlot

Author

Sarah Urbut

Published

February 17, 2024

Step 1: Preparing the Data

  1. Merge Predicted Risks with Actual Outcomes: For each model’s predictions (PCE, ASCVD, states), you’ll need to ensure that you have a way to align each prediction with the actual outcome for the same individual at the same age. This may require reshaping or merging data frames.

  2. Handling Censored Data in states Predictions: For individuals who have been censored at certain ages in the states data, you’ll need to decide on an approach. One common method is to exclude these individuals from the analysis for ages where they are censored since you don’t have predictions for them.

Step 2: Calculating Observed and Predicted Risks

For each age from 40 to 70, and for each model:

  • Calculate the mean predicted risk for that age.

  • Calculate the observed rate of Cad_Any == 2 within the individuals not censored at that age.

Step 3: Creating Calibration Plots

You can create calibration plots by following these steps for each model:

  1. Bin Predicted Risks: If your predictions span a continuous range, consider binning them into deciles or another suitable grouping. This step might be slightly different for the states data, depending on how risk is represented.

  2. Calculate Observed Rates by Bin: For each bin, calculate the observed frequency of the outcome (Cad_Any == 2).

  3. Plotting: Plot the mean predicted risk against the observed frequency for each bin. Repeat this for each age group or consider aggregating across age groups if appropriate.We have all of our predictions stored in a list


Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

Attaching package: 'data.table'
The following objects are masked from 'package:dplyr':

    between, first, last
[1] 78974    67
[1] TRUE
[1] TRUE
[1] TRUE
[1] 2206675       9
`summarise()` has grouped output by 'age'. You can override using the `.groups`
argument.

`summarise()` has grouped output by 'age'. You can override using the `.groups`
argument.