## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment  = "#>",
  fig.width  = 7,
  fig.height = 4
)

## ----setup, message = FALSE---------------------------------------------------
library(PTSDdiag)
library(dplyr)

data("simulated_ptsd")
dim(simulated_ptsd)
names(simulated_ptsd)[1:6]

## ----preflight----------------------------------------------------------------
check_pcl5_data(simulated_ptsd[1:120, ], id_col = c("patient_id", "age", "sex"))

## ----rename-------------------------------------------------------------------
ptsd <- rename_ptsd_columns(simulated_ptsd[1:120, ],
                            id_col = c("patient_id", "age", "sex"))
names(ptsd)[1:6]

## ----diagnosis----------------------------------------------------------------
ptsd <- ptsd %>%
  create_ptsd_diagnosis_nonbinarized()

## ----describe-----------------------------------------------------------------
desc <- calculate_ptsd_total(ptsd)
mean(desc$total)

## ----prevalence---------------------------------------------------------------
mean(ptsd$PTSD_orig) * 100

## ----optimize, message = FALSE------------------------------------------------
res <- optimize_combinations(
  ptsd,
  n_symptoms    = 6,
  n_required    = 4,
  n_top         = 3,
  score_by      = "balanced_accuracy",
  show_progress = FALSE
)
res$best_symptoms

## ----summary------------------------------------------------------------------
res$summary

