## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment  = "#>",
  fig.align = "center"
)
library(smoothROC)

## -----------------------------------------------------------------------------
data(dystrophy)
str(dystrophy)

## -----------------------------------------------------------------------------
roc <- smoothROC(
  data      = dystrophy,
  biomarker = "CK",
  status    = "Class",
  diseased  = "carrier",
  kernel    = "biweight",
  bw_method = "PB",
  alpha     = 0.05,
  logtrans  = TRUE,
  grid_n    = 1000
)

## -----------------------------------------------------------------------------
roc
summary(roc)

## ----roc-plot-full, fig.cap="ROC curve with Youden point and annotation"------
plot(roc)

## ----roc-plot-nolabel, fig.cap="ROC curve with Youden point, no annotation"----
plot(roc, label = FALSE)

## ----roc-plot-noyouden, fig.cap="ROC curve with annotation, no Youden point"----
plot(roc, youden = FALSE)

## ----roc-plot-clean, fig.cap="ROC curve only"---------------------------------
plot(roc, label = FALSE, youden = FALSE)

## -----------------------------------------------------------------------------
head(roc$curve)     # FPR, TPR, threshold, J (one row per unique FPR)
roc$AUC             # AUC estimate
roc$AUC_ci          # AUC confidence interval
roc$J               # Youden index estimate
roc$J_ci            # Youden index CI
roc$t0              # Youden cutoff
roc$sensitivity     # Sensitivity at Youden point
roc$specificity     # Specificity at Youden point
roc$hX              # Bandwidth for non-diseased CDF
roc$hY              # Bandwidth for diseased CDF

