How metodologianavarrabiomed/mice-ext-val works
This project is an R package designed to facilitate the external validation of predictive models—specifically Cox and logistic regression models—in the context of multiple imputation analysis. Its purpose is to provide a set of functions that define models (mv_model_cox and mv_model_logreg), calculate predictions (including two types of recalibration), compute performance metrics (like the Harrell’s C-index), and produce visualizations such as calibration plots and C-index forestplots.
Main Components
• Code Base and Package Structure:
• The DESCRIPTION, NAMESPACE, and other configuration files indicate it is a standard R package.
• Data Layer:
• The “data” directory holds example datasets (e.g., framingham.rda) used for demonstration or testing.
• Testing and Documentation:
• The “tests” directory contains unit tests (using testthat) that assure the validity of functions.
• The “docs” and “vignettes” directories contain documentation and guides (using pkgdown and Quarto) that explain usage and workflow.
• Model Workflow Components:
• Model Definition: Functions like mv_model_cox and mv_model_logreg.
• Prediction Calculation: Functions starting with calculate_predictions and “calculate_predictions_recalibrated_type_1”/“type_2”.
• Aggregation and Metric Calculation: e.g., calculate_c_index.
• Visualization: Functions like get_calibration_plot_data, get_calibration_plot, and get_c_index_forestplot.
• Supporting Files:
• Configuration (e.g., pkgdown.yml) and GitHub workflows to ensure continuous integration and documentation generation.
Out the Relationships and Data Flow
• Analysis Pipeline for Each Imputed Dataset:
• Model Application:
• Link each imputed dataset node to a “Results Analysis” node (each computed using a predict function).
• Aggregate these individual results into a unified “Aggregated Results” node.
• Post-Aggregation Actions:
▪ A “Calibration Plot” node (through get_calibration_plot_data and get_calibration_plot functions).
▪ A “C-index Forestplot” node (via get_c_index_forestplot).
• Support Infrastructure:
• A peripheral section indicating “Testing” with testthat and “Documentation” (docs, vignettes) as supportive pillars in the overall design.
Important Architectural Patterns
• Modularity: The package cleanly separates model definition, prediction calculation, performance metric aggregation, and visualization into distinct function groups.
• Reusability: Functions are designed to be chained using R’s native pipe operator (|>), showing a clear pipeline processing from raw imputed data through to final output.
• Extensibility: The presence of different prediction calculation methods and plotting functions indicates a design meant to be extended for additional statistical models or recalibration approaches.