Validate variable total scores
Categories:
This below section renders a vignette article from the youthvars library. You can use the following links to:
- view the vignette on the library website (adds useful hyperlinks to code blocks)
- view the source file from that article, and;
- edit its contents (requires a GitHub account).
Variable classes and data integrity
The youthvars
package includes a number of ready4 framework sub-module classes that form part of the ready4 economic model of youth mental health. The primary use of youthvars
sub-modules is to quality assure the variables used in model input and output datasets by:
- facilitating automated data integrity checks that verify no impermissible values (e.g. utility scores greater than one) are present in source data, transformed data or results; and
- implementing rules-based automated selection and application of appropriate methods for each dataset variable.
Included sub-module classes
The initial set of sub-module classes included in the youthvars
package are one class for Assessment of Quality of Life (Adolescent) health utility and one for each of the predictors used in the utility prediction algorithms included in the related youthu package.
Assessment of Quality of Life Six Dimension (Adolescent) Health Utility
The youthvars_aqol6d_adol
class is defined for numeric vectors with a minimum value of 0.03 and maximum value of 1.0.
youthvars_aqol6d_adol(0.4)
#> [1] 0.4
#> attr(,"class")
#> [1] "youthvars_aqol6d_adol" "numeric"
youthvars_aqol6d_adol(c(0.03,0.2,1))
#> [1] 0.03 0.20 1.00
#> attr(,"class")
#> [1] "youthvars_aqol6d_adol" "numeric"
Non numeric objects and values outside these ranges will produce errors.
youthvars_aqol6d_adol("0.5")
#> Error in make_new_youthvars_aqol6d_adol(x): is.numeric(x) is not TRUE
youthvars_aqol6d_adol(-0.1)
#> Error: All non-missing values in valid youthvars_aqol6d_adol object must be greater than or equal to 0.03.
youthvars_aqol6d_adol(1.2)
#> Error: All non-missing values in valid youthvars_aqol6d_adol object must be less than or equal to 1.
Child Health Utility Nine Dimension - Australian Adolescent Scoring
The youthvars_chu9d_adolaus
class is defined for numeric vectors with a minimum value of -0.2118 and maximum value of 1.0.
youthvars_chu9d_adolaus(0.4)
#> [1] 0.4
#> attr(,"class")
#> [1] "youthvars_chu9d_adolaus" "numeric"
youthvars_chu9d_adolaus(c(0.03,0.2,1))
#> [1] 0.03 0.20 1.00
#> attr(,"class")
#> [1] "youthvars_chu9d_adolaus" "numeric"
Non numeric objects and values outside these ranges will produce errors.
youthvars_chu9d_adolaus("0.5")
#> Error in make_new_youthvars_chu9d_adolaus(x): is.numeric(x) is not TRUE
youthvars_chu9d_adolaus(-0.3)
#> Error: All non-missing values in valid youthvars_chu9d_adolaus object must be greater than or equal to -0.2118.
youthvars_chu9d_adolaus(1.2)
#> Error: All non-missing values in valid youthvars_chu9d_adolaus object must be less than or equal to 1.
Behavioural Activation for Depression Scale (BADS)
The youthvars_bads
class is defined for integer vectors with a minimum value of 0 and maximum value of 150.
youthvars_bads(143L)
#> [1] 143
#> attr(,"class")
#> [1] "youthvars_bads" "integer"
youthvars_bads(as.integer(c(1,15,150)))
#> [1] 1 15 150
#> attr(,"class")
#> [1] "youthvars_bads" "integer"
Non-integers and values outside these ranges will produce errors.
youthvars_bads(22.5)
#> Error in make_new_youthvars_bads(x): is.integer(x) is not TRUE
youthvars_bads(-1L)
#> Error: All non-missing values in valid youthvars_bads object must be greater than or equal to 0.
youthvars_bads(160L)
#> Error: All non-missing values in valid youthvars_bads object must be less than or equal to 150.
Generalised Anxiety Disorder Scale (GAD-7)
The youthvars_gad7
class is defined for integer vectors with a minimum value of 0 and a maximum value of 21.
youthvars_gad7(15L)
#> [1] 15
#> attr(,"class")
#> [1] "youthvars_gad7" "integer"
youthvars_gad7(as.integer(c(0,14,21)))
#> [1] 0 14 21
#> attr(,"class")
#> [1] "youthvars_gad7" "integer"
Non-integers and values outside these ranges will produce errors.
youthvars_gad7(14.6)
#> Error in make_new_youthvars_gad7(x): is.integer(x) is not TRUE
youthvars_gad7(-1L)
#> Error: All non-missing values in valid youthvars_gad7 object must be greater than or equal to 0.
youthvars_gad7(22L)
#> Error: All non-missing values in valid youthvars_gad7 object must be less than or equal to 21.
Kessler Psychological Distress Scale (K6) - Australian Scoring System
The youthvars_k6_aus
class is defined for integer vectors with a minimum value of 6 and a maximum value of 30.
youthvars_k6_aus(21L)
#> [1] 21
#> attr(,"class")
#> [1] "youthvars_k6_aus" "integer"
youthvars_k6_aus(as.integer(c(6,13,25)))
#> [1] 6 13 25
#> attr(,"class")
#> [1] "youthvars_k6_aus" "integer"
Non-integers and values outside these ranges will produce errors.
youthvars_k6_aus(11.2)
#> Error in make_new_youthvars_k6_aus(x): is.integer(x) is not TRUE
youthvars_k6_aus(1L)
#> Error: All non-missing values in valid youthvars_k6_aus object must be greater than or equal to 6.
youthvars_k6_aus(31L)
#> Error: All non-missing values in valid youthvars_k6_aus object must be less than or equal to 30.
Kessler Psychological Distress Scale (K6) - US Scoring System
The youthvars_k6
class is defined for integer vectors with a minimum value of 0 and a maximum value of 24.
youthvars_k6(21L)
#> [1] 21
#> attr(,"class")
#> [1] "youthvars_k6" "integer"
youthvars_k6(as.integer(c(0,13,24)))
#> [1] 0 13 24
#> attr(,"class")
#> [1] "youthvars_k6" "integer"
Non-integers and values outside these ranges will produce errors.
youthvars_k6(11.2)
#> Error in make_new_youthvars_k6(x): is.integer(x) is not TRUE
youthvars_k6(-1L)
#> Error: All non-missing values in valid youthvars_k6 object must be greater than or equal to 0.
youthvars_k6(25L)
#> Error: All non-missing values in valid youthvars_k6 object must be less than or equal to 24.
Kessler Psychological Distress Scale (K10) - Australian Scoring System
The youthvars_k10_aus
class is defined for integer vectors with a minimum value of 10 and a maximum value of 50.
youthvars_k10_aus(21L)
#> [1] 21
#> attr(,"class")
#> [1] "youthvars_k10_aus" "integer"
youthvars_k10_aus(as.integer(c(13,25,41)))
#> [1] 13 25 41
#> attr(,"class")
#> [1] "youthvars_k10_aus" "integer"
Non-integers and values outside these ranges will produce errors.
youthvars_k10_aus(11.2)
#> Error in make_new_youthvars_k10_aus(x): is.integer(x) is not TRUE
youthvars_k10_aus(9L)
#> Error: All non-missing values in valid youthvars_k10_aus object must be greater than or equal to 10.
youthvars_k10_aus(51L)
#> Error: All non-missing values in valid youthvars_k10_aus object must be less than or equal to 50.
Kessler Psychological Distress Scale (K10) - US Scoring System
The youthvars_k10
class is defined for integer vectors with a minimum value of 0 and a maximum value of 40.
youthvars_k10(21L)
#> [1] 21
#> attr(,"class")
#> [1] "youthvars_k10" "integer"
youthvars_k10(as.integer(c(0,13,34)))
#> [1] 0 13 34
#> attr(,"class")
#> [1] "youthvars_k10" "integer"
Non-integers and values outside these ranges will produce errors.
youthvars_k10(11.2)
#> Error in make_new_youthvars_k10(x): is.integer(x) is not TRUE
youthvars_k10(-1L)
#> Error: All non-missing values in valid youthvars_k10 object must be greater than or equal to 0.
youthvars_k10(41L)
#> Error: All non-missing values in valid youthvars_k10 object must be less than or equal to 40.
Overall Anxiety Severity and Impairment Scale (OASIS)
The youthvars_oasis
class is defined for integer vectors with a minimum value of 0 and a maximum value of 20.
youthvars_oasis(15L)
#> [1] 15
#> attr(,"class")
#> [1] "youthvars_oasis" "integer"
youthvars_oasis(as.integer(c(0,12,20)))
#> [1] 0 12 20
#> attr(,"class")
#> [1] "youthvars_oasis" "integer"
Non-integers and values outside these ranges will produce errors.
youthvars_oasis(14.2)
#> Error in make_new_youthvars_oasis(x): is.integer(x) is not TRUE
youthvars_oasis(-1L)
#> Error: All non-missing values in valid youthvars_oasis object must be greater than or equal to 0.
youthvars_oasis(21L)
#> Error: All non-missing values in valid youthvars_oasis object must be less than or equal to 20.
Patient Health Questionnaire (PHQ-9)
The youthvars_phq9
class is defined for integer vectors with a minimum value of 0 and a maximum value of 27.
youthvars_phq9(11L)
#> [1] 11
#> attr(,"class")
#> [1] "youthvars_phq9" "integer"
youthvars_phq9(as.integer(c(0,13,27)))
#> [1] 0 13 27
#> attr(,"class")
#> [1] "youthvars_phq9" "integer"
Non-integers and values outside these ranges will produce errors.
youthvars_phq9(15.2)
#> Error in make_new_youthvars_phq9(x): is.integer(x) is not TRUE
youthvars_phq9(-1L)
#> Error: All non-missing values in valid youthvars_phq9 object must be greater than or equal to 0.
youthvars_phq9(28L)
#> Error: All non-missing values in valid youthvars_phq9 object must be less than or equal to 27.
Screen for Child Anxiety Related Disorders (SCARED)
The youthvars_scared
class is defined for integer vectors with a minimum value of 0 and a maximum value of 82.
youthvars_scared(77L)
#> [1] 77
#> attr(,"class")
#> [1] "youthvars_scared" "integer"
youthvars_scared(as.integer(c(0,42,82)))
#> [1] 0 42 82
#> attr(,"class")
#> [1] "youthvars_scared" "integer"
Non-integers and values outside these ranges will produce errors.
youthvars_scared(33.2)
#> Error in make_new_youthvars_scared(x): is.integer(x) is not TRUE
youthvars_scared(-1L)
#> Error: All non-missing values in valid youthvars_scared object must be greater than or equal to 0.
youthvars_scared(83)
#> Error in make_new_youthvars_scared(x): is.integer(x) is not TRUE
Social and Occupational Functioning Assessment Scale (SOFAS)
The youthvars_sofas
class is defined for integer vectors with a minimum value of 0 and a maximum value of 100.
youthvars_sofas(44L)
#> [1] 44
#> attr(,"class")
#> [1] "youthvars_sofas" "integer"
youthvars_sofas(as.integer(c(0,23,89)))
#> [1] 0 23 89
#> attr(,"class")
#> [1] "youthvars_sofas" "integer"
Non-integers and values outside these ranges will produce errors.
youthvars_sofas(73.2)
#> Error in make_new_youthvars_sofas(x): is.integer(x) is not TRUE
youthvars_sofas(-1L)
#> Error: All non-missing values in valid youthvars_sofas object must be greater than or equal to 0.
youthvars_sofas(103L)
#> Error: All non-missing values in valid youthvars_sofas object must be less than or equal to 100.