Score a Sleep Diaries questionnaire from raw answers
Source:R/questionnaires.R
score_questionnaire.RdRe-scores any of the eight validated instruments included in the Sleep Diaries app. Scoring algorithms exactly match the app's JavaScript implementation.
Value
A named list with at minimum:
scoreNumeric. The computed total or mean score (for MCTQ: a list with
msf_scandsjl).labelCharacter. The clinical interpretation label.
referenceCharacter. Citation for the instrument.
PSQI additionally returns components (a named vector of the 7 component
scores). MCTQ additionally returns msf_sc and sjl as top-level fields.
Examples
# ESS
score_questionnaire("ess", answers = list(
ess1 = 2, ess2 = 1, ess3 = 0, ess4 = 3,
ess5 = 1, ess6 = 0, ess7 = 2, ess8 = 1
))
#> $score
#> [1] 10
#>
#> $label
#> [1] "Excessive"
#>
#> $reference
#> [1] "Johns, M. W. (1991). Sleep, 14(6), 540-545."
#>
# MCTQ (free-day mid-sleep and social jetlag)
score_questionnaire("mctq", answers = list(
mctq_wd = 5,
mctq_bt_w = list(hour = 23, minute = 0),
mctq_sl_w = 15,
mctq_wt_w = list(hour = 7, minute = 0),
mctq_bt_f = list(hour = 0, minute = 30),
mctq_sl_f = 20,
mctq_wt_f = list(hour = 9, minute = 0)
))
#> $score
#> $score$msf_sc
#> [1] 4.77
#>
#> $score$sjl
#> [1] 1.79
#>
#>
#> $label
#> [1] "Late chronotype"
#>
#> $msf_sc
#> [1] 4.77
#>
#> $sjl
#> [1] 1.79
#>
#> $reference
#> [1] "Roenneberg, T., et al. (2003). J Biol Rhythms, 18(1), 80-90."
#>