The following code chunk shows how to create a simulated data.frame containing the items of the PHQ-15 questionnaire:

library(qscorer)
library(dplyr)
library(wakefield)
df.test.phq15  Observations: 100
#> Variables: 16
#> $ id        "001", "002", "003", "004", "005", "006", "007", "008", "0...
#> $ phq15_1   2, 2, 2, 1, 2, 1, 1, 1, 2, 0, 1, 1, 0, 1, 2, 0, 2, 2, 0, 0...
#> $ phq15_2   2, 1, 1, 2, 0, 0, 2, NA, 1, 1, 1, NA, 1, 2, 1, 0, 1, 1, 1,...
#> $ phq15_3   2, 1, 2, 1, NA, 0, 0, 0, 0, 2, 1, 0, 1, 0, 2, 2, 0, 1, 2, ...
#> $ phq15_4   1, 0, 1, 1, 1, 1, 2, 2, NA, 2, 0, 2, 2, 2, 1, 2, 2, 2, 0, ...
#> $ phq15_5   0, 0, 2, 0, 1, 1, 2, 1, 0, 2, 0, 0, 2, 1, 0, 0, 1, 1, 1, 1...
#> $ phq15_6   1, 1, 2, 1, 2, 2, 1, 2, 2, 0, NA, 0, 1, 0, 2, 2, 1, 1, 0, ...
#> $ phq15_7   1, 2, 0, 0, 2, 0, 1, 1, 2, 0, 2, 0, 2, NA, 0, 2, 2, 2, 2, ...
#> $ phq15_8   2, 1, 1, 1, 2, 2, 1, 0, 0, NA, 1, 0, 1, 1, 2, 2, 2, 2, 1, ...
#> $ phq15_9   0, 2, 2, 1, 1, 1, 0, 2, 0, 1, 2, 0, 0, 1, 2, 0, 1, 0, 0, 2...
#> $ phq15_10  0, 2, 2, 0, 2, 0, 0, 1, 0, 0, NA, NA, 0, 0, 2, 2, 0, NA, 2...
#> $ phq15_11  1, 2, NA, 0, 2, 0, 2, 2, 1, 2, 2, 1, 2, 0, 1, 1, 0, 0, 2, ...
#> $ phq15_12  2, 1, 2, 2, 0, 0, 0, 0, 1, 1, 2, 2, 1, 0, 0, 2, 1, 0, 0, 1...
#> $ phq15_13  2, 0, 0, 1, 1, 0, 0, 2, 2, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0...
#> $ phq15_14  0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 2, 1, 0, 0, 0, 1, 0, 0...
#> $ phq15_15  NA, 1, 0, 1, 2, 0, 1, 1, 2, 0, 2, 0, 0, 1, 2, 2, 0, 1, 1, ...

The resulting data.frame may be used for testing the package’s scoring functions:

df.phq15 % 
  scoring_phq15(., items = 2:16, keep = FALSE)
glimpse(df.phq15)
#> Observations: 100
#> Variables: 3
#> $ id            "001", "002", "003", "004", "005", "006", "007", "008"...
#> $ score.phq15   17.142857, 17.000000, 19.285714, 13.000000, 20.357143,...
#> $ cutoff.phq15  Severe, Severe, Severe, Moderate, Severe, Mild, Modera...