├── .nojekyll
├── docs
├── .nojekyll
├── cover-snippet.PNG
├── chapters
│ └── fig
│ │ ├── Fig18.3-1.png
│ │ ├── Fig18.4-1.png
│ │ ├── Fig18.4-2.png
│ │ ├── Fig19.1-1.png
│ │ ├── Fig19.2-1.png
│ │ ├── Fig19.3-1.png
│ │ ├── Fig19.4-1.png
│ │ ├── Fig19.5-1.png
│ │ ├── Fig19.6-1.png
│ │ ├── Fig19.7-1.png
│ │ ├── Fig19.8-1.png
│ │ ├── Fig19.9-1.png
│ │ ├── Fig9.1-1.png
│ │ ├── Fig9.2-1.png
│ │ ├── Fig9.3-1.png
│ │ ├── Fig9.4-1.png
│ │ ├── Fig9.5-1.png
│ │ ├── Fig9.6-1.png
│ │ ├── Fig_5.2-1.png
│ │ ├── Fig_5.3-1.png
│ │ ├── Fig_5.4-1.png
│ │ ├── AAA.models-1.png
│ │ ├── AAA.models-2.png
│ │ ├── Fig 12.1-1.png
│ │ ├── Fig 12.1-2.png
│ │ ├── Fig 12.2-1.png
│ │ ├── Fig 12.2-2.png
│ │ ├── Fig 12.2-3.png
│ │ ├── Fig 12.2-4.png
│ │ ├── LDH.scores-1.png
│ │ ├── Scenarios-1.png
│ │ ├── Scenarios-2.png
│ │ ├── Scenarios-3.png
│ │ ├── Table 12.2-1.png
│ │ ├── nomogram-1.png
│ │ ├── post.size-1.png
│ │ ├── reduction-1.png
│ │ ├── scoreplot-1.png
│ │ ├── performance-1.png
│ │ ├── shrunk.model-1.png
│ │ ├── unnamed-chunk-1-1.png
│ │ ├── unnamed-chunk-1-2.png
│ │ ├── unnamed-chunk-1-3.png
│ │ ├── unnamed-chunk-1-4.png
│ │ ├── unnamed-chunk-1-5.png
│ │ ├── unnamed-chunk-1-6.png
│ │ ├── unnamed-chunk-1-7.png
│ │ ├── unnamed-chunk-1-8.png
│ │ ├── unnamed-chunk-2-1.png
│ │ ├── unnamed-chunk-2-2.png
│ │ ├── unnamed-chunk-2-3.png
│ │ ├── unnamed-chunk-2-4.png
│ │ ├── unnamed-chunk-2-5.png
│ │ ├── unnamed-chunk-2-6.png
│ │ ├── unnamed-chunk-2-7.png
│ │ ├── unnamed-chunk-2-8.png
│ │ ├── unnamed-chunk-2-9.png
│ │ ├── unnamed-chunk-3-1.png
│ │ ├── unnamed-chunk-4-1.png
│ │ ├── unnamed-chunk-6-1.png
│ │ ├── unnamed-chunk-7-1.png
│ │ ├── unnamed-chunk-2-10.png
│ │ ├── unnamed-chunk-2-11.png
│ │ ├── unnamed-chunk-2-12.png
│ │ ├── unnamed-chunk-2-13.png
│ │ ├── unnamed-chunk-2-14.png
│ │ └── unnamed-chunk-2-15.png
└── site_libs
│ ├── bootstrap
│ └── bootstrap-icons.woff
│ ├── kePrint-0.0.1
│ └── kePrint.js
│ ├── quarto-html
│ ├── tippy.css
│ ├── tabsets
│ │ └── tabsets.js
│ ├── quarto-syntax-highlighting-e1a5c8363afafaef2c763b6775fbf3ca.css
│ └── anchor.min.js
│ ├── quarto-nav
│ ├── headroom.min.js
│ └── quarto-nav.js
│ ├── lightable-0.0.1
│ └── lightable.css
│ └── clipboard
│ └── clipboard.min.js
├── cover-snippet.PNG
├── chapters
├── fig
│ ├── Fig18.3-1.png
│ ├── Fig18.4-1.png
│ ├── Fig18.4-2.png
│ ├── Fig19.1-1.png
│ ├── Fig19.2-1.png
│ ├── Fig19.3-1.png
│ ├── Fig19.4-1.png
│ ├── Fig19.5-1.png
│ ├── Fig19.6-1.png
│ ├── Fig19.7-1.png
│ ├── Fig19.8-1.png
│ ├── Fig19.9-1.png
│ ├── Fig9.1-1.png
│ ├── Fig9.2-1.png
│ ├── Fig9.3-1.png
│ ├── Fig9.4-1.png
│ ├── Fig9.5-1.png
│ ├── Fig9.6-1.png
│ ├── Fig_5.2-1.png
│ ├── Fig_5.3-1.png
│ ├── Fig_5.4-1.png
│ ├── AAA.models-1.png
│ ├── AAA.models-2.png
│ ├── Fig 12.1-1.png
│ ├── Fig 12.1-2.png
│ ├── Fig 12.2-1.png
│ ├── Fig 12.2-2.png
│ ├── Fig 12.2-3.png
│ ├── Fig 12.2-4.png
│ ├── LDH.scores-1.png
│ ├── Scenarios-1.png
│ ├── Scenarios-2.png
│ ├── Scenarios-3.png
│ ├── Table 12.2-1.png
│ ├── nomogram-1.png
│ ├── post.size-1.png
│ ├── reduction-1.png
│ ├── scoreplot-1.png
│ ├── performance-1.png
│ ├── shrunk.model-1.png
│ ├── unnamed-chunk-1-1.png
│ ├── unnamed-chunk-1-2.png
│ ├── unnamed-chunk-1-3.png
│ ├── unnamed-chunk-1-4.png
│ ├── unnamed-chunk-1-5.png
│ ├── unnamed-chunk-1-6.png
│ ├── unnamed-chunk-1-7.png
│ ├── unnamed-chunk-1-8.png
│ ├── unnamed-chunk-2-1.png
│ ├── unnamed-chunk-2-2.png
│ ├── unnamed-chunk-2-3.png
│ ├── unnamed-chunk-2-4.png
│ ├── unnamed-chunk-2-5.png
│ ├── unnamed-chunk-2-6.png
│ ├── unnamed-chunk-2-7.png
│ ├── unnamed-chunk-2-8.png
│ ├── unnamed-chunk-2-9.png
│ ├── unnamed-chunk-3-1.png
│ ├── unnamed-chunk-3-2.png
│ ├── unnamed-chunk-3-3.png
│ ├── unnamed-chunk-3-4.png
│ ├── unnamed-chunk-3-5.png
│ ├── unnamed-chunk-3-6.png
│ ├── unnamed-chunk-3-7.png
│ ├── unnamed-chunk-3-8.png
│ ├── unnamed-chunk-3-9.png
│ ├── unnamed-chunk-4-1.png
│ ├── unnamed-chunk-4-2.png
│ ├── unnamed-chunk-4-3.png
│ ├── unnamed-chunk-4-4.png
│ ├── unnamed-chunk-4-5.png
│ ├── unnamed-chunk-4-6.png
│ ├── unnamed-chunk-4-7.png
│ ├── unnamed-chunk-4-8.png
│ ├── unnamed-chunk-5-1.png
│ ├── unnamed-chunk-6-1.png
│ ├── unnamed-chunk-7-1.png
│ ├── unnamed-chunk-2-10.png
│ ├── unnamed-chunk-2-11.png
│ ├── unnamed-chunk-2-12.png
│ ├── unnamed-chunk-2-13.png
│ ├── unnamed-chunk-2-14.png
│ └── unnamed-chunk-2-15.png
├── 01-introduction.qmd
├── 11-main-effects-select.qmd
├── 20-updating.qmd
├── 03-design.qmd
├── 04-stat-mods.qmd
├── 13-modern-estimation.qmd
├── 17-validation.qmd
├── 15-evaluation-performance.qmd
├── 16-clinical-usefulness.qmd
├── 24-lessons-datasets.qmd
├── 21-updating-multiple.qmd
├── 22-case-study-gusto.qmd
├── 23-case-study-cardiovascular.qmd
├── 02-applications-pred-mods.qmd
├── 05-overfitting.qmd
├── 06-choosing-alt-mods.qmd
├── 08-case-study-missing.qmd
├── 12-additivity-linearity.qmd
├── 10-restrict-cand-pred.qmd
└── 19-external-validity.qmd
├── R
├── AUC.R
├── Brier 30sept19.R
├── ci.auc.R
├── HLtest.R
├── bootcor.uni.mult.R
├── auc.nonpara.mw.R
└── val.functions.17jan19.R
├── index.qmd
├── clin-pred-mods_bookdown.Rproj
├── README.md
├── _quarto.yml
└── data
├── Fmort.csv
├── AAA.csv
└── Gustos4Age.csv
/.nojekyll:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/.nojekyll:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/cover-snippet.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/cover-snippet.PNG
--------------------------------------------------------------------------------
/docs/cover-snippet.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/cover-snippet.PNG
--------------------------------------------------------------------------------
/chapters/fig/Fig18.3-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig18.3-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig18.4-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig18.4-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig18.4-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig18.4-2.png
--------------------------------------------------------------------------------
/chapters/fig/Fig19.1-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig19.1-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig19.2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig19.2-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig19.3-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig19.3-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig19.4-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig19.4-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig19.5-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig19.5-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig19.6-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig19.6-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig19.7-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig19.7-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig19.8-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig19.8-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig19.9-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig19.9-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig9.1-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig9.1-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig9.2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig9.2-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig9.3-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig9.3-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig9.4-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig9.4-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig9.5-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig9.5-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig9.6-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig9.6-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig_5.2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig_5.2-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig_5.3-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig_5.3-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig_5.4-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig_5.4-1.png
--------------------------------------------------------------------------------
/chapters/fig/AAA.models-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/AAA.models-1.png
--------------------------------------------------------------------------------
/chapters/fig/AAA.models-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/AAA.models-2.png
--------------------------------------------------------------------------------
/chapters/fig/Fig 12.1-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig 12.1-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig 12.1-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig 12.1-2.png
--------------------------------------------------------------------------------
/chapters/fig/Fig 12.2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig 12.2-1.png
--------------------------------------------------------------------------------
/chapters/fig/Fig 12.2-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig 12.2-2.png
--------------------------------------------------------------------------------
/chapters/fig/Fig 12.2-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig 12.2-3.png
--------------------------------------------------------------------------------
/chapters/fig/Fig 12.2-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Fig 12.2-4.png
--------------------------------------------------------------------------------
/chapters/fig/LDH.scores-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/LDH.scores-1.png
--------------------------------------------------------------------------------
/chapters/fig/Scenarios-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Scenarios-1.png
--------------------------------------------------------------------------------
/chapters/fig/Scenarios-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Scenarios-2.png
--------------------------------------------------------------------------------
/chapters/fig/Scenarios-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Scenarios-3.png
--------------------------------------------------------------------------------
/chapters/fig/Table 12.2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/Table 12.2-1.png
--------------------------------------------------------------------------------
/chapters/fig/nomogram-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/nomogram-1.png
--------------------------------------------------------------------------------
/chapters/fig/post.size-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/post.size-1.png
--------------------------------------------------------------------------------
/chapters/fig/reduction-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/reduction-1.png
--------------------------------------------------------------------------------
/chapters/fig/scoreplot-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/scoreplot-1.png
--------------------------------------------------------------------------------
/chapters/fig/performance-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/performance-1.png
--------------------------------------------------------------------------------
/chapters/fig/shrunk.model-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/shrunk.model-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig18.3-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig18.3-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig18.4-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig18.4-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig18.4-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig18.4-2.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig19.1-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig19.1-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig19.2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig19.2-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig19.3-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig19.3-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig19.4-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig19.4-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig19.5-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig19.5-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig19.6-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig19.6-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig19.7-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig19.7-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig19.8-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig19.8-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig19.9-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig19.9-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig9.1-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig9.1-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig9.2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig9.2-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig9.3-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig9.3-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig9.4-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig9.4-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig9.5-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig9.5-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig9.6-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig9.6-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig_5.2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig_5.2-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig_5.3-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig_5.3-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig_5.4-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig_5.4-1.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-1-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-1-1.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-1-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-1-2.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-1-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-1-3.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-1-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-1-4.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-1-5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-1-5.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-1-6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-1-6.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-1-7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-1-7.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-1-8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-1-8.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-2-1.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-2-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-2-2.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-2-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-2-3.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-2-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-2-4.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-2-5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-2-5.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-2-6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-2-6.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-2-7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-2-7.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-2-8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-2-8.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-2-9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-2-9.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-3-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-3-1.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-3-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-3-2.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-3-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-3-3.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-3-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-3-4.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-3-5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-3-5.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-3-6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-3-6.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-3-7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-3-7.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-3-8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-3-8.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-3-9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-3-9.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-4-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-4-1.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-4-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-4-2.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-4-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-4-3.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-4-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-4-4.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-4-5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-4-5.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-4-6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-4-6.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-4-7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-4-7.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-4-8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-4-8.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-5-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-5-1.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-6-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-6-1.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-7-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-7-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/AAA.models-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/AAA.models-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/AAA.models-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/AAA.models-2.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig 12.1-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig 12.1-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig 12.1-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig 12.1-2.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig 12.2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig 12.2-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig 12.2-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig 12.2-2.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig 12.2-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig 12.2-3.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Fig 12.2-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Fig 12.2-4.png
--------------------------------------------------------------------------------
/docs/chapters/fig/LDH.scores-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/LDH.scores-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Scenarios-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Scenarios-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Scenarios-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Scenarios-2.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Scenarios-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Scenarios-3.png
--------------------------------------------------------------------------------
/docs/chapters/fig/Table 12.2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/Table 12.2-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/nomogram-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/nomogram-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/post.size-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/post.size-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/reduction-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/reduction-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/scoreplot-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/scoreplot-1.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-2-10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-2-10.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-2-11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-2-11.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-2-12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-2-12.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-2-13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-2-13.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-2-14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-2-14.png
--------------------------------------------------------------------------------
/chapters/fig/unnamed-chunk-2-15.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/chapters/fig/unnamed-chunk-2-15.png
--------------------------------------------------------------------------------
/docs/chapters/fig/performance-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/performance-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/shrunk.model-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/shrunk.model-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-1-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-1-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-1-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-1-2.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-1-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-1-3.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-1-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-1-4.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-1-5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-1-5.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-1-6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-1-6.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-1-7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-1-7.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-1-8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-1-8.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-2-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-2-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-2-2.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-2-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-2-3.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-2-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-2-4.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-2-5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-2-5.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-2-6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-2-6.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-2-7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-2-7.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-2-8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-2-8.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-2-9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-2-9.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-3-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-3-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-4-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-4-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-6-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-6-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-7-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-7-1.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-2-10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-2-10.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-2-11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-2-11.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-2-12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-2-12.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-2-13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-2-13.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-2-14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-2-14.png
--------------------------------------------------------------------------------
/docs/chapters/fig/unnamed-chunk-2-15.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/chapters/fig/unnamed-chunk-2-15.png
--------------------------------------------------------------------------------
/docs/site_libs/bootstrap/bootstrap-icons.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clinical-prediction-models/supplementary-material/HEAD/docs/site_libs/bootstrap/bootstrap-icons.woff
--------------------------------------------------------------------------------
/R/AUC.R:
--------------------------------------------------------------------------------
1 | cat("AUC(xb.hat,y)", "\n")
2 |
3 | AUC <- function(xb.hat, y) {
4 | n <- length(xb.hat)
5 | n1 <- sum(y)
6 | mean.rank <- mean(rank(xb.hat)[y == 1])
7 | AUC <- (mean.rank - (n1 + 1) / 2) / (n - n1)
8 | return(AUC)
9 | }
10 |
--------------------------------------------------------------------------------
/index.qmd:
--------------------------------------------------------------------------------
1 | # Preface {.unnumbered}
2 |
3 | ***Work in progress***
4 |
5 | This bookdown-based website containing the supplementary materials from 'Clinical Prediction Models: A Practical Approach to Development, Validation, and Updating', by E. W. Steyerberg (2009).
6 |
7 |
--------------------------------------------------------------------------------
/chapters/01-introduction.qmd:
--------------------------------------------------------------------------------
1 | # Introduction {#introduction}
2 |
3 | ```{r setup-ch1, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 | ```
13 |
14 | Chapter 1 has no additional material.
15 |
--------------------------------------------------------------------------------
/chapters/11-main-effects-select.qmd:
--------------------------------------------------------------------------------
1 | # Selection of Main Effects {#selection}
2 |
3 | ```{r setup-ch11, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 | ```
13 |
14 | Chapter 11 materials upcoming.
15 |
--------------------------------------------------------------------------------
/chapters/20-updating.qmd:
--------------------------------------------------------------------------------
1 | # Updating for a New Setting {#updating}
2 |
3 | ```{r setup-ch20, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 | ```
13 |
14 | Chapter 20 additional material upcoming.
15 |
--------------------------------------------------------------------------------
/chapters/03-design.qmd:
--------------------------------------------------------------------------------
1 | # Study Design for Prediction Modeling {#design}
2 |
3 | ```{r setup-ch3, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 | ```
13 |
14 | Chapter 3 has no additional material.
15 |
--------------------------------------------------------------------------------
/chapters/04-stat-mods.qmd:
--------------------------------------------------------------------------------
1 | # Statistical Models for Prediction {#statmods}
2 |
3 | ```{r setup-ch4, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 | ```
13 |
14 | Chapter 4 has no additional material.
15 |
--------------------------------------------------------------------------------
/clin-pred-mods_bookdown.Rproj:
--------------------------------------------------------------------------------
1 | Version: 1.0
2 |
3 | RestoreWorkspace: Default
4 | SaveWorkspace: Default
5 | AlwaysSaveHistory: Default
6 |
7 | EnableCodeIndexing: Yes
8 | UseSpacesForTab: Yes
9 | NumSpacesForTab: 2
10 | Encoding: UTF-8
11 |
12 | RnwWeave: Sweave
13 | LaTeX: pdfLaTeX
14 |
15 | BuildType: Website
16 |
--------------------------------------------------------------------------------
/chapters/13-modern-estimation.qmd:
--------------------------------------------------------------------------------
1 | # Modern Estimation Methods {#estimation}
2 |
3 | ```{r setup-ch13, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 | ```
13 |
14 | Chapter 13 additional material upcoming.
15 |
--------------------------------------------------------------------------------
/chapters/17-validation.qmd:
--------------------------------------------------------------------------------
1 | # Validation of Prediction Models {#validation}
2 |
3 | ```{r setup-ch17, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 | ```
13 |
14 | Chapter 17 additional material upcoming.
15 |
--------------------------------------------------------------------------------
/chapters/15-evaluation-performance.qmd:
--------------------------------------------------------------------------------
1 | # Evaluation of Performance {#evaluation}
2 |
3 | ```{r setup-ch15, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 | ```
13 |
14 | Chapter 15 additional material upcoming.
15 |
--------------------------------------------------------------------------------
/chapters/16-clinical-usefulness.qmd:
--------------------------------------------------------------------------------
1 | # Evaluation of Clinical Usefulness {#usefulness}
2 |
3 | ```{r setup-ch16, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 | ```
13 |
14 | Chapter 16 additional material upcoming.
15 |
--------------------------------------------------------------------------------
/chapters/24-lessons-datasets.qmd:
--------------------------------------------------------------------------------
1 | # Overall Lessons and Data Sets {#lessons-datasets}
2 |
3 | ```{r setup-ch24, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 | ```
13 |
14 | Chapter 24 additional material upcoming.
15 |
--------------------------------------------------------------------------------
/docs/site_libs/kePrint-0.0.1/kePrint.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function(){
2 | if (typeof $('[data-toggle="tooltip"]').tooltip === 'function') {
3 | $('[data-toggle="tooltip"]').tooltip();
4 | }
5 | if ($('[data-toggle="popover"]').popover === 'function') {
6 | $('[data-toggle="popover"]').popover();
7 | }
8 | });
9 |
--------------------------------------------------------------------------------
/chapters/21-updating-multiple.qmd:
--------------------------------------------------------------------------------
1 | # Updating for Multiple Settings {#updating-multiple}
2 |
3 | ```{r setup-ch21, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 | ```
13 |
14 | Chapter 21 additional material upcoming.
15 |
--------------------------------------------------------------------------------
/chapters/22-case-study-gusto.qmd:
--------------------------------------------------------------------------------
1 | # Case Study on a Prediction of 30-Day Mortality {#case-study-gusto}
2 |
3 | ```{r setup-ch22, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 | ```
13 |
14 | Chapter 22 additional material upcoming.
15 |
--------------------------------------------------------------------------------
/chapters/23-case-study-cardiovascular.qmd:
--------------------------------------------------------------------------------
1 | # Case Study on Survival Analysis: Prediction of Cardiovascular Event {#case-study-cardiovascular}
2 |
3 | ```{r setup-ch23, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 | ```
13 |
14 | Chapter 23 additional material upcoming.
15 |
--------------------------------------------------------------------------------
/chapters/02-applications-pred-mods.qmd:
--------------------------------------------------------------------------------
1 | # Applications of Prediction Models {#applications}
2 |
3 | ```{r setup-ch2, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 | ```
13 |
14 | See [here](https://www.clinicalpredictionmodels.org/extra-material/chapter-2) for additional material.
15 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Supplementary materials
2 |
3 | ***Work in progress***
4 |
5 | This is a bookdown-based repository containing the supplementary materials from the Clinical Prediction Models book. It can be accessed at:
6 |
7 | https://clinical-prediction-models.github.io/supplementary-material/
8 |
9 | For further information and materials related to the book, refer to the update website:
10 |
11 | https://www.clinicalpredictionmodels.org/
12 |
13 |
--------------------------------------------------------------------------------
/R/Brier 30sept19.R:
--------------------------------------------------------------------------------
1 | # Dec 08, Ewout Steyerberg
2 | # function to calculate scaled Brier score
3 |
4 | Brier <- function(lp, y, digits = 3, pr = T) {
5 | B <- mean((y) * (1 - plogis(lp))^2 + (1 - y) * plogis(lp)^2)
6 | Bmax <- mean(y) * (1 - mean(y))^2 + (1 - mean(y)) * mean(y)^2
7 | Bscaled <- 1 - B / Bmax
8 | result <- c(B, Bmax, Bscaled)
9 | names(result) <- Cs(B, Bmax, Bscaled)
10 | if (pr) {
11 | print(result, digits = digits)
12 | }
13 | result
14 | }
15 |
--------------------------------------------------------------------------------
/R/ci.auc.R:
--------------------------------------------------------------------------------
1 | ci.auc <- function(crit, pred, conf.level = 0.95, method = "pepe") {
2 | tmp <- cbind.data.frame(crit = crit, pred = pred)
3 | # healthy
4 | nondis <- tmp[which(tmp$crit == 0), ]
5 |
6 | # disease
7 | dis <- tmp[which(tmp$crit == 1), ]
8 |
9 | # ci auc
10 | if (!grepl("bootstrap", method)) {
11 | result <- auc.nonpara.mw(dis$pred, nondis$pred, conf.level, method)
12 | } else if (grepl("bootstrap", method)) {
13 | cat("Bootstrap-based methods are not supported by this package. Method will be set to 'pepe'. \n\n")
14 | result <- auc.nonpara.mw(dis$pred, nondis$pred, conf.level, method = "pepe")
15 | }
16 |
17 | return(result)
18 | }
19 |
--------------------------------------------------------------------------------
/docs/site_libs/quarto-html/tippy.css:
--------------------------------------------------------------------------------
1 | .tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[data-tippy-root]{max-width:calc(100vw - 10px)}.tippy-box{position:relative;background-color:#333;color:#fff;border-radius:4px;font-size:14px;line-height:1.4;white-space:normal;outline:0;transition-property:transform,visibility,opacity}.tippy-box[data-placement^=top]>.tippy-arrow{bottom:0}.tippy-box[data-placement^=top]>.tippy-arrow:before{bottom:-7px;left:0;border-width:8px 8px 0;border-top-color:initial;transform-origin:center top}.tippy-box[data-placement^=bottom]>.tippy-arrow{top:0}.tippy-box[data-placement^=bottom]>.tippy-arrow:before{top:-7px;left:0;border-width:0 8px 8px;border-bottom-color:initial;transform-origin:center bottom}.tippy-box[data-placement^=left]>.tippy-arrow{right:0}.tippy-box[data-placement^=left]>.tippy-arrow:before{border-width:8px 0 8px 8px;border-left-color:initial;right:-7px;transform-origin:center left}.tippy-box[data-placement^=right]>.tippy-arrow{left:0}.tippy-box[data-placement^=right]>.tippy-arrow:before{left:-7px;border-width:8px 8px 8px 0;border-right-color:initial;transform-origin:center right}.tippy-box[data-inertia][data-state=visible]{transition-timing-function:cubic-bezier(.54,1.5,.38,1.11)}.tippy-arrow{width:16px;height:16px;color:#333}.tippy-arrow:before{content:"";position:absolute;border-color:transparent;border-style:solid}.tippy-content{position:relative;padding:5px 9px;z-index:1}
--------------------------------------------------------------------------------
/R/HLtest.R:
--------------------------------------------------------------------------------
1 | # 26-4-00, Yvonne Vergouwe
2 | # Jan 07, Ewout Steyerberg
3 | # function to perform Hosmer-Lemeshow test for external validation
4 | # instead of chi square and corresponding p-value, this function provides the number of subjects per group,
5 | # and the mean values of p and y per group.
6 | ##########################
7 | # p : predicted probability
8 | # Y : outcome variable
9 | # g : number of groups to calculate H-L (10 is default)
10 | #
11 | # NB: the library Hmisc need to be attached in order to be able to run hl.ext2
12 | ##########################
13 |
14 | hl.ext2 <- function(p, y, g = 10, df = g - 1) {
15 | matres <- matrix(NA, nrow = g, ncol = 5)
16 | sor <- order(p)
17 | p <- p[sor]
18 | y <- y[sor]
19 | group <- cut2(p, g = g) # g more or less equal sized groups
20 |
21 | len <- tapply(y, group, length) # n per group
22 | sump <- tapply(p, group, sum) # expected per group
23 | sumy <- tapply(y, group, sum) # observed per group
24 | meanp <- tapply(p, group, mean) # mean probability per group
25 | meany <- tapply(y, group, mean) # mean observed per group
26 | matres <- cbind(len, meanp, meany, sump, sumy)
27 | contr <- ((sumy - sump)^2) / (len * meanp * (1 - meanp)) # contribution per group to chi square
28 | chisqr <- sum(contr) # chi square total
29 | pval <- 1 - pchisq(chisqr, df) # p-value corresponding to chi square with df degrees of freedom
30 | cat("\nChi-square", chisqr, " p-value", pval, "\n")
31 | dimnames(matres) <- list(c(1:g), Cs(n, avg(p), avg(y), Nexp, Nobs))
32 | result <- list(table(group), matres, chisqr, pval)
33 | }
34 |
35 | # function for winsorizing
36 | winsorize <- function(x, lower = quantile(x, probs = 0.01), higher = quantile(x, probs = 0.99)) {
37 | ifelse(x < lower, lower,
38 | ifelse(x > higher, higher, x)
39 | )
40 | }
41 |
--------------------------------------------------------------------------------
/_quarto.yml:
--------------------------------------------------------------------------------
1 | project:
2 | type: book
3 | output-dir: docs
4 | execute-dir: project
5 |
6 | book:
7 | title: "Clinical Prediction Models"
8 | subtitle: ""
9 | author: "Ewout Steyerberg"
10 | date: last-modified
11 | sidebar:
12 | logo: cover-snippet.PNG
13 | title: " "
14 | page-footer:
15 | left: |
16 | Clinical Prediction Models
17 | right: |
18 | Built with Quarto and RStudio
19 | cover-image: cover-snippet.PNG
20 | favicon: cover-snippet.PNG
21 | repo-actions: issue
22 | repo-url: https://github.com/clinical-prediction-models/supplementary-material
23 | chapters:
24 | - index.qmd
25 | - chapters/01-introduction.qmd
26 | - part: "Part I: Prediction Models in Medicine"
27 | chapters:
28 | - chapters/02-applications-pred-mods.qmd
29 | - chapters/03-design.qmd
30 | - chapters/04-stat-mods.qmd
31 | - chapters/05-overfitting.qmd
32 | - chapters/06-choosing-alt-mods.qmd
33 | - part: "Part II: Developing Valid Prediction Models"
34 | chapters:
35 | - chapters/07-missing.qmd
36 | - chapters/08-case-study-missing.qmd
37 | - chapters/09-coding-categ-contin.qmd
38 | - chapters/10-restrict-cand-pred.qmd
39 | - chapters/11-main-effects-select.qmd
40 | - chapters/12-additivity-linearity.qmd
41 | - chapters/13-modern-estimation.qmd
42 | - chapters/14-estimation-external.qmd
43 | - chapters/15-evaluation-performance.qmd
44 | - chapters/16-clinical-usefulness.qmd
45 | - chapters/17-validation.qmd
46 | - chapters/18-presentation.qmd
47 | - part: "Part III: Generalizability of Prediction Models"
48 | chapters:
49 | - chapters/19-external-validity.qmd
50 | - chapters/20-updating.qmd
51 | - chapters/21-updating-multiple.qmd
52 | - part: "Part IV: Applications"
53 | chapters:
54 | - chapters/22-case-study-gusto.qmd
55 | - chapters/23-case-study-cardiovascular.qmd
56 | - chapters/24-lessons-datasets.qmd
57 | #- errata.qmd
58 | execute:
59 | warning: false
60 | message: false
61 | freeze: auto
62 |
63 | format:
64 | html:
65 | code-block-border-left: "#6C6C6C"
66 | code-block-bg: true
67 | code-fold: show
68 | code-tools:
69 | source: false
70 | toggle: true
71 | caption: "Show/hide all code"
72 | code-summary: "Code show/hide"
73 | fig-width: 11.69
74 | fig-height: 8.27
75 | number-depth: 0
76 | toc-depth: 5
77 | theme:
78 | - cosmo
79 | # - dynpredb.scss
80 | editor: source
81 | number-sections: true
82 |
--------------------------------------------------------------------------------
/R/bootcor.uni.mult.R:
--------------------------------------------------------------------------------
1 | # Bootcor.uni.mult
2 | # Determine correlation between logistic regression coefficients
3 | # in univariable and multivariable analysis
4 | # Uses stratified bootstrapping (by outcome)
5 | #
6 | # Author: Ewout Steyerberg, July-Dec 1997
7 |
8 | bootcor.uni.mult <- function(fit, B=40, maxit=25, group=fit$y, trim=0.1, save.indices=F,...)
9 | {if(is.null(X <- fit$x) | is.null(Y <- fit$y))
10 | stop("you did not specify x=T and y=T in the fit")
11 |
12 | n <- nrow(X)
13 | cases <- sum(Y)
14 | p <- length(fit$coef) - 1
15 | namec <- names(fit$coef[2:(p+1)])
16 | bootsamp <- matrix(0, nrow=B, ncol=(2*p+1)) ## to collect boot results
17 | dimnames(bootsamp) <- list(NULL,c(paste(namec,"u",sep=""),paste(namec,"m",sep=""),"Shrinkage"))
18 |
19 | Y <- as.matrix(Y)
20 | order1 <- order(group) # stratified bootstrapping
21 | X <- X[order1,]
22 |
23 | cat("Bootsample: ")
24 | for(i in 1:B)
25 | { j <- c(sample(1:(n-cases-1), replace=T),sample( (n-cases):n, replace=T) )
26 | ## take bootstrap samples rownumbers
27 | for (m in 1:p) ## p predictors
28 | { f <- lrm.fit(X[j,m,drop=F], Y[j,,drop=F], maxit=maxit) ## univariable coef
29 | if (!f$fail) {bootsamp[i,m] <- f$coefficients[2]}
30 | else {bootsamp[i,m] <- NA} }
31 |
32 | f <- lrm.fit(X[j,,drop=F], Y[j,,drop=F], maxit=maxit) ## multivariable coef
33 | if (!f$fail) {bootsamp[i,(p+1):(2*p)] <- f$coefficients[2:(p+1)]
34 | lp <- X %*% f$coefficients[2:(p+1)]
35 | f <- lrm.fit(lp, Y, maxit=maxit)
36 | bootsamp[i,(2*p+1)] <- f$coefficients[2]} ## shrinkage
37 | else { bootsamp[i,(p+1):(2*p+1)] <- NA }
38 | if (i %% 10==0) cat(i,"", fill=)
39 | } # end loop over bootstraps
40 |
41 | # Select rows without missings in any column
42 | for (m in 1:(2*p+1)) {bootsamp <- bootsamp[!is.na(bootsamp[,m]), ] }
43 |
44 | # remove outliers in coefficient estimates; close to non-convergence
45 | require(outliers)
46 | out <- outlier(bootsamp[,1:(2*p)], logical=TRUE)
47 | indices <- which(rowSums(out) > 0)
48 | bootsamp <- bootsamp[-indices, ]
49 |
50 | # Calculate correlation
51 | corcoef <- cor(bootsamp[ ,1 : p ],
52 | bootsamp[ ,(p+1):(2*p)])
53 |
54 | corcoef <- corcoef[row(corcoef) == col(corcoef) ]
55 |
56 | # Calculate mean shrinkage factor
57 | shrink <- mean(bootsamp[,(2*p+1)], trim=trim)
58 | nB <- nrow(bootsamp)
59 | cat("\nNumber of valid bootstraps for correlation and shrinkage: ",nB )
60 |
61 | names(corcoef) <- namec
62 | names(shrink) <- "shrinkage"
63 | names(nB) <- "B"
64 |
65 | if (!save.indices) retlist <- list(r=corcoef,shrink=shrink,B=nB) else
66 | retlist <- list(r=corcoef,shrink=shrink,B=nB,Bmatrix=bootsamp)
67 |
68 | cat("\nCorrelation coefficients:",round(retlist$r,2),
69 | "\nShrinkage:", round(retlist$shrink,2),"\n")
70 |
71 | retlist
72 | } # end function bootcor.uni.mult
73 |
--------------------------------------------------------------------------------
/docs/site_libs/quarto-html/tabsets/tabsets.js:
--------------------------------------------------------------------------------
1 | // grouped tabsets
2 |
3 | export function init() {
4 | window.addEventListener("pageshow", (_event) => {
5 | function getTabSettings() {
6 | const data = localStorage.getItem("quarto-persistent-tabsets-data");
7 | if (!data) {
8 | localStorage.setItem("quarto-persistent-tabsets-data", "{}");
9 | return {};
10 | }
11 | if (data) {
12 | return JSON.parse(data);
13 | }
14 | }
15 |
16 | function setTabSettings(data) {
17 | localStorage.setItem(
18 | "quarto-persistent-tabsets-data",
19 | JSON.stringify(data)
20 | );
21 | }
22 |
23 | function setTabState(groupName, groupValue) {
24 | const data = getTabSettings();
25 | data[groupName] = groupValue;
26 | setTabSettings(data);
27 | }
28 |
29 | function toggleTab(tab, active) {
30 | const tabPanelId = tab.getAttribute("aria-controls");
31 | const tabPanel = document.getElementById(tabPanelId);
32 | if (active) {
33 | tab.classList.add("active");
34 | tabPanel.classList.add("active");
35 | } else {
36 | tab.classList.remove("active");
37 | tabPanel.classList.remove("active");
38 | }
39 | }
40 |
41 | function toggleAll(selectedGroup, selectorsToSync) {
42 | for (const [thisGroup, tabs] of Object.entries(selectorsToSync)) {
43 | const active = selectedGroup === thisGroup;
44 | for (const tab of tabs) {
45 | toggleTab(tab, active);
46 | }
47 | }
48 | }
49 |
50 | function findSelectorsToSyncByLanguage() {
51 | const result = {};
52 | const tabs = Array.from(
53 | document.querySelectorAll(`div[data-group] a[id^='tabset-']`)
54 | );
55 | for (const item of tabs) {
56 | const div = item.parentElement.parentElement.parentElement;
57 | const group = div.getAttribute("data-group");
58 | if (!result[group]) {
59 | result[group] = {};
60 | }
61 | const selectorsToSync = result[group];
62 | const value = item.innerHTML;
63 | if (!selectorsToSync[value]) {
64 | selectorsToSync[value] = [];
65 | }
66 | selectorsToSync[value].push(item);
67 | }
68 | return result;
69 | }
70 |
71 | function setupSelectorSync() {
72 | const selectorsToSync = findSelectorsToSyncByLanguage();
73 | Object.entries(selectorsToSync).forEach(([group, tabSetsByValue]) => {
74 | Object.entries(tabSetsByValue).forEach(([value, items]) => {
75 | items.forEach((item) => {
76 | item.addEventListener("click", (_event) => {
77 | setTabState(group, value);
78 | toggleAll(value, selectorsToSync[group]);
79 | });
80 | });
81 | });
82 | });
83 | return selectorsToSync;
84 | }
85 |
86 | const selectorsToSync = setupSelectorSync();
87 | for (const [group, selectedName] of Object.entries(getTabSettings())) {
88 | const selectors = selectorsToSync[group];
89 | // it's possible that stale state gives us empty selections, so we explicitly check here.
90 | if (selectors) {
91 | toggleAll(selectedName, selectors);
92 | }
93 | }
94 | });
95 | }
96 |
--------------------------------------------------------------------------------
/docs/site_libs/quarto-nav/headroom.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * headroom.js v0.12.0 - Give your page some headroom. Hide your header until you need it
3 | * Copyright (c) 2020 Nick Williams - http://wicky.nillia.ms/headroom.js
4 | * License: MIT
5 | */
6 |
7 | !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).Headroom=n()}(this,function(){"use strict";function t(){return"undefined"!=typeof window}function d(t){return function(t){return t&&t.document&&function(t){return 9===t.nodeType}(t.document)}(t)?function(t){var n=t.document,o=n.body,s=n.documentElement;return{scrollHeight:function(){return Math.max(o.scrollHeight,s.scrollHeight,o.offsetHeight,s.offsetHeight,o.clientHeight,s.clientHeight)},height:function(){return t.innerHeight||s.clientHeight||o.clientHeight},scrollY:function(){return void 0!==t.pageYOffset?t.pageYOffset:(s||o.parentNode||o).scrollTop}}}(t):function(t){return{scrollHeight:function(){return Math.max(t.scrollHeight,t.offsetHeight,t.clientHeight)},height:function(){return Math.max(t.offsetHeight,t.clientHeight)},scrollY:function(){return t.scrollTop}}}(t)}function n(t,s,e){var n,o=function(){var n=!1;try{var t={get passive(){n=!0}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){n=!1}return n}(),i=!1,r=d(t),l=r.scrollY(),a={};function c(){var t=Math.round(r.scrollY()),n=r.height(),o=r.scrollHeight();a.scrollY=t,a.lastScrollY=l,a.direction=ls.tolerance[a.direction],e(a),l=t,i=!1}function h(){i||(i=!0,n=requestAnimationFrame(c))}var u=!!o&&{passive:!0,capture:!1};return t.addEventListener("scroll",h,u),c(),{destroy:function(){cancelAnimationFrame(n),t.removeEventListener("scroll",h,u)}}}function o(t){return t===Object(t)?t:{down:t,up:t}}function s(t,n){n=n||{},Object.assign(this,s.options,n),this.classes=Object.assign({},s.options.classes,n.classes),this.elem=t,this.tolerance=o(this.tolerance),this.offset=o(this.offset),this.initialised=!1,this.frozen=!1}return s.prototype={constructor:s,init:function(){return s.cutsTheMustard&&!this.initialised&&(this.addClass("initial"),this.initialised=!0,setTimeout(function(t){t.scrollTracker=n(t.scroller,{offset:t.offset,tolerance:t.tolerance},t.update.bind(t))},100,this)),this},destroy:function(){this.initialised=!1,Object.keys(this.classes).forEach(this.removeClass,this),this.scrollTracker.destroy()},unpin:function(){!this.hasClass("pinned")&&this.hasClass("unpinned")||(this.addClass("unpinned"),this.removeClass("pinned"),this.onUnpin&&this.onUnpin.call(this))},pin:function(){this.hasClass("unpinned")&&(this.addClass("pinned"),this.removeClass("unpinned"),this.onPin&&this.onPin.call(this))},freeze:function(){this.frozen=!0,this.addClass("frozen")},unfreeze:function(){this.frozen=!1,this.removeClass("frozen")},top:function(){this.hasClass("top")||(this.addClass("top"),this.removeClass("notTop"),this.onTop&&this.onTop.call(this))},notTop:function(){this.hasClass("notTop")||(this.addClass("notTop"),this.removeClass("top"),this.onNotTop&&this.onNotTop.call(this))},bottom:function(){this.hasClass("bottom")||(this.addClass("bottom"),this.removeClass("notBottom"),this.onBottom&&this.onBottom.call(this))},notBottom:function(){this.hasClass("notBottom")||(this.addClass("notBottom"),this.removeClass("bottom"),this.onNotBottom&&this.onNotBottom.call(this))},shouldUnpin:function(t){return"down"===t.direction&&!t.top&&t.toleranceExceeded},shouldPin:function(t){return"up"===t.direction&&t.toleranceExceeded||t.top},addClass:function(t){this.elem.classList.add.apply(this.elem.classList,this.classes[t].split(" "))},removeClass:function(t){this.elem.classList.remove.apply(this.elem.classList,this.classes[t].split(" "))},hasClass:function(t){return this.classes[t].split(" ").every(function(t){return this.classList.contains(t)},this.elem)},update:function(t){t.isOutOfBounds||!0!==this.frozen&&(t.top?this.top():this.notTop(),t.bottom?this.bottom():this.notBottom(),this.shouldUnpin(t)?this.unpin():this.shouldPin(t)&&this.pin())}},s.options={tolerance:{up:0,down:0},offset:0,scroller:t()?window:null,classes:{frozen:"headroom--frozen",pinned:"headroom--pinned",unpinned:"headroom--unpinned",top:"headroom--top",notTop:"headroom--not-top",bottom:"headroom--bottom",notBottom:"headroom--not-bottom",initial:"headroom"}},s.cutsTheMustard=!!(t()&&function(){}.bind&&"classList"in document.documentElement&&Object.assign&&Object.keys&&requestAnimationFrame),s});
8 |
--------------------------------------------------------------------------------
/chapters/05-overfitting.qmd:
--------------------------------------------------------------------------------
1 | # Overfitting and Optimism in Prediction Models {#overfitting}
2 |
3 | ```{r setup-ch5, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 | # Have only one set-up chunck at the beginning,
9 | # And before chapter run rm(list = ls())
10 | # Also set fig path per chapter
11 |
12 | knitr::opts_chunk$set(
13 | fig.path = "fig/"
14 | )
15 |
16 | library(rms)
17 |
18 | mycolors <- c(
19 | "black" = 1,
20 | "Red" = "#ED0000",
21 | "CongressBlue" = "#00468B",
22 | "Apple" = "#42B540",
23 | "BondiBlue" = "#0099B4",
24 | "TrendyPink" = "#925E9F",
25 | "Carmine" = "#AD002A",
26 | "CodGray" = "#1B1919",
27 | "MonaLisa" = "#FDAF91",
28 | "Edward" = "#ADB6B6"
29 | )
30 | ```
31 |
32 | ## Figures 5.2 to 5.5 {-}
33 |
34 |
35 | ### Fig 5.2: Noise in estimating 10% mortality per center {-}
36 |
37 | ```{r Fig_5.2, echo=T}
38 | # Surg mortality; 10%
39 | par(mfrow = c(1, 1), mar = c(5, 5, 1, 1))
40 | for (mort in c(.1)) { ## ,0.05,0.02,.01)) { # 4 mortalities or only 1
41 | plot(
42 | x = seq(from = -.025, to = .975, by = .05), dbinom(x = 0:20, 20, mort), axes = F, type = "s", lwd = 2,
43 | xlim = c(-.05, .35), ylim = c(0, .33), col = mycolors[2],
44 | xlab = paste("Observed mortality, true mortality ", round(100 * mort, 0), "%", sep = ""), ylab = "probability density"
45 | )
46 | axis(side = 1, at = c(0, .1, .2, .3), labels = c("0%", "10%", "20%", "30%"))
47 | axis(side = 2, at = c(0, 0.1, .2, .3, .4, .5, .6, .7), labels = c("0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%"))
48 | text(x = mort, y = .02 + dbinom(x = max(round(mort * 20), 0), 20, mort), labels = paste("n=20"), col = mycolors[2])
49 |
50 | for (i in c(50, 200)) { # add more sample sizes
51 | lines(
52 | x = seq(from = 0 - (0.5 * 1 / i), to = 1 - (0.5 * 1 / i), by = 1 / i), dbinom(x = 0:i, i, mort),
53 | type = "s", lty = ifelse(i == 50, 2, 4), lwd = 2, col = mycolors[ifelse(i == 50, 3, 4)]
54 | )
55 | text(x = mort, y = .02 + dbinom(x = max(round(mort * i), 0), i, mort), labels = paste("n=", i, sep = ""), col = mycolors[ifelse(i == 50, 3, 4)])
56 | } # end loop n=50,200
57 | } # end loop mort
58 | ## End Fig 5.2 ##
59 | ```
60 |
61 |
62 | ```{r Fig_5.3+4_function, echo=T}
63 | ## function for Fig 5.3 and Fig 5.4: Noise vs Heterogeneity
64 | illustrate_noise_heterogeneity <- function(n = 20, mort = 0.1, tau = c(0, .01, .02, .03)) {
65 | par(mfrow = c(2, 2), pty = "m", mar = c(2.5, 4, 1.5, 1))
66 | # Make data set with 100 centers, each 20 patients, 10% mortality, variability sd 0 to 0.03
67 | seedn <- 102
68 | set.seed(seedn)
69 | ncenter <- 50
70 | nsubjects <- n # n can be changed
71 | # simple SD used on probability scale, can be improved upon
72 | for (sdtau in tau) { # set for tau can be changed
73 | truemort <- rnorm(n = ncenter, mean = mort, sd = sdtau) # mort can be changed
74 | mortmat <- as.matrix(cbind(1:ncenter, sapply(truemort, FUN = function(x) rbinom(n = 1, nsubjects, x)) / nsubjects, truemort))
75 |
76 | # Start plotting
77 | plot(x = 0, y = 0, pch = "", xlim = c(-.2, 1.2), ylim = c(-.03, .35), axes = F, xlab = "", ylab = ifelse(sdtau == 0 | sdtau == .02, "Mortality", ""))
78 | axis(side = 2, at = c(0, .1, .2, .3), labels = c("0%", "10%", "20%", "30%"), las = 1)
79 | axis(side = 1, at = c(0, 1), labels = c("Observed", "True mortality"))
80 | text(x = 1, y = .3, ifelse(sdtau == 0, "No heterogeneity",
81 | ifelse(sdtau != 0, paste("+/-", sdtau))
82 | ), cex = 1, adj = 1, font = 2)
83 | for (i in (1:ncenter)) {
84 | set.seed(i + seedn)
85 | lines(
86 | x = c(0 + runif(1, min = -.07, max = .07), 1),
87 | y = c(mortmat[i, 2] + runif(1, min = -.001, max = .01), mortmat[i, 3]), col = mycolors[rep(1:10, 10)[i]]
88 | )
89 | set.seed(i + seedn)
90 | points(
91 | x = c(0 + runif(1, min = -.07, max = .07), 1),
92 | y = c(mortmat[i, 2] + runif(1, min = -.001, max = .01), mortmat[i, 3]), pch = c("o", "+"), col = mycolors[rep(1:10, 10)[i]]
93 | )
94 | }
95 | }
96 | } # end function that illustrates the impact of noise (determined by n) vs heterogeneity (determined by sdtau)
97 | ```
98 |
99 | ### Figs 5.3 and 5.4 {-}
100 |
101 | These plots llustrate the impact of noise (determined by n, 20 or 200) vs heterogeneity (determined by sdtau (0 - 0.03)). With small n, such as n=20 per center, mortality such as 10% cannot be estimated reliably. Reliable estimation of a center's performance requires a large n, such as n=200.
102 |
103 | ### n=20 {-}
104 |
105 | ```{r Fig_5.3, echo=F}
106 | illustrate_noise_heterogeneity(n = 20, mort = 0.1, tau = c(0, .01, .02, .03))
107 | ```
108 |
109 | ### n=200 {-}
110 |
111 | ```{r Fig_5.4, echo=F}
112 | illustrate_noise_heterogeneity(n = 200, mort = 0.1, tau = c(0, .01, .02, .03))
113 | ```
114 |
115 |
--------------------------------------------------------------------------------
/docs/site_libs/quarto-html/quarto-syntax-highlighting-e1a5c8363afafaef2c763b6775fbf3ca.css:
--------------------------------------------------------------------------------
1 | /* quarto syntax highlight colors */
2 | :root {
3 | --quarto-hl-ot-color: #003B4F;
4 | --quarto-hl-at-color: #657422;
5 | --quarto-hl-ss-color: #20794D;
6 | --quarto-hl-an-color: #5E5E5E;
7 | --quarto-hl-fu-color: #4758AB;
8 | --quarto-hl-st-color: #20794D;
9 | --quarto-hl-cf-color: #003B4F;
10 | --quarto-hl-op-color: #5E5E5E;
11 | --quarto-hl-er-color: #AD0000;
12 | --quarto-hl-bn-color: #AD0000;
13 | --quarto-hl-al-color: #AD0000;
14 | --quarto-hl-va-color: #111111;
15 | --quarto-hl-bu-color: inherit;
16 | --quarto-hl-ex-color: inherit;
17 | --quarto-hl-pp-color: #AD0000;
18 | --quarto-hl-in-color: #5E5E5E;
19 | --quarto-hl-vs-color: #20794D;
20 | --quarto-hl-wa-color: #5E5E5E;
21 | --quarto-hl-do-color: #5E5E5E;
22 | --quarto-hl-im-color: #00769E;
23 | --quarto-hl-ch-color: #20794D;
24 | --quarto-hl-dt-color: #AD0000;
25 | --quarto-hl-fl-color: #AD0000;
26 | --quarto-hl-co-color: #5E5E5E;
27 | --quarto-hl-cv-color: #5E5E5E;
28 | --quarto-hl-cn-color: #8f5902;
29 | --quarto-hl-sc-color: #5E5E5E;
30 | --quarto-hl-dv-color: #AD0000;
31 | --quarto-hl-kw-color: #003B4F;
32 | }
33 |
34 | /* other quarto variables */
35 | :root {
36 | --quarto-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
37 | }
38 |
39 | /* syntax highlight based on Pandoc's rules */
40 | pre > code.sourceCode > span {
41 | color: #003B4F;
42 | }
43 |
44 | code.sourceCode > span {
45 | color: #003B4F;
46 | }
47 |
48 | div.sourceCode,
49 | div.sourceCode pre.sourceCode {
50 | color: #003B4F;
51 | }
52 |
53 | /* Normal */
54 | code span {
55 | color: #003B4F;
56 | }
57 |
58 | /* Alert */
59 | code span.al {
60 | color: #AD0000;
61 | font-style: inherit;
62 | }
63 |
64 | /* Annotation */
65 | code span.an {
66 | color: #5E5E5E;
67 | font-style: inherit;
68 | }
69 |
70 | /* Attribute */
71 | code span.at {
72 | color: #657422;
73 | font-style: inherit;
74 | }
75 |
76 | /* BaseN */
77 | code span.bn {
78 | color: #AD0000;
79 | font-style: inherit;
80 | }
81 |
82 | /* BuiltIn */
83 | code span.bu {
84 | font-style: inherit;
85 | }
86 |
87 | /* ControlFlow */
88 | code span.cf {
89 | color: #003B4F;
90 | font-weight: bold;
91 | font-style: inherit;
92 | }
93 |
94 | /* Char */
95 | code span.ch {
96 | color: #20794D;
97 | font-style: inherit;
98 | }
99 |
100 | /* Constant */
101 | code span.cn {
102 | color: #8f5902;
103 | font-style: inherit;
104 | }
105 |
106 | /* Comment */
107 | code span.co {
108 | color: #5E5E5E;
109 | font-style: inherit;
110 | }
111 |
112 | /* CommentVar */
113 | code span.cv {
114 | color: #5E5E5E;
115 | font-style: italic;
116 | }
117 |
118 | /* Documentation */
119 | code span.do {
120 | color: #5E5E5E;
121 | font-style: italic;
122 | }
123 |
124 | /* DataType */
125 | code span.dt {
126 | color: #AD0000;
127 | font-style: inherit;
128 | }
129 |
130 | /* DecVal */
131 | code span.dv {
132 | color: #AD0000;
133 | font-style: inherit;
134 | }
135 |
136 | /* Error */
137 | code span.er {
138 | color: #AD0000;
139 | font-style: inherit;
140 | }
141 |
142 | /* Extension */
143 | code span.ex {
144 | font-style: inherit;
145 | }
146 |
147 | /* Float */
148 | code span.fl {
149 | color: #AD0000;
150 | font-style: inherit;
151 | }
152 |
153 | /* Function */
154 | code span.fu {
155 | color: #4758AB;
156 | font-style: inherit;
157 | }
158 |
159 | /* Import */
160 | code span.im {
161 | color: #00769E;
162 | font-style: inherit;
163 | }
164 |
165 | /* Information */
166 | code span.in {
167 | color: #5E5E5E;
168 | font-style: inherit;
169 | }
170 |
171 | /* Keyword */
172 | code span.kw {
173 | color: #003B4F;
174 | font-weight: bold;
175 | font-style: inherit;
176 | }
177 |
178 | /* Operator */
179 | code span.op {
180 | color: #5E5E5E;
181 | font-style: inherit;
182 | }
183 |
184 | /* Other */
185 | code span.ot {
186 | color: #003B4F;
187 | font-style: inherit;
188 | }
189 |
190 | /* Preprocessor */
191 | code span.pp {
192 | color: #AD0000;
193 | font-style: inherit;
194 | }
195 |
196 | /* SpecialChar */
197 | code span.sc {
198 | color: #5E5E5E;
199 | font-style: inherit;
200 | }
201 |
202 | /* SpecialString */
203 | code span.ss {
204 | color: #20794D;
205 | font-style: inherit;
206 | }
207 |
208 | /* String */
209 | code span.st {
210 | color: #20794D;
211 | font-style: inherit;
212 | }
213 |
214 | /* Variable */
215 | code span.va {
216 | color: #111111;
217 | font-style: inherit;
218 | }
219 |
220 | /* VerbatimString */
221 | code span.vs {
222 | color: #20794D;
223 | font-style: inherit;
224 | }
225 |
226 | /* Warning */
227 | code span.wa {
228 | color: #5E5E5E;
229 | font-style: italic;
230 | }
231 |
232 | .prevent-inlining {
233 | content: "";
234 | }
235 |
236 | /*# sourceMappingURL=c735b2cac6c846c1abc72f5ce1520814.css.map */
237 |
--------------------------------------------------------------------------------
/docs/site_libs/quarto-html/anchor.min.js:
--------------------------------------------------------------------------------
1 | // @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
2 | //
3 | // AnchorJS - v5.0.0 - 2023-01-18
4 | // https://www.bryanbraun.com/anchorjs/
5 | // Copyright (c) 2023 Bryan Braun; Licensed MIT
6 | //
7 | // @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
8 | !function(A,e){"use strict";"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():(A.AnchorJS=e(),A.anchors=new A.AnchorJS)}(globalThis,function(){"use strict";return function(A){function u(A){A.icon=Object.prototype.hasOwnProperty.call(A,"icon")?A.icon:"",A.visible=Object.prototype.hasOwnProperty.call(A,"visible")?A.visible:"hover",A.placement=Object.prototype.hasOwnProperty.call(A,"placement")?A.placement:"right",A.ariaLabel=Object.prototype.hasOwnProperty.call(A,"ariaLabel")?A.ariaLabel:"Anchor",A.class=Object.prototype.hasOwnProperty.call(A,"class")?A.class:"",A.base=Object.prototype.hasOwnProperty.call(A,"base")?A.base:"",A.truncate=Object.prototype.hasOwnProperty.call(A,"truncate")?Math.floor(A.truncate):64,A.titleText=Object.prototype.hasOwnProperty.call(A,"titleText")?A.titleText:""}function d(A){var e;if("string"==typeof A||A instanceof String)e=[].slice.call(document.querySelectorAll(A));else{if(!(Array.isArray(A)||A instanceof NodeList))throw new TypeError("The selector provided to AnchorJS was invalid.");e=[].slice.call(A)}return e}this.options=A||{},this.elements=[],u(this.options),this.add=function(A){var e,t,o,i,n,s,a,r,l,c,h,p=[];if(u(this.options),0!==(e=d(A=A||"h2, h3, h4, h5, h6")).length){for(null===document.head.querySelector("style.anchorjs")&&((A=document.createElement("style")).className="anchorjs",A.appendChild(document.createTextNode("")),void 0===(h=document.head.querySelector('[rel="stylesheet"],style'))?document.head.appendChild(A):document.head.insertBefore(A,h),A.sheet.insertRule(".anchorjs-link{opacity:0;text-decoration:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}",A.sheet.cssRules.length),A.sheet.insertRule(":hover>.anchorjs-link,.anchorjs-link:focus{opacity:1}",A.sheet.cssRules.length),A.sheet.insertRule("[data-anchorjs-icon]::after{content:attr(data-anchorjs-icon)}",A.sheet.cssRules.length),A.sheet.insertRule('@font-face{font-family:anchorjs-icons;src:url(data:n/a;base64,AAEAAAALAIAAAwAwT1MvMg8yG2cAAAE4AAAAYGNtYXDp3gC3AAABpAAAAExnYXNwAAAAEAAAA9wAAAAIZ2x5ZlQCcfwAAAH4AAABCGhlYWQHFvHyAAAAvAAAADZoaGVhBnACFwAAAPQAAAAkaG10eASAADEAAAGYAAAADGxvY2EACACEAAAB8AAAAAhtYXhwAAYAVwAAARgAAAAgbmFtZQGOH9cAAAMAAAAAunBvc3QAAwAAAAADvAAAACAAAQAAAAEAAHzE2p9fDzz1AAkEAAAAAADRecUWAAAAANQA6R8AAAAAAoACwAAAAAgAAgAAAAAAAAABAAADwP/AAAACgAAA/9MCrQABAAAAAAAAAAAAAAAAAAAAAwABAAAAAwBVAAIAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAMCQAGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAg//0DwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAAIAAAACgAAxAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEADAAAAAIAAgAAgAAACDpy//9//8AAAAg6cv//f///+EWNwADAAEAAAAAAAAAAAAAAAAACACEAAEAAAAAAAAAAAAAAAAxAAACAAQARAKAAsAAKwBUAAABIiYnJjQ3NzY2MzIWFxYUBwcGIicmNDc3NjQnJiYjIgYHBwYUFxYUBwYGIwciJicmNDc3NjIXFhQHBwYUFxYWMzI2Nzc2NCcmNDc2MhcWFAcHBgYjARQGDAUtLXoWOR8fORYtLTgKGwoKCjgaGg0gEhIgDXoaGgkJBQwHdR85Fi0tOAobCgoKOBoaDSASEiANehoaCQkKGwotLXoWOR8BMwUFLYEuehYXFxYugC44CQkKGwo4GkoaDQ0NDXoaShoKGwoFBe8XFi6ALjgJCQobCjgaShoNDQ0NehpKGgobCgoKLYEuehYXAAAADACWAAEAAAAAAAEACAAAAAEAAAAAAAIAAwAIAAEAAAAAAAMACAAAAAEAAAAAAAQACAAAAAEAAAAAAAUAAQALAAEAAAAAAAYACAAAAAMAAQQJAAEAEAAMAAMAAQQJAAIABgAcAAMAAQQJAAMAEAAMAAMAAQQJAAQAEAAMAAMAAQQJAAUAAgAiAAMAAQQJAAYAEAAMYW5jaG9yanM0MDBAAGEAbgBjAGgAbwByAGoAcwA0ADAAMABAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAH//wAP) format("truetype")}',A.sheet.cssRules.length)),h=document.querySelectorAll("[id]"),t=[].map.call(h,function(A){return A.id}),i=0;i\]./()*\\\n\t\b\v\u00A0]/g,"-").replace(/-{2,}/g,"-").substring(0,this.options.truncate).replace(/^-+|-+$/gm,"").toLowerCase()},this.hasAnchorJSLink=function(A){var e=A.firstChild&&-1<(" "+A.firstChild.className+" ").indexOf(" anchorjs-link "),A=A.lastChild&&-1<(" "+A.lastChild.className+" ").indexOf(" anchorjs-link ");return e||A||!1}}});
9 | // @license-end
--------------------------------------------------------------------------------
/docs/site_libs/lightable-0.0.1/lightable.css:
--------------------------------------------------------------------------------
1 | /*!
2 | * lightable v0.0.1
3 | * Copyright 2020 Hao Zhu
4 | * Licensed under MIT (https://github.com/haozhu233/kableExtra/blob/master/LICENSE)
5 | */
6 |
7 | .lightable-minimal {
8 | border-collapse: separate;
9 | border-spacing: 16px 1px;
10 | width: 100%;
11 | margin-bottom: 10px;
12 | }
13 |
14 | .lightable-minimal td {
15 | margin-left: 5px;
16 | margin-right: 5px;
17 | }
18 |
19 | .lightable-minimal th {
20 | margin-left: 5px;
21 | margin-right: 5px;
22 | }
23 |
24 | .lightable-minimal thead tr:last-child th {
25 | border-bottom: 2px solid #00000050;
26 | empty-cells: hide;
27 |
28 | }
29 |
30 | .lightable-minimal tbody tr:first-child td {
31 | padding-top: 0.5em;
32 | }
33 |
34 | .lightable-minimal.lightable-hover tbody tr:hover {
35 | background-color: #f5f5f5;
36 | }
37 |
38 | .lightable-minimal.lightable-striped tbody tr:nth-child(even) {
39 | background-color: #f5f5f5;
40 | }
41 |
42 | .lightable-classic {
43 | border-top: 0.16em solid #111111;
44 | border-bottom: 0.16em solid #111111;
45 | width: 100%;
46 | margin-bottom: 10px;
47 | margin: 10px 5px;
48 | }
49 |
50 | .lightable-classic tfoot tr td {
51 | border: 0;
52 | }
53 |
54 | .lightable-classic tfoot tr:first-child td {
55 | border-top: 0.14em solid #111111;
56 | }
57 |
58 | .lightable-classic caption {
59 | color: #222222;
60 | }
61 |
62 | .lightable-classic td {
63 | padding-left: 5px;
64 | padding-right: 5px;
65 | color: #222222;
66 | }
67 |
68 | .lightable-classic th {
69 | padding-left: 5px;
70 | padding-right: 5px;
71 | font-weight: normal;
72 | color: #222222;
73 | }
74 |
75 | .lightable-classic thead tr:last-child th {
76 | border-bottom: 0.10em solid #111111;
77 | }
78 |
79 | .lightable-classic.lightable-hover tbody tr:hover {
80 | background-color: #F9EEC1;
81 | }
82 |
83 | .lightable-classic.lightable-striped tbody tr:nth-child(even) {
84 | background-color: #f5f5f5;
85 | }
86 |
87 | .lightable-classic-2 {
88 | border-top: 3px double #111111;
89 | border-bottom: 3px double #111111;
90 | width: 100%;
91 | margin-bottom: 10px;
92 | }
93 |
94 | .lightable-classic-2 tfoot tr td {
95 | border: 0;
96 | }
97 |
98 | .lightable-classic-2 tfoot tr:first-child td {
99 | border-top: 3px double #111111;
100 | }
101 |
102 | .lightable-classic-2 caption {
103 | color: #222222;
104 | }
105 |
106 | .lightable-classic-2 td {
107 | padding-left: 5px;
108 | padding-right: 5px;
109 | color: #222222;
110 | }
111 |
112 | .lightable-classic-2 th {
113 | padding-left: 5px;
114 | padding-right: 5px;
115 | font-weight: normal;
116 | color: #222222;
117 | }
118 |
119 | .lightable-classic-2 tbody tr:last-child td {
120 | border-bottom: 3px double #111111;
121 | }
122 |
123 | .lightable-classic-2 thead tr:last-child th {
124 | border-bottom: 1px solid #111111;
125 | }
126 |
127 | .lightable-classic-2.lightable-hover tbody tr:hover {
128 | background-color: #F9EEC1;
129 | }
130 |
131 | .lightable-classic-2.lightable-striped tbody tr:nth-child(even) {
132 | background-color: #f5f5f5;
133 | }
134 |
135 | .lightable-material {
136 | min-width: 100%;
137 | white-space: nowrap;
138 | table-layout: fixed;
139 | font-family: Roboto, sans-serif;
140 | border: 1px solid #EEE;
141 | border-collapse: collapse;
142 | margin-bottom: 10px;
143 | }
144 |
145 | .lightable-material tfoot tr td {
146 | border: 0;
147 | }
148 |
149 | .lightable-material tfoot tr:first-child td {
150 | border-top: 1px solid #EEE;
151 | }
152 |
153 | .lightable-material th {
154 | height: 56px;
155 | padding-left: 16px;
156 | padding-right: 16px;
157 | }
158 |
159 | .lightable-material td {
160 | height: 52px;
161 | padding-left: 16px;
162 | padding-right: 16px;
163 | border-top: 1px solid #eeeeee;
164 | }
165 |
166 | .lightable-material.lightable-hover tbody tr:hover {
167 | background-color: #f5f5f5;
168 | }
169 |
170 | .lightable-material.lightable-striped tbody tr:nth-child(even) {
171 | background-color: #f5f5f5;
172 | }
173 |
174 | .lightable-material.lightable-striped tbody td {
175 | border: 0;
176 | }
177 |
178 | .lightable-material.lightable-striped thead tr:last-child th {
179 | border-bottom: 1px solid #ddd;
180 | }
181 |
182 | .lightable-material-dark {
183 | min-width: 100%;
184 | white-space: nowrap;
185 | table-layout: fixed;
186 | font-family: Roboto, sans-serif;
187 | border: 1px solid #FFFFFF12;
188 | border-collapse: collapse;
189 | margin-bottom: 10px;
190 | background-color: #363640;
191 | }
192 |
193 | .lightable-material-dark tfoot tr td {
194 | border: 0;
195 | }
196 |
197 | .lightable-material-dark tfoot tr:first-child td {
198 | border-top: 1px solid #FFFFFF12;
199 | }
200 |
201 | .lightable-material-dark th {
202 | height: 56px;
203 | padding-left: 16px;
204 | padding-right: 16px;
205 | color: #FFFFFF60;
206 | }
207 |
208 | .lightable-material-dark td {
209 | height: 52px;
210 | padding-left: 16px;
211 | padding-right: 16px;
212 | color: #FFFFFF;
213 | border-top: 1px solid #FFFFFF12;
214 | }
215 |
216 | .lightable-material-dark.lightable-hover tbody tr:hover {
217 | background-color: #FFFFFF12;
218 | }
219 |
220 | .lightable-material-dark.lightable-striped tbody tr:nth-child(even) {
221 | background-color: #FFFFFF12;
222 | }
223 |
224 | .lightable-material-dark.lightable-striped tbody td {
225 | border: 0;
226 | }
227 |
228 | .lightable-material-dark.lightable-striped thead tr:last-child th {
229 | border-bottom: 1px solid #FFFFFF12;
230 | }
231 |
232 | .lightable-paper {
233 | width: 100%;
234 | margin-bottom: 10px;
235 | color: #444;
236 | }
237 |
238 | .lightable-paper tfoot tr td {
239 | border: 0;
240 | }
241 |
242 | .lightable-paper tfoot tr:first-child td {
243 | border-top: 1px solid #00000020;
244 | }
245 |
246 | .lightable-paper thead tr:last-child th {
247 | color: #666;
248 | vertical-align: bottom;
249 | border-bottom: 1px solid #00000020;
250 | line-height: 1.15em;
251 | padding: 10px 5px;
252 | }
253 |
254 | .lightable-paper td {
255 | vertical-align: middle;
256 | border-bottom: 1px solid #00000010;
257 | line-height: 1.15em;
258 | padding: 7px 5px;
259 | }
260 |
261 | .lightable-paper.lightable-hover tbody tr:hover {
262 | background-color: #F9EEC1;
263 | }
264 |
265 | .lightable-paper.lightable-striped tbody tr:nth-child(even) {
266 | background-color: #00000008;
267 | }
268 |
269 | .lightable-paper.lightable-striped tbody td {
270 | border: 0;
271 | }
272 |
273 |
--------------------------------------------------------------------------------
/data/Fmort.csv:
--------------------------------------------------------------------------------
1 | "","class","surgery","agecat","age","mort","w"
2 | "1","CVD ","Abdominal aortic aneurysms","65-69 ",67.5,1,1073
3 | "2","CVD ","Abdominal aortic aneurysms","65-69 ",67.5,0,37253
4 | "3","CVD ","Abdominal aortic aneurysms","70-74 ",72.5,1,920
5 | "4","CVD ","Abdominal aortic aneurysms","70-74 ",72.5,0,24631
6 | "5","CVD ","Abdominal aortic aneurysms","75-80 ",77.2,1,903
7 | "6","CVD ","Abdominal aortic aneurysms","75-80 ",77.2,0,16131
8 | "7","CVD ","Abdominal aortic aneurysms","80-85 ",82,1,245
9 | "8","CVD ","Abdominal aortic aneurysms","80-85 ",82,0,3162
10 | "9","CVD ","Abdominal aortic aneurysms","85-99 ",90,1,101
11 | "10","CVD ","Abdominal aortic aneurysms","85-99 ",90,0,751
12 | "11","CVD ","Aortic valve","65-69 ",67.5,1,1528
13 | "12","CVD ","Aortic valve","65-69 ",67.5,0,29657
14 | "13","CVD ","Aortic valve","70-74 ",72.5,1,1310
15 | "14","CVD ","Aortic valve","70-74 ",72.5,0,19481
16 | "15","CVD ","Aortic valve","75-80 ",77.2,1,1081
17 | "16","CVD ","Aortic valve","75-80 ",77.2,0,12779
18 | "17","CVD ","Aortic valve","80-85 ",82,1,261
19 | "18","CVD ","Aortic valve","80-85 ",82,0,2511
20 | "19","CVD ","Aortic valve","85-99 ",90,1,71
21 | "20","CVD ","Aortic valve","85-99 ",90,0,622
22 | "21","CVD ","CABG","65-69 ",67.5,1,3695
23 | "22","CVD ","CABG","65-69 ",67.5,0,128258
24 | "23","CVD ","CABG","70-74 ",72.5,1,3343
25 | "24","CVD ","CABG","70-74 ",72.5,0,84626
26 | "25","CVD ","CABG","75-80 ",77.2,1,2991
27 | "26","CVD ","CABG","75-80 ",77.2,0,55655
28 | "27","CVD ","CABG","80-85 ",82,1,786
29 | "28","CVD ","CABG","80-85 ",82,0,10943
30 | "29","CVD ","CABG","85-99 ",90,1,252
31 | "30","CVD ","CABG","85-99 ",90,0,2680
32 | "31","Cancer ","Colectomy","65-69 ",67.5,1,1078
33 | "32","Cancer ","Colectomy","65-69 ",67.5,0,58838
34 | "33","Cancer ","Colectomy","70-74 ",72.5,1,959
35 | "34","Cancer ","Colectomy","70-74 ",72.5,0,38986
36 | "35","Cancer ","Colectomy","75-80 ",77.2,1,852
37 | "36","Cancer ","Colectomy","75-80 ",77.2,0,25777
38 | "37","Cancer ","Colectomy","80-85 ",82,1,245
39 | "38","Cancer ","Colectomy","80-85 ",82,0,5081
40 | "39","Cancer ","Colectomy","85-99 ",90,1,96
41 | "40","Cancer ","Colectomy","85-99 ",90,0,1236
42 | "41","Cancer ","Cystectomy","65-69 ",67.5,1,152
43 | "42","Cancer ","Cystectomy","65-69 ",67.5,0,6476
44 | "43","Cancer ","Cystectomy","70-74 ",72.5,1,164
45 | "44","Cancer ","Cystectomy","70-74 ",72.5,0,4256
46 | "45","Cancer ","Cystectomy","75-80 ",77.2,1,162
47 | "46","Cancer ","Cystectomy","75-80 ",77.2,0,2784
48 | "47","Cancer ","Cystectomy","80-85 ",82,1,44
49 | "48","Cancer ","Cystectomy","80-85 ",82,0,545
50 | "49","Cancer ","Cystectomy","85-99 ",90,1,14
51 | "50","Cancer ","Cystectomy","85-99 ",90,0,134
52 | "51","CVD ","Endarterectomy","65-69 ",67.5,1,1385
53 | "52","CVD ","Endarterectomy","65-69 ",67.5,0,137115
54 | "53","CVD ","Endarterectomy","70-74 ",72.5,1,1016
55 | "54","CVD ","Endarterectomy","70-74 ",72.5,0,91317
56 | "55","CVD ","Endarterectomy","75-80 ",77.2,1,862
57 | "56","CVD ","Endarterectomy","75-80 ",77.2,0,60694
58 | "57","CVD ","Endarterectomy","80-85 ",82,1,209
59 | "58","CVD ","Endarterectomy","80-85 ",82,0,12102
60 | "59","CVD ","Endarterectomy","85-99 ",90,1,71
61 | "60","CVD ","Endarterectomy","85-99 ",90,0,3007
62 | "61","Cancer ","Esophagectomy","65-69 ",67.5,1,196
63 | "62","Cancer ","Esophagectomy","65-69 ",67.5,0,1640
64 | "63","Cancer ","Esophagectomy","70-74 ",72.5,1,163
65 | "64","Cancer ","Esophagectomy","70-74 ",72.5,0,1061
66 | "65","Cancer ","Esophagectomy","75-80 ",77.2,1,139
67 | "66","Cancer ","Esophagectomy","75-80 ",77.2,0,677
68 | "67","Cancer ","Esophagectomy","80-85 ",82,1,31
69 | "68","Cancer ","Esophagectomy","80-85 ",82,0,132
70 | "69","Cancer ","Esophagectomy","85-99 ",90,1,10
71 | "70","Cancer ","Esophagectomy","85-99 ",90,0,31
72 | "71","Cancer ","Gastrectomy","65-69 ",67.5,1,437
73 | "72","Cancer ","Gastrectomy","65-69 ",67.5,0,6609
74 | "73","Cancer ","Gastrectomy","70-74 ",72.5,1,333
75 | "74","Cancer ","Gastrectomy","70-74 ",72.5,0,4364
76 | "75","Cancer ","Gastrectomy","75-80 ",77.2,1,279
77 | "76","Cancer ","Gastrectomy","75-80 ",77.2,0,2853
78 | "77","Cancer ","Gastrectomy","80-85 ",82,1,65
79 | "78","Cancer ","Gastrectomy","80-85 ",82,0,562
80 | "79","Cancer ","Gastrectomy","85-99 ",90,1,26
81 | "80","Cancer ","Gastrectomy","85-99 ",90,0,131
82 | "81","CVD ","Lower-extremity bypass","65-69 ",67.5,1,1400
83 | "82","CVD ","Lower-extremity bypass","65-69 ",67.5,0,68609
84 | "83","CVD ","Lower-extremity bypass","70-74 ",72.5,1,1213
85 | "84","CVD ","Lower-extremity bypass","70-74 ",72.5,0,45459
86 | "85","CVD ","Lower-extremity bypass","75-80 ",77.2,1,1058
87 | "86","CVD ","Lower-extremity bypass","75-80 ",77.2,0,30057
88 | "87","CVD ","Lower-extremity bypass","80-85 ",82,1,280
89 | "88","CVD ","Lower-extremity bypass","80-85 ",82,0,5943
90 | "89","CVD ","Lower-extremity bypass","85-99 ",90,1,109
91 | "90","CVD ","Lower-extremity bypass","85-99 ",90,0,1447
92 | "91","CVD ","Mitral valve","65-69 ",67.5,1,893
93 | "92","CVD ","Mitral valve","65-69 ",67.5,0,11343
94 | "93","CVD ","Mitral valve","70-74 ",72.5,1,783
95 | "94","CVD ","Mitral valve","70-74 ",72.5,0,7374
96 | "95","CVD ","Mitral valve","75-80 ",77.2,1,669
97 | "96","CVD ","Mitral valve","75-80 ",77.2,0,4769
98 | "97","CVD ","Mitral valve","80-85 ",82,1,171
99 | "98","CVD ","Mitral valve","80-85 ",82,0,917
100 | "99","CVD ","Mitral valve","85-99 ",90,1,57
101 | "100","CVD ","Mitral valve","85-99 ",90,0,215
102 | "101","Cancer ","Nephrectomy","65-69 ",67.5,1,193
103 | "102","Cancer ","Nephrectomy","65-69 ",67.5,0,15902
104 | "103","Cancer ","Nephrectomy","70-74 ",72.5,1,182
105 | "104","Cancer ","Nephrectomy","70-74 ",72.5,0,10548
106 | "105","Cancer ","Nephrectomy","75-80 ",77.2,1,207
107 | "106","Cancer ","Nephrectomy","75-80 ",77.2,0,6946
108 | "107","Cancer ","Nephrectomy","80-85 ",82,1,43
109 | "108","Cancer ","Nephrectomy","80-85 ",82,0,1388
110 | "109","Cancer ","Nephrectomy","85-99 ",90,1,18
111 | "110","Cancer ","Nephrectomy","85-99 ",90,0,339
112 | "111","Cancer ","Pancreatic resection","65-69 ",67.5,1,166
113 | "112","Cancer ","Pancreatic resection","65-69 ",67.5,0,2178
114 | "113","Cancer ","Pancreatic resection","70-74 ",72.5,1,127
115 | "114","Cancer ","Pancreatic resection","70-74 ",72.5,0,1436
116 | "115","Cancer ","Pancreatic resection","75-80 ",77.2,1,124
117 | "116","Cancer ","Pancreatic resection","75-80 ",77.2,0,918
118 | "117","Cancer ","Pancreatic resection","80-85 ",82,1,29
119 | "118","Cancer ","Pancreatic resection","80-85 ",82,0,179
120 | "119","Cancer ","Pancreatic resection","85-99 ",90,1,7
121 | "120","Cancer ","Pancreatic resection","85-99 ",90,0,46
122 | "121","Cancer ","Pneumonectomy","65-69 ",67.5,1,364
123 | "122","Cancer ","Pneumonectomy","65-69 ",67.5,0,2721
124 | "123","Cancer ","Pneumonectomy","70-74 ",72.5,1,276
125 | "124","Cancer ","Pneumonectomy","70-74 ",72.5,0,1781
126 | "125","Cancer ","Pneumonectomy","75-80 ",77.2,1,219
127 | "126","Cancer ","Pneumonectomy","75-80 ",77.2,0,1152
128 | "127","Cancer ","Pneumonectomy","80-85 ",82,1,59
129 | "128","Cancer ","Pneumonectomy","80-85 ",82,0,215
130 | "129","Cancer ","Pneumonectomy","85-99 ",90,1,31
131 | "130","Cancer ","Pneumonectomy","85-99 ",90,0,38
132 | "131","Cancer ","Pulmonary lobectomy","65-69 ",67.5,1,822
133 | "132","Cancer ","Pulmonary lobectomy","65-69 ",67.5,0,22006
134 | "133","Cancer ","Pulmonary lobectomy","70-74 ",72.5,1,730
135 | "134","Cancer ","Pulmonary lobectomy","70-74 ",72.5,0,14488
136 | "135","Cancer ","Pulmonary lobectomy","75-80 ",77.2,1,619
137 | "136","Cancer ","Pulmonary lobectomy","75-80 ",77.2,0,9527
138 | "137","Cancer ","Pulmonary lobectomy","80-85 ",82,1,142
139 | "138","Cancer ","Pulmonary lobectomy","80-85 ",82,0,1887
140 | "139","Cancer ","Pulmonary lobectomy","85-99 ",90,1,46
141 | "140","Cancer ","Pulmonary lobectomy","85-99 ",90,0,462
142 |
--------------------------------------------------------------------------------
/R/auc.nonpara.mw.R:
--------------------------------------------------------------------------------
1 | # get the auc through Mann-Whitney statistics
2 | # References:
3 | # Comparing the Areas under Two or More
4 | # Correlated Receiver Operating Characteristic Curves:
5 | # A Nonparametric Approach
6 | # Author(s): Elizabeth R. DeLong, David M. DeLong and Daniel L. Clarke-Pearson
7 | # Source: Biometrics, Vol. 44, No. 3 (Sep., 1988), pp. 837-845
8 |
9 | # STATISTICS IN MEDICINE
10 | # Statist. Med. 2006; 25:559-573
11 | # Confidence intervals for an effect size measure based on
12 | # the Mann-Whitney statistic. Part 2: Asymptotic methods
13 | # and evaluation
14 | # Robert G. Newcombe
15 |
16 | # x: the scores of subjects from class P
17 | # y: the scores of subjects from class N
18 | # alpha: type I error
19 |
20 | # NOTE: the larger the score, the more likely a subject is from class P
21 |
22 |
23 | getAUCmw <- function(x, y) {
24 | xy <- expand.grid(x, y)
25 | mean(ifelse(xy[, 2] < xy[, 1], 1, (ifelse(xy[, 2] == xy[, 1], 1 / 2, 0))))
26 | }
27 |
28 | # get the variance V_2(\theta) from method 4 of Newcombe 2006
29 | getVARmw <- function(theta, m, n) {
30 | nstar <- mstar <- (m + n) / 2 - 1
31 | theta *
32 | (1 - theta) *
33 | (1 + nstar * (1 - theta) / (2 - theta) + mstar * theta / (1 + theta)) /
34 | (m * n)
35 | }
36 |
37 | # note that here x < y
38 | # m is the length of x and n is the length of y
39 | getS2mw <- function(x, y, m, n) {
40 | xi <- sort(x)
41 | yj <- sort(y)
42 | rxy <- rank(c(xi, yj))
43 | Ri <- rxy[1:m]
44 | Sj <- rxy[m + 1:n]
45 | S102 <- 1 / ((m - 1) * n^2) * (sum((Ri - 1:m)^2) - m * (mean(Ri) - (m + 1) / 2)^2)
46 | S012 <- 1 / ((n - 1) * m^2) * (sum((Sj - 1:n)^2) - n * (mean(Sj) - (n + 1) / 2)^2)
47 | S2 <- (m * S012 + n * S102) / (m + n)
48 | S2
49 | }
50 |
51 |
52 | # get the CI by method 5 of Newcombe 2006
53 | getAUCCImwu <- function(hat.theta, zalpha, m, n) {
54 | nstar <- mstar <- (m + n) / 2 - 1
55 |
56 | a <- -1 - nstar - mstar
57 | b <- 1 + 2 * mstar
58 | c <- 2 + nstar
59 | d <- 1 + 2 * hat.theta
60 | ht2 <- hat.theta^2
61 | e <- 2 - 2 * hat.theta - ht2
62 | f <- ht2 - 4 * hat.theta
63 | g <- 2 * ht2
64 |
65 | z2 <- zalpha^2
66 | mn <- m * n
67 | z5 <- -mn + z2 * a
68 | z4 <- mn * d - z2 * (a - b)
69 | z3 <- mn * e - z2 * (b - c)
70 | z2 <- mn * f - z2 * c
71 | z1 <- mn * g
72 |
73 | roots <- polyroot(c(z1, z2, z3, z4, z5))
74 | real <- Re(roots[sapply(1:4, function(i) all.equal(Im(roots[i]), 0))])
75 | real <- real[real > 0 & real < 1]
76 | ci <- sort(real)
77 | if (length(ci) > 2) {
78 | warning("There are three roots meet the requirement when computing
79 | the confidence interval.")
80 | } else {
81 | if (length(real) == 1) {
82 | if (real <= hat.theta) {
83 | ci <- c(real, 1)
84 | }
85 | else {
86 | ci <- c(0, real)
87 | }
88 | }
89 | if (length(real) == 0) {
90 | ci <- c(0, 1)
91 | }
92 | }
93 | ci
94 | }
95 |
96 |
97 |
98 | # get the CI by method 5 of Newcombe 2006
99 | auc.mw.newcombe <- function(x, y, alpha) {
100 | point <- getAUCmw(x, y)
101 | nx <- length(x)
102 | ny <- length(y)
103 | zalpha <- qnorm(1 - alpha / 2)
104 | ci <- getAUCCImwu(point, zalpha, ny, nx)
105 |
106 | c(point, ci)
107 | }
108 |
109 | auc.mw.zhou <- function(x, y, alpha) {
110 | if (max(y) < min(x)) {
111 | c(1, 1, 1)
112 | }
113 | else {
114 | point <- getAUCmw(x, y)
115 | nx <- length(x)
116 | ny <- length(y)
117 | zalpha <- qnorm(1 - alpha / 2)
118 | varHatTheta <- getVARmw(point, nx, ny)
119 |
120 | Z <- 1 / 2 * log((1 + point) / (1 - point))
121 | varZ <- 4 / (1 - point^2)^2 * varHatTheta
122 | LL <- Z - zalpha * sqrt(varZ)
123 | UL <- Z + zalpha * sqrt(varZ)
124 | ci <- c((exp(2 * LL) - 1) / (exp(2 * LL) + 1), (exp(2 * UL) - 1) / (exp(2 * UL) + 1))
125 |
126 | c(point, ci)
127 | }
128 | }
129 |
130 | auc.mw.pepe <- function(x, y, alpha) {
131 | if (max(y) < min(x)) {
132 | c(1, 1, 1)
133 | }
134 | else {
135 | point <- getAUCmw(x, y)
136 | nx <- length(x)
137 | ny <- length(y)
138 | zalpha <- qnorm(1 - alpha / 2)
139 |
140 | varHatTheta <- (nx + ny) * getS2mw(y, x, ny, nx) / (nx * ny)
141 | # varHatTheta <- getVARmw(point,nx, ny)
142 | LL <- log(point / (1 - point)) - zalpha * sqrt(varHatTheta) / (point * (1 - point))
143 | UL <- log(point / (1 - point)) + zalpha * sqrt(varHatTheta) / (point * (1 - point))
144 | ci <- c(exp(LL) / (1 + exp(LL)), exp(UL) / (1 + exp(UL)))
145 |
146 | c(point, ci)
147 | }
148 | }
149 |
150 | auc.mw.delong <- function(x, y, alpha) {
151 | point <- getAUCmw(x, y)
152 | nx <- length(x)
153 | ny <- length(y)
154 | zalpha <- qnorm(1 - alpha / 2)
155 |
156 | D10 <- sapply(1:ny, function(i) {
157 | mean(ifelse(x > y[i], 1, ifelse(x == y[i], 1 / 2, 0)))
158 | })
159 | D01 <- sapply(1:nx, function(i) {
160 | mean(ifelse(x[i] > y, 1, ifelse(x[i] == y, 1 / 2, 0)))
161 | })
162 | varDhatTheta <- 1 / (ny * (ny - 1)) * sum((D10 - point)^2) +
163 | 1 / (nx * (nx - 1)) * sum((D01 - point)^2)
164 | ci <- c(
165 | point - zalpha * sqrt(varDhatTheta),
166 | point + zalpha * sqrt(varDhatTheta)
167 | )
168 |
169 | c(point, ci)
170 | }
171 |
172 | mw.jackknife <- function(x, y) {
173 | nx <- length(x)
174 | ny <- length(y)
175 | n <- nx + ny
176 |
177 | hatThetaPartial <- rep(0, n)
178 |
179 | for (i in 1:nx) {
180 | hatThetaPartial[i] <- getAUCmw(x[-i], y)
181 | }
182 | for (i in 1:ny) {
183 | hatThetaPartial[i + nx] <- getAUCmw(x, y[-i])
184 | }
185 |
186 | hatThetaPartial
187 | }
188 |
189 | auc.mw.jackknife <- function(x, y, alpha) {
190 | nx <- length(x)
191 | ny <- length(y)
192 | n <- nx + ny
193 |
194 | hatTheta <- getAUCmw(x, y)
195 |
196 | hatThetaPseudo <- rep(0, n)
197 |
198 | hatThetaPartial <- mw.jackknife(x, y)
199 |
200 | for (i in 1:n) {
201 | hatThetaPseudo[i] <- n * hatTheta - (n - 1) * hatThetaPartial[i]
202 | }
203 |
204 | point <- mean(hatThetaPseudo)
205 | ST2 <- mean((hatThetaPseudo - point)^2) / (n - 1)
206 | ST <- sqrt(ST2)
207 | z.alpha2 <- qt(1 - alpha / 2, df = n - 1)
208 | ci <- c(point - z.alpha2 * ST, point + z.alpha2 * ST)
209 |
210 | c(point, ci)
211 | }
212 |
213 | auc.mw.boot <- function(x, y, alpha, nboot = 1000, method) {
214 | if (max(y) < min(x)) {
215 | c(1, 1, 1)
216 | }
217 | else {
218 | nx <- length(x)
219 | ny <- length(y)
220 |
221 | point <- getAUCmw(x, y)
222 | index.x <- matrix(
223 | sample.int(nx, size = nx * nboot, replace = TRUE),
224 | nboot, nx
225 | )
226 | index.y <- matrix(
227 | sample.int(ny, size = ny * nboot, replace = TRUE),
228 | nboot, ny
229 | )
230 | mw.boot <- sapply(1:nboot, function(i) {
231 | getAUCmw(
232 | x[index.x[i, ]],
233 | y[index.y[i, ]]
234 | )
235 | })
236 | if (method == "P") {
237 | ci <- as.vector(quantile(mw.boot, c(alpha / 2, 1 - alpha / 2), type = 6))
238 | }
239 | else {
240 | hatZ0 <- qnorm(mean(mw.boot < point))
241 |
242 | partial <- mw.jackknife(x, y)
243 | mpartial <- mean(partial)
244 | hatA <- sum((mpartial - partial)^3) /
245 | (6 * (sum((mpartial - partial)^2))^(3 / 2))
246 |
247 | alpha1 <- pnorm(hatZ0 + (hatZ0 + qnorm(alpha / 2)) /
248 | (1 - hatA * (hatZ0 + qnorm(alpha / 2))))
249 | alpha2 <- pnorm(hatZ0 + (hatZ0 + qnorm(1 - alpha / 2)) /
250 | (1 - hatA * (hatZ0 + qnorm(1 - alpha / 2))))
251 |
252 | ci <- as.vector(quantile(mw.boot, c(alpha1, alpha2), type = 6))
253 | }
254 | c(point, ci)
255 | }
256 | }
257 |
258 | auc.nonpara.mw <- function(x, y, conf.level = 0.95,
259 | method = c("newcombe", "pepe", "delong", "jackknife", "bootstrapP", "bootstrapBCa"),
260 | nboot) {
261 | alpha <- 1 - conf.level
262 | method <- match.arg(method)
263 | estimate <- switch(method,
264 | newcombe = auc.mw.newcombe(x, y, alpha),
265 | pepe = auc.mw.pepe(x, y, alpha),
266 | delong = auc.mw.delong(x, y, alpha),
267 | jackknife = auc.mw.jackknife(x, y, alpha),
268 | bootstrapP = auc.mw.boot(x, y, alpha, nboot, method = "P"),
269 | bootstrapBCa = auc.mw.boot(x, y, alpha, nboot, method = "BCa")
270 | )
271 | estimate
272 | }
273 |
--------------------------------------------------------------------------------
/data/AAA.csv:
--------------------------------------------------------------------------------
1 | "","SEX","AGE10","MI","CHF","ISCHEMIA","LUNG","RENAL","STATUS"
2 | "1",0,4.3,0,0,0,0,0,0
3 | "2",0,4.5,0,0,0,0,0,0
4 | "3",0,4.9,0,0,0,0,0,0
5 | "4",0,5,0,0,0,0,0,0
6 | "5",0,5.4,0,0,0,0,0,0
7 | "6",1,5.5,0,0,0,0,0,0
8 | "7",1,5.5,0,0,0,0,0,0
9 | "8",0,5.59999990463257,0,0,0,0,0,0
10 | "9",0,5.59999990463257,0,0,0,0,0,0
11 | "10",0,5.59999990463257,0,0,0,0,0,0
12 | "11",0,5.6,0,0,0,0,0,0
13 | "12",0,5.69999980926514,0,0,0,0,0,0
14 | "13",0,5.69999980926514,0,0,0,0,0,0
15 | "14",0,5.7,0,0,0,0,0,0
16 | "15",0,5.8,0,0,0,0,0,0
17 | "16",0,5.80000019073486,0,0,0,0,0,0
18 | "17",0,5.80000019073486,0,0,0,0,0,0
19 | "18",0,5.9,0,0,0,0,0,0
20 | "19",0,5.9,0,0,0,0,0,0
21 | "20",0,5.90000009536743,0,0,0,0,0,0
22 | "21",0,5.90000009536743,0,0,0,0,0,0
23 | "22",0,5.90000009536743,0,0,0,0,0,0
24 | "23",0,5.90000009536743,0,0,0,0,0,0
25 | "24",0,4.90000009536743,0,0,0,1,0,0
26 | "25",0,6,0,0,0,0,0,0
27 | "26",0,6,0,0,0,0,0,0
28 | "27",0,6,0,0,0,0,0,0
29 | "28",0,6.09999990463257,0,0,0,0,0,0
30 | "29",0,6.09999990463257,0,0,0,0,0,0
31 | "30",0,6.09999990463257,0,0,0,0,0,0
32 | "31",0,6.09999990463257,0,0,0,0,0,0
33 | "32",0,6.19999980926514,0,0,0,0,0,0
34 | "33",0,6.19999980926514,0,0,0,0,0,0
35 | "34",0,6.2,0,0,0,0,0,0
36 | "35",0,6.2,0,0,0,0,0,0
37 | "36",0,6.3,0,0,0,0,0,0
38 | "37",0,6.3,0,0,0,0,0,0
39 | "38",1,6.30000019073486,0,0,0,0,0,0
40 | "39",0,6.30000019073486,0,0,0,0,0,0
41 | "40",0,6.4,0,0,0,0,0,0
42 | "41",0,6.4,0,0,0,0,0,0
43 | "42",0,6.40000009536743,0,0,0,0,0,0
44 | "43",0,6.40000009536743,0,0,0,0,0,0
45 | "44",0,6.40000009536743,0,0,0,0,0,0
46 | "45",0,6.40000009536743,0,0,0,0,0,0
47 | "46",0,6.40000009536743,0,0,0,0,0,0
48 | "47",0,6.40000009536743,0,0,0,0,0,0
49 | "48",0,6.40000009536743,0,0,0,0,0,0
50 | "49",0,6.40000009536743,0,0,0,0,0,0
51 | "50",0,6.40000009536743,0,0,0,0,0,0
52 | "51",1,5.40000009536743,0,0,0,1,0,0
53 | "52",0,6.5,0,0,0,0,0,0
54 | "53",0,6.5,0,0,0,0,0,0
55 | "54",0,6.5,0,0,0,0,0,0
56 | "55",0,6.59999990463257,0,0,0,0,0,0
57 | "56",0,6.59999990463257,0,0,0,0,0,0
58 | "57",0,6.59999990463257,0,0,0,0,0,0
59 | "58",1,6.59999990463257,0,0,0,0,0,0
60 | "59",0,6.6,0,0,0,0,0,0
61 | "60",0,6.69999980926514,0,0,0,0,0,0
62 | "61",0,6.69999980926514,0,0,0,0,0,0
63 | "62",0,6.7,0,0,0,0,0,0
64 | "63",1,6.8,0,0,0,0,0,0
65 | "64",0,6.80000019073486,0,0,0,0,0,0
66 | "65",0,6.90000009536743,0,0,0,0,0,0
67 | "66",0,6.90000009536743,0,0,0,0,0,0
68 | "67",0,6.90000009536743,0,0,0,0,0,0
69 | "68",0,5.19999980926514,0,1,0,0,0,0
70 | "69",0,7,0,0,0,0,0,0
71 | "70",1,7,0,0,0,0,0,0
72 | "71",0,7,0,0,0,0,0,0
73 | "72",0,7,0,0,0,0,0,0
74 | "73",0,7,0,0,0,0,0,0
75 | "74",0,7,0,0,0,0,0,0
76 | "75",0,6,0,0,0,1,0,0
77 | "76",0,7.09999990463257,0,0,0,0,0,0
78 | "77",1,7.09999990463257,0,0,0,0,0,0
79 | "78",0,7.09999990463257,0,0,0,0,0,0
80 | "79",0,7.09999990463257,0,0,0,0,0,0
81 | "80",0,7.1,0,0,0,0,0,0
82 | "81",0,7.1,0,0,0,0,0,0
83 | "82",0,7.1,0,0,0,0,0,0
84 | "83",0,7.1,0,0,0,0,0,0
85 | "84",0,5.4,0,0,1,0,0,0
86 | "85",0,6.09999990463257,0,0,0,1,0,0
87 | "86",0,7.19999980926514,0,0,0,0,0,0
88 | "87",0,7.2,0,0,0,0,0,0
89 | "88",0,5,1,0,0,1,0,0
90 | "89",0,5.5,0,1,0,0,0,0
91 | "90",0,7.3,0,0,0,0,0,0
92 | "91",1,7.30000019073486,0,0,0,0,0,0
93 | "92",0,7.30000019073486,0,0,0,0,0,0
94 | "93",0,7.30000019073486,0,0,0,0,0,0
95 | "94",0,7.30000019073486,0,0,0,0,0,0
96 | "95",0,7.30000019073486,0,0,0,0,0,0
97 | "96",0,5.59999990463257,0,0,1,0,0,0
98 | "97",0,6.30000019073486,0,0,0,1,0,0
99 | "98",0,7.40000009536743,0,0,0,0,0,0
100 | "99",0,7.5,0,0,0,0,0,0
101 | "100",0,7.5,0,0,0,0,0,0
102 | "101",0,5.80000019073486,0,0,1,0,0,0
103 | "102",0,6.3,1,0,0,0,0,0
104 | "103",0,5.80000019073486,0,1,0,0,0,0
105 | "104",1,7.6,0,0,0,0,0,0
106 | "105",0,5.90000009536743,0,0,1,0,0,0
107 | "106",0,5.69999980926514,0,0,0,0,1,0
108 | "107",0,6.09999990463257,0,0,1,0,0,1
109 | "108",0,6.09999990463257,0,0,1,0,0,0
110 | "109",0,6.1,0,0,1,0,0,0
111 | "110",0,6.80000019073486,0,0,0,1,0,0
112 | "111",0,6.59999990463257,1,0,0,0,0,0
113 | "112",0,6.09999990463257,0,1,0,0,0,0
114 | "113",0,7.9,0,0,0,0,0,0
115 | "114",0,7.9,0,0,0,0,0,0
116 | "115",0,5,1,0,1,0,0,0
117 | "116",0,8,0,0,0,0,0,0
118 | "117",0,7,0,0,0,1,0,0
119 | "118",0,7,0,0,0,1,0,0
120 | "119",0,7,0,0,0,1,0,0
121 | "120",0,6.8,1,0,0,0,0,0
122 | "121",1,6.30000019073486,0,1,0,0,0,0
123 | "122",0,6.30000019073486,0,1,0,0,0,0
124 | "123",0,7.1,0,0,0,1,0,0
125 | "124",0,6.40000009536743,0,1,0,0,0,0
126 | "125",0,6.40000009536743,0,1,0,0,0,0
127 | "126",0,6.5,0,0,1,0,0,0
128 | "127",0,6.59999990463257,0,0,1,0,0,0
129 | "128",0,6.59999990463257,0,0,1,0,0,0
130 | "129",0,6.59999990463257,0,1,0,0,0,0
131 | "130",0,6.69999980926514,0,0,1,0,0,0
132 | "131",0,6.69999980926514,0,0,1,0,0,0
133 | "132",0,6.5,0,0,0,0,1,0
134 | "133",0,5.59999990463257,0,1,0,1,0,0
135 | "134",0,5.69999980926514,0,1,0,1,0,0
136 | "135",1,6.80000019073486,0,1,0,0,0,0
137 | "136",0,6.9,0,0,1,0,0,0
138 | "137",1,7.59999990463257,0,0,0,1,0,0
139 | "138",0,7.4,1,0,0,0,0,0
140 | "139",0,5.90000009536743,0,0,1,1,0,0
141 | "140",0,6.40000009536743,1,0,0,1,0,0
142 | "141",0,6.90000009536743,0,1,0,0,0,0
143 | "142",1,7,0,0,1,0,0,1
144 | "143",0,7.69999980926514,0,0,0,1,0,1
145 | "144",0,5.80000019073486,1,0,1,0,0,0
146 | "145",0,7,0,1,0,0,0,0
147 | "146",0,7.09999990463257,0,0,1,0,0,0
148 | "147",0,5.90000009536743,1,0,1,0,0,1
149 | "148",0,7.09999990463257,0,1,0,0,0,0
150 | "149",0,7.09999990463257,0,1,0,0,0,0
151 | "150",0,7.19999980926514,0,0,1,0,0,0
152 | "151",0,7.2,0,0,1,0,0,0
153 | "152",0,6,1,0,1,0,0,0
154 | "153",0,7.19999980926514,0,1,0,0,0,0
155 | "154",0,5.5,0,1,1,0,0,0
156 | "155",0,6.09999990463257,0,0,0,1,1,0
157 | "156",0,6.80000019073486,1,0,0,1,0,0
158 | "157",0,7.90000009536743,1,0,0,0,0,0
159 | "158",0,5.69999980926514,0,1,1,0,0,0
160 | "159",0,5.5,0,1,0,0,1,0
161 | "160",0,8.2,0,0,0,1,0,0
162 | "161",0,7.5,0,1,0,0,0,0
163 | "162",0,7.5,0,1,0,0,0,0
164 | "163",0,7.5,0,1,0,0,0,0
165 | "164",0,6.40000009536743,1,0,1,0,0,0
166 | "165",0,6.69999980926514,0,0,1,1,0,0
167 | "166",1,6.69999980926514,0,1,0,1,0,0
168 | "167",0,6.8,0,0,1,1,0,0
169 | "168",1,6.6,1,0,1,0,0,0
170 | "169",0,6.80000019073486,0,1,0,1,0,1
171 | "170",0,6.90000009536743,0,0,1,1,0,0
172 | "171",1,6.69999980926514,1,0,1,0,0,0
173 | "172",0,6.80000019073486,0,0,0,1,1,0
174 | "173",0,7,0,1,0,1,0,0
175 | "174",0,7,0,1,0,1,0,0
176 | "175",0,6.9,1,0,1,0,0,0
177 | "176",0,6.40000009536743,0,1,1,0,0,1
178 | "177",0,6.5,0,1,1,0,0,0
179 | "178",0,7.09999990463257,1,0,1,0,0,0
180 | "179",0,6.59999990463257,0,1,1,0,0,0
181 | "180",0,7.30000019073486,0,1,0,1,0,1
182 | "181",0,7.30000019073486,0,1,0,1,0,0
183 | "182",0,7.09999990463257,1,1,0,0,0,0
184 | "183",0,5.40000009536743,1,1,1,0,0,0
185 | "184",0,5.40000009536743,1,1,1,0,0,0
186 | "185",0,7.2,1,0,1,0,0,0
187 | "186",0,7.2,1,0,1,0,0,0
188 | "187",0,7.30000019073486,1,0,1,0,0,0
189 | "188",0,7.09999990463257,1,0,0,0,1,0
190 | "189",0,5.59999990463257,1,1,1,0,0,0
191 | "190",0,7.40000009536743,1,0,1,0,0,0
192 | "191",0,6.9,0,1,1,0,0,0
193 | "192",0,7.40000009536743,1,1,0,0,0,1
194 | "193",0,7.5,1,0,1,0,0,0
195 | "194",0,5.80000019073486,1,1,1,0,0,1
196 | "195",0,7.69999980926514,1,1,0,0,0,1
197 | "196",0,6.69999980926514,1,1,0,1,0,0
198 | "197",0,7.09999990463257,0,1,0,0,1,0
199 | "198",0,7.40000009536743,0,1,1,0,0,0
200 | "199",0,5.5,0,1,1,0,1,0
201 | "200",0,7.5,0,1,1,0,0,0
202 | "201",0,7,1,1,0,1,0,0
203 | "202",0,6.59999990463257,0,1,1,1,0,0
204 | "203",0,7.69999980926514,0,1,1,0,0,0
205 | "204",0,6.69999980926514,0,1,1,1,0,0
206 | "205",0,6.5,1,1,1,0,0,0
207 | "206",0,7.30000019073486,1,0,1,1,0,0
208 | "207",1,7.80000019073486,0,1,1,0,0,0
209 | "208",0,6.59999990463257,1,1,1,0,0,1
210 | "209",0,7.90000009536743,0,1,1,0,0,0
211 | "210",0,7.90000009536743,0,1,1,0,0,0
212 | "211",0,8,0,1,1,0,0,0
213 | "212",0,6.80000019073486,1,1,1,0,0,0
214 | "213",0,6.80000019073486,1,1,1,0,0,0
215 | "214",0,6.80000019073486,1,1,1,0,0,0
216 | "215",0,5.90000009536743,1,1,1,1,0,0
217 | "216",0,7.69999980926514,1,0,1,1,0,0
218 | "217",0,7.2,0,1,1,1,0,0
219 | "218",0,7,1,1,1,0,0,0
220 | "219",0,6.80000019073486,1,1,0,0,1,0
221 | "220",0,7.1,1,1,1,0,0,0
222 | "221",0,7.30000019073486,1,1,1,0,0,0
223 | "222",0,7.09999990463257,1,1,0,0,1,0
224 | "223",1,6.69999980926514,0,1,1,0,1,1
225 | "224",0,7.4,1,1,1,0,0,1
226 | "225",0,7.4,1,0,1,0,1,1
227 | "226",0,7.59999990463257,1,1,1,0,0,0
228 | "227",1,7.7,1,1,1,0,0,0
229 | "228",0,7.09999990463257,0,1,1,0,1,0
230 | "229",0,8,1,1,1,0,0,0
231 | "230",1,7,1,1,1,1,0,0
232 | "231",0,7.09999990463257,1,1,1,1,0,1
233 | "232",0,6.30000019073486,1,1,1,0,1,0
234 | "233",0,7.19999980926514,1,1,1,1,0,0
235 | "234",0,7.30000019073486,1,1,1,1,0,1
236 | "235",0,8.39999961853027,1,1,1,0,0,1
237 | "236",0,7.59999990463257,1,1,1,1,0,0
238 | "237",0,8,1,1,1,1,0,0
239 | "238",0,8.39999961853027,0,1,1,1,1,1
240 |
--------------------------------------------------------------------------------
/docs/site_libs/clipboard/clipboard.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * clipboard.js v2.0.11
3 | * https://clipboardjs.com/
4 | *
5 | * Licensed MIT © Zeno Rocha
6 | */
7 | !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ClipboardJS=e():t.ClipboardJS=e()}(this,function(){return n={686:function(t,e,n){"use strict";n.d(e,{default:function(){return b}});var e=n(279),i=n.n(e),e=n(370),u=n.n(e),e=n(817),r=n.n(e);function c(t){try{return document.execCommand(t)}catch(t){return}}var a=function(t){t=r()(t);return c("cut"),t};function o(t,e){var n,o,t=(n=t,o="rtl"===document.documentElement.getAttribute("dir"),(t=document.createElement("textarea")).style.fontSize="12pt",t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px",o=window.pageYOffset||document.documentElement.scrollTop,t.style.top="".concat(o,"px"),t.setAttribute("readonly",""),t.value=n,t);return e.container.appendChild(t),e=r()(t),c("copy"),t.remove(),e}var f=function(t){var e=113500) in all fits. Age is als relevant (chi2>3000), and a square term is not needed (chi2 = 2); the interaction adds a little bit (chi2 95). With these large numbers (1.1M patients), most effects have p<.0001.
154 |
155 | We will evaluate the differences between fits with or without interaction term graphically further down
156 |
157 | ```{r echo=T}
158 | # Look for model improvements
159 | anova(fitplot2) # linear age effect, no interaction with surgery
160 | anova(fitage2) # age square added
161 | anova(fitplot) # interaction added to linear age effect
162 | ```
163 |
164 | ### Plotting of predicted age effects, with interaction by type of surgery; add 95% CI {-}
165 |
166 | Plot age effects at logodds scale with 95% CI
167 |
168 | ```{r echo=F}
169 | plot(Predict(fitplot, age = 65:100, surgery = NA),
170 | ylab = "Mortality",
171 | par.settings = list(superpose.line = list(col = mycolors[c(2:10, 2:6)]))
172 | )
173 | ```
174 |
175 | ### Plotting of age effects with original data points {-}
176 |
177 | Fit with interaction (solid lines) and no interaction (dashed lines)
178 |
179 | ```{r echo=F}
180 | # Points
181 | Fsum <- aggregate(data = Fmort, w ~ age + surgery, sum) # total N
182 | Fdead <- aggregate(data = Fmort, w ~ age + surgery, min) # N dead
183 | Fsum$mort <- Fdead[, 3] / Fsum[, 3] # mortality per group
184 | Fsum$dead <- Fdead[, 3]
185 | Fsum$lmort <- log(Fsum$mort / (1 - Fsum$mort))
186 |
187 | # Interaction fit
188 | Fmort$surgery <- as.factor(Fmort$surgery)
189 | fit.mat <- Predict(fitplot, age = 65:100, surgery = levels(Fmort$surgery))
190 | # Main effect fit
191 | fit.mat2 <- Predict(fitplot2, age = 65:100, surgery = levels(Fmort$surgery))
192 |
193 | # Do some advanced lattice plotting
194 | foo_key <- list(
195 | corner = c(1, 1), x = 80, y = -1,
196 | text = list(lab = c("Observed", "Age interaction", "Common age effect")),
197 | points = list(pch = c(16, NA, NA), cex = c(2, NA, NA), col = c("red", "red", "black")),
198 | lines = list(type = c("p", "l", "l"), pch = 16, lty = c(0, 1, 2), lwd = 3, col = c("red", "red", "black"))
199 | )
200 |
201 |
202 | plot1 <- xyplot(lmort ~ age | surgery,
203 | groups = surgery, Fsum, ylim = c(-4.7, -0.8),
204 | ylab = "logit(mortality)", xlab = "Age (years)", xlim = c(64, 92),
205 | par.settings = list(
206 | superpose.symbol = list(pch = 16, cex = 1, col = mycolors[c(2:10, 2:6)]),
207 | par.ylab.text = list(cex = 1.2), par.xlab.text = list(cex = 1.2)
208 | )
209 | )
210 |
211 | plot2 <- xyplot(yhat ~ age | surgery,
212 | groups = surgery, fit.mat, type = "l",
213 | ylab = "logit(mortality)", xlab = "Age (years)", xlim = c(64, 92),
214 | par.settings = list(
215 | superpose.line = list(lwd = 3, col = mycolors[c(2:10, 2:6)]),
216 | par.ylab.text = list(cex = 1.2), par.xlab.text = list(cex = 1.2)
217 | )
218 | )
219 |
220 | plot3 <- xyplot(yhat ~ age | surgery,
221 | groups = surgery, fit.mat2, type = "l",
222 | ylab = "logit(mortality)", xlab = "Age (years)", xlim = c(64, 92),
223 | par.settings = list(
224 | superpose.line = list(lwd = 2, lty = 2, col = "black"),
225 | par.ylab.text = list(cex = 1.2), par.xlab.text = list(cex = 1.2)
226 | )
227 | )
228 |
229 | # all three overlayed
230 | plot1 + plot2 + plot3
231 | ```
232 |
233 |
--------------------------------------------------------------------------------
/chapters/08-case-study-missing.qmd:
--------------------------------------------------------------------------------
1 | # Case Study on Dealing with Missing Values {#missing-case}
2 |
3 | ```{r setup-ch8, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 |
13 | library(rms)
14 | library(mice)
15 | library(foreign)
16 | options(width = 100)
17 | ```
18 |
19 | ## Read and describe data file
20 |
21 | ```{r describe_data, warnings = FALSE }
22 | TBI1 <- read.csv("data/TBI1.csv", row.names = 1)
23 | TBI1$study <- as.factor(TBI1$study)
24 | TBI1$pupil <- as.factor(TBI1$pupil)
25 | TBI1$ctclass <- as.factor(TBI1$ctclass)
26 | describe(TBI1)
27 | ```
28 |
29 | ## Missing value analysis
30 |
31 | ### Start with rms functions
32 |
33 | ```{r message = FALSE }
34 | na.patterns <- naclus(TBI1)
35 | plot(na.patterns, ylab = "Fraction of NAs in common", col = "red")
36 | par(mfrow = c(1, 2))
37 | naplot(na.patterns, col = "red", cex = 1.1, cex.main = 0.9)
38 | ```
39 |
40 | ### Other visualization: VIM package
41 |
42 | ```{r message = FALSE }
43 | library(VIM)
44 | par(mfrow = c(1, 1))
45 | aggr(TBI1, sortVars = T, col = c("green", "red"))
46 | ```
47 |
48 | ## 9 separate plots
49 |
50 | ```{r message = FALSE,fig.height=12}
51 | par(mar = c(4, 4, 3, 1) + 0.1,mfrow = c(3, 3))
52 |
53 | plot(summary(is.na(ctclass) ~ study + age + unfav, data = TBI1), main = "CT classification", pch = 19, cex.main = 0.6, cex.axis = 0.8, cex.lab = .6, cex.sub = 0.3, col = "red",reset.par = FALSE)
54 |
55 | plot(summary(is.na(cisterns) ~ study + age + unfav, data = TBI1), main = "CT: compressed cisterns", pch = 19, cex.main = 0.6, cex.axis = 0.8, cex.lab = .6, cex.sub = 0.3, col = "red",reset.par = FALSE)
56 |
57 | plot(summary(is.na(shift) ~ study + age + unfav, data = TBI1), main = "CT: shift", pch = 19, cex.main = 0.6, cex.axis = 0.8, cex.lab = .6, cex.sub = 0.3, col = "red",reset.par = FALSE)
58 |
59 | plot(summary(is.na(tsah) ~ study + age + unfav, data = TBI1), main = "CT: tSAH", pch = 19, cex.main = 0.6, cex.axis = 0.8, cex.lab = .6, cex.sub = 0.3, col = "red",reset.par = FALSE)
60 |
61 | plot(summary(is.na(hb) ~ study + age + unfav, data = TBI1), main = "Lab: hb", pch = 19, cex.main = 0.6, cex.axis = 0.8, cex.lab = .6, cex.sub = 0.3, col = "red",reset.par = FALSE)
62 |
63 | plot(summary(is.na(glucose) ~ study + age + unfav, data = TBI1), main = "Lab: glucose", pch = 19, cex.main = 0.6, cex.axis = 0.8, cex.lab = .6, cex.sub = 0.3, col = "red",reset.par = FALSE)
64 |
65 | plot(summary(is.na(hypoxia) ~ study + age + unfav, data = TBI1), main = "Presentation: hypoxia", pch = 19, cex.main = 0.6, cex.axis = 0.8, cex.lab = .6, cex.sub = 0.3, col = "red",reset.par = FALSE)
66 |
67 | plot(summary(is.na(hypotens) ~ study + age + unfav, data = TBI1), main = "Presentation: hypotension", pch = 19, cex.main = 0.6, cex.axis = 0.8, cex.lab = .6, cex.sub = 0.3, col = "red",reset.par = FALSE)
68 |
69 | plot(summary(is.na(pupil) ~ study + age + unfav, data = TBI1), main = "Pupillary reactivity", pch = 19, cex.main = 0.6, cex.axis = 0.8, cex.lab = .6, cex.sub = 0.3, col = "red",reset.par = FALSE)
70 | # End plot missing patterns
71 | ```
72 |
73 |
74 | ## Imputation
75 |
76 | ### mice in action
77 |
78 | We define the matrix pmat for mice predictorMatrix.
79 | A value of '1' means that the column variable is used as a predictor for the target variable (in the rows). The diagonal of 'predictorMatrix' must be zero. In our matrix we don't want 'study', 'age', 'motor', 'unfav' and 'mort' to be imputed.
80 |
81 | ```{r warning=FALSE }
82 | p <- 16
83 | pmat <- matrix(rep(1, p * p), nrow = p, ncol = p)
84 | diag(pmat) <- rep(0, p)
85 | pmat[, c(1:2, 10, 15:16)] <- 0 # set some columns to zero
86 | pmat[c(1:2, 10, 15:16), ] <- 0 # set the rows for the same variables to zero
87 |
88 | ## defines data to be used and the imputation method for each column, seed=1
89 | gm <- mice(TBI1,
90 | m = 10,
91 | imputationMethod = c(
92 | "polyreg", "pmm", "logreg", "logreg", "logreg", "logreg", "logreg", "logreg", "polyreg",
93 | "polyreg", "polyreg", "pmm", "pmm", "pmm", "logreg", "logreg"
94 | ), predictorMatrix = pmat, seed = 1
95 | )
96 | gm
97 |
98 | densityplot(gm) # Nice check for imputed vs original distributions
99 | ```
100 |
101 | ### Univariate, CC analyses for age and motor
102 |
103 | ```{r message = FALSE }
104 | lrm(unfav ~ study + age, data = TBI1)
105 | lrm(unfav ~ study + motor, data = TBI1)
106 | ```
107 |
108 | ## Prediction model analyses
109 |
110 | ```{r message = FALSE,eval=FALSE}
111 | ## CC, n = 2428
112 | lrm(unfav ~ study + age + motor + pupil + hypoxia + hypotens + ctclass + tsah, data = TBI1)
113 | ## SI, n = 8530
114 | lrm(unfav ~ study + age + motor + pupil + hypoxia + hypotens + ctclass + tsah, data = complete(gm, action = 1))
115 | ## MI, n = 8530
116 | fit.mult.impute(unfav ~ study + age + motor + pupil + hypoxia + hypotens + ctclass + tsah, lrm, xtrans = gm, data = TBI1)
117 | ```
118 |
119 | ## Make adjusted analyses per complete predictor
120 |
121 | ```{r message = FALSE,eval=FALSE}
122 | names.uni <- Cs(pupil, hypoxia, hypotens, ctclass, tsah) # 5 names
123 | TBIc <- complete(gm, action = "long", include = TRUE) # completed data set
124 |
125 | ###################################################
126 | # pupils
127 | TBI2 <- TBIc[!TBIc$.id %in% TBIc$.id[is.na(TBIc$pupil)], ]
128 | gm2 <- as.mids(TBI2)
129 | fit.CC <- lrm(unfav ~ study + pupil, data = TBI2[TBI2$.imp == 0, ])
130 | fit.SI <- lrm(unfav ~ study + age + motor + pupil + hypoxia + hypotens + ctclass + tsah, data = TBI2[TBI2$.imp == 1, ])
131 | fit.MI <- fit.mult.impute(unfav ~ study + age + motor + pupil + hypoxia + hypotens + ctclass + tsah, lrm, xtrans = gm2)
132 | ```
133 |
134 | ```{r message = FALSE,eval=FALSE}
135 | options(digits = 2)
136 | i <- 1 # indicates index for the predictor we are studying
137 | print(coef(fit.CC)[startsWith(names(coef(fit.CC)), names.uni[i])]) # CC
138 | print(sqrt(diag(fit.CC$var))[startsWith(names(coef(fit.CC)), names.uni[i])])
139 | print(coef(fit.SI)[startsWith(names(coef(fit.SI)), names.uni[i])]) # SI
140 | print(sqrt(diag(fit.SI$var))[startsWith(names(coef(fit.SI)), names.uni[i])])
141 | print(coef(fit.MI)[startsWith(names(coef(fit.MI)), names.uni[i])]) # MI
142 | print(sqrt(diag(fit.MI$var))[startsWith(names(coef(fit.MI)), names.uni[i])])
143 | ```
144 |
145 | ```{r message = FALSE,eval=FALSE}
146 | # hypoxia
147 | TBI2 <- TBIc[!TBIc$.id %in% TBIc$.id[is.na(TBIc$hypoxia)], ]
148 | gm2 <- as.mids(TBI2)
149 | fit.CC <- lrm(unfav ~ study + hypoxia, data = TBI2[TBI2$.imp == 0, ])
150 | fit.SI <- lrm(unfav ~ study + age + motor + pupil + hypoxia + hypotens + ctclass + tsah, data = TBI2[TBI2$.imp == 1, ])
151 | fit.MI <- fit.mult.impute(unfav ~ study + age + motor + pupil + hypoxia + hypotens + ctclass + tsah, lrm, xtrans = gm2)
152 |
153 | i <- 2 # index 2
154 | print(coef(fit.CC)[startsWith(names(coef(fit.CC)), names.uni[i])]) # CC
155 | print(sqrt(diag(fit.CC$var))[startsWith(names(coef(fit.CC)), names.uni[i])])
156 | print(coef(fit.SI)[startsWith(names(coef(fit.SI)), names.uni[i])]) # SI
157 | print(sqrt(diag(fit.SI$var))[startsWith(names(coef(fit.SI)), names.uni[i])])
158 | print(coef(fit.MI)[startsWith(names(coef(fit.MI)), names.uni[i])]) # MI
159 | print(sqrt(diag(fit.MI$var))[startsWith(names(coef(fit.MI)), names.uni[i])])
160 |
161 | # hypotens
162 | TBI2 <- TBIc[!TBIc$.id %in% TBIc$.id[is.na(TBIc$hypotens)], ]
163 | gm2 <- as.mids(TBI2)
164 | fit.CC <- lrm(unfav ~ study + hypotens, data = TBI2[TBI2$.imp == 0, ])
165 | fit.SI <- lrm(unfav ~ study + age + motor + pupil + hypoxia + hypotens + ctclass + tsah, data = TBI2[TBI2$.imp == 1, ])
166 | fit.MI <- fit.mult.impute(unfav ~ study + age + motor + pupil + hypoxia + hypotens + ctclass + tsah, lrm, xtrans = gm2)
167 |
168 | i <- 3
169 | print(coef(fit.CC)[startsWith(names(coef(fit.CC)), names.uni[i])]) # CC
170 | print(sqrt(diag(fit.CC$var))[startsWith(names(coef(fit.CC)), names.uni[i])])
171 | print(coef(fit.SI)[startsWith(names(coef(fit.SI)), names.uni[i])]) # SI
172 | print(sqrt(diag(fit.SI$var))[startsWith(names(coef(fit.SI)), names.uni[i])])
173 | print(coef(fit.MI)[startsWith(names(coef(fit.MI)), names.uni[i])]) # MI
174 | print(sqrt(diag(fit.MI$var))[startsWith(names(coef(fit.MI)), names.uni[i])])
175 |
176 | # ctclass
177 | TBI2 <- TBIc[!TBIc$.id %in% TBIc$.id[is.na(TBIc$ctclass)], ]
178 | gm2 <- as.mids(TBI2)
179 | fit.CC <- lrm(unfav ~ study + ctclass, data = TBI2[TBI2$.imp == 0, ])
180 | fit.SI <- lrm(unfav ~ study + age + motor + pupil + hypoxia + hypotens + ctclass + tsah, data = TBI2[TBI2$.imp == 1, ])
181 | fit.MI <- fit.mult.impute(unfav ~ study + age + motor + pupil + hypoxia + hypotens + ctclass + tsah, lrm, xtrans = gm2)
182 |
183 | i <- 4
184 | print(coef(fit.CC)[startsWith(names(coef(fit.CC)), names.uni[i])]) # CC
185 | print(sqrt(diag(fit.CC$var))[startsWith(names(coef(fit.CC)), names.uni[i])])
186 | print(coef(fit.SI)[startsWith(names(coef(fit.SI)), names.uni[i])]) # SI
187 | print(sqrt(diag(fit.SI$var))[startsWith(names(coef(fit.SI)), names.uni[i])])
188 | print(coef(fit.MI)[startsWith(names(coef(fit.MI)), names.uni[i])]) # MI
189 | print(sqrt(diag(fit.MI$var))[startsWith(names(coef(fit.MI)), names.uni[i])])
190 |
191 | # tsah
192 | TBI2 <- TBIc[!TBIc$.id %in% TBIc$.id[is.na(TBIc$tsah)], ]
193 | gm2 <- as.mids(TBI2)
194 | fit.CC <- lrm(unfav ~ study + tsah, data = TBI2[TBI2$.imp == 0, ])
195 | fit.SI <- lrm(unfav ~ study + age + motor + pupil + hypoxia + hypotens + ctclass + tsah, data = TBI2[TBI2$.imp == 1, ])
196 | fit.MI <- fit.mult.impute(unfav ~ study + age + motor + pupil + hypoxia + hypotens + ctclass + tsah, lrm, xtrans = gm2)
197 |
198 | i <- 5
199 | print(coef(fit.CC)[startsWith(names(coef(fit.CC)), names.uni[i])]) # CC
200 | print(sqrt(diag(fit.CC$var))[startsWith(names(coef(fit.CC)), names.uni[i])])
201 | print(coef(fit.SI)[startsWith(names(coef(fit.SI)), names.uni[i])]) # SI
202 | print(sqrt(diag(fit.SI$var))[startsWith(names(coef(fit.SI)), names.uni[i])])
203 | print(coef(fit.MI)[startsWith(names(coef(fit.MI)), names.uni[i])]) # MI
204 | print(sqrt(diag(fit.MI$var))[startsWith(names(coef(fit.MI)), names.uni[i])])
205 |
206 | ## End C, SI, and MI analyses ##
207 | ################################
208 | ```
209 |
--------------------------------------------------------------------------------
/R/val.functions.17jan19.R:
--------------------------------------------------------------------------------
1 | # Yvonne Vergouwe, 06.05.02
2 | # Ewout Steyerberg, June 2007:
3 | # for graphs with calibration, discrimination, and clinical usefulness
4 |
5 | # lp to p
6 |
7 | InvLogit <-function(lp)
8 | { p <-1/(1+exp(-lp)) }
9 |
10 | ####
11 | # ter nec
12 | # p(ter)>cut nac[2] nbd[2]
13 | # p(ter) 0) {
91 | group <- group[nma]
92 | weights <- weights[nma]
93 | return(val.probg(p, y, group, evaluate, weights, normwt, nmin)
94 | )
95 | }
96 | if(length(unique(p)) == 1) {
97 | #22Sep94
98 | P <- mean(y)
99 | Intc <- log(P/(1 - P))
100 | n <- length(y)
101 | D <- -1/n
102 | L01 <- -2 * sum(y * logit - log(1 + exp(logit)), na.rm = T)
103 | L.cal <- -2 * sum(y * Intc - log(1 + exp(Intc)), na.rm = T)
104 | U.chisq <- L01 - L.cal
105 | U.p <- 1 - pchisq(U.chisq, 1)
106 | U <- (U.chisq - 1)/n
107 | Q <- D - U
108 |
109 | stats <- c(0, 0.5, 0, D, 0, 1, U, U.chisq, U.p, Q, mean((y - p[
110 | 1])^2), Intc, 0, rep(abs(p[1] - P), 2))
111 | names(stats) <- c("Dxy", "C (ROC)", "R2", "D", "D:Chi-sq",
112 | "D:p", "U", "U:Chi-sq", "U:p", "Q", "Brier",
113 | "Intercept", "Slope", "Emax", "Eavg")
114 | return(stats)
115 | }
116 | i <- !is.infinite(logit)
117 | nm <- sum(!i)
118 | if(nm > 0)
119 | warning(paste(nm,
120 | "observations deleted from logistic calibration due to probs. of 0 or 1"
121 | ))
122 | f <- lrm.fit(logit[i], y[i])
123 | f2<- lrm.fit(offset=logit[i], y=y[i])
124 | stats <- f$stats
125 | n <- stats["Obs"]
126 | predprob <- seq(emax.lim[1], emax.lim[2], by = 0.0005)
127 | lt <- f$coef[1] + f$coef[2] * log(predprob/(1 - predprob))
128 | calp <- 1/(1 + exp( - lt))
129 | emax <- max(abs(predprob - calp))
130 | if(pl) {
131 | plot(0.5, 0.5, xlim = xlim, ylim = ylim, type = "n", xlab = "",ylab = "")
132 | mtext(xlab, side=1, line=2.5)
133 | mtext(ylab, side=2, line=2.5)
134 | abline(0, 1, lty = 3)
135 | lt <- 3
136 | leg <- "Ideal"
137 | marks <- -1
138 | if(logistic.cal) {
139 | lt <- c(lt, 1)
140 | leg <- c(leg, "Logistic calibration")
141 | marks <- c(marks, -1)
142 | }
143 | if(smooth) {
144 | Sm <- lowess(p, y, iter = 0)
145 | if(connect.smooth) {
146 | lines(Sm, lty = 1)
147 | lt <- c(lt, 1)
148 | marks <- c(marks, -1)
149 | }
150 | else {
151 | points(Sm)
152 | lt <- c(lt, 0)
153 | marks <- c(marks, 1)
154 | }
155 | leg <- c(leg, "Nonparametric")
156 | cal.smooth <- approx(Sm, xout = p)$y
157 | eavg <- mean(abs(p - cal.smooth))
158 | }
159 | if(!missing(m) | !missing(g) | !missing(cuts)) {
160 | if(!missing(m))
161 | q <- cut2(p, m = m, levels.mean = T, digits =
162 | 7)
163 | else if(!missing(g))
164 | q <- cut2(p, g = g, levels.mean = T, digits =
165 | 7)
166 | else if(!missing(cuts))
167 | q <- cut2(p, cuts = cuts, levels.mean = T,
168 | digits = 7)
169 | means <- as.single(levels(q))
170 | prop <- tapply(y, q, function(x)
171 | mean(x, na.rm = T))
172 | points(means, prop, pch = 2, col=col.point, lwd=2)
173 | if(connect.group) {
174 | lines(means, prop)
175 | lt <- c(lt, 1)
176 | }
177 | else lt <- c(lt, 0)
178 | leg <- c(leg, "Grouped patients")
179 | marks <- c(marks, 2)
180 | }
181 | }
182 | lr <- stats["Model L.R."]
183 | p.lr <- stats["P"]
184 | D <- (lr - 1)/n
185 | L01 <- -2 * sum(y * logit - log(1 + exp(logit)), na.rm = T)
186 | U.chisq <- L01 - f$deviance[2]
187 | p.U <- 1 - pchisq(U.chisq, 2)
188 | U <- (U.chisq - 2)/n
189 | Q <- D - U
190 | Dxy <- stats["Dxy"]
191 | C <- stats["C"]
192 |
193 | #several R2 measures set to zero June 2007 (nopt necessary now)
194 | n <-length(y)
195 | r2.pear <-0
196 | r2.nagel <-0
197 | r2.harr <- 0
198 |
199 | B <- sum((p - y)^2)/n
200 | stats <- c(Dxy, C, r2.pear,r2.nagel,r2.harr, D, lr, p.lr, U, U.chisq, p.U, Q, B, f2$coef[1],f$coef[2],
201 | emax)
202 | names(stats) <- c("Dxy", "C (ROC)", "R2 Pearson", "R2 Nagelkerke", "R2 Harrell", "D", "D:Chi-sq", "D:p", "U",
203 | "U:Chi-sq", "U:p", "Q", "Brier", "Int|slope=1", "Slope", "Emax")
204 | if(smooth)
205 | stats <- c(stats, c(Eavg = eavg))
206 | if(!missing(cutoff)) {
207 | lines(c(cutoff),c(1),lty=2,type="h")
208 | lt <- c(lt, 2)
209 | leg <- c(leg, Cs(Cut-off))
210 | }
211 | if(pl) {
212 | logit <- seq(-7, 7, length = 200)
213 | prob <- 1/(1 + exp( - logit))
214 | pred.prob <- f$coef[1] + f$coef[2] * logit
215 | pred.prob <- 1/(1 + exp( - pred.prob))
216 | if(logistic.cal) lines(prob, pred.prob, lty = 1, col=col.logcal, lwd=2)
217 | # pc <- rep(" ", length(lt))
218 | # pc[lt==0] <- "."
219 | lp <- legendloc
220 | if(!is.logical(lp)) {
221 | if(!is.list(lp))
222 | lp <- list(x = lp[1], y = lp[2])
223 | legend(lp, leg, lty = lt, marks = marks, mkh = mkh,
224 | cex = cex, bty = "n") #, pch=pc)
225 | }
226 | if(!is.logical(statloc)) {
227 | dostats <- c(1, 2, 3, 4, 7, 10, 11, 12, 13, 14)
228 | leg <- format(names(stats)[dostats]) #constant length
229 | leg <- paste(leg, ":", format(stats[dostats]), sep =
230 | "")
231 | if(!is.list(statloc))
232 | statloc <- list(x = statloc[1], y = statloc[2]
233 | )
234 | text(statloc, paste(format(names(stats[dostats])),
235 | collapse = "\n"), adj = 0, cex = cex)
236 | text(statloc$x + 0.225 , statloc$y, paste(
237 | format(round(stats[dostats], 3)), collapse =
238 | "\n"), adj = 1, cex = cex)
239 | # legend(statloc, leg, lty=rep(0, length(dostats)))
240 | }
241 | if(is.character(riskdist)) {
242 | if(riskdist == "calibrated") {
243 | x <- f$coef[1] + f$coef[2] * log(p/(1 - p))
244 | x <- 1/(1 + exp( - x))
245 | x[p == 0] <- 0
246 | x[p == 1] <- 1
247 | }
248 | else x <- p
249 | bins <- seq(0, 1, length = 99)
250 | x <- x[x >= 0 & x <= 1]
251 | #08.04.01,yvon: verdeling van predicted opgesplitst naar uitkomst
252 | f0 <-table(cut(x[y==0],bins))
253 | f1 <-table(cut(x[y==1],bins))
254 | j0 <-f0 > 0
255 | j1 <-f1 > 0
256 | bins0 <-(bins[-99])[j0]
257 | bins1 <-(bins[-99])[j1]
258 | f0 <-f0[j0]
259 | f1 <-f1[j1]
260 | maxf <-max(f0,f1)
261 | f0 <-(0.1*f0)/maxf
262 | f1 <-(0.1*f1)/maxf
263 | segments(bins1,-0.05,bins1,f1-0.05, col=col1)
264 | segments(bins0,-0.05,bins0,-f0-0.05, col=col0)
265 | lines(c(min(bins0,bins1)-0.01,max(bins0,bins1)+0.01),c(-0.05,-0.05))
266 | text(max(bins0,bins1)+0.02,-0.025,d1lab,cex=0.7)
267 | text(max(bins0,bins1)+0.02,-0.08,d0lab,cex=0.7)
268 | }
269 | }
270 | stats
271 | }
272 |
273 | #################
274 | stat.ES <- function(p,y,cutoff=.7, rounddec1=2, rounddec2=2, rounddec3=2, rounddec4=2,cex.text=1,
275 | pl=T, g=10, d0lab="", d1lab="", logistic.cal=F, smooth=T, cutline=T, main="", cex.main=1) {
276 | r <- c(val.prob.yvon(p=p,y=y, pl=pl, g=g, smooth=smooth, logistic.cal=logistic.cal, d0lab=d0lab, d1lab=d1lab,
277 | xlab="Predicted Probability", ylab="Actual Proportion",
278 | statloc=F, legendloc=F)[c(14,15,2,3)],
279 | sesp(p=p,y=y,cutoff=cutoff)[c(3,4,1,10:13)])
280 | text(x=rep(0,4),y=c(0.95,0.85,0.75,0.65), c("a|b=1", "slope b", "c stat", "NB"), adj=0, cex=cex.text)
281 | text(x=rep(0.25,4),y=c(0.95,0.85,0.75,0.65),
282 | c(round(r[1],rounddec1),round(r[2],rounddec2),round(r[3],rounddec3),round(r[11],rounddec4)),
283 | adj=0, cex=cex.text)
284 | if (cutline) arrows(x0=cutoff, y0=.05, x1=cutoff, y1=-0.05, length = 0.08)
285 | text(x=cutoff,y=.1, "Cutoff", adj=0.5, cex=cex.text)
286 | title(main, cex.main=cex.main)
287 | names(r) <-list('Int|slope=1',"Slope", "C (ROC)", "R2 Pearson",
288 | "sens", "spec", "acc","NBmodel", "NBtreat", "NBnotreat", "NB")
289 | }
290 | # stat.ES(p=pred1,y=y)
291 | #################
292 |
293 |
--------------------------------------------------------------------------------
/docs/site_libs/quarto-nav/quarto-nav.js:
--------------------------------------------------------------------------------
1 | const headroomChanged = new CustomEvent("quarto-hrChanged", {
2 | detail: {},
3 | bubbles: true,
4 | cancelable: false,
5 | composed: false,
6 | });
7 |
8 | const announceDismiss = () => {
9 | const annEl = window.document.getElementById("quarto-announcement");
10 | if (annEl) {
11 | annEl.remove();
12 |
13 | const annId = annEl.getAttribute("data-announcement-id");
14 | window.localStorage.setItem(`quarto-announce-${annId}`, "true");
15 | }
16 | };
17 |
18 | const announceRegister = () => {
19 | const annEl = window.document.getElementById("quarto-announcement");
20 | if (annEl) {
21 | const annId = annEl.getAttribute("data-announcement-id");
22 | const isDismissed =
23 | window.localStorage.getItem(`quarto-announce-${annId}`) || false;
24 | if (isDismissed) {
25 | announceDismiss();
26 | return;
27 | } else {
28 | annEl.classList.remove("hidden");
29 | }
30 |
31 | const actionEl = annEl.querySelector(".quarto-announcement-action");
32 | if (actionEl) {
33 | actionEl.addEventListener("click", function (e) {
34 | e.preventDefault();
35 | // Hide the bar immediately
36 | announceDismiss();
37 | });
38 | }
39 | }
40 | };
41 |
42 | window.document.addEventListener("DOMContentLoaded", function () {
43 | let init = false;
44 |
45 | announceRegister();
46 |
47 | // Manage the back to top button, if one is present.
48 | let lastScrollTop = window.pageYOffset || document.documentElement.scrollTop;
49 | const scrollDownBuffer = 5;
50 | const scrollUpBuffer = 35;
51 | const btn = document.getElementById("quarto-back-to-top");
52 | const hideBackToTop = () => {
53 | btn.style.display = "none";
54 | };
55 | const showBackToTop = () => {
56 | btn.style.display = "inline-block";
57 | };
58 | if (btn) {
59 | window.document.addEventListener(
60 | "scroll",
61 | function () {
62 | const currentScrollTop =
63 | window.pageYOffset || document.documentElement.scrollTop;
64 |
65 | // Shows and hides the button 'intelligently' as the user scrolls
66 | if (currentScrollTop - scrollDownBuffer > lastScrollTop) {
67 | hideBackToTop();
68 | lastScrollTop = currentScrollTop <= 0 ? 0 : currentScrollTop;
69 | } else if (currentScrollTop < lastScrollTop - scrollUpBuffer) {
70 | showBackToTop();
71 | lastScrollTop = currentScrollTop <= 0 ? 0 : currentScrollTop;
72 | }
73 |
74 | // Show the button at the bottom, hides it at the top
75 | if (currentScrollTop <= 0) {
76 | hideBackToTop();
77 | } else if (
78 | window.innerHeight + currentScrollTop >=
79 | document.body.offsetHeight
80 | ) {
81 | showBackToTop();
82 | }
83 | },
84 | false
85 | );
86 | }
87 |
88 | function throttle(func, wait) {
89 | var timeout;
90 | return function () {
91 | const context = this;
92 | const args = arguments;
93 | const later = function () {
94 | clearTimeout(timeout);
95 | timeout = null;
96 | func.apply(context, args);
97 | };
98 |
99 | if (!timeout) {
100 | timeout = setTimeout(later, wait);
101 | }
102 | };
103 | }
104 |
105 | function headerOffset() {
106 | // Set an offset if there is are fixed top navbar
107 | const headerEl = window.document.querySelector("header.fixed-top");
108 | if (headerEl) {
109 | return headerEl.clientHeight;
110 | } else {
111 | return 0;
112 | }
113 | }
114 |
115 | function footerOffset() {
116 | const footerEl = window.document.querySelector("footer.footer");
117 | if (footerEl) {
118 | return footerEl.clientHeight;
119 | } else {
120 | return 0;
121 | }
122 | }
123 |
124 | function dashboardOffset() {
125 | const dashboardNavEl = window.document.getElementById(
126 | "quarto-dashboard-header"
127 | );
128 | if (dashboardNavEl !== null) {
129 | return dashboardNavEl.clientHeight;
130 | } else {
131 | return 0;
132 | }
133 | }
134 |
135 | function updateDocumentOffsetWithoutAnimation() {
136 | updateDocumentOffset(false);
137 | }
138 |
139 | function updateDocumentOffset(animated) {
140 | // set body offset
141 | const topOffset = headerOffset();
142 | const bodyOffset = topOffset + footerOffset() + dashboardOffset();
143 | const bodyEl = window.document.body;
144 | bodyEl.setAttribute("data-bs-offset", topOffset);
145 | bodyEl.style.paddingTop = topOffset + "px";
146 |
147 | // deal with sidebar offsets
148 | const sidebars = window.document.querySelectorAll(
149 | ".sidebar, .headroom-target"
150 | );
151 | sidebars.forEach((sidebar) => {
152 | if (!animated) {
153 | sidebar.classList.add("notransition");
154 | // Remove the no transition class after the animation has time to complete
155 | setTimeout(function () {
156 | sidebar.classList.remove("notransition");
157 | }, 201);
158 | }
159 |
160 | if (window.Headroom && sidebar.classList.contains("sidebar-unpinned")) {
161 | sidebar.style.top = "0";
162 | sidebar.style.maxHeight = "100vh";
163 | } else {
164 | sidebar.style.top = topOffset + "px";
165 | sidebar.style.maxHeight = "calc(100vh - " + topOffset + "px)";
166 | }
167 | });
168 |
169 | // allow space for footer
170 | const mainContainer = window.document.querySelector(".quarto-container");
171 | if (mainContainer) {
172 | mainContainer.style.minHeight = "calc(100vh - " + bodyOffset + "px)";
173 | }
174 |
175 | // link offset
176 | let linkStyle = window.document.querySelector("#quarto-target-style");
177 | if (!linkStyle) {
178 | linkStyle = window.document.createElement("style");
179 | linkStyle.setAttribute("id", "quarto-target-style");
180 | window.document.head.appendChild(linkStyle);
181 | }
182 | while (linkStyle.firstChild) {
183 | linkStyle.removeChild(linkStyle.firstChild);
184 | }
185 | if (topOffset > 0) {
186 | linkStyle.appendChild(
187 | window.document.createTextNode(`
188 | section:target::before {
189 | content: "";
190 | display: block;
191 | height: ${topOffset}px;
192 | margin: -${topOffset}px 0 0;
193 | }`)
194 | );
195 | }
196 | if (init) {
197 | window.dispatchEvent(headroomChanged);
198 | }
199 | init = true;
200 | }
201 |
202 | // initialize headroom
203 | var header = window.document.querySelector("#quarto-header");
204 | if (header && window.Headroom) {
205 | const headroom = new window.Headroom(header, {
206 | tolerance: 5,
207 | onPin: function () {
208 | const sidebars = window.document.querySelectorAll(
209 | ".sidebar, .headroom-target"
210 | );
211 | sidebars.forEach((sidebar) => {
212 | sidebar.classList.remove("sidebar-unpinned");
213 | });
214 | updateDocumentOffset();
215 | },
216 | onUnpin: function () {
217 | const sidebars = window.document.querySelectorAll(
218 | ".sidebar, .headroom-target"
219 | );
220 | sidebars.forEach((sidebar) => {
221 | sidebar.classList.add("sidebar-unpinned");
222 | });
223 | updateDocumentOffset();
224 | },
225 | });
226 | headroom.init();
227 |
228 | let frozen = false;
229 | window.quartoToggleHeadroom = function () {
230 | if (frozen) {
231 | headroom.unfreeze();
232 | frozen = false;
233 | } else {
234 | headroom.freeze();
235 | frozen = true;
236 | }
237 | };
238 | }
239 |
240 | window.addEventListener(
241 | "hashchange",
242 | function (e) {
243 | if (
244 | getComputedStyle(document.documentElement).scrollBehavior !== "smooth"
245 | ) {
246 | window.scrollTo(0, window.pageYOffset - headerOffset());
247 | }
248 | },
249 | false
250 | );
251 |
252 | // Observe size changed for the header
253 | const headerEl = window.document.querySelector("header.fixed-top");
254 | if (headerEl && window.ResizeObserver) {
255 | const observer = new window.ResizeObserver(() => {
256 | setTimeout(updateDocumentOffsetWithoutAnimation, 0);
257 | });
258 | observer.observe(headerEl, {
259 | attributes: true,
260 | childList: true,
261 | characterData: true,
262 | });
263 | } else {
264 | window.addEventListener(
265 | "resize",
266 | throttle(updateDocumentOffsetWithoutAnimation, 50)
267 | );
268 | }
269 | setTimeout(updateDocumentOffsetWithoutAnimation, 250);
270 |
271 | // fixup index.html links if we aren't on the filesystem
272 | if (window.location.protocol !== "file:") {
273 | const links = window.document.querySelectorAll("a");
274 | for (let i = 0; i < links.length; i++) {
275 | if (links[i].href) {
276 | links[i].dataset.originalHref = links[i].href;
277 | links[i].href = links[i].href.replace(/\/index\.html/, "/");
278 | }
279 | }
280 |
281 | // Fixup any sharing links that require urls
282 | // Append url to any sharing urls
283 | const sharingLinks = window.document.querySelectorAll(
284 | "a.sidebar-tools-main-item, a.quarto-navigation-tool, a.quarto-navbar-tools, a.quarto-navbar-tools-item"
285 | );
286 | for (let i = 0; i < sharingLinks.length; i++) {
287 | const sharingLink = sharingLinks[i];
288 | const href = sharingLink.getAttribute("href");
289 | if (href) {
290 | sharingLink.setAttribute(
291 | "href",
292 | href.replace("|url|", window.location.href)
293 | );
294 | }
295 | }
296 |
297 | // Scroll the active navigation item into view, if necessary
298 | const navSidebar = window.document.querySelector("nav#quarto-sidebar");
299 | if (navSidebar) {
300 | // Find the active item
301 | const activeItem = navSidebar.querySelector("li.sidebar-item a.active");
302 | if (activeItem) {
303 | // Wait for the scroll height and height to resolve by observing size changes on the
304 | // nav element that is scrollable
305 | const resizeObserver = new ResizeObserver((_entries) => {
306 | // The bottom of the element
307 | const elBottom = activeItem.offsetTop;
308 | const viewBottom = navSidebar.scrollTop + navSidebar.clientHeight;
309 |
310 | // The element height and scroll height are the same, then we are still loading
311 | if (viewBottom !== navSidebar.scrollHeight) {
312 | // Determine if the item isn't visible and scroll to it
313 | if (elBottom >= viewBottom) {
314 | navSidebar.scrollTop = elBottom;
315 | }
316 |
317 | // stop observing now since we've completed the scroll
318 | resizeObserver.unobserve(navSidebar);
319 | }
320 | });
321 | resizeObserver.observe(navSidebar);
322 | }
323 | }
324 | }
325 | });
326 |
--------------------------------------------------------------------------------
/data/Gustos4Age.csv:
--------------------------------------------------------------------------------
1 | "DAY30","AGE"
2 | 0,48.391
3 | 0,58.234
4 | 0,35.25
5 | 0,47.32
6 | 0,81.688
7 | 0,66.719
8 | 0,63.883
9 | 0,64.719
10 | 0,71.078
11 | 0,67.375
12 | 0,46.375
13 | 0,43.203
14 | 0,73.438
15 | 0,70.281
16 | 0,75.656
17 | 0,74.734
18 | 1,76.422
19 | 0,62.82
20 | 0,57.148
21 | 0,72.047
22 | 0,64.938
23 | 0,28.367
24 | 0,48.813
25 | 0,69.891
26 | 0,57.828
27 | 0,69.953
28 | 0,70.516
29 | 0,62.813
30 | 0,59.148
31 | 0,64.266
32 | 0,71.984
33 | 0,58.031
34 | 0,58.828
35 | 0,44.367
36 | 0,59.625
37 | 0,44.242
38 | 0,69.156
39 | 0,47.875
40 | 0,69.469
41 | 0,56.547
42 | 0,64.578
43 | 0,63.492
44 | 0,64.203
45 | 0,70.922
46 | 0,56.156
47 | 0,64.094
48 | 0,66.484
49 | 0,73.641
50 | 0,47.734
51 | 0,75.469
52 | 0,55.289
53 | 0,56.766
54 | 0,71.063
55 | 0,48.492
56 | 0,66.109
57 | 0,47.922
58 | 0,53.422
59 | 0,62.414
60 | 0,70.813
61 | 0,64.578
62 | 0,54.586
63 | 0,73.5
64 | 0,53.891
65 | 0,56.906
66 | 0,58.805
67 | 0,64.031
68 | 0,70.234
69 | 0,78.031
70 | 0,53.891
71 | 0,52.352
72 | 0,42.094
73 | 0,68.641
74 | 0,51.742
75 | 0,63.18
76 | 1,62.273
77 | 0,62.281
78 | 0,68.797
79 | 0,34.797
80 | 0,46.633
81 | 0,67.281
82 | 0,67.922
83 | 0,61.758
84 | 0,62.695
85 | 0,47.836
86 | 0,58.531
87 | 0,59.477
88 | 0,56.172
89 | 0,59.086
90 | 1,70.625
91 | 0,78.047
92 | 0,41.195
93 | 0,69.25
94 | 0,63.789
95 | 0,79.188
96 | 0,65.609
97 | 0,67.516
98 | 0,57.398
99 | 0,64.766
100 | 0,73.172
101 | 0,67.266
102 | 0,73.125
103 | 0,67.781
104 | 1,67.313
105 | 0,43.859
106 | 0,59.914
107 | 0,62.844
108 | 0,37.734
109 | 0,49.273
110 | 0,48.031
111 | 0,55.703
112 | 0,56.406
113 | 0,52.086
114 | 0,56.086
115 | 0,52.016
116 | 0,79.297
117 | 0,80.438
118 | 0,52.148
119 | 0,80.469
120 | 0,78.266
121 | 0,79.703
122 | 0,49.805
123 | 0,78.344
124 | 0,57.313
125 | 0,54.164
126 | 0,71.391
127 | 1,68.313
128 | 0,68.047
129 | 0,78.063
130 | 0,55.031
131 | 0,73.141
132 | 0,72.594
133 | 0,45.969
134 | 0,68.266
135 | 1,77.828
136 | 0,65.484
137 | 0,71.141
138 | 0,59.578
139 | 0,68.656
140 | 0,56.938
141 | 0,49.742
142 | 0,68.266
143 | 0,72
144 | 1,64.625
145 | 0,48.375
146 | 0,79.531
147 | 0,41.813
148 | 0,43.164
149 | 0,54.758
150 | 0,68.625
151 | 0,43.016
152 | 0,57.695
153 | 0,63.078
154 | 0,58.367
155 | 1,72.359
156 | 0,52.008
157 | 0,61.297
158 | 0,72.078
159 | 0,59.227
160 | 0,69.016
161 | 0,53.359
162 | 0,74.203
163 | 0,50.867
164 | 0,54.203
165 | 0,45.781
166 | 0,59.859
167 | 0,65
168 | 0,54.336
169 | 0,48.023
170 | 0,45.18
171 | 0,68.453
172 | 0,62.938
173 | 1,47.727
174 | 0,63.75
175 | 0,75.031
176 | 0,44.531
177 | 0,43.438
178 | 0,68.391
179 | 0,59.625
180 | 0,54.891
181 | 0,69.328
182 | 0,64.969
183 | 0,58.656
184 | 0,78.609
185 | 0,70.516
186 | 0,68.828
187 | 0,81.875
188 | 0,54.523
189 | 0,69.563
190 | 0,78.938
191 | 0,68.672
192 | 1,66.953
193 | 0,65.141
194 | 0,59.836
195 | 0,62.344
196 | 0,66.172
197 | 0,78.828
198 | 0,41.922
199 | 0,83.563
200 | 0,47.18
201 | 0,69.828
202 | 0,62.844
203 | 0,56.586
204 | 0,76.516
205 | 0,56.852
206 | 0,45.719
207 | 0,58.938
208 | 0,73.266
209 | 0,67.016
210 | 1,75.922
211 | 0,47.484
212 | 0,71.375
213 | 0,76.297
214 | 0,60.891
215 | 0,67.938
216 | 0,46.758
217 | 0,61.289
218 | 0,70.703
219 | 0,76.172
220 | 0,50.227
221 | 0,73.5
222 | 0,85.328
223 | 0,62.742
224 | 0,65
225 | 0,41.469
226 | 0,54.07
227 | 0,57.047
228 | 0,60.57
229 | 0,73.234
230 | 0,73.406
231 | 0,72.297
232 | 0,67.953
233 | 0,80.781
234 | 0,67.516
235 | 0,50.172
236 | 0,64.656
237 | 0,55.102
238 | 0,71.453
239 | 0,48.672
240 | 0,49.227
241 | 0,73.094
242 | 0,67.016
243 | 0,60.68
244 | 0,77.953
245 | 0,66.188
246 | 1,80.922
247 | 0,59.227
248 | 0,58.758
249 | 0,73.328
250 | 0,68.719
251 | 0,66.313
252 | 0,53.797
253 | 0,63.445
254 | 0,54.133
255 | 0,72.844
256 | 0,50.758
257 | 0,69.922
258 | 0,66.391
259 | 0,59.336
260 | 0,47.352
261 | 0,73.422
262 | 0,53.844
263 | 0,52.969
264 | 0,51.156
265 | 0,45.313
266 | 0,64.891
267 | 0,74.094
268 | 0,77.609
269 | 1,64.938
270 | 0,61.367
271 | 0,57.875
272 | 0,76.797
273 | 0,69.031
274 | 0,72.5
275 | 0,44.039
276 | 0,46.734
277 | 0,68.859
278 | 0,66.734
279 | 0,65.313
280 | 0,69.313
281 | 0,55.891
282 | 0,68.078
283 | 0,72.078
284 | 0,66.234
285 | 0,62.898
286 | 0,70.844
287 | 0,82.578
288 | 0,54.859
289 | 0,70.469
290 | 0,51.195
291 | 0,62.867
292 | 0,47.625
293 | 0,61.336
294 | 0,72.484
295 | 0,76.75
296 | 0,56.391
297 | 0,61.805
298 | 0,57.383
299 | 0,48.883
300 | 0,75.266
301 | 0,76.203
302 | 0,70.078
303 | 0,45.922
304 | 0,63.078
305 | 0,37.719
306 | 1,77.813
307 | 0,49.914
308 | 0,72.953
309 | 0,74.5
310 | 0,57.359
311 | 0,56.32
312 | 0,58.82
313 | 0,51.82
314 | 0,64.766
315 | 0,67.422
316 | 0,69.703
317 | 0,58.406
318 | 0,44.273
319 | 0,49.82
320 | 0,71.703
321 | 0,48.531
322 | 0,71.594
323 | 0,72.156
324 | 0,61.758
325 | 0,57.109
326 | 0,59.836
327 | 0,65.359
328 | 0,60.695
329 | 0,65.344
330 | 1,76.953
331 | 0,47.352
332 | 0,68.875
333 | 0,69.813
334 | 0,73.609
335 | 0,49.641
336 | 0,69.938
337 | 0,75.484
338 | 0,76.375
339 | 0,65.469
340 | 0,68.422
341 | 0,74
342 | 0,36.938
343 | 0,71.156
344 | 0,64.828
345 | 0,70.844
346 | 0,63.172
347 | 0,55.664
348 | 0,60.539
349 | 0,73.703
350 | 0,48.898
351 | 0,53.984
352 | 0,46.461
353 | 0,79.891
354 | 0,72.281
355 | 0,68.656
356 | 0,68.547
357 | 0,70.719
358 | 0,49.664
359 | 0,66.344
360 | 0,56.773
361 | 0,74.594
362 | 0,45.445
363 | 0,43.766
364 | 0,56.93
365 | 1,66.344
366 | 0,48.586
367 | 1,75.984
368 | 0,79.141
369 | 0,51.484
370 | 0,59.563
371 | 0,59.898
372 | 0,50.617
373 | 0,59.016
374 | 0,73.203
375 | 0,68.469
376 | 0,36.297
377 | 0,55.133
378 | 0,67.25
379 | 0,42.766
380 | 0,48.648
381 | 0,58.766
382 | 0,47.281
383 | 0,78.844
384 | 0,56.797
385 | 0,78.844
386 | 0,63.438
387 | 1,84.172
388 | 0,61.797
389 | 0,53.914
390 | 0,45.477
391 | 0,55.813
392 | 0,52.609
393 | 0,78.625
394 | 0,49.883
395 | 0,46.945
396 | 0,55.656
397 | 0,55.688
398 | 0,58.305
399 | 0,64.719
400 | 0,62.18
401 | 0,53.961
402 | 0,51.992
403 | 0,69.719
404 | 0,51.555
405 | 1,77.563
406 | 0,45.227
407 | 0,63.195
408 | 0,55.227
409 | 0,61.961
410 | 0,45.422
411 | 0,52.617
412 | 1,73.984
413 | 0,75.031
414 | 0,53.242
415 | 0,39.164
416 | 0,78.813
417 | 0,58.875
418 | 0,70.984
419 | 0,54.563
420 | 0,44.016
421 | 0,44.516
422 | 0,72.547
423 | 0,57.883
424 | 0,81.719
425 | 0,36.438
426 | 0,54.664
427 | 0,77.188
428 | 0,63.281
429 | 0,62.828
430 | 0,63.602
431 | 0,66.031
432 | 0,44.258
433 | 0,64.109
434 | 0,64.891
435 | 0,60.422
436 | 0,50.523
437 | 0,75.172
438 | 0,53.039
439 | 0,48.641
440 | 0,74.109
441 | 0,59.625
442 | 0,47.727
443 | 1,72.563
444 | 0,54.742
445 | 0,75.656
446 | 0,57.008
447 | 0,65.25
448 | 0,58.258
449 | 0,72.328
450 | 0,81.234
451 | 0,54.938
452 | 0,46.82
453 | 0,40.352
454 | 0,73.578
455 | 0,73.203
456 | 0,44.273
457 | 1,62.469
458 | 0,56.172
459 | 1,74.078
460 | 0,65.844
461 | 0,56.039
462 | 0,64.875
463 | 0,86
464 | 0,56.422
465 | 0,57.945
466 | 0,51.648
467 | 0,62.844
468 | 0,56.438
469 | 0,62.969
470 | 0,53.602
471 | 0,79.5
472 | 0,70.984
473 | 0,47.836
474 | 0,67.063
475 | 0,80.172
476 | 0,77.391
477 | 0,56.289
478 | 0,54.75
479 | 0,57.672
480 | 0,44.445
481 | 0,75.641
482 | 0,52.68
483 | 0,68.156
484 | 0,67.188
485 | 0,75.016
486 | 0,60.383
487 | 0,52.055
488 | 1,82.281
489 | 0,68.047
490 | 1,71.094
491 | 0,50.398
492 | 0,63.438
493 | 0,44.586
494 | 0,51.539
495 | 0,57.742
496 | 0,77
497 | 0,70.969
498 | 0,72.609
499 | 0,44.938
500 | 0,72.516
501 | 0,61.57
502 | 1,72.484
503 | 0,51.055
504 | 0,58.445
505 | 0,64.734
506 | 0,62.195
507 | 0,55.82
508 | 0,51.898
509 | 0,49.07
510 | 0,57.75
511 | 0,78.109
512 | 1,73.719
513 | 0,67.234
514 | 0,72.422
515 | 0,53.008
516 | 0,73.922
517 | 0,34.383
518 | 0,63.328
519 | 0,60.461
520 | 0,65.188
521 | 0,82.656
522 | 0,67.156
523 | 0,48.25
524 | 0,47.148
525 | 1,53.516
526 | 0,32.094
527 | 0,68.875
528 | 0,63.719
529 | 0,42.305
530 | 0,44.414
531 | 0,42.586
532 | 0,58.867
533 | 0,72.859
534 | 0,70.953
535 | 0,66.016
536 | 0,44.648
537 | 0,57.953
538 | 0,41.938
539 | 0,66.281
540 | 0,39.969
541 | 0,63.563
542 | 0,61.25
543 | 0,64.75
544 | 0,67.625
545 | 0,40.125
546 | 1,69.672
547 | 0,68.875
548 | 0,51.234
549 | 0,55.641
550 | 0,59.594
551 | 1,81
552 | 0,66.297
553 | 0,57.398
554 | 0,44.359
555 | 0,67.672
556 | 0,61.25
557 | 0,53.109
558 | 0,68.297
559 | 0,62.109
560 | 0,63.797
561 | 0,60.609
562 | 0,55.859
563 | 0,35.625
564 | 0,81.031
565 | 0,79.578
566 | 0,66.594
567 | 0,65.719
568 | 1,80.813
569 | 0,75.063
570 | 0,66.375
571 | 0,51.445
572 | 0,53.898
573 | 0,64.547
574 | 0,66.828
575 | 0,63.406
576 | 1,55.984
577 | 0,59.086
578 | 0,51.688
579 | 1,72.547
580 | 0,66.125
581 | 0,82.844
582 | 0,71.453
583 | 0,47.07
584 | 0,47.789
585 | 0,71.297
586 | 0,66.688
587 | 0,52.414
588 | 0,50.906
589 | 0,44.055
590 | 0,58.633
591 | 0,67.906
592 | 0,63.523
593 | 0,73.203
594 | 0,71.922
595 | 0,55.375
596 | 1,82.641
597 | 0,71.172
598 | 0,52.422
599 | 0,56.563
600 | 0,77.672
601 | 1,77.797
602 | 0,50.359
603 | 0,47.289
604 | 0,67.266
605 | 0,52.281
606 | 0,45.719
607 | 0,70.672
608 | 0,58.633
609 | 0,63.68
610 | 1,60
611 | 0,51.688
612 | 0,63.375
613 | 0,64.766
614 | 1,59.914
615 | 0,77.594
616 | 0,54.625
617 | 0,66.266
618 | 0,61.938
619 | 0,67.281
620 | 0,71.25
621 | 0,68.344
622 | 0,57.469
623 | 0,63.227
624 | 0,45.836
625 | 0,47.461
626 | 0,52.336
627 | 0,45.547
628 | 1,69.734
629 | 0,60.391
630 | 0,54.766
631 | 0,53.781
632 | 0,74.25
633 | 0,39.727
634 | 0,52.18
635 | 0,40.648
636 | 0,72.797
637 | 0,48.133
638 | 0,48.938
639 | 0,59.797
640 | 0,44.602
641 | 0,47.984
642 | 0,54.133
643 | 0,64.109
644 | 0,67.188
645 | 0,41.266
646 | 0,73.953
647 | 0,73.234
648 | 0,59.383
649 | 0,71.422
650 | 0,57.336
651 | 0,59.055
652 | 0,57.57
653 | 1,75.031
654 | 0,59.492
655 | 1,85.797
656 | 0,53.43
657 | 0,53.297
658 | 0,63.156
659 | 0,60.711
660 | 0,50.492
661 | 0,60.469
662 | 0,67.188
663 | 0,60.805
664 | 0,58.641
665 | 0,55.156
666 | 0,74.359
667 | 0,67.594
668 | 0,72.859
669 | 0,39.914
670 | 0,79.219
671 | 0,63.5
672 | 0,76.078
673 | 0,66.453
674 | 1,77.688
675 | 0,63.313
676 | 0,49.68
677 | 0,81.375
678 | 0,51.555
679 | 1,73.797
680 | 0,50.164
681 | 1,58.375
682 | 0,59.18
683 | 0,85.234
684 | 1,61.633
685 | 0,45.609
686 | 0,79.844
687 | 0,69.141
688 | 0,77.859
689 | 0,49.836
690 | 0,48.359
691 | 0,79.406
692 | 0,32.906
693 | 0,79.938
694 | 0,73.641
695 | 0,63.438
696 | 0,58.281
697 | 0,59.883
698 | 0,64.391
699 | 0,50.102
700 | 0,75.156
701 | 0,58.25
702 | 1,77.109
703 | 0,44.32
704 | 0,55.5
705 | 0,66.359
706 | 0,45.07
707 | 0,69.734
708 | 0,69.031
709 | 0,75.859
710 | 0,57.352
711 | 0,53.047
712 | 0,66.797
713 | 0,70.516
714 | 0,67.391
715 | 0,61.086
716 | 0,59.797
717 | 0,50.805
718 | 0,53.148
719 | 0,72.734
720 | 0,68
721 | 0,69.188
722 | 0,52.992
723 | 0,62.742
724 | 0,65.375
725 | 0,46.969
726 | 0,54.016
727 | 0,51
728 | 0,82.484
729 | 0,75.469
730 | 0,68.469
731 | 0,64.828
732 | 0,59.695
733 | 0,62.531
734 | 0,47.953
735 | 0,62.57
736 | 0,52.641
737 | 0,53.75
738 | 1,77.922
739 | 0,73.484
740 | 1,78.188
741 | 0,71.328
742 | 0,55.117
743 | 0,69.453
744 | 0,44.094
745 | 0,61.422
746 | 0,63.273
747 | 1,78.516
748 | 0,71.703
749 | 0,49.523
750 | 0,64.781
751 | 0,65.734
752 | 0,65.297
753 | 0,64.5
754 | 0,54.844
755 | 0,63.75
756 | 0,52.734
757 | 0,76.125
758 | 1,51
759 | 0,66.891
760 | 0,84.906
761 | 0,72.781
762 | 0,73.375
763 | 1,68.438
764 | 1,76.75
765 | 0,44.859
766 | 0,76.813
767 | 0,64.703
768 | 0,74.891
769 | 0,72.031
770 | 0,62.875
771 | 0,52.07
772 | 0,53.047
773 | 0,38.375
774 | 0,48.555
775 | 0,51.563
776 | 0,55.523
777 | 0,44.813
778 | 1,78.5
779 | 0,57.164
780 | 0,73.047
781 | 0,50.852
782 | 0,40.719
783 | 0,65.125
784 | 0,49.578
785 | 0,72.063
786 | 0,56.469
787 |
--------------------------------------------------------------------------------
/chapters/12-additivity-linearity.qmd:
--------------------------------------------------------------------------------
1 | # Assumptions in Regression Models - Additivity and Linearity {#additivity-linearity}
2 |
3 | ## GUSTO-I interaction analysis {-}
4 |
5 | ```{r setup-ch12, include=FALSE}
6 | knitr::opts_knit$set(
7 | echo = TRUE,
8 | root.dir = here::here()
9 | )
10 |
11 | knitr::opts_chunk$set(
12 | fig.path = "fig/"
13 | )
14 |
15 | # Load chapter libraries
16 | library(foreign)
17 | library(rms)
18 | library(interactions)
19 | library(mfp) # the MFP library
20 | library(gam)
21 | library(mgcv)
22 | library(kableExtra)
23 |
24 | # Colours
25 | mycolors <- c(
26 | "black" = 1,
27 | "Red" = "#ED0000",
28 | "CongressBlue" = "#00468B",
29 | "Apple" = "#42B540",
30 | "BondiBlue" = "#0099B4",
31 | "TrendyPink" = "#925E9F",
32 | "Carmine" = "#AD002A",
33 | "CodGray" = "#1B1919",
34 | "MonaLisa" = "#FDAF91",
35 | "Edward" = "#ADB6B6"
36 | )
37 | ```
38 |
39 | ### Examine interactions {-}
40 |
41 | ```{r}
42 | # Import gusto, gustoB, and sample4 data sets
43 | gusto <- read.csv("data/gusto1.csv") # GUSTO sample with 40830 patients
44 | gustoB <- read.csv("data/gustoB.csv") # GUSTO part B sample with 20318 patients
45 | gustos <- read.csv("data/sample4.csv") # GUSTO sample4 with 785 patients
46 |
47 | source("R/auc.nonpara.mw.R")
48 | source("R/ci.auc.R")
49 | source("R/val.prob.ci.2.R")
50 |
51 | # levels(gustos$HRT) <- c("No tachycardia", "Tachycardia")
52 | dd <- datadist(gustos)
53 | options(datadist = "dd")
54 | ```
55 |
56 |
57 | Evaluate interactions with age in a full model, which includes 8 predictors in total. The data set is small (sample4, n=785, 52 events)
58 |
59 | ```{r interactions}
60 | ### Full model and age interactions
61 | full <- lrm(DAY30 ~ AGE + KILLIP + HIG + DIA + HYP + HRT + TTR + SEX, data = gustos, x = T, y = T, linear.predictors = F)
62 | fullint <- lrm(DAY30 ~ AGE * (KILLIP + HIG + DIA + HYP + HRT + TTR + SEX), data = gustos, x = T, y = T, linear.predictors = F)
63 | anova(fullint)
64 |
65 | ### Select only interaction AGE * HRT
66 | fullints <- lrm(DAY30 ~ AGE + KILLIP + HIG + DIA + HYP + HRT + TTR + SEX + AGE * HRT, data = gustos, x = T, y = T, linear.predictors = T)
67 | anova(fullints)
68 | ```
69 |
70 |
71 | ### Fig 12.1 {-}
72 |
73 | Make 2 plots with linear interaction, in the small n=785 sample, and in the full n=40830 sample
74 |
75 | ``` {r Fig 12.1, echo=F}
76 | ### Linear interaction
77 | fullints2 <- glm(DAY30 ~ AGE + KILLIP + HIG + DIA + HYP + HRT + TTR + SEX + AGE * HRT, data = gustos, family = "binomial")
78 | fullintF <- update(fullints2, data = gusto)
79 |
80 | ### Plot in n=785
81 | interact_plot(fullints2,
82 | pred = AGE, modx = HRT, outcome.scale = "link", colors = mycolors[c(4, 2)], lwd = c(3, 2), main.title = "GUSTO-I, n=785, AGE*HRT interaction",
83 | interval = T, xlim = c(35, 85), x.label = "Age (years)", y.label = "Logit 30-day mortality", modx.labels = c(0, 1), legend.main = "HRT"
84 | )
85 | ### Plot in full data, n=40830
86 | interact_plot(fullintF,
87 | pred = AGE, modx = HRT, outcome.scale = "link", colors = mycolors[c(4, 2)], lwd = c(3, 2), main.title = "GUSTO-I, n=40,830, AGE*HRT interaction",
88 | interval = T, ylim = c(-4, 0), xlim = c(35, 85), x.label = "Age (years)", y.label = "Logit 30-day mortality", modx.labels = c(0, 1), legend.main = "HRT"
89 | )
90 | ## End Fig 12.1
91 | ```
92 |
93 |
94 | ### Fig 12.2 {-}
95 |
96 | Make 4 plots with main effects, linear interaction, and 2 variants of interaction only above age 55. The variable is (Age-55)[+].
97 |
98 | ``` {r Fig 12.2, echo=F, warning=F}
99 | ### Main effects
100 | full8 <- glm(DAY30 ~ AGE + KILLIP + HIG + DIA + HYP + HRT + TTR + SEX, data = gustos, family = "binomial")
101 | interact_plot(full8,
102 | pred = AGE, modx = HRT, outcome.scale = "link", colors = mycolors[c(4, 2)], lwd = c(3, 2), main.title = "AGE + HRT, 2 df",
103 | interval = T, xlim = c(35, 85), x.label = "Age (years)", y.label = "Logit 30-day mortality", modx.labels = c(0, 1), legend.main = "HRT"
104 | )
105 |
106 | ### Linear interaction
107 | fullints2 <- update(full8, . ~ . + AGE * HRT)
108 | interact_plot(fullints2,
109 | pred = AGE, modx = HRT, outcome.scale = "link", colors = mycolors[c(4, 2)], lwd = c(3, 2), main.title = "GUSTO-I, n=785, AGE*HRT interaction",
110 | interval = T, xlim = c(35, 85), x.label = "Age (years)", y.label = "Logit 30-day mortality", modx.labels = c(0, 1), legend.main = "HRT"
111 | )
112 | ### Age>55 interaction, 3 df
113 | fullints4 <- glm(DAY30 ~ AGE + KILLIP + HIG + DIA + HYP + TTR + SEX + ifelse(AGE > 55, (AGE - 55) * (HRT), 0) + ifelse(AGE > 55, (AGE - 55) * (1 - HRT), 0), data = gustos, family = "binomial")
114 | interact_plot(fullints4,
115 | pred = AGE, modx = HRT, data = gustos, outcome.scale = "link", colors = mycolors[c(4, 2)], lwd = c(3, 2),
116 | main.title = ("AGE + (AGE-55))[+] * HRT + (AGE-55)[+] * (1-HRT), 3 df"),
117 | interval = T, ylim = c(-9, 1), xlim = c(35, 85), x.label = "Age (years)", y.label = "Logit 30-day mortality", modx.labels = c(0, 1), legend.main = "HRT"
118 | )
119 |
120 | ### Age>55 interaction, 2 df; no effect of age among HRT=0
121 | fullints3 <- glm(DAY30 ~ AGE + KILLIP + HIG + DIA + HYP + TTR + SEX + ifelse(AGE > 55, (AGE - 55) * (HRT), 0), data = gustos, family = "binomial")
122 | interact_plot(fullints3,
123 | pred = AGE, modx = HRT, data = gustos, outcome.scale = "link", colors = mycolors[c(4, 2)], lwd = c(3, 2),
124 | main.title = "AGE + (AGE-55)[+] * HRT, 2 df",
125 | interval = T, x.label = "Age (years)", y.label = "Logit 30-day mortality", modx.labels = c(0, 1), legend.main = "HRT"
126 | )
127 |
128 | ## End Fig 12.2
129 | ```
130 |
131 | In the last graph, the green dotted line follows the angle from below age 55 years (only 1 Age effect is estimated for the HRT==0 and HRT==1 and age<55 patients). In the pre-final graph, there are 2 separate angles from age 55 for HRT==0 and HRT==1 (barely noticable for the green dotted line).
132 |
133 |
134 | ### Smart coding illustration {-}
135 |
136 | Smart coding of age effect: separate for no HRT (HRT==0) and for HRT (HRT==1)
137 |
138 | ``` {r Coding, echo=T, warning=F}
139 | # Smart coding of age effect: separate for no HRT (HRT==0) and for HRT (HRT==1)
140 | gustos$AGE0 <- gustos$AGE * (1 - gustos$HRT)
141 | gustos$AGE1 <- gustos$AGE * gustos$HRT
142 | # Standard
143 | lrm(DAY30 ~ AGE + KILLIP + HIG + DIA + HYP + HRT + TTR + SEX + AGE * HRT, data = gustos, x = T, y = T, linear.predictors = F)
144 | # Smart coding
145 | lrm(DAY30 ~ AGE0 + AGE1 + HRT + KILLIP + HIG + DIA + HYP + TTR + SEX, data = gustos, x = T, y = T, linear.predictors = F)
146 | # Identical fit, easier interpretation
147 |
148 | # Age 55 as reference for HRT effect
149 | gustos$AGE0 <- (gustos$AGE - 55) * (1 - gustos$HRT)
150 | gustos$AGE1 <- (gustos$AGE - 55) * gustos$HRT
151 | lrm(DAY30 ~ AGE0 + AGE1 + HRT + KILLIP + HIG + DIA + HYP + TTR + SEX, data = gustos, x = T, y = T, linear.predictors = F)
152 | # Even nicer interpretation, HRT effect for age=55
153 | ```
154 |
155 | The fit of each of the models is identical (always LR chi2=86.28); each model allows for linear interaction between AGE and HRT. The interpretation of the model is easier if the age effects are estimated for HRT==1 and for HRT==0. Scaling is easier by subtracting 55 from AGE (AGE-55); this implies the HRT effect relates to age 55.
156 |
157 |
158 | ### Table 12.2 Better predictions? {-}
159 |
160 | Assess the performance if the models created in n=785 in an independent validation part, GustoB, n=20318.
161 | Plots created with a modification of Frank Harrell's val.prob() function:
162 |
163 | ```{r, results='hide',fig.keep='all'}
164 | # Validate in independent part, named gustoB
165 | # main effects
166 | lrm.val.full <- predict(full, newdata = gustoB, type = "lp")
167 | # simple interaction
168 | lrm.val.int1 <- predict(fullints, newdata = gustoB, type = "lp")
169 |
170 | # Plot
171 | val.prob.ci.2(
172 | y = gustoB[, "DAY30"], logit = lrm.val.full, riskdist = "predicted", logistic.cal = F,
173 | smooth = "rcs", nr.knots = 3, g = 8, xlim = c(0, .5), ylim = c(0, .5),
174 | legendloc = c(0.18, 0.15), statloc = c(0, .4), roundstats = 3,
175 | xlab = "Predicted probability from n=785", ylab = "Observed proportion in n=20318"
176 | )
177 | ```
178 |
179 | ``` {r Table 12.2, echo=F, results=F, warning=F}
180 | # Age>55 interaction, 3 df, or 2 df
181 | gustos$AGE55min <- ifelse(gustos$AGE < 55, gustos$AGE - 55, 0)
182 | gustos$AGE55plusHRT <- ifelse(gustos$AGE < 55 | gustos$HRT == 0, 0, gustos$AGE - 55)
183 | gustos$AGE55plusNoHRT <- ifelse(gustos$AGE < 55 | gustos$HRT == 1, 0, gustos$AGE - 55)
184 | gustos$AGE55 <- gustos$AGE - 55
185 | # Same for GustoB set
186 | gustoB$AGE55min <- ifelse(gustoB$AGE < 55, gustoB$AGE - 55, 0)
187 | gustoB$AGE55plusHRT <- ifelse(gustoB$AGE < 55 | gustoB$HRT == 0, 0, gustoB$AGE - 55)
188 | gustoB$AGE55plusNoHRT <- ifelse(gustoB$AGE < 55 | gustoB$HRT == 1, 0, gustoB$AGE - 55)
189 | gustoB$AGE55 <- gustoB$AGE - 55
190 |
191 | # Fit in n=785
192 | fit3ages <- lrm(DAY30 ~ AGE55min + AGE55plusNoHRT + AGE55plusHRT + KILLIP + HIG + DIA + HYP + TTR + SEX, data = gustos, x = T, y = T, linear.predictors = F)
193 | fitage.HRT <- lrm(DAY30 ~ AGE55 + AGE55plusHRT + KILLIP + HIG + DIA + HYP + TTR + SEX, data = gustos, x = T, y = T, linear.predictors = F)
194 |
195 | # Age>55 interaction, 3 df
196 | lrm.val.int2 <- predict(fit3ages, newdata = gustoB, type = "lp")
197 | # Age>55 interaction, 2 df; no effect of age among HRT=0
198 | lrm.val.int3 <- predict(fitage.HRT, newdata = gustoB, type = "lp")
199 |
200 | par(mfrow = c(2, 2), mar = c(4, 4, 3, 1))
201 | val.prob.ci.2(
202 | y = gustoB[, "DAY30"], logit = lrm.val.full, riskdist = "predicted", logistic.cal = F, smooth = "rcs", nr.knots = 3, g = 8,
203 | xlim = c(0, .5), ylim = c(0, .5), legendloc = c(0.18, 0.15), statloc = c(0, .4), roundstats = 3,
204 | xlab = "Predicted probability from n=785", ylab = "Observed proportion in n=20318"
205 | )
206 | title(bquote(paste("Main effects, 2", italic("df"))))
207 |
208 | val.prob.ci.2(
209 | y = gustoB[, "DAY30"], logit = lrm.val.int1, riskdist = "predicted", logistic.cal = F, smooth = "rcs", nr.knots = 3, g = 8,
210 | xlim = c(0, .5), ylim = c(0, .5), legendloc = c(0.18, 0.15), statloc = c(0, .4), roundstats = 3,
211 | xlab = "Predicted probability from n=785", ylab = "Observed proportion in n=20318"
212 | )
213 | title(bquote(paste("Simple AGE*HRT interaction, 3", italic("df"))))
214 |
215 | val.prob.ci.2(
216 | y = gustoB[, "DAY30"], logit = lrm.val.int2, riskdist = "predicted", logistic.cal = F, smooth = "rcs", nr.knots = 3, g = 8,
217 | xlim = c(0, .5), ylim = c(0, .5), legendloc = c(0.18, 0.15), statloc = c(0, .4), roundstats = 3,
218 | xlab = "Predicted probability from n=785", ylab = "Observed proportion in n=20318"
219 | )
220 | title(bquote(paste("(AGE-55)+*HRT interaction, 3", italic("df"))))
221 |
222 | val.prob.ci.2(
223 | y = gustoB[, "DAY30"], logit = lrm.val.int3, riskdist = "predicted", logistic.cal = F, smooth = "rcs", nr.knots = 3, g = 8,
224 | xlim = c(0, .5), ylim = c(0, .5), legendloc = c(0.18, 0.15), statloc = c(0, .4), roundstats = 3,
225 | xlab = "Predicted probability from n=785", ylab = "Observed proportion in n=20318"
226 | )
227 | title(bquote(paste("AGE + (AGE-55)+*HRT, 2", italic("df"))))
228 | # End performance evaluation in GustoB part, n=20318
229 | ```
230 |
231 | **Conclusions**
232 | Discrimination: worse with interactions than without.
233 | Calibration: We note some overfitting, as expected by a fit in a small sample.
234 |
235 | ## MFP and other non-linear analyses in n544 data {-}
236 |
237 | Upcoming.
238 |
--------------------------------------------------------------------------------
/chapters/10-restrict-cand-pred.qmd:
--------------------------------------------------------------------------------
1 | # Restrictions on Candidate Predictors {#restrictions}
2 |
3 | ```{r setup-ch10, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 |
13 | options(digits=2)
14 | library(rms)
15 | library(knitr)
16 | ```
17 |
18 | ## Case-study: {-}
19 |
20 | ### Mortality after surgery for esophageal cancer {-}
21 |
22 | Let's consider the example of predicting 30 day mortality after surgery for esophageal cancer, We analyzed data from the SEER-Medicare database. Among 2041 patients who were over 65 years old and diagnosed between 1991 and 1996, 221 had died by 30 days [JCO 2006](https://pubmed.ncbi.nlm.nih.gov/16963730/ "Surgical mortality in patients with esophageal cancer: development and validation of a simple risk score").
23 |
24 | For a robust evaluation of the prognostic relevance of comorbidity, we create a simple sum score. It is based on the sum of imputed values for 5 comorbidities. The maximum is 3 comorbidities in this case.
25 |
26 | | Variable | Meaning |
27 | |------------|---------------------------------------------------------|
28 | | `COMORBI` | Comorbidity score based on the count of 5 comorbidities |
29 | | `CPD` | Chronic Pulmonary Disease |
30 | | `Cardio` | Cardiovascular disease |
31 | | `Diabetes` | Diabetes |
32 | | `Liver` | Liver disease |
33 | | `Renal` | Renal disease |
34 |
35 | : Comorbidity variables
36 |
37 | We describe the data below. Note that some missing values for comorbidities were imputed with values between 0 and 1. A regression imputation model was used, with the expected value used as a single imputed value.
38 |
39 | ```{r Initial.Data.Analysis, warning=F}
40 | # Import SEER data set, n=2041
41 | Surgery <- read.csv("data/EsoSurgery.csv")
42 | options(prType='html')
43 | html(describe(Surgery), scroll=TRUE)
44 | fit1 <- lrm(D30~COMORBI, data=Surgery)
45 | print(fit1)
46 | ```
47 |
48 | The prognostic value of the score is modest; on its own (univariate logistic regression of `D30~COMORBI)`, we find a *c* statistic of 0.55.
49 |
50 | ### Testing the equal weights assumption in a simple sumscore {-}
51 |
52 | Simple sums of predictors make the assumption of equal weights for each predictor. This assumption can be assessed in at least two ways
53 |
54 | 1. An overall test: is a more refined coding preferable over a simple sum?\
55 | In the example of comorbidity, we consider the sum of 5 comorbidity conditions as a simple sumscore (Table 10.2). A model considering the 5 comorbidity conditions separately has 5 df and a Likelihood Ratio statistic of 18, in contrast to 14 for the simple sumscore. The difference of 3.6 with 4 df has a p-value of 0.46, far from convincing against the idea of using the simple sumscore.
56 | 2. Component-wise testing: is one of the comborbidities really deviant in a prognostic value?\
57 | We adding the conditions one by one in a regression model that already contains the sumscore. The coefficient of the condition added in a model indicates the deviation from the common effect based on the other conditions.\
58 | We note that the deviations from the common effect are relatively small, except for liver disease and renal disease. Renal disease even seemed to have a protective effect. Both effects were based on small numbers. The standard errors of the estimates were large, and the effects were statistically nonsignificant.
59 |
60 | ```{r test.equal.weights}
61 | # Make function that that a score plus its components
62 | # outcome and data specified as well
63 | test.equal.weights <- function(data=Surgery, y="D30", sumscore="COMORBI",
64 | components=Cs(CPD, Cardio, Diabetes, Liver, Renal)) {
65 | # results in matrix
66 | matrix.coefs <- matrix(nrow=(2+length(components)), ncol=7)
67 | # labels.components <- dput(as.character(components)) # to get it nice for row.labels
68 | dimnames(matrix.coefs) <- list(c("sumscore", "ALL", dput(as.character(components))),
69 | Cs(Coef.Sumscore, SE.Sumscore, Coef.Component, SE.Component,
70 | LR, df, p-value))
71 | # Make models:
72 | # 1. sumscore
73 | fit1 <- lrm(data[,y] ~ data[,sumscore])
74 | matrix.coefs[1,] <- c(fit1$coef[2], sqrt(fit1$var[2,2]), NA, NA, fit1$stats[3:5])
75 |
76 | # 2. full model for overall comparison
77 | fit.full <- lrm(data[,y] ~ as.matrix(data[,components]), x=T)
78 | # compare model fits
79 | p.anova.comparison <- pchisq(fit.full$stats[3] - fit1$stats[3],
80 | df= fit.full$stats[4] - fit1$stats[4], lower.tail = F )
81 | matrix.coefs[2,] <- c(NA, NA, NA, NA, fit.full$stats[3:4], p.anova.comparison)
82 |
83 | # 3. fit incremenal differences to sumscore
84 | for (i in 1:length(components)) {
85 | fiti <- update(fit1, .~.+ fit.full$x[,i])
86 | # compare model fits
87 | p.anova.comparison <- pchisq(fiti$stats[3] - fit1$stats[3],
88 | df= fiti$stats[4] - fit1$stats[4], lower.tail = F )
89 | matrix.coefs[2+i,] <- c(fiti$coef[2], sqrt(fiti$var[2,2]), fiti$coef[3], sqrt(fiti$var[3,3]),
90 | fiti$stats[3:4], p.anova.comparison) } # end loop
91 | return(matrix.coefs)
92 | } # end function
93 |
94 | kable(test.equal.weights(data=Surgery, y="D30", sumscore="COMORBI",
95 | components=Cs(CPD, Cardio, Diabetes, Liver, Renal)),
96 | caption="**Table 10.2**: Testing deviations for each condition in a sum score. Data from esophageal cancer patients who underwent surgery (2041 patients from SEER-Medicare data, 221 died by 30 days). The overall test for deviations from a simple sum score had a p-value of 0.46 (overall LR test, 4 *df*)")
97 | ```
98 |
99 | ### Discussion {-}
100 |
101 | In the SEER data case study, **we stick to our assumption of a similar effect for all comorbities**. The apparently most deviant effects of liver disease and renal disease were unreliable. We hence may assume similar effects for `Liver` and `Renal` as for the other comorbidities.
102 |
103 | An extension of the component-wise testing might be to apply a **LASSO regression model** where the sumscore effect is taken as an offset, with shrinkage of deviations from this offset. In the case study, the overall test was far from statistically significant, and hence we expect shrinkage of most or all of these deviations to zero. This idea is similar to **updating** of a prediction model, with shrinkage of deviating coefficients to values of a prior model: `y~predictor, offset=linear.predictor` [Stat Med 2004](https://pubmed.ncbi.nlm.nih.gov/15287085/ "Validation and updating of predictive logistic regression models: a study on sample size and shrinkage").
104 |
105 | Further discussions on robust modeling were motivated by a case study on **prediction of mutations based on family history** [JAMA 2006](https://pubmed.ncbi.nlm.nih.gov/17003395/ "Prediction of MLH1 and MSH2 mutations in Lynch syndrome"). A simple weighting of second degree relatives as half the effect of first degree relatives worked well in this case. And the effect for age of diagnosis in a relative could be assumed identical for the index patient (proband) and the first and second degree relatives. This simplification saved degrees of freedom in the modeling process at the expense of potentially missing specific patterns in the data [Stat Med 2007](https://pubmed.ncbi.nlm.nih.gov/17948867/ "Data reduction for prediction: a case study on robust coding of age and family history for the risk of having a genetic mutation").\
106 | A robust approach is especially attractive in relatively small data set. Indeed, a major study attempted to model family history for different cancers (*colon, endometrial, other*) separately for first and second degree relatives, with dichotomization of age as below or above 50 years in 870 patients with only 38 mutations identified [NEJM 2006](https://pubmed.ncbi.nlm.nih.gov/16807412/ "Identification and survival of carriers of mutations in DNA mismatch-repair genes in colon cancer"). Simulations confirmed that attempting such modeling was a bad idea [JCE 2018](https://pubmed.ncbi.nlm.nih.gov/29174118/ "Poor performance of clinical prediction models: the harm of commonly applied methods"), both because of severe overfitting (38 events) and [dichotomania](https://twitter.com/MaartenvSmeden/status/1504422652215185413 "Dichotomania - dichotomizing variables is often a very bad idea"). In contrast, the robust modeling strategy was applied in various versions of prediction models for mutation status [Gastroenterology 2011](https://pubmed.ncbi.nlm.nih.gov/20727894/ "The PREMM(1,2,6) model predicts risk of MLH1, MSH2, and MSH6 germline mutations based on cancer history"); [JCO 2017](https://pubmed.ncbi.nlm.nih.gov/28489507/ "Development and Validation of the PREMM5 Model for Comprehensive Risk Assessment of Lynch Syndrome"), with satisfactory performance in a large-scale international validation study [JNCI 2015](https://pubmed.ncbi.nlm.nih.gov/26582061/ "Comparison of Prediction Models for Lynch Syndrome Among Individuals With Colorectal Cancer").
107 |
108 | ### Literature {-}
109 |
110 | **SEER data case study**:
111 |
112 | - Steyerberg EW, Neville BA, Koppert LB, Lemmens VE, Tilanus HW, Coebergh JW, Weeks JC, Earle CC. [Surgical mortality in patients with esophageal cancer: development and validation of a simple risk score.](https://pubmed.ncbi.nlm.nih.gov/16963730/) J Clin Oncol. 2006 Sep 10;24(26):4277-84. doi: 10.1200/JCO.2005.05.0658. PMID: 16963730
113 |
114 | **Methods papers:**
115 |
116 | - Steyerberg EW, Borsboom GJ, van Houwelingen HC, Eijkemans MJ, Habbema JD. [Validation and updating of predictive logistic regression models: a study on sample size and shrinkage.](https://pubmed.ncbi.nlm.nih.gov/15287085/) Stat Med. 2004 Aug 30;23(16):2567-86. doi: 10.1002/sim.1844. PMID: 15287085
117 |
118 | - Steyerberg EW, Uno H, Ioannidis JPA, van Calster B; Collaborators. [Poor performance of clinical prediction models: the harm of commonly applied methods.](https://pubmed.ncbi.nlm.nih.gov/29174118/) J Clin Epidemiol. 2018 Jun;98:133-143. doi: 10.1016/j.jclinepi.2017.11.013. Epub 2017 Nov 24. PMID: 29174118
119 |
120 | - Steyerberg EW, Balmaña J, Stockwell DH, Syngal S. [Data reduction for prediction: a case study on robust coding of age and family history for the risk of having a genetic mutation.](https://pubmed.ncbi.nlm.nih.gov/17948867/) Stat Med. 2007 Dec 30;26(30):5545-56. doi: 10.1002/sim.3119. PMID: 17948867
121 |
122 | **Mutation status prediction:**
123 |
124 | - Balmaña J, Stockwell DH, Steyerberg EW, ..., Burbidge LA, Syngal S. [Prediction of MLH1 and MSH2 mutations in Lynch syndrome.](https://pubmed.ncbi.nlm.nih.gov/17003395/) JAMA. 2006 Sep 27;296(12):1469-78. doi: 10.1001/jama.296.12.1469. PMID: 17003395
125 |
126 | - Barnetson RA, Tenesa A, Farrington SM, Nicholl ID, Cetnarskyj R, Porteous ME, Campbell H, Dunlop MG. [Identification and survival of carriers of mutations in DNA mismatch-repair genes in colon cancer.](https://pubmed.ncbi.nlm.nih.gov/16807412/) N Engl J Med. 2006 Jun 29;354(26):2751-63. doi: 10.1056/NEJMoa053493
127 |
128 | - Kastrinos F, Uno H, Ukaegbu C, ..., Steyerberg EW, Syngal S. [Development and Validation of the PREMM~5~ Model for Comprehensive Risk Assessment of Lynch Syndrome.](https://pubmed.ncbi.nlm.nih.gov/28489507/) J Clin Oncol. 2017 Jul 1;35(19):2165-2172. doi: 10.1200/JCO.2016.69.6120. Epub 2017 May 10. PMID: 28489507
129 |
130 | - Kastrinos F, Steyerberg EW, Mercado R, ..., Wenstrup RJ, Syngal S. [The PREMM(1,2,6) model predicts risk of MLH1, MSH2, and MSH6 germline mutations based on cancer history.](https://pubmed.ncbi.nlm.nih.gov/20727894/) Gastroenterology. 2011 Jan;140(1):73-81. doi: 10.1053/j.gastro.2010.08.021. Epub 2010 Aug 19. PMID: 20727894
131 |
132 | - Kastrinos F, Ojha RP, Leenen C, ..., Syngal S, Steyerberg EW; Lynch Syndrome prediction model validation study group. [Comparison of Prediction Models for Lynch Syndrome Among Individuals With Colorectal Cancer.](https://pubmed.ncbi.nlm.nih.gov/26582061/) [J]{.underline} Natl Cancer Inst. 2015 Nov 18;108(2):djv308. doi: 10.1093/jnci/djv308. Print 2016 Feb.PMID: 26582061
133 |
--------------------------------------------------------------------------------
/chapters/19-external-validity.qmd:
--------------------------------------------------------------------------------
1 | # Patterns of External Validity {#external-validity}
2 |
3 | ```{r setup-ch19, include=FALSE}
4 | knitr::opts_knit$set(
5 | echo = TRUE,
6 | root.dir = here::here()
7 | )
8 |
9 | knitr::opts_chunk$set(
10 | fig.path = "fig/"
11 | )
12 |
13 | library(rms)
14 | library(knitr)
15 | library(kableExtra)
16 |
17 | options(digits=3)
18 | mycolors <- c(
19 | "black" = 1,
20 | "Red" = "#ED0000",
21 | "CongressBlue" = "#00468B",
22 | "Apple" = "#42B540",
23 | "BondiBlue" = "#0099B4",
24 | "TrendyPink" = "#925E9F",
25 | "Carmine" = "#AD002A",
26 | "CodGray" = "#1B1919",
27 | "MonaLisa" = "#FDAF91",
28 | "Edward" = "#ADB6B6"
29 | )
30 | # need the stat.ES() function
31 | source("R/val.functions.17jan19.R")
32 | ```
33 |
34 | ### Fig 19.1: a missed predictor Z {-}
35 |
36 | ```{r Fig19.1, echo=FALSE}
37 | set.seed(2)
38 | n <- 1000
39 | x <- rnorm(n, 0, 1)
40 | x <- x[order(x)]
41 | z <- rnorm(n, 0, 1) # uncorrelated z, 'missed predictor'
42 | z2 <- rnorm(n=n, mean=0) # Make correlated below
43 | z3 <- rnorm(n=n, mean=0) # Make weakly correlated below
44 |
45 | # Make vars truly Normal in mean and sd
46 | x <- (x - mean(x))/sd(x)
47 | z <- (z - mean(z))/sd(z)
48 | z2 <- (z2 - mean(z2))/sd(z2)
49 | z3 <- (z3 - mean(z3))/sd(z3)
50 |
51 | z2 <- sqrt(.25) * x + sqrt(1-.25) * z2
52 | z3 <- sqrt(.11) * x + sqrt(1-.11) * z3
53 |
54 | cat("Actual correlations in n=1000\nr=0:", cor(z, x), " r=.33:", cor(z3, x), " r=.5:",cor(z2, x))
55 |
56 |
57 | # Fig 19.1 #
58 | par(mfrow=c(1,3), pty="s", mar=c(4,4,3,1))
59 | plot(x,z, xlab="x", ylab="z, uncorrelated", xlim=c(-3,3), ylim=c(-3,3), cex.lab=1.2, main="r = 0", cex.main=2, col=mycolors[2])
60 | plot(x,z3, xlab="x", ylab="z, weakly correlated", xlim=c(-3,3), ylim=c(-3,3), cex.lab=1.2, main="r = 0.33", cex.main=2, col=mycolors[3])
61 | plot(x,z2, xlab="x", ylab="z, moderately correlated", xlim=c(-3,3), ylim=c(-3,3), cex.lab=1.2, main="r = 0.5", cex.main=2, col=mycolors[4])
62 | # End Fig 19.1 #
63 | ```
64 |
65 | ### Fig 19.2: a missed predictor Z with identical distribution {-}
66 |
67 | --> no impact
68 | ```{r Fig19.2, echo=FALSE}
69 | # simulations: z indep, z correlated, z weakly correlated
70 | set.seed(12)
71 | n <- 500000
72 | x <- rnorm(n, 0, 1)
73 | x <- x[order(x)]
74 | z <- rnorm(n, 0, 1) # uncorrelated z, 'missed predictor'
75 | z2 <- rnorm(n=n, mean=0) # Make correlated below
76 | z3 <- rnorm(n=n, mean=0) # Make weakly correlated below
77 |
78 | # Make vars truly Normal in mean and sd
79 | x <- (x - mean(x))/sd(x)
80 | z <- (z - mean(z))/sd(z)
81 | z2 <- (z2 - mean(z2))/sd(z2)
82 | z3 <- (z3 - mean(z3))/sd(z3)
83 |
84 | z2 <- sqrt(.25) * x + sqrt(1-.25) * z2 # weak correlation
85 | z3 <- sqrt(.106) * x + sqrt(1-.106) * z3 # stronger = 'moderate' correlation
86 |
87 | # Set coefficients for adjusted / unadjusted analysis
88 | b <- 1.53
89 | b2 <- 2.045
90 | bz2 <- 1.5
91 | b3 <- 1.179
92 | logit <- b*x
93 | logit2 <- b2*x + bz2*z
94 | logit3 <- b3*x + bz2*z2
95 | logit4 <- b*x + b*z3 # correlation and stratification balance out
96 |
97 | # Weak correlation
98 | p2 <- plogis(logit4)
99 | y2 <- ifelse(runif(n)<=p2, 1, 0)
100 |
101 | # No correlation
102 | p <- plogis(logit2)
103 | y <- ifelse(runif(n)<=p, 1, 0)
104 |
105 | # Moderate correlation
106 | p3 <- plogis(logit3)
107 | y3 <- ifelse(runif(n)<=p3, 1, 0)
108 |
109 | # Fig 19.2: Graphs for 3 situations
110 | par(mfrow=c(1,3), pty="s", mar=c(4,4,3,1))
111 | stat.ES(p=plogis(logit),y=y,cutoff=.3, smooth=F, logistic.cal=T, main="Uncorrelated x-z", rounddec1=1, rounddec2=1, rounddec4=3, cex.main=1.5)
112 | stat.ES(p=plogis(logit),y=y2,cutoff=.3, smooth=F, logistic.cal=T, main="Weakly correlated x-z",rounddec1=1, rounddec2=1, rounddec4=3, cex.main=1.5)
113 | stat.ES(p=plogis(logit),y=y3,cutoff=.3, smooth=F, logistic.cal=T, main="Correlated x-z", rounddec1=1, rounddec2=1, rounddec4=3, cex.main=1.5)
114 | ### end Fig 19.2 ###
115 | ```
116 |
117 | ### Fig 19.3: more or less severe cases selected {-}
118 |
119 | ```{r Fig19.3, echo=FALSE}
120 | ### selection on x
121 | # MNAR on x, R2 50%, 50% missing (since mean x1==0)
122 | # More severe case-mix
123 | # Fig 19.3 #
124 | par(mfrow=c(1,2), pty="s", mar=c(4,4,3,1))
125 | set.seed(6)
126 | xMNAR1 <- ifelse(rnorm(n=n,sd=.8) < x, x, NA)
127 | stat.ES(p=plogis(logit)[!is.na(xMNAR1)],y=y2[!is.na(xMNAR1)],cutoff=.3, smooth=F, logistic.cal=T, main="More severe x selected", rounddec1=0,rounddec2=1, rounddec4=3, cex.main=1.5)
128 | # Less severe case-mix
129 | xMNAR <- ifelse(rnorm(n=n,sd=.8) > x, x, NA)
130 | stat.ES(p=plogis(logit)[!is.na(xMNAR)],y=y2[!is.na(xMNAR)],cutoff=.3, smooth=F, logistic.cal=T, main="Less severe x selected", rounddec1=1,rounddec2=1, rounddec4=3, cex.main=1.5)
131 | ## End Fig 19.3 ##
132 | ```
133 |
134 | ### Fig 19.4: more or less heterogeneous cases selected {-}
135 |
136 | ```{r Fig19.4, echo=FALSE}
137 | # More heterogeneous case-mix
138 | par(mfrow=c(1,2), pty="s", mar=c(4,4,3,1))
139 | set.seed(2)
140 | xhetero <- ifelse(runif(n=n, min=0, max=max(x)) < abs(x), x, NA)
141 | stat.ES(p=plogis(logit)[!is.na(xhetero)],y=y2[!is.na(xhetero)],cutoff=.3, smooth=F, logistic.cal=T,
142 | main="More heterogeneous x selected", rounddec1=0,rounddec2=1, rounddec4=3, cex.main=1.2)
143 | # More homogeneous case-mix
144 | xhomo <- ifelse(rnorm(n=n,sd=1.5) > abs(x), x, NA)
145 | stat.ES(p=plogis(logit)[!is.na(xhomo)],y=y2[!is.na(xhomo)],cutoff=.3, smooth=F, logistic.cal=T,
146 | main="Less heterogeneous x selected", rounddec1=1,rounddec2=1, rounddec4=3, cex.main=1.2)
147 | ## End Fig 19.4 ##
148 | ```
149 |
150 | ### Fig 19.5: more or less severe cases selected by Z {-}
151 |
152 | --> Selection by missed predictor leads to miscalibration
153 | ```{r Fig19.5, echo=FALSE}
154 | ##### Missed predictor, z ###
155 | # More severe z
156 | par(mfrow=c(2,3), pty="s", mar=c(4,4,3,1))
157 | set.seed(2)
158 | zMNAR1 <- ifelse(rnorm(n=n,sd=.8) < z, z, NA)
159 | stat.ES(p=plogis(logit)[!is.na(zMNAR1)],y=y[!is.na(zMNAR1)],cutoff=.3, smooth=F, logistic.cal=T, main="More severe z selected, r=0",rounddec1=2,rounddec2=2, rounddec4=3)
160 | zMNAR2 <- ifelse(rnorm(n=n,sd=.8) < z3, z3, NA)
161 | stat.ES(p=plogis(logit)[!is.na(zMNAR2)],y=y2[!is.na(zMNAR2)],cutoff=.3, smooth=F, logistic.cal=T, main="More severe z selected, r=0.33",rounddec1=2,rounddec2=2, rounddec4=3)
162 | zMNAR3 <- ifelse(rnorm(n=n,sd=.8) < z2, z2, NA)
163 | stat.ES(p=plogis(logit)[!is.na(zMNAR3)],y=y3[!is.na(zMNAR3)],cutoff=.3, smooth=F, logistic.cal=T, main="More severe z selected, r=0.5",rounddec1=2,rounddec2=2, rounddec4=3)
164 | # Less severe z
165 | zMNAR11 <- ifelse(rnorm(n=n,sd=.8) > z, z, NA)
166 | stat.ES(p=plogis(logit)[!is.na(zMNAR11)],y=y[!is.na(zMNAR11)],cutoff=.3, smooth=F, logistic.cal=T, main="Less severe z selected, r=0",rounddec1=2,rounddec2=2, rounddec4=3)
167 | zMNAR21 <- ifelse(rnorm(n=n,sd=.8) > z3, z3, NA)
168 | stat.ES(p=plogis(logit)[!is.na(zMNAR21)],y=y2[!is.na(zMNAR21)],cutoff=.3, smooth=F, logistic.cal=T, main="Less severe z selected, r=0.33",rounddec1=2,rounddec2=2, rounddec4=3)
169 | zMNAR31 <- ifelse(rnorm(n=n,sd=.8) > z2, z2, NA)
170 | stat.ES(p=plogis(logit)[!is.na(zMNAR31)],y=y3[!is.na(zMNAR31)],cutoff=.3, smooth=F, logistic.cal=T, main="Less severe z selected, r=0.5",rounddec1=2,rounddec2=2, rounddec4=3)
171 | # End Fig 19.5 #
172 | ```
173 |
174 |
175 | ### Fig 19.6: more or less heterogeneous cases selected by Z {-}
176 |
177 | --> Selection by missed predictor has minor impact
178 | ```{r Fig19.6, echo=FALSE}
179 | # More heterogeneous case-mix
180 | par(mfrow=c(2,3), pty="s", mar=c(4,4,3,1))
181 | set.seed(1)
182 | zhetero1 <- ifelse(runif(n=n, min=0, max=max(z)) < abs(z), z, NA)
183 | stat.ES(p=plogis(logit)[!is.na(zhetero1)],y=y[!is.na(zhetero1)],cutoff=.3, smooth=F, logistic.cal=T, main="More heterogeneous z selected, r=0",rounddec1=1,rounddec2=2, rounddec4=3, cex.main=0.8)
184 | zhetero2 <- ifelse(runif(n=n, min=0, max=max(z3)) < abs(z3), z3, NA)
185 | stat.ES(p=plogis(logit)[!is.na(zhetero2)],y=y2[!is.na(zhetero2)],cutoff=.3, smooth=F, logistic.cal=T, main="More heterogeneous z selected, r=0.33",rounddec1=1,rounddec2=1, rounddec4=3, cex.main=0.8)
186 | zhetero3 <- ifelse(runif(n=n, min=0, max=max(z2)) < abs(z2), z2, NA)
187 | stat.ES(p=plogis(logit)[!is.na(zhetero3)],y=y3[!is.na(zhetero3)],cutoff=.3, smooth=F, logistic.cal=T, main="More heterogeneous z selected, r=0.5",rounddec1=1,rounddec2=2, rounddec4=3, cex.main=0.8)
188 | # More homogeneous case-mix
189 | zhomo1 <- ifelse(rnorm(n=n,sd=1.5) > abs(z), z, NA)
190 | stat.ES(p=plogis(logit)[!is.na(zhomo1)],y=y[!is.na(zhomo1)],cutoff=.3, smooth=F, logistic.cal=T, main="Less heterogeneous z selected, r=0", rounddec1=1,rounddec2=2, rounddec4=3, cex.main=0.8)
191 | zhomo2 <- ifelse(rnorm(n=n,sd=1.5) > abs(z3), z3, NA)
192 | stat.ES(p=plogis(logit)[!is.na(zhomo2)],y=y2[!is.na(zhomo2)],cutoff=.3, smooth=F, logistic.cal=T, main="Less heterogeneous z selected, r=0.33", rounddec1=1,rounddec2=1, rounddec4=3, cex.main=0.8)
193 | zhomo3 <- ifelse(rnorm(n=n,sd=1.5) > abs(z2), z2, NA)
194 | stat.ES(p=plogis(logit)[!is.na(zhomo3)],y=y3[!is.na(zhomo3)],cutoff=.3, smooth=F, logistic.cal=T, main="Less heterogeneous z selected, r=0.5", rounddec1=2,rounddec2=2, rounddec4=3, cex.main=0.8)
195 | # End Fig 19.6 #
196 | ## End z simulations ##
197 | ```
198 |
199 |
200 | ## Fig 19.7: Case-control design disturbs calibration {-}
201 |
202 | Disturbance is exactly as expected by ratio of selecting cases:controls (log(2))
203 | Select all cases, and half of the controls --> same as shift in intercept
204 |
205 | ```{r Fig19.7, echo=FALSE}
206 | par(mfrow=c(1,2), pty="s", mar=c(4,4,3,1))
207 | set.seed(1)
208 | j <- ifelse(y==1 | sample(y==0, 0.5*length(y==0)),T,F)
209 | stat.ES(p=plogis(logit)[j],y=y[j],cutoff=.3, smooth=F, logistic.cal=T, main="More cases selected", rounddec1=1,rounddec2=1, rounddec4=3, cex.main=1.5)
210 | ## Select more severe cases according to x
211 | j2 <- ifelse(y==0 | sample(y==1, 0.5*length(y==1)),T,F)
212 | stat.ES(p=plogis(logit)[j2],y=y[j2],cutoff=.3, smooth=F, logistic.cal=T, main="Less cases selected", rounddec1=1,rounddec2=1, rounddec4=3, cex.main=1.5)
213 | ```
214 |
215 |
216 | ### Fig 19.8: Overfitting disturbs discrimination and calibration {-}
217 |
218 | ```{r Fig19.8, echo=FALSE}
219 | set.seed(1)
220 | logit <- b*x
221 | logit2s <- 0.804*b2*x + bz2*z
222 | logit3s <- 0.683*b3*x + bz2*z2
223 | logit4s <- 0.74*b*x + b*z3 # correlation and stratification balance out
224 | logit4ss <- 0.479*b*x + b*z3 # correlation and stratification balance out
225 |
226 | # Weak correlation
227 | p2s <- plogis(logit4s)
228 | y2s <- ifelse(runif(n)<=p2s, 1, 0)
229 |
230 |
231 | p2ss <- plogis(logit4ss) # with double shrinkage = 0.6
232 | y2ss <- ifelse(runif(n)<=p2ss, 1, 0)
233 |
234 | #### Graphs for 2 shrinkage scenarios, 19.8 ####
235 | par(mfrow=c(1,2), pty="s", mar=c(4,4,3,1))
236 | stat.ES(p=plogis(logit),y=y2s,cutoff=.3, smooth=F, logistic.cal=T, main="Slope linear predictor 0.8",rounddec1=1,rounddec2=1, rounddec4=3)
237 | stat.ES(p=plogis(logit),y=y2ss,cutoff=.3, smooth=F, logistic.cal=T, main="Slope linear predictor 0.6",rounddec1=1,rounddec2=1, rounddec4=3)
238 | ## End Fig 19.8
239 | ```
240 |
241 |
242 | ### Fig 19.9: Different coeficients (model misspecification) disturbs discrimination and calibration {-}
243 |
244 | ```{r Fig19.9, echo=FALSE}
245 | set.seed(1)
246 | n <- 500000
247 | x1 <- rnorm(n,sd=1)
248 | x2 <- rnorm(n,sd=.9)
249 | x3 <- rnorm(n,sd=.8)
250 | x4 <- rnorm(n,sd=.7)
251 | x5 <- rnorm(n,sd=.6)
252 | x6 <- rnorm(n,sd=.5)
253 | x7 <- rnorm(n,sd=.4)
254 | x8 <- rnorm(n,sd=.3)
255 | x9 <- rnorm(n,sd=.2)
256 | x10 <- rnorm(n,sd=.1)
257 | xsum <- x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 # lp in development data
258 | xval <- .5*x1 + 1.5*x2 + .5*x3 + 1.5*x4 + 0.5*x5 + 1.5*x6 + 0.5*x7 + 1.5*x8 + 0.5*x9 + 1.5*x10 # lp in validation data
259 | xval2 <- .25*x1 + 1.5*x2 + .25*x3 + 1.5*x4 + .25 *x5 + 1.5*x6 + .25*x7 + 1.5*x8 + .25*x9 + 1.5*x10 # lp in validation data
260 |
261 | logit.dev <- 0.76 * xsum
262 | pdev <- plogis(logit.dev)
263 | ydev <- ifelse(runif(n)<=pdev, 1, 0)
264 |
265 | logit.val <- 0.76 * xval
266 | pval <- plogis(logit.val)
267 | yval <- ifelse(runif(n)<=pval, 1, 0)
268 |
269 | logit.val2 <- 0.76 * xval2
270 | pval2 <- plogis(logit.val2)
271 | yval2 <- ifelse(runif(n)<=pval2, 1, 0)
272 |
273 | #### Graphs for 2 different coefs scenarios ####
274 | par(mfrow=c(1,2), pty="s", mar=c(4,4,3,1))
275 | stat.ES(p=plogis(logit.dev),y=yval,cutoff=.3, smooth=F, logistic.cal=T, main="X effects * 0.5 or 1.5",rounddec1=1,rounddec2=2, rounddec4=3)
276 | stat.ES(p=plogis(logit.dev),y=yval2,cutoff=.3, smooth=F, logistic.cal=T, main="X effects * 0.25 or 1.5",rounddec1=1,rounddec2=2, rounddec4=3)
277 | ### End different effects, Fig 19.9 ###
278 | ```
279 |
280 |
281 | ### Scenarios: Table 19.4 {-}
282 |
283 | Change of setting may especially impact calibration
284 | RCT vs survey may impact discrimination (more homogeneity) and calibration
285 |
286 | ```{r Scenarios, echo=FALSE}
287 | # Case-mix + different effects (some shrinkage)
288 | z3 <- rnorm(n=n, mean=0) # Make weakly correlated below
289 | z3 <- (z3 - mean(z3))/sd(z3) # Make vars truly Normal in mean and sd
290 | z3 <- sqrt(.107) * ((xsum - mean(xsum))/sd(xsum)) + sqrt(1-.107) * z3
291 |
292 | # Set coefficients for adjusted / unadjusted analysis
293 | b <- 1.5
294 | logitsum <- 0.76*xsum
295 | logit4 <- 0.76*xval + b*z3 # correlation and stratification balance out
296 |
297 | # Weak correlation
298 | p2 <- plogis(logit4)
299 | y2 <- ifelse(runif(n)<=p2, 1, 0)
300 |
301 | ## graphs change of setting scenarios
302 | par(mfrow=c(1,2), pty="s", mar=c(4,4,3,1))
303 | zMNAR1 <- ifelse(rnorm(n=n,sd=.8) < z3, z3, NA) # More severe
304 | stat.ES(p=plogis(logitsum)[!is.na(zMNAR1)],y=y2[!is.na(zMNAR1)],cutoff=.3, smooth=F, logistic.cal=T, main="More severe z; \nX effects 0.5 or 1.5",rounddec1=2,rounddec2=2, rounddec4=3)
305 | zMNAR2 <- ifelse(rnorm(n=n,sd=.8) > z3, z3, NA) # Less severe
306 | stat.ES(p=plogis(logitsum)[!is.na(zMNAR2)],y=y2[!is.na(zMNAR2)],cutoff=.3, smooth=F, logistic.cal=T, main="Less severe z; \nX effects 0.5 or 1.5",rounddec1=2,rounddec2=2, rounddec4=3)
307 |
308 | ## scenario RCT validation
309 | # More homogeneous x case-mix + more severe z
310 | # par(mfrow=c(2,2), pty="s", mar=c(4,4,3,1))
311 | xhomo <- ifelse(rnorm(n=n,sd=1.5) > abs(xval), xval, NA)
312 | xhetero <- ifelse(runif(n=n, min=0, max=max(xval)) < abs(xval), xval, NA)
313 | stat.ES(p=plogis(logitsum)[!is.na(zMNAR1)&!is.na(xhetero)],y=y2[!is.na(zMNAR1)&!is.na(xhetero)],cutoff=.3, smooth=F, logistic.cal=T, main="More severe z; more heterogeneous x;\nX effects 0.5 or 1.5",rounddec1=2,rounddec2=2, rounddec4=3, cex.main=.8)
314 | stat.ES(p=plogis(logitsum)[!is.na(zMNAR1)&!is.na(xhomo)],y=y2[!is.na(zMNAR1)&!is.na(xhomo)],cutoff=.3, smooth=F, logistic.cal=T, main="More severe z; less heterogeneous x;\nX effects 0.5 or 1.5",rounddec1=2,rounddec2=2, rounddec4=3, cex.main=.8)
315 | stat.ES(p=plogis(logitsum)[!is.na(zMNAR2)&!is.na(xhetero)],y=y2[!is.na(zMNAR2)&!is.na(xhetero)],cutoff=.3, smooth=F, logistic.cal=T, main="Less severe z; more heterogeneous x;\nX effects 0.5 or 1.5",rounddec1=2,rounddec2=2, rounddec4=3, cex.main=.8)
316 | stat.ES(p=plogis(logitsum)[!is.na(zMNAR2)&!is.na(xhomo)],y=y2[!is.na(zMNAR2)&!is.na(xhomo)],cutoff=.3, smooth=F, logistic.cal=T, main="Less severe z; less heterogeneous x;\nX effects 0.5 or 1.5",rounddec1=2,rounddec2=2, rounddec4=3, cex.main=.8)
317 | ```
318 |
319 | ### Uncertainty in validation simulations {-}
320 |
--------------------------------------------------------------------------------