A new release of the qscorer
package is now available on GitHub.
Scoring procedures
The package (version 0.0.10) provides procedures for scoring the following health-related questionnaires:
- Atrial Fibrillation Effect on QualiTy-of-Life Questionnaire (AFEQT)
- Beck Depression Inventory (BDI, BDI-II)
- Behavior Rating Inventory of Executuve Function, adult version (BRIEF-A)
- Dutch Eating Behavior Questionnaire, German version (DEBQ)
- Eating Disorder Examination Questionnaire, short form (EDE-Q8)
- EORTC QLQ-C30 Quality of Life Questionnaire
- Epworth Sleepiness Scale (ESS)
- European Quality of Life Five Dimension Three Level Scale Questionnaire (EQ-5D-3L)
- General Self-Efficacy Scale (GSES)
- Hospital Anxiety and Depression Scale (HADS)
- Impact of Weight on Quality of Life-Lite Questionnaire (IWQOL-Lite)
- Internaltional Index of Erectile Function, short form (IIEF-5)
- International Physical Activity Questionnaire, short form (IPAQ)
- Patient Health Questionnaire-9 (PHQ-9)
- Patient Health Questionnaire-15 (PHQ-15)
- Rosenberg Self-Esteem Scale (RSES)
- Severe Respiratory Questionnaire (SRI)
- Skala zur Selbstregulation (REG) (German)
- Social Support Questionnaire, short form (F-SozU-K-7) (German)
- Weight Bias Internalization Scale (WBIS)
- Weight Self-Stigma Questionnaire (WSSQ)
- Yale Food Addiction Scale, Version 2.0 (YFAS V2.0)
The scoring functions usually have the following arguments:
data
: A data frame containing the items of the questionnaire in a pre-specified order. The data.frame may contain further variables.items
: A character vector with the item names in a pre-specified order, or a numeric vector indicating the column numbers of the items indata
.keep
: Logical, whether to keep the single items and whether to return variables containing the number of non-missing items on each scale for each respondent. The default is TRUE.nvalid
: A numeric value indicating the number of non-missing items required for score calculations. A default is pre-specified for each questionnaire.digits
: Integer of length one: value to round to. No rounding by default.
If there are items that need to be scored reversely:
reverse
: Items to be scored reversely. These items can be specified either by name or by index. Default is pre-specified.
Data
Furthermore, the package contains real-life data of the following questionnaires:
- Beck Depression Inventory II (
df.test.bdi
) - Dutch Eating Behavior Questionnaire, German version (
df.test.debq
) - EORTC QLQ-C30 Quality of Life Questionnaire (
df.test.eortcc30
) - European Quality of Life Five Dimension Three Level Scale Questionnaire (
df.test.eq5d3l
) - Hospital Anxiety and Depression Scale (
df.test.hads
) - Patient Health Questionnaire-9 (
df.test.phq9
)
These real-life data are publicly available; sources can be found in the package documentation. The following output shows the df.test.phq9
data set (data of the PHQ-9 (a.k.a. PHQ-D) questionnaire).
dplyr::glimpse(qscorer::df.test.phq9)
## Observations: 1,337 ## Variables: 11 ## $ age <dbl> 79, 62, 71, 65, 63, 68, 52, 88, 71, 77, 69, 55, 71, 65, 69, 65, 71, 53, 86, 58, 69, 70, 69, 69, 74, 74, 60… ## $ gender <fct> f, f, m, f, f, f, m, m, f, f, f, m, f, f, f, f, f, m, f, f, f, m, f, m, m, m, f, f, m, f, m, m, f, f, f, f… ## $ phq9_1 <dbl> 1, 3, 2, 0, 0, 0, 1, 0, 0, 2, 1, 1, 0, 3, 0, 0, 0, 2, 0, 0, 2, 3, 0, 0, 0, 3, 1, 0, 1, 1, 1, 1, 0, 1, 1, 2… ## $ phq9_2 <dbl> 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 2, 0, 1, 0, 1… ## $ phq9_3 <dbl> 3, 2, 2, 2, 1, 0, 1, 3, 1, 0, 1, 1, 0, 3, 1, 0, 0, 0, 0, 0, 1, 3, 1, 0, 0, 3, 0, 0, 1, 1, 1, 1, 3, 3, 1, 1… ## $ phq9_4 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 3, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 3, 0, 0, 1, 1, 1, 2, 2, 2, 1, 2… ## $ phq9_5 <dbl> 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0, 0, 1, 3, 0, 1, 0, 2, 0, 0, 1, 0, 0, 1, 3, 1, 1, 0… ## $ phq9_6 <dbl> 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0… ## $ phq9_7 <dbl> 0, 1, 1, 1, 0, 1, 0, 0, 0, 3, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 3, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1… ## $ phq9_8 <dbl> 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1… ## $ phq9_9 <dbl> 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
Questionnaires without real-life data may be simulated using the simulate_items()
function. The following code simulates data for the PHQ-15 questionnaire:
df.phq15 <- qscorer::simulate_items(num_cols = 15, item_name = 'PHQ15', item_range = 0:2)
Two more arguments have default values and don't need to be explicitly specified:
num_rows
(Number of rows; default = 100)prop_mis
(Proportion of missing values to be put into each item; default = 0.05)
The function returns a data frame including the items of the questionnaire and an id variable.
dplyr::glimpse(df.phq15)
## Observations: 100 ## Variables: 16 ## $ id <chr> "001", "002", "003", "004", "005", "006", "007", "008", "009", "010", "011", "012", "013", "014", "015",… ## $ PHQ15_1 <int> 2, 2, 2, 1, 2, 1, 1, 1, 2, 0, 1, 1, 0, 1, 2, 0, 2, 2, 0, 0, 0, 0, 2, NA, 2, 1, NA, 1, 2, 1, 0, 2, 2, 0, … ## $ PHQ15_2 <int> 2, 1, 1, 2, 0, 0, 2, NA, 1, 1, 1, NA, 1, 2, 1, 0, 1, 1, 1, 2, 1, 2, 1, 2, 0, 2, 2, 2, 0, 2, 2, 1, 1, 1, … ## $ PHQ15_3 <int> 2, 1, 2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2, 0, 2, 2, 2, 1, 1, 0, 0, 2… ## $ PHQ15_12 <int> 2, 1, 2, 2, 0, 0, 0, 0, 1, 1, 2, 2, 1, 0, 0, 2, 1, 0, 0, 1, 2, 0, 1, 0, 1, 2, 1, 0, 2, NA, 0, 1, 0, 0, 0… ## $ PHQ15_13 <int> 2, 0, 0, 1, 1, 0, 0, 2, 2, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 2, 1, 0, 1, 2, 0, 1, 2, NA, 1, 2, 0, 1, 0, 2… ## $ PHQ15_14 <int> 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 2, 1, 0, 0, 0, 1, 0, 0, 2, 1, 2, 2, 2, 1, 0, 2, 1, 0, 2, 1, 2, 2, 2,… ## $ PHQ15_15 <int> NA, 1, 0, 1, 2, 0, 1, 1, 2, 0, 2, 0, 0, 1, 2, 2, 0, 1, 1, 2, 1, 1, 0, 0, 0, 0, 0, 0, NA, 0, 2, NA, 0, NA…
Now, the corresponding scoring function (scoring_phq15()
) can be apllied to this data:
library(dplyr) df.phq15 <- df.phq15 %>% qscorer::scoring_phq15(.,items = 2:16, keep = FALSE)
The function returns a data frame including the PHQ-15 score and the corresponding cut-off values (severe, moderate, mild, …):
dplyr::glimpse(df.phq15)
## Observations: 100 ## Variables: 3 ## $ id <chr> "001", "002", "003", "004", "005", "006", "007", "008", "009", "010", "011", "012", "013", "014", "0… ## $ score.phq15 <dbl> 17.142857, 17.000000, 19.285714, 13.000000, 20.357143, 8.000000, 14.000000, 16.071429, 15.000000, 11… ## $ cutoff.phq15 <fct> Severe, Severe, Severe, Moderate, Severe, Mild, Moderate, Severe, Severe, Moderate, Severe, Mild, Se…
Documentation
The package documentation is hosted on GitHub Pages.