{"data":{"slug":"github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-decision-curve-analysis-c14bdb0ff828","title":"Decision Curve Analysis for Binary Prediction Models","summary":"Evaluate clinical utility of binary prediction models with decision and clinical-impact curves from a CSV file containing sample IDs, a binary outcome column, and a numeric predictor column.","url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-decision-curve-analysis-c14bdb0ff828","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-decision-curve-analysis-c14bdb0ff828","markdown_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-decision-curve-analysis-c14bdb0ff828.md","download_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-decision-curve-analysis-c14bdb0ff828\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"Ensure the CSV file has a `.csv` extension, non-missing row names as unique sample IDs, and at least one binary outcome column (encoded as `0\/1`) and one numeric predictor column. The dataset must contain at least 20 rows, 5 positive outcomes, and 5 negative outcomes.","instructions":"---\nname: decision-curve-analysis\ndescription: \"Use when evaluating the clinical utility of a binary prediction model from a single clinical CSV file by fitting a logistic decision-curve model, plotting decision and clinical-impact curves, and exporting summary outputs. NOT for: survival calibration, ROC-only discrimination analysis, nomogram construction, or time-to-event outcomes.\"\nlicense: MIT\nskill-author: AIPOCH\n---\n\n# Decision Curve Analysis\n\n## When to Use\n\nUse this skill when you need to:\n- evaluate whether a binary prediction model adds clinical net benefit across threshold probabilities;\n- visualize decision curves and clinical-impact curves from a clinical cohort;\n- export an auditable DCA model object together with summary text and PDFs.\n\nTypical user requests:\n- \"Run decision-curve analysis on this binary outcome and risk-score dataset.\"\n- \"Generate DCA and clinical-impact plots for this prediction model.\"\n- \"Compare net benefit across thresholds for this case-control cohort.\"\n\n## When Not to Use\n\nDo not use this skill for:\n- time-to-event or survival outcomes;\n- ROC-only discrimination analysis without decision-curve outputs;\n- nomogram construction or calibration-curve analysis;\n- multiclass outcomes or non-binary endpoints.\n\n## When to Read External Files\n\n| Situation | File to Read | Purpose |\n|-----------|--------------|---------|\n| Need algorithm details | `references\/algorithm.md` | Statistical methods and formulas |\n| Need to run analysis | `scripts\/main.R` | Get the complete command |\n| Encounter errors | `references\/troubleshooting.md` | Find solutions |\n| Need CLI examples | `references\/cli-guide.md` | Parameter usage examples |\n\n---\n\n## Usage\n\n```bash\nRscript scripts\/main.R \\\n  --data_file .\/clinical_dca_data.csv \\\n  --outcome_col fustat \\\n  --predictor_col riskScore \\\n  --output_dir .\/output\/\n```\n\n---\n\n## Arguments\n\n| Short | Long | Type | Default | Description |\n|-------|------|------|---------|-------------|\n| `-d` | `--data_file` | character | **required** | Clinical CSV file with row names as sample IDs |\n|  | `--outcome_col` | character | `fustat` | Binary outcome column encoded as `0\/1` |\n|  | `--predictor_col` | character | `riskScore` | Numeric predictor column used in the logistic DCA model |\n|  | `--study_design` | character | `case-control` | Study design: `case-control` or `cohort` |\n|  | `--population_prevalence` | double | `0.3` | Population prevalence for case-control DCA (ignored for cohort design) |\n|  | `--threshold_by` | double | `0.01` | Threshold step size; values below 0.005 significantly increase computation time |\n|  | `--confidence_level` | double | `0.95` | Confidence level passed to `rmda::decision_curve()` |\n|  | `--population_size` | integer | `1000` | Population size used in the clinical-impact plot |\n|  | `--n_cost_benefits` | integer | `8` | Number of cost-benefit labels in the clinical-impact plot |\n|  | `--show_confidence_intervals` | flag | `FALSE` | Show confidence intervals on the decision curve |\n|  | `--standardize_net_benefit` | flag | `FALSE` | Report standardized net benefit (`sNB`) instead of raw net benefit (`NB`) |\n|  | `--decision_curve_color` | character | `#E64B35` | Decision-curve line color |\n|  | `--impact_colors` | character | `#E64B35,#4DBBD5` | Two comma-separated colors for the clinical-impact plot |\n|  | `--plot_width` | double | `6` | PDF width in inches |\n|  | `--plot_height` | double | `5.5` | PDF height in inches |\n|  | `--font_family` | character | `sans` | PDF font family |\n|  | `--plot_title` | character | `Decision Curve Analysis` | Decision-curve plot title |\n|  | `--base_cex` | double | `0.9` | Base text-size multiplier |\n| `-o` | `--output_dir` | character | `.\/output\/` | Output directory |\n|  | `--overwrite` | flag | `FALSE` | Allow writing into a non-empty output directory |\n| `-s` | `--seed` | integer | `42` | Random seed for reproducibility |\n| `-T` | `--timeout_seconds` | integer | `0` | Elapsed time limit in seconds; `0` disables timeout |\n\n---\n\n## Input Format\n\n### Clinical Data (`--data_file`)\n\nCSV file with row names as sample IDs. The dataset must contain at least one binary outcome column and one numeric predictor column.\n\n```csv\n,fustat,riskScore,FOXP3,CD45\nPatient_1,1,0.630147268229631,5.7783584300481,3.5407433709834\nPatient_2,0,0.23007730941193,6.70308857663772,3.11795942819676\nPatient_3,1,0.534809528754818,5.46860669585825,3.40086667402884\n```\n\n**Requirements**\n- File extension must be `.csv`.\n- Row names must be non-missing, unique sample IDs.\n- `outcome_col` and `predictor_col` must exist.\n- Outcome values must use `0\/1` encoding. Outcome values are coerced to numeric before validation; logical `TRUE`\/`FALSE` are converted to `1`\/`0`. Factor or character values will produce `SKILL_INVALID_PARAMETER`.\n- Predictor values must be finite numeric values.\n- At least 20 rows, 5 positive outcomes, and 5 negative outcomes are required.\n\n**Design note:** When `--study_design cohort` is selected, `--population_prevalence` has no statistical effect; the raw observed event rate is used instead. A warning is emitted if you set a non-default `population_prevalence` with cohort design.\n\n---\n\n## Output Files\n\n| File | Format | Description |\n|------|--------|-------------|\n| `data\/dca_model.rds` | RDS | Saved `rmda::decision_curve()` result object |\n| `table\/dca_summary.txt` | Plain text | Text summary of decision-curve net benefit statistics |\n| `plot\/decision_curve.pdf` | PDF | Decision-curve plot |\n| `plot\/clinical_impact_curve.pdf` | PDF | Clinical-impact plot |\n| `session_info.txt` | Plain text | Session information and run parameters |\n\n### `dca_summary.txt`\n\nSummary fields include:\n- threshold-specific net benefit statistics from `summary(dca_model)`;\n- the selected measure (`NB` or `sNB`);\n- the fitted formula and study-design context recorded in `session_info.txt`.\n\n---\n\n## Workflow\n\n### Step 1: Validate Input\n- Confirm the clinical CSV exists and is readable.\n- Check that the requested outcome and predictor columns are present.\n- Validate sample IDs, binary outcome coding, and numeric predictor values.\n- Emit warning if `population_prevalence` is non-default and `study_design` is `cohort`.\n\n### Step 2: Prepare Analysis Dataset\n- Keep only the outcome and predictor columns required for DCA.\n- Coerce outcome and predictor values to numeric.\n- Reject cohorts with too few rows or too few events\/non-events.\n\n### Step 3: Fit Decision-Curve Model\n- Fit a logistic decision-curve model with `rmda::decision_curve()`.\n- Build a threshold grid from `0` to `1` using `threshold_by`.\n- Apply `population_prevalence` when `study_design` is `case-control`.\n\n### Step 4: Save Outputs\n- Save the fitted DCA object as `.rds`.\n- Export the text summary as `.txt`.\n- Render the decision curve and clinical-impact curve as PDFs.\n- Record session metadata for reproducibility.\n\n---\n\n## Agent Response Contract\n\nAfter a successful run, report:\n\n1. **Study design and predictor** used (e.g., case-control, riskScore)\n2. **Net benefit metric** reported (NB or sNB)\n3. **Threshold range and step** used for the grid\n4. **Key finding**: net benefit at clinically relevant threshold(s) from `dca_summary.txt`\n5. **Artifact paths**: `plot\/decision_curve.pdf`, `plot\/clinical_impact_curve.pdf`, `data\/dca_model.rds`\n\n---\n\n## Examples\n\n### Basic Usage\n\n```bash\nRscript scripts\/main.R \\\n  --data_file clinical_dca_data.csv \\\n  --outcome_col fustat \\\n  --predictor_col riskScore \\\n  --output_dir .\/output\/\n```\n\n### Cohort Design With Custom Plotting\n\n```bash\nRscript scripts\/main.R \\\n  --data_file clinical_dca_data.csv \\\n  --study_design cohort \\\n  --outcome_col fustat \\\n  --predictor_col riskScore \\\n  --plot_title \"Cohort DCA\" \\\n  --decision_curve_color \"#3C5488\" \\\n  --impact_colors \"#3C5488,#00A087\" \\\n  --show_confidence_intervals \\\n  --output_dir .\/cohort_output\/\n```\n\n### With Bundled Test Data\n\n```bash\nRscript scripts\/main.R \\\n  --data_file tests\/data\/dca_data.csv \\\n  --outcome_col fustat \\\n  --predictor_col riskScore \\\n  --output_dir tests\/output\/ \\\n  --overwrite\n```\n\n---\n\n## Error Handling\n\n| Error | Cause | Solution |\n|-------|-------|----------|\n| `SKILL_INVALID_PARAMETER` | Invalid design, invalid numeric range, invalid outcome coding, insufficient rows\/class counts, or failed model fitting | Check arguments, data ranges, and binary outcome coding |\n| `SKILL_FILE_NOT_FOUND` | Input CSV does not exist | Verify the input path |\n| `SKILL_MISSING_COLUMNS` | Required columns are absent | Check `outcome_col` and `predictor_col` names |\n| `SKILL_EMPTY_DATA` | Input file is empty or contains no usable rows\/columns | Check the CSV content |\n| `SKILL_SAMPLE_MISMATCH` | Reserved for cross-file sample mismatch scenarios | Not expected for this single-file workflow |\n| `SKILL_PACKAGE_NOT_FOUND` | Required R package is missing | Install with: `Rscript -e \"install.packages('rmda', repos='https:\/\/cloud.r-project.org')\"` |\n\n**IF error persists**, READ: `references\/troubleshooting.md`\n\n---\n\n## Input Validation\n\nThis skill accepts: a single clinical CSV file with a binary outcome column (0\/1 encoded) and a numeric predictor column, for decision curve analysis of a binary prediction model.\n\nIf the user's request does not involve decision curve analysis of a binary prediction model \u2014 for example, asking to run survival analysis, build ROC curves only, construct a nomogram, or analyze multiclass outcomes \u2014 do not proceed with the workflow. Instead respond:\n\n> \"Decision Curve Analysis is designed to evaluate the clinical utility of binary prediction models by computing net benefit across decision thresholds. Your request appears to be outside this scope. Please provide a binary outcome dataset for DCA, or use a more appropriate tool for survival analysis, ROC analysis, or nomogram construction.\"\n\n---\n\n## Testing\n\n### Smoke Test With Included Data\n\n```bash\nRscript scripts\/main.R --help\n\nRscript scripts\/main.R \\\n  --data_file tests\/data\/dca_data.csv \\\n  --outcome_col fustat \\\n  --predictor_col riskScore \\\n  --output_dir tests\/output\/ \\\n  --overwrite\n```\n\n### Automated Smoke Test Script\n\n```bash\nRscript tests\/run_smoke_test.R\n```\n\nOptional shell wrapper:\n\n```bash\nbash tests\/run_smoke_test.sh\n```\n\n### Expected Output\n\n```text\ntests\/output\/\n|-- data\/dca_model.rds\n|-- plot\/clinical_impact_curve.pdf\n|-- plot\/decision_curve.pdf\n|-- session_info.txt\n`-- table\/dca_summary.txt\n```\n\n---\n\n## References\n\n1. Vickers AJ, Elkin EB. Decision curve analysis: a novel method for evaluating prediction models.\n2. rmda package documentation for clinical decision-curve analysis.\n\n**For detailed algorithm**, READ: `references\/algorithm.md`\n\n---\n\n## Implementation Checklist\n\n- [x] CLI parsing with `optparse`\n- [x] `set.seed()` for reproducibility\n- [x] Top-level CRAN dependency checks\n- [x] Session info recording\n- [x] Timeout parameter exposed as CLI option\n- [x] Relative-path `source()` usage via `get_script_dir()`\n- [x] Modular script structure in `scripts\/`\n- [x] Test data provided in `tests\/data\/`\n- [x] Error handling with `SKILL_*` codes\n- [x] Reference docs provided in `references\/`\n\n---\n\n*Last updated: 2026-04-27 | Version: 1.1.0*\n","use_cases":["Run decision-curve analysis on a binary outcome and risk-score dataset.","Generate DCA and clinical-impact plots for a prediction model.","Compare net benefit across thresholds for a case-control cohort."],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/aipoch\/medical-research-skills\/blob\/686e09dfdb45d9fa1a08664f06bb93769b3c9d91\/awesome-med-research-skills\/Data%20Analysis\/decision-curve-analysis\/SKILL.md","source_commit":"686e09dfdb45d9fa1a08664f06bb93769b3c9d91","license":"MIT","version":null,"listing_approved_at":"2026-11-24","created_at":"2026-11-23T06:58:58.000000Z","updated_at":"2026-11-24T07:13:04.000000Z","seo_title":"Decision Curve Analysis for Binary Models","seo_description":"Evaluate clinical utility of binary prediction models with decision and clinical-impact curves from a CSV file.","seo_keywords":["decision curve analysis","clinical utility evaluation","binary prediction model analysis","DCA plot generation","clinical-impact curve analysis"]}}