关于使用survIDINRI包IDI.INF函数比较Cox回归模型性能的问题求助
IDI.INF from survIDINRI Package I’ve used the IDI.INF function to compare Cox model performance before, so I can share some common troubleshooting steps based on the issues I’ve run into:
Verify model input types and data consistency
The function requires both inputs to be validcoxphobjects fitted on the exact same dataset. If one model uses a different subset of data, or isn’t a standard Cox model (e.g., includes custom non-standard terms), you’ll likely get errors.- Quick checks: Run
class(model1)andclass(model2)to confirm both returncoxph, and comparedim(model1$data)anddim(model2$data)to ensure matching rows/columns.
- Quick checks: Run
Align outcome variable definitions
Both Cox models must use identical survival outcomes (time + event status), including the coding of events (e.g., if one model usesstatus=1for events and the other usesstatus=2, the function will fail to reconcile them).- Check: Compare
model1$yandmodel2$ydirectly to ensure their structure and values match perfectly.
- Check: Compare
Clean up missing/extreme values
Even if each model fits successfully, unhandled missing values or extreme outliers in the dataset can break the IDI/NRI calculation.- Fix: Preprocess your data with
na.omit()before fitting either model to ensure no missing values are carried through.
- Fix: Preprocess your data with
Double-check parameter syntax
The order of models and explicitdataparameter matter. For example, if you usedsubsetwhen fitting your Cox models, you must pass the full dataset toIDI.INFand ensure both models use the same subset logic.- Example of correct syntax:
IDI.INF(model_old, model_new, data = your_full_dataset)
- Example of correct syntax:
Update the survIDINRI package
Older versions of the package have known bugs with certain Cox model configurations (like models with interaction terms or splines). Update to the latest version first:install.packages("survIDINRI")
If you can share the specific error message and a snippet of your code, we can narrow this down further—but these steps resolve most common issues I’ve encountered with IDI.INF.
内容的提问来源于stack exchange,提问作者Triade




