This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Documentation

1 - Overview

About the readyforwhatsnext model.

What is readyforwhatsnext?

readyforwhatsnext is a prototype modular and open source economic model of youth mental health that is being implemented in R. The project is led by researchers at Monash University.

What makes readyforwhatsnext model modular?

readyforwhatsnext is developed with ready4 - a software framework for transparent, reusable and updatable health economic models. The model is comprised of four sub-models. Each sub-model is comprised of model modules that can be independently reused (e.g., in other models) and safely and flexibly combined (e.g., to model more extensive systems).

What is it being used for?

Currently, readyforwhatsnext is being applied to explore multiple economic topics in youth mental health.

Can I use it?

readyforwhatsnext is publicly available and free for you to assess (to verify and validate), apply (to generate novel insights into decision problems of interest to you) and to derive your own derivative works from (to leverage and enhance the work of others) under liberal terms of use.

Why is it a prototype?

Currently readyforwhatsnext model software is only available in the form of development releases. That means readyforwhatsnext modules may require more development, documentation and testing before they could be confidently used for scientific purposes other than the specific studies to which our development team have already applied it.

Can I help?

readyforwhatsnext is a collaborative project and we’d love your help in progressing our priorty project goals! You can help fund our development, contribute code improvements, enhance our documentation and community support, give us advice and/or lead a modelling project.

Where should I go next?

We’d recommend reading the documentation in the order in which sections appear in the table of contents (so go next to Examples, then to Getting started and so on). A scientific manuscript is also available.

2 - Examples

See how readyforwhatsnext has been applied to model real world decision problems in youth mental health.

An scientific summary briefly introducing the readyforwhatsnext model is available as a pre-print manuscript.

Examples of how we are applying readyforwhatsnext in youth mental health include:

3 - Getting started

What you need to know to start using readyforwhatsnext.

3.1 - System requirements

What you need in order to be able to use readyforwhatsnext model software on your machine.

Currently, all readyforwhatsnext model software is written in R (for model module libraries), R Markdown (for analysis programs and reporting sub-routines) and JavaScript (for the user interface component of Shiny applications) using the ready4 framework.

Therefore:

  • to use readyforwhatsnext model module libraries and programs / subroutines you must have an up to date version of R and the ready4 R library installed on your machine and it is recommended that you install the RStudio IDE; and

  • the requirements for using readyforwhatsnext model user interfaces depend on whether you are running a version we have deployed to the web (in which case you just need a supported browser) or whether you are running the app on your local machine (in which case you will need R, the ready4 library and RStudio).

3.2 - Installing readyforwhatsnext model modules

To implement a modelling analysis with readyforwhatsnext you need to install model module R libraries.

Before you install

If you plan on using existing readyforwhatsnext modules for a modelling project, you can review currently available module libraries, to identify which libraries are relevant to your project.

However, please note that no readyforwhatsnext module library is yet available as a [production release](https://www.ready4-dev.com/docs/software/status/production-releases/. You should therefore understand the limitations of using readyforwhatsnext model software development releases before you make the decision to install this software.

Installation

readyforwhatsnext module libraries are currently only available as development releases, so you will need to use a tool like devtools to assist with installing readyforwhatsnext R packages directly from our GitHub organisation. If you do not have devtools on your machine you can install it with the following command.

install.packages("devtools")

The command to install each readyforwhatsnext module takes the following format.

devtools::install_github("ready4-dev/PACKAGE_NAME")

For example, if you are planning to predict health utility using some of the mapping algorithms that we have previously developed, you can install the youthu library with the following command.

devtools::install_github("ready4-dev/youthu")

Configuration

A small number of readyforwhatsnext modules require that you configure some of the dependencies installed with them before they can be used. In particular:

  • if you are using modules from the TTU package to undertake a utility mapping study, you will need to have both installed and configured the cmdstanr R package as per the instructions on that package’s documentation website; and

  • if you are using the mychoice package to undertake a discrete choice experiment study and are using a Mac, you need to ensure that you have a Fortran compiler installed. Some relevant advice on this: https://mac.r-project.org/tools/ .

Try it out!

Before you apply readyforwhatsnext modules to your own project, you should make sure you can run some or all of the example code included in relevant library vignette articles. The package website URL takes the form of https://ready4-dev.github.io/PACKAGE_NAME/articles/ (e.g. the vignettes for the youthvars package are available at https://ready4-dev.github.io/youthvars/articles/).

3.3 - Terms of use

readyforwhatsnext is distributed without warranties under open source licenses - we just ask you to appropriately cite it.

3.3.1 - Open source licensing

readyforwhatsnext is freely available to all under copy-left licensing arrangements.

To help ensure the models we develop are as transparent as possible and to make their algorithms as useful to others as possible, all readyforwhatsnext software is free and open-source. You are encouraged to make as widespread use of our software, including the creation of derivative works, as you see fit, so long as it is consistent with each item’s license. Our software is typically licensed under GPL-3, a copy-left open-source licensing regime.

3.3.2 - Citing readyforwhatsnext

If you find readyforwhatsnext useful, please cite it appropriately - it is easy to do!

To make it easier to cite our software, each software item bundle includes a CITATION.cff file. Inclusion of this file means that the repositories storing our software can generate appropriate citations in the format of most relevance to you.

Currently:

  • Zenodo provides a free text field under the heading “Cite as” which enables you to generate a wide range of citation manager and journal specific citation outputs. There is also an “Export” tool that will generate citation metadata in multiple output formats;
  • OpenAire Explore has a “Cite this software” button that allows you to generate a citation in multiple journal formats or to download BibTeX or RIS files;
  • Github repositories have a “Cite this repository” button that can generate both BibTeX and APA output as well as link to the Citation.cff file.

Additionally, we have included a CITATION file in each of our R libraries so that you can generate a citation from within an R session using the citation function (for example: citation("ready4").

3.3.3 - Disclaimer

readyforwhatsnext is distributed without any warranties.

All readyforwhatsnext model software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Furthermore, no readyforwhatsnext model software is yet sufficiently well documented and tested to be given a production release. All readyforwhatsnext model software should therefore viewed as experimental development releases.

3.4 - The readyforwhatsnext model

readyforwhatsnext is an in-development modular economic model of the systems shaping the mental helath of young people. It is comprised of four sub-models.

3.4.1 - Modules for modelling people

Modules to model the characteristics, relationships, behaviours, risk factors and outcomes of young people and individuals who interact with young people are collectively referred to as the “Spring To Life” sub-model. A table summarising Spring To Life module libraries for modelling people is available. Additional information (e.g. tutorials and blog articles) about currently available Spring To Life modules is labelled with the “model-modules-people” tag. Resources about Spring To Life datasets are tagged with “data-datasets-people”. Brief information about additional unreleased Spring To Life modules that are in development is also available.

3.4.2 - Modules for modelling places

Modules for spatio-temporal modelling of the environments that shape young people’s mental health are collectively referred to as the “Springtides” sub-model. Both Springtides module libraries for modelling places that are available are highly preliminary and lack tutorials to demonstrate their use. A deprecated app built using these libraries is available for illustration purposes. Resources relating to preliminary and unreleased modules for the Springtides model is tagged with the “model-modules-places” tag and those relating to compatible datasets are tagged with “data-datasets-places”. Brief information on unreleased work in progress module libraries are also available.

3.4.3 - Modules for modelling platforms

Modules that model the processes, eligibility requirements, staffing and configurations of youth service platforms are collectively referred to as the “First Bounce” sub-model. No First Bounce modules are yet available - see details on unreleased work in progress.

3.4.4 - Modules for modelling programs

Modules for modelling the efficacy, cost-effectiveness and budget impact of youth mental health programs (e.g. interventions for prevention, treatment and wellbeing) are collectively referred to as the “On Target” sub-model. There are currently two development releases of On Target module libraries for modelling programs but both are highly preliminary. Resources (including tutorials) relating to these module libaries is tagged with “model-modules-programs”.

3.5 - Modules pipeline

Unreleased software and other preliminary work is currently being developed into readyforwhatsnext model modules.

3.5.1 - Pipeline of people modules

Current unreleased work to develop modules for modelling the characteristics, relationships, behaviours, risk factors and outcomes of young people and those important to them.

Our current pipeline of modules for modelling people is principally focused on developing tools for:

  • creating synthetic household datasets from multiple longitudinal datasets of varying structure, including modules specifically designed to streamline wrangling data from the HILDA and LSAC datasets (both from Australia); and

  • implementing agent based model simulations.

A significant amount of work has already been completed on the first project and initial development releases of each, along with one scientific manuscript, are planned for late 2024.

3.5.2 - Pipeline of places modules

Current unreleased work to develop modules for modelling the demographic, environmental and proximity drivers of access, equity and outcomes in youth mental health.

Our current pipeline of modules for modelling places (from the Springtides sub-model) will extend the libraries listed in summary table of module libraries for modelling places to:

  • predict prevalence and incidence by area; and

  • provide a user-interface (i.e. software to implement an updated version of the currently deprecated Springtides app).

Although unreleased, the source code for the above projects has been used to generate analysis during the early phase of the COVID-19 pandemic. Initial development releases of places module libraries, along with an updated app, are anticipated in the second half of 2024.

3.5.3 - Pipeline of platforms modules

Current unreleased work to develop modules for modelling the optimal staffing and configuration of support services for young people.

Our current pipeline of modules for modelling platforms includes code for implementing:

  • a discrete event simulation of primary mental health services for young people;
  • a simple cohort model of early psychosis services; and
  • a blended (systems dynamics / discrete event simulation) model for optimising eligibility and referral policies across multiple services.

The first two of the above models are currently implemented in R and are sufficiently advanced to produce exploratory analysis. However, neither are adequately documented or tested and need to be redeveloped as First Bounce sub-model modules and re-validated prior to development releases. The optimisation model was implemented in Java and was populated with toy data - this will require more substantial development prior to public release.

3.5.4 - Pipeline of programs modules

Current preliminary work to develop modules for modelling the affordability, value for money and appropriate targeting of interventions for young people.

We have no current pipeline of new module libraries for modelling programs (ie for the On Target sub-model). The currently released On Target libraries modules itemised in the summary table of module libraries for modelling programs are highly preliminary and are therefore our focus for future development in this area.

4 - Tutorials

Learn how to find and use readyforwhatsnext modules and datasets.

4.1 - Find model modules and datasets

How to find individual modules, module libraries, dataset collections and datasets.

4.1.1 - Finding specific modules and sub-modules

How to find individual readyforwhatsnext modules and sub-modules.

This below section renders a vignette article from the ready4 library. You can use the following links to:

Motivation

When considering whether to use a model module, it is useful to first see tutorials about appropriate use of that module.

Implementation

A table itemising individual model modules and sub-modules authored with ready4 can be generated using make_modules_tb. This function scrapes relevant data from the websites of module libraries that have been developed within a specified project’s GitHub organisation.

Use

In this example, we are going to examine modules from the readyforwhatsnext model. The value supplied to the gh_repo_1L_chr argument specifies the repository in which a dataset of readyforwhatsnext module libraries is stored. Note, the following command may take a couple of minutes to execute.

modules_tb <-  make_modules_tb(gh_repo_1L_chr = "ready4-dev/ready4")

A slightly quicker method to achieve a similar result is to use the get_modules_tb function. This function retrieves an archived version (and therefore potentially less up to date) of the modules summary table.

# Not run
# modules_tb <- get_modules_tb(gh_repo_1L_chr = "ready4-dev/ready4")

The modules_tb object itemises both model modules (which always use R’s “S4” class type) and sub-modules (“S3” class type).

To display a HTML summary of just model modules, you can use the print_modules function.

print_modules(modules_tb, what_1L_chr = "S4")
Class Description Examples
AusACT Meta data for processing ACT population projections
AusHeadspace Meta data for constructing Headspace Centre geometries
AusLookup Lookup tables for Australian geometry and spatial attribute data
AusOrygen Meta data for constructing OYH Specialist Mental Health Catchment geometries
AusProjections Meta data for constructing custom Australian population projections boundary
AusTasmania Meta data for processing Tasmanian population projections
CostlyCorrespondences Collection of input, standards definition and results datasets for projects to generate standardised costing datasets 1, 2
CostlyCountries Collection of input, standards definition and results datasets for projects to generate standardised country data for use in costing datasets 1, 2
CostlyCurrencies Collection of input, standards definition and results datasets for projects to generate standardised currency data for use in costing datasets 2
CostlySeed Original (non-standardised) dataset (and metadata) 1, 2
CostlySource Input dataset (and metadata) for generating standardised costing datasets
CostlyStandards Dataset (and metadata) defining the allowable values of specified variables 1, 2
ScorzAqol6 A dataset and metadata to support implementation of an AQoL-6D scoring algorithm
ScorzAqol6Adol A dataset and metadata to support implementation of a scoring algorithm for the adolescent version of AQoL-6D 3
ScorzAqol6Adult A dataset and metadata to support implementation of a scoring algorithm for the adult version of AQoL-6D
ScorzEuroQol5 A dataset and metadata to support implementation of an EQ-5D scoring algorithm 4
ScorzProfile A dataset to be scored, its associated metadata and details of the scoring instrument
SpecificConverter Container for seed objects used for creating SpecificModels modules 5
SpecificFixed Modelling project dataset, input parameters and complete fixed models results
SpecificInitiator Modelling project dataset, input parameters and empty results placeholder
SpecificMixed Modelling project dataset, input parameters and complete mixed models results
SpecificModels Modelling project dataset, input parameters and model comparison results
SpecificParameters Input parameters that specify candidate models to be explored
SpecificPredictors Modelling project dataset, input parameters and predictor comparison results
SpecificPrivate Analysis outputs not intended for public dissemination
SpecificProject Modelling project dataset, parameters and results
SpecificResults Analysis results
SpecificShareable Analysis outputs intended for public dissemination
SpecificSynopsis Input, Output and Authorship Data For Generating Reports
TTUProject Input And Output Data For Undertaking and Reporting Utility Mapping Studies 6
TTUReports Metadata to produce utility mapping study reports
TTUSynopsis Input, Output and Authorship Data For Generating Utility Mapping Study Reports
VicinityArguments Function arguments for constructing a spatial object
VicinityLocal Object defining data to be saved in local directory
VicinityLocalProcessed Object defining data to be saved in local directory in a processed (R) format
VicinityLocalRaw Object defining data to be saved in local directory in a raw (unprocessed) format
VicinityLookup Look up tables for spatiotemporal data
VicinityMacro Macro level context
VicinityMesoArea Meso level context - area
VicinityMesoRegion Meso level context - region
VicinityMicro Micro level context
VicinityProfile Information to create a profiled area object
VicinitySpaceTime Spatiotemporal environment
YouthvarsDescriptives Metadata about descriptive statistics to be generated
YouthvarsProfile A dataset and its associated dictionary, descriptive statistics and metadata 8
YouthvarsSeries A longitudinal dataset and its associated dictionary, descriptive statistics and metadata 8

You can use the same function to display only model sub-modules.

print_modules(modules_tb, what_1L_chr = "S3")
Class Description Examples
specific_models Candidate models lookup table
specific_predictors Candidate predictors lookup table
vicinity_abbreviations ready4 submodule class for tibble object lookup table for spatial data abbreviations
vicinity_identifiers ready4 submodule class for tibble object lookup table of unique feature identifiers used for different spatial objects
vicinity_mapes ready4 submodule class for tibble object that stores spatial simulation parameters relating to Mean Absolute Prediction Errors
vicinity_parameters ready4 submodule class for tibble object that stores simulation structural parameters relating to the spatial environment
vicinity_points ready4 submodule class for tibble object lookup table of the longitude and latitude cordinates of sites of services / homes
vicinity_processed ready4 submodule class for tibble object lookup table of meta-data for spatial data packs (imported and pre-processed data)
vicinity_raw ready4 submodule class for tibble object lookup table of metadata about raw (un-processed) spatial data to import
vicinity_resolutions ready4 submodule class for tibble object lookup table of the relative resolutions of different spatial objects
vicinity_templates ready4 submodule class for tibble object lookup table for base file used in creation of certain spatial objects
vicinity_values ready4 submodule class for tibble object that stores simulation parameter values for each iteration
youthvars_aqol6d_adol youthvars ready4 sub-module (S3 class) for Assessment of Quality of Life Six Dimension Health Utility - Adolescent Version (AQoL6d Adolescent) 7
youthvars_bads youthvars ready4 sub-module (S3 class) for Behavioural Activation for Depression Scale (BADS) scores 7
youthvars_chu9d_adolaus youthvars ready4 sub-module (S3 class) for Child Health Utility Nine Dimension Health Utility - Australian Adolescent Scoring (CHU-9D Australian Adolescent) 7
youthvars_gad7 youthvars ready4 sub-module (S3 class) for Generalised Anxiety Disorder Scale (GAD-7) scores 7
youthvars_k10 youthvars ready4 sub-module (S3 class) for Kessler Psychological Distress Scale (K10) - US Scoring System scores 7
youthvars_k10_aus youthvars ready4 sub-module (S3 class) for Kessler Psychological Distress Scale (K10) - Australian Scoring System scores 7
youthvars_k6 youthvars ready4 sub-module (S3 class) for Kessler Psychological Distress Scale (K6) - US Scoring System scores 7
youthvars_k6_aus youthvars ready4 sub-module (S3 class)for Kessler Psychological Distress Scale (K6) - Australian Scoring System scores 7
youthvars_oasis youthvars ready4 sub-module (S3 class) for Overall Anxiety Severity and Impairment Scale (OASIS) scores 7
youthvars_phq9 youthvars ready4 sub-module (S3 class) for Patient Health Questionnaire (PHQ-9) scores 7
youthvars_scared youthvars ready4 sub-module (S3 class) for Screen for Child Anxiety Related Disorders (SCARED) scores 7
youthvars_sofas youthvars ready4 sub-module (S3 class) for Social and Occupational Functioning Assessment Scale (SOFAS) 7

Details of how to search for themed collections of modules is described in another article.

4.1.2 - Model module libraries

Bundles of readyforwhatsnext modules are distributed as R libraries.

readyforwhatsnext model modules are intended to be both transferable (they are tools that can be used in multiple decision contexts) and modular (they are comprised of self-contained components, each of which performs a narrow sub-set of tasks). For these reasons, readyforwhatsnext model modules are developed and distributed as libraries of modules.

The three types of readyforwhatsnext module libraries are:

  • - modules for describing and quality assuring model data;

  • - modules to specify, assess and report statisitical models; and

  • - modules for making predictions.

A table summarising currently available readyforwhatsnext module libraries can be retrieved from an online repository by using the get_libraries_tb function from the ready4 framework library.

library(ready4)
libraries_tb <- get_libraries_tb() %>% update_libraries_tb(include_1L_chr = "modules")#make_libraries_tb("modules")

Module libraries are thematically grouped under one of four “sub-models” of readyforwhatsnext, one each for modelling People (collectively, the “Spring To Life” sub-model), Places (the “Springtides” sub-model), Platforms (collectively, the “First Bounce” sub-model) and Programs (the “On Target” sub-model). We can use the print_packages function to display the module libraries currently available for each section (currently, there are no publicly available libraries of readyforwhatsnext modules for modelling platforms).

Module libraries for modelling people

print_packages(libraries_tb %>% dplyr::filter(Section == "People"))
Type Package Purpose Documentation Code Examples
Describe and Validate Youth Mental Health Dataset Variables Citation , Website , Manual - Short (PDF) , Manual - Full (PDF) Dev , Archive 12, 13
Score Multi-Attribute Utility Instruments Citation , Website , Manual - Short (PDF) , Manual - Full (PDF) Dev , Archive 14, 15
Model Youth Choice Behaviours Citation , Website , Citation Dev , Archive
Implement Transfer to Utility Mapping Algorithms Citation , Website , Manual - Short (PDF) , Manual - Full (PDF) Dev , Archive 16
Explore and Characterise Heterogeneity in Quality of Life Data Citation , Website , Manual - Short (PDF) , Manual - Full (PDF) Dev , Archive
Specify Models to Solve Inverse Problems Citation , Website , Manual - Short (PDF) , Manual - Full (PDF) Dev , Archive 17
Transform Youth Outcomes to Health Utility Predictions Citation , Website , Manual - Short (PDF) , Manual - Full (PDF) Dev , Archive 18

Module libraries for modelling places

print_packages(libraries_tb %>% dplyr::filter(Section == "Places"))
Type Package Purpose Documentation Code Examples
Model Australian Spatial Data Citation , Website , Manual - Short (PDF) , Manual - Full (PDF) Dev , Archive
Model Spatial Features of Health Systems Citation , Website , Manual - Short (PDF) , Manual - Full (PDF) Dev , Archive

Module libraries for modelling programs

print_packages(libraries_tb %>% dplyr::filter(Section == "Programs"))
Type Package Purpose Documentation Code Examples
Undertake Health Economic Budget Impact Analysis. Citation , Website , Manual - Short (PDF) , Manual - Full (PDF) Dev , Archive
Develop, Use and Share Unit Cost Datasets for Health Economic Citation , Website , Manual - Short (PDF) , Manual - Full (PDF) Dev , Archive 19, 20

4.1.3 - Find open access model data

Tools from the ready4 framework library can be used to search for relevant open access readyforwhatsnext model data collections and datasets.

The make_datasets_tb function from the ready4 library can be used to create a summary table of the open access datasets we curate in our ready4 Dataverse Collection.

make_datasets_tb("ready4") -> x

One way to inspect this information is to group contents by Dataverse Collections using the print-data function.

print_data(x,
           by_dv_1L_lgl = T) %>%
  kableExtra::scroll_box(width = "100%")
Dataverse Name Description Creator Datasets
TTU Transfer to Utility A collection of transfer to utility datasets developed with the ready4 open science framework. Orygen 1, 2, 3
fakes Fake Data For Instruction And Illustration Fake data used to illustrate toolkits developed with the ready4 open science framework. Orygen 4 , 5 , 6 , 7 , 8 , 9 , 10, 11
firstbounce First Bounce A ready4 framework model of platforms. Aims to identify opportunities to improve the efficiency and equity of mental health services. Orygen
ready4fw ready4 Framework A collection of datasets that support implementation of the ready4 framework for open science computational models of mental health systems. Orygen 12
readyforwhatsnext readyforwhatsnext Data collections for the readyforwhatsnext mental health systems model. Orygen 13, 14
springtides Springtides A ready4 framework model of places. Synthesises geometry (boundary, coordinate) and spatial attribute (e.g. population counts, environmental characteristics, service identifier and model coefficients associated with areas) data. Orygen 15
springtolife Spring To Life A ready4 framework model of people. Models the characteristics, behaviours, relationships and outcomes of groups of individuals relevant to policymakers and service planners aiming to improve population mental health. Orygen 16

Alternatively, we can itemise individual Dataverse Datasets. When doing so, it makes sense to prepare separate views for toy datasets designed for instruction and real datasets appropriate for use in modelling.

Datasets appropriate for use in modelling projects can be returned by supplying the value “real” to the what_1L_chr argument of print_data.

print_data(x,
           what_1L_chr = "real") %>%
  kableExtra::scroll_box(width = "100%")
Title Description Dataverse DOI
Transfer to AQoL-6D Utility Mapping Algorithms Catalogues of models (and the programs that produced them) that can be used in conjunction with the youthu R package to predict AQoL-6D health utility (and thus, derive QALYs) from measures collected in youth mental health services. TTU
Transfer to AQoL-6D From Measures Collected In Primary Youth Mental Health Services This is a work in progress dataset to support the implementation and reporting of a study to map measures collected in Australian primary youth mental health services to AQoL-6D health utility. TTU
Transfer to CHU-9D From Measures Collected In Primary Youth Mental Health Services This is a work in progress dataset to support the implementation and reporting of a study to map measures collected in Australian primary youth mental health services to CHU-9D health utility TTU
ready4 Framework Abbreviations and Definitions This dataset contains resources that help ready4 Framework Developers adopt common standards and workflows. ready4fw
readyforwhatsnext posters A collection of poster summaries about the readyforwhatsnext project and its outputs. readyforwhatsnext
Australian demographic input parameters for Springtides model Geometry, spatial attribute and metadata inputs for the demographic module of the readyforwhatsnext model. The demographic module is a systems dynamics spatial simulation of area demographic characteristics. The current version of the model is quite rudimentary and is designed to be extended by other models developped with the ready4 open science mental health modelling tools. readyforwhatsnext
Springtides reports for Local Government Areas in the North West of Melbourne This dataset is a collection of reports generated by a development version of the Springtides Model Of Places. Each report summarises prevalence projections for a specified mental disorder / mental health condition for a Local Government Area that is wholly or partially within the catchment area of the Orygen youth mental health service in North West Melbourne. As these reports were generated by a development version of the Springtides Model, these projections should be regarded as exploratory. springtides
Modelling the online helpseeking choice of socially anxious young people

Models to predict the online helpseeking choices of socially anxious young people in Australia and replication code and documentation to implement the discrete choice experiment that generated the models.

All study outputs were created with the aid of the mychoice R package (https://ready4-dev.github.io/mychoice).

springtolife

To view toy datasets, instead supply the value “fakes”.

print_data(x,
           what_1L_chr = "fakes") %>%
  kableExtra::scroll_box(width = "100%")
Title Description Dataverse DOI
TTU (Transfer to Utility) R package - AQoL-6D vignette output This dataset has been generated from fake data as an instructional aid. It is not to be used to inform decision making. fakes
TTU (Transfer to Utility) R package - EQ-5D vignette output This dataset is provided as a teaching aid. It is the output of tools from the TTU R package, applied to a synthetic dataset (Fake Data) of psychological distress and psychological wellbeing. It is not to be used to support decision-making. fakes
Synthetic (fake) youth mental health datasets and data dictionaries The datasets in this collection are entirely fake. They were developed principally to demonstrate the workings of a number of utility scoring and mapping algorithms. However, they may be of more general use to others. In some limited cases, some of the included files could be used in exploratory simulation based analyses. However, you should read the metadata descriptors for each file to inform yourself of the validity and limitations of each fake dataset. To open the RDS format files included in this dataset, the R package ready4use needs to be installed (see ). It is also recommended that you install the youthvars package ( ) as this provides useful tools for inspecting and validating each dataset. fakes
ready4use R package vignette output This dataset is provided so that others can compare the output they generate when implementing vignette code with that generated by the authors. fakes
Replication Data For Quality of Life Heterogeneity Analysis In A Clinical Youth Mental Health Sample This dataset is provided so that others can apply and test the analysis algorithms we have developed. It includes synthetic (fake) data that was generated for the sole purpose of enabling users to rerun our analysis algorithm. fakes
Specific R Package - AQoL-6D Vignette Output This dataset is provided so that others can apply the algorithms we have developed, consistent with the principles of the ready4 open science framework for data synthesis and simulation in mental health. fakes
Synthetic (fake) dataset for hypothetical replication of study mapping psychological distress and functioning measures to AQoL-6D health utility This dataset is comprised of fake data that has been created to illustrate the potential transfer of a study algorithm for creating utility mapping models to new data. Outputs in this dataset are for instructional purposes only and should not be used to inform decision making. fakes
Synthetic (fake) dataset for hypothetical replication of study mapping psychological distress and functioning measures to CHU-9D health utility This dataset is comprised of fake data that has been created to illustrate the potential transfer of a study algorithm for creating CHU-9D utility mapping models to new data. Outputs in this dataset are for instructional purposes only and should not be used to inform decision making fakes

4.2 - Use readyforwhastsnext model modules

How to use readyforwhatsnext model modules to model the people, places, platforms and programs that shape young people’s mental health.

4.2.1 - Add metadata to datasets of individual human records

Appending appropriate metadata to datasets of individual unit records can facilitate partial automation of some modelling tasks. This tutorial describes how a module from the youthvars R package can help you to add metadata to a youth mental health dataset so that it can be more readily used by other readyforwhatsnext modules.

This below section renders a vignette article from the youthvars library. You can use the following links to:

Note: This vignette is illustrated with fake data. The dataset explored in this example should not be used to inform decision-making.

library(ready4)
library(youthvars)

Youthvars provides two ready4 framework modules - YouthvarsProfile and YouthvarsSeries that form part of the readyforwhatsnext economic model of youth mental health. The ready4 modules in youthvars extend the Ready4useDyad module and can be used to help describe key structural properties of youth mental health datasets.

Ingest data

To start we ingest X, a Ready4useDyad (dataset and data dictionary pair) that we can download from a remote repository.

X <- ready4use::Ready4useRepos(dv_nm_1L_chr = "fakes",
                               dv_ds_nm_1L_chr = "https://doi.org/10.7910/DVN/W95KED",
                               dv_server_1L_chr = "dataverse.harvard.edu") %>%
  ingest(fls_to_ingest_chr = "ymh_clinical_dyad_r4",
         metadata_1L_lgl = F)

Add metadata

If a dataset is cross-sectional or we wish to treat it as if it were (i.e., where data collection rounds are ignored) we can create Y, an instance of the YouthvarsProfile module, to add minimal metadata (the name of the unique identifier variable).

Y <- YouthvarsProfile(a_Ready4useDyad = X, id_var_nm_1L_chr = "fkClientID")

If the temporal dimension of the dataset is important, it may be therefore preferable to instead transform X into a YouthvarsSeries module instance. YouthvarsSeries objects contain all of the fields of YouthvarsProfile objects, but also include additional fields that are specific for longitudinal datasets (e.g. timepoint_var_nm_1L_chr and timepoint_vals_chr that respectively specify the data-collection timepoint variable name and values and participation_var_1L_chr that specifies the desired name of a yet to be created variable that will summarise the data-collection timepoints for which each unit record supplied data).

Z <- YouthvarsSeries(a_Ready4useDyad = X,
                     id_var_nm_1L_chr = "fkClientID",
                     participation_var_1L_chr = "participation",
                     timepoint_vals_chr = c("Baseline","Follow-up"),
                     timepoint_var_nm_1L_chr = "round")

YouthvarsProfile methods

Inspect data

We can now specify the variables that we would like to prepare descriptive statistics for by using the renew method. The variables to be profiled are specified in the profile_chr argument, the number of decimal digits (default = 3) of numeric values in the summary tables to be generated can be specified with nbr_of_digits_1L_int.

Y <- renew(Y, nbr_of_digits_1L_int = 2L, profile_chr = c("d_age","d_sexual_ori_s","d_studying_working"))

We can now view the descriptive statistics we created in the previous step.

Y %>%
  exhibit(profile_idx_int = 1L, scroll_box_args_ls = list(width = "100%"))
Descriptive summary
(N = 1711)
Age Mean (SD) 17.64 (3.09)
Median (Q1, Q3) 18.00 (15.00, 20.00)
Min - Max 12.00 25.00
Missing 0.00
Sexual orientation Heterosexual 1178.00 (71.74%)
Other 464.00 (28.26%)
Missing 69.00
Education and employment status Not studying or working 311.00 (18.75%)
Studying and working 451.00 (27.19%)
Studying only 572.00 (34.48%)
Working only 325.00 (19.59%)
Missing 52.00

We can also plot the distributions of selected variables in our dataset.

depict(Y, var_nms_chr = c("c_sofas"), labels_chr = c("SOFAS"))
SOFAS total scores

SOFAS total scores

YouthvarsSeries methods

Validate data

To explore longitudinal data we need to first use the ratify method to ensure that Z has been appropriately configured for methods examining datasets reporting measures at two timepoints.

Z <- ratify(Z,
            type_1L_chr = "two_timepoints")

Inspect data

We can now specify the variables that we would like to prepare descriptive statistics for using the renew method. The variables to be profiled are specified in arguments beginning with “compare_”. Use compare_ptcpn_chr to compare variables based on whether cases reported data at one or both timepoints and compare_by_time_chr to compare the summary statistics of variables by timepoints, e.g at baseline and follow-up. If you wish these comparisons to report p values, then use the compare_ptcpn_with_test_chr and compare_by_time_with_test_chr arguments.

Z <- renew(Z,
           compare_by_time_chr = c("d_age","d_sexual_ori_s","d_studying_working"),
           compare_by_time_with_test_chr = c("k6_total", "phq9_total", "bads_total"),
           compare_ptcpn_with_test_chr = c("k6_total", "phq9_total", "bads_total")) 

The tables generated in the preceding step can be inspected using the exhibit method.

Z %>%
  exhibit(profile_idx_int = 1L,
          scroll_box_args_ls = list(width = "100%"))
Outcomes by data completeness
Baseline only
Baseline and follow-up
(N = 1068) (N = 643) p
Kessler Psychological Distress Scale (6 Dimension) Mean (SD) 12.153 (5.409) 11.069 (5.778) 0.001
Median (Q1, Q3) 12.000 (8.000, 16.000) 11.000 (7.000, 15.000) 0.001
Min - Max 0.000 24.000 0.000 24.000 0.001
Missing 0.000 3.000 0.001
Patient Health Questionnaire Mean (SD) 12.632 (6.086) 11.194 (6.434) 0.000
Median (Q1, Q3) 13.000 (8.000, 17.000) 11.000 (6.000, 16.000) 0.000
Min - Max 0.000 27.000 0.000 27.000 0.000
Missing 1.000 5.000 0.000
Behavioural Activation for Depression Scale Mean (SD) 79.814 (26.478) 83.571 (25.809) 0.010
Median (Q1, Q3) 79.000 (62.000, 95.250) 84.000 (66.000, 101.000) 0.010
Min - Max 0.000 150.000 0.000 150.000 0.010
Missing 1.000 10.000 0.010
Z %>%
  exhibit(profile_idx_int = 2L,
          scroll_box_args_ls = list(width = "100%"))
Outcomes by data collection round
Baseline
Follow-up
(N = 1068) (N = 643)
Age Mean (SD) 17.555 (3.090) 17.770 (3.091)
Median (Q1, Q3) 17.000 (15.000, 20.000) 18.000 (16.000, 20.000)
Min - Max 12.000 25.000 12.000 25.000
Missing 0.000 0.000
Sexual orientation Heterosexual 738.000 (71.860%) 440.000 (71.545%)
Other 289.000 (28.140%) 175.000 (28.455%)
Missing 41.000 28.000
Education and employment status Not studying or working 159.000 (15.347%) 152.000 (24.398%)
Studying and working 305.000 (29.440%) 146.000 (23.435%)
Studying only 405.000 (39.093%) 167.000 (26.806%)
Working only 167.000 (16.120%) 158.000 (25.361%)
Missing 32.000 20.000
Z %>%
  exhibit(profile_idx_int = 3L,
          scroll_box_args_ls = list(width = "100%"))
Outcomes by data collection round (with p values)
Baseline
Follow-up
(N = 1068) (N = 643) p
Kessler Psychological Distress Scale (6 Dimension) Mean (SD) 12.082 (5.603) 10.100 (5.665) 0.000
Median (Q1, Q3) 12.000 (8.000, 16.000) 10.000 (6.000, 14.000) 0.000
Min - Max 0.000 24.000 0.000 24.000 0.000
Missing 1.000 2.000 0.000
Patient Health Questionnaire Mean (SD) 12.646 (6.230) 9.736 (6.210) 0.000
Median (Q1, Q3) 13.000 (8.000, 17.000) 10.000 (5.000, 14.000) 0.000
Min - Max 0.000 27.000 0.000 27.000 0.000
Missing 4.000 2.000 0.000
Behavioural Activation for Depression Scale Mean (SD) 78.429 (25.608) 89.615 (25.205) 0.000
Median (Q1, Q3) 78.000 (61.000, 95.000) 88.000 (73.000, 106.000) 0.000
Min - Max 0.000 150.000 0.000 150.000 0.000
Missing 7.000 4.000 0.000

The depict method can create plots, comparing numeric variables by timepoint.

depict(Z,
       type_1L_chr = "by_time",
       var_nms_chr = c("c_sofas"),
       label_fill_1L_chr = "Time",#
       labels_chr = c("SOFAS"),#
       y_label_1L_chr = "")
SOFAS total scores by data collection round

SOFAS total scores by data collection round

Share data

If and only if the dataset you are working with is appropriate for public dissemination (e.g. is synthetic data), you can use the following workflow for sharing it. We can share the dataset we created for this example using the share method, specifying the repository to which we wish to publish the dataset (and for which we have write permissions) in a (Ready4useRepos object).

A <- Ready4useRepos(gh_repo_1L_chr = "ready4-dev/youthvars", # Replace with your repository 
                          gh_tag_1L_chr = "Documentation_0.0"), # (need write permissions).
A <- share(A,
           obj_to_share_xx = Z,
           fl_nm_1L_chr = "ymh_YouthvarsSeries")

Z is now available for download as the file ymh_YouthvarsSeries.RDS from the “Documentation_0.0” release of the youthvars package.

4.2.2 - Validate variable total scores

Vector based classes can be used to help validate variable values. This tutorial describes how to do that with sub-module classes exported as part of the youthvars R package.

This below section renders a vignette article from the youthvars library. You can use the following links to:

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:

  1. 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
  2. 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.

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.

4.2.3 - Standardise Variable Values With Fuzzy Logic And Correspondence Tables

Costing health economic datasets is an activity that can involve repeated use of lookup tables. This tutorial describes how a module from the costly R package can help you to use a combination of fuzzy logic and correspondence tables to standardise variable values and thus facilitate partial automation of costing algorithms.

This below section renders a vignette article from the costly library. You can use the following links to:

In brief

The steps described and explained in this vignette can also be (more succinctly) accomplished with the following code.

X <- CostlyCountries() 
X <- renew(X, type_1L_chr = "default") 
X <- renew(X, "jw", type_1L_chr = "slot", what_1L_chr = "logic") 
X <- renew(X, T, type_1L_chr = "slot", what_1L_chr = "force")
X <- ratify(X) 

Create project

We begin by creating X, an instance of the CostlyCorrespondences module.

Supply seed dataset

We begin by creating a CostlySeed module instance that includes a dataset containing our variable of interest (in this case, countries). The dataset needs to be paired with a dataset dictionary using the Ready4useDyad module from the ready4use R library. You can supply a custom standards dataset (a tibble), dictionary (a ready4use_dictionary) and the concept represented by our variable of interest using a command of the following format.

# Not run
# A <- CostlySeed(Ready4useDyad_r4 = Ready4useDyad(ds_tb = tibble::tibble(), dictionary_r3 = ready4use_dictionary()), include_chr = c("Country"), label_1L_chr = "Country")

The add_default_country_seed function will perform the previous step using values that pair the world.cities dataset of the maps R library with an appropriate dictionary and specifies countries as the concept we will be standardising.

We can now inspect the first few records from our labelled seed dataset.

renewSlot(A, "Ready4useDyad_r4", type_1L_chr = "label") %>%
exhibitSlot("Ready4useDyad_r4", display_1L_chr = "head", scroll_box_args_ls = list(width = "100%"))
Dataset
City name Country name Population size Latitude coordinate Longitude coordinate Is the nation's capital city
'Abasan al-Jadidah Palestine 5629 31.31 34.34 0
'Abasan al-Kabirah Palestine 18999 31.32 34.35 0
'Abdul Hakim Pakistan 47788 30.55 72.11 0
'Abdullah-as-Salam Kuwait 21817 29.36 47.98 0
'Abud Palestine 2456 32.03 35.07 0
'Abwein Palestine 3434 32.03 35.20 0

We can also inspect the data dictionary contained in A.

exhibitSlot(A, "Ready4useDyad_r4", type_1L_chr = "dict", scroll_box_args_ls = list(width = "100%"))
Data Dictionary
Variable Category Description Class
name City City name character
country.etc Country Country name character
pop Population Population size integer
lat Latitude Latitude coordinate numeric
long Longitude Longitude coordinate numeric
capital Capital Is the nation's capital city integer

We now specify the dictionary category that corresponds to the variable we wish to standardise (“Country”). We need to use the same category name to label the results objects that we generate in subsequent steps.

A@include_chr <- A@label_1L_chr <- "Country"

We now add A to X.

X <- renew(X, A, what_1L_chr = "seed")

Specify standards

We next must specify a dataset that includes the complete list of allowable variable values.

This workflow for this step is similar to that for specifying standards, except that instead of a CostlySeed module we use a CostlyStandards module.

# Not run
# Y <- CostlyStandards(Ready4useDyad_r4 = Ready4useDyad(ds_tb = tibble::tibble(), dictionary_r3 = ready4use_dictionary()))

In many cases using the ISO_3166_1 dataset from the ISOcodes library will be the optimal choice for the standardised form of country names. We can use the add_country_standards function to pair this dataset with its dictionary and create B, a CostlyStandards module instance.

We can inspect the first few cases of the labelled version of the dataset in B.

renewSlot(B, "Ready4useDyad_r4", type_1L_chr = "label") %>% 
  exhibitSlot("Ready4useDyad_r4", display_1L_chr = "head", scroll_box_args_ls = list(width = "100%"))
Dataset
Alpabetical country code (two letters) Alpabetical country code (three letters) Numeric country code Country name Country name (official) Country name (common alternative)
AW ABW 533 Aruba NA NA
AF AFG 004 Afghanistan Islamic Republic of Afghanistan NA
AO AGO 024 Angola Republic of Angola NA
AI AIA 660 Anguilla NA NA
AX ALA 248 Åland Islands NA NA
AL ALB 008 Albania Republic of Albania NA

We can also inspect the data dictionary contained in B.

exhibitSlot(B, "Ready4useDyad_r4", type_1L_chr = "dict", scroll_box_args_ls = list(width = "100%"))
Data Dictionary
Variable Category Description Class
Alpha_2 A2 Alpabetical country code (two letters) character
Alpha_3 A3 Alpabetical country code (three letters) character
Numeric N Numeric country code character
Name Country Country name character
Official_name Official Country name (official) character
Common_name Common Country name (common alternative) character

We can now specifying both the concept (from the “Category” column of the data dictionary) that specifies allowable values for our target variable and all concepts we plan to use for fuzzy logic matching (described below).

B@label_1L_chr <- "Country"
B@include_chr <- c("Country", "Official","Common","A3","A2")

We now add B to X.

X <- renew(X, B, what_1L_chr = "standards")

Compare variable of interest values from seed and standards dataset.

To identify any disparities between the variable of interest in our seed and standards datasets we can use the ratify method. Supplying the value “identity” ensures that the output will differ from input only in the slot reserved for results.

X <- ratify(X, new_val_xx = "identity")

We can now identify the values from our seed dataset variable of interest that were not in our standard values.

X@results_ls$Country_Output_Validation$Invalid_Values

We can also identify standard values that were not present in the seed dataset variable of interest.

X@results_ls$Country_Output_Validation$Absent_Values
#>  [1] "Åland Islands"                                "Antarctica"                                   "Bolivia, Plurinational State of"              "Bonaire, Sint Eustatius and Saba"             "Bouvet Island"                               
#>  [6] "British Indian Ocean Territory"               "Brunei Darussalam"                            "Cabo Verde"                                   "Christmas Island"                             "Cocos (Keeling) Islands"                     
#> [11] "Congo, The Democratic Republic of the"        "Côte d'Ivoire"                                "Curaçao"                                      "Czechia"                                      "Eswatini"                                    
#> [16] "Falkland Islands (Malvinas)"                  "French Southern Territories"                  "Guernsey"                                     "Heard Island and McDonald Islands"            "Holy See (Vatican City State)"               
#> [21] "Hong Kong"                                    "Iran, Islamic Republic of"                    "Korea, Democratic People's Republic of"       "Korea, Republic of"                           "Lao People's Democratic Republic"            
#> [26] "Macao"                                        "Micronesia, Federated States of"              "Moldova, Republic of"                         "Palestine, State of"                          "Réunion"                                     
#> [31] "Russian Federation"                           "Saint Barthélemy"                             "Saint Helena, Ascension and Tristan da Cunha" "Saint Martin (French part)"                   "Saint Vincent and the Grenadines"            
#> [36] "Sint Maarten (Dutch part)"                    "South Georgia and the South Sandwich Islands" "Syrian Arab Republic"                         "Taiwan, Province of China"                    "Tanzania, United Republic of"                
#> [41] "Timor-Leste"                                  "Türkiye"                                      "Turks and Caicos Islands"                     "United Kingdom"                               "United States"                               
#> [46] "United States Minor Outlying Islands"         "Venezuela, Bolivarian Republic of"            "Viet Nam"                                     "Virgin Islands, British"                      "Virgin Islands, U.S."

Standardise variable values

We can explore the extent to which we can use fuzzy logic to reconcile some of these discrepancies. To identify the types of fuzzy logic algorithms we could use, run the following command to explore the relevant part of the documentation from the stringdist library.

# Not run
# help("stringdist-metrics", package=stringdist)

In this case, we have chosen the Jaro, or Jaro-Winkler distance method (“jw”).

X <- renew(X, "jw", type_1L_chr = "slot", what_1L_chr = "logic") 
X <- ratify(X, new_val_xx = NULL)

This method will replace every previously invalid seed dataset variable value with the best available match identified by the selected fuzzy logic algorithm.

X@results_ls$Country_Output_Validation$Invalid_Values
#> character(0)

However, some of the replacements will be spurious as can be seen by inspecting the record of the replacements made.

X@results_ls$Country_Output_Correspondences
#> # A tibble: 42 × 2
#>    old_nms_chr               new_nms_chr                          
#>    <chr>                     <chr>                                
#>  1 Azores                    Timor-Leste                          
#>  2 Bolivia                   Bolivia, Plurinational State of      
#>  3 British Virgin Islands    Virgin Islands, British              
#>  4 Brunei                    Brunei Darussalam                    
#>  5 Canary Islands            Åland Islands                        
#>  6 Cape Verde                Cabo Verde                           
#>  7 Congo Democratic Republic Congo, The Democratic Republic of the
#>  8 Czech Republic            Czechia                              
#>  9 East Timor                Eswatini                             
#> 10 Easter Island             Christmas Island                     
#> # ℹ 32 more rows

For each of the incorrect correspondences, we will need to manually specify correct values. We can do this using the ready4show_correspondences sub-module.

# Not run
# a <- ready4show::renew.ready4show_correspondences(ready4show::ready4show_correspondences(), 
#         old_nms_chr = c("old_name_1", "old_name_2", "etc...."), new_nms_chr = c("new_name_1", "new_name_2", "etc...."))

The make_country_correspondences can be used as a shortcut for creating the alternative correspondences for this specific example.

We can inspect the values of this correspondence table.

exhibit(a, scroll_box_args_ls = list(width = "100%"))
Old name New name
Azores Portugal
Canary Islands Spain
Easter Island Chile
East Timor Timor-Leste
Ivory Coast Côte d'Ivoire
Kosovo Kosovo
Madeira Portugal
Netherlands Antilles Bonaire, Sint Eustatius and Saba
Sicily Italy
Vatican City Holy See (Vatican City State)

When the ratify method was used to apply the fuzzy logic algorithm in a previous step, X was modified so that this logic is by default switched off for future calls to ratify. If we had created a new correspondence table that specified replacements for all invalid values, this would not be a problem. However, in this example we are only specifying correspondences where the fuzzy logic algorithm failed, so we need to again supply our desired fuzzy logic value.

X <- renew(X, "jw", type_1L_chr = "slot", what_1L_chr = "logic") 

We now rerun our ratify method (which in this example will combine fuzzy logic with lookups from the manually created correspondences table).

X <- ratify(X, new_val_xx = a)

We once again inspect results.

Our correspondences table looks better.

X@results_ls$Country_Output_Correspondences
#> # A tibble: 42 × 2
#>    old_nms_chr               new_nms_chr                          
#>    <chr>                     <chr>                                
#>  1 Azores                    Portugal                             
#>  2 Bolivia                   Bolivia, Plurinational State of      
#>  3 British Virgin Islands    Virgin Islands, British              
#>  4 Brunei                    Brunei Darussalam                    
#>  5 Canary Islands            Spain                                
#>  6 Cape Verde                Cabo Verde                           
#>  7 Congo Democratic Republic Congo, The Democratic Republic of the
#>  8 Czech Republic            Czechia                              
#>  9 East Timor                Timor-Leste                          
#> 10 Easter Island             Chile                                
#> # ℹ 32 more rows

There is still a value that is not included in our standards.

X@results_ls$Country_Output_Validation$Invalid_Values
#> [1] "Kosovo"

We can rerun the ratify method to force the removal of any record that is not included in our standards dataset.

X <- renew(X, T, type_1L_chr = "slot", what_1L_chr = "force") 
X <- ratify(X, new_val_xx = "identity")

No invalid values remain.

X@results_ls$Country_Output_Validation$Invalid_Values
#> character(0)

However, there are also a some values from our standards dataset that are not represented in the results dataset values.

X@results_ls$Country_Output_Validation$Absent_Values
#>  [1] "Åland Islands"                                "Antarctica"                                   "Bouvet Island"                                "British Indian Ocean Territory"               "Christmas Island"                            
#>  [6] "Cocos (Keeling) Islands"                      "Curaçao"                                      "French Southern Territories"                  "Heard Island and McDonald Islands"            "Hong Kong"                                   
#> [11] "Macao"                                        "Sint Maarten (Dutch part)"                    "South Georgia and the South Sandwich Islands" "United States Minor Outlying Islands"

Whether this is a problem or not depends on the intended purposes of the standardised dataset we are creating. We could choose to rerun the previous steps after making edits to either or both of the standards dataset (e.g. we could delete any superfluous, outdated or incorrect records or use an entirely new standards dataset) and seed dataset (e.g. adding new records or recategorising existing records so that there are corresponding values for every missing standard value). In this case we are going to assume that the above missing values are not a cause for concern for the valid use of our updated dataset for it intended purposes. We can now create a new object Y, using our results dataset’s Ready4useDyad module instance.

Y <- X@results_ls$Country_Output_Lookup

We can inspect the records for cases corresponding to capital cities from our new dataset.

renewSlot(Y,"ds_tb",Y@ds_tb %>% dplyr::filter(capital==1)) %>%
  renew(type_1L_chr = "label") %>%
  exhibit(scroll_box_args_ls = list(width = "100%"))
Dataset
City name Country name Population size Latitude coordinate Longitude coordinate Is the nation's capital city
'Amman Jordan 1303197 31.95 35.93 1
Abu Dhabi United Arab Emirates 619316 24.48 54.37 1
Abuja Nigeria 178462 9.18 7.17 1
Accra Ghana 2029143 5.56 -0.20 1
Adamstown Pitcairn 51 -25.05 -130.10 1
Addis Abeba Ethiopia 2823167 9.03 38.74 1
Agana Guam 1041 13.47 144.75 1
Algiers Algeria 2029936 36.77 3.04 1
Alofi Niue 627 -19.05 -169.92 1
Amsterdam Netherlands 744159 52.37 4.89 1
Andorra la Vella Andorra 20314 42.51 1.51 1
Ankara Türkiye 3579706 39.93 32.85 1
Antananarivo Madagascar 1463754 -18.89 47.51 1
Apia Samoa 40805 -13.83 -171.76 1
Asgabat Turkmenistan 823013 37.95 58.38 1
Asmara Eritrea 578860 15.33 38.94 1
Astana Kazakhstan 351343 51.17 71.47 1
Asuncion Paraguay 507574 -25.30 -57.63 1
Athens Greece 725049 37.98 23.73 1
Avarua Cook Islands 13645 -21.20 -159.76 1
Baghdad Iraq 5753612 33.33 44.44 1
Bairiki Kiribati 45982 1.33 172.99 1
Baku Azerbaijan 1118725 40.39 49.86 1
Bamako Mali 1342519 12.65 -7.99 1
Bandar Seri Begawan Brunei Darussalam 67077 4.93 114.95 1
Bangkok Thailand 4935988 13.73 100.50 1
Bangui Central African Republic 547668 4.36 18.56 1
Banjul Gambia 34388 13.46 -16.60 1
Basse-Terre Guadeloupe 11298 16.00 -61.72 1
Basseterre Saint Kitts and Nevis 12883 17.31 -62.73 1
Bayrut Lebanon 1273440 33.88 35.50 1
Beijing China 7602069 39.93 116.40 1
Belgrade Serbia 1113589 44.83 20.50 1
Belmopan Belize 14590 17.25 -88.79 1
Berlin Germany 3378275 52.52 13.38 1
Bern Switzerland 120596 46.95 7.44 1
Biskek Kyrgyzstan 915625 42.87 74.57 1
Bissau Guinea-Bissau 404119 11.87 -15.60 1
Bogota Colombia 7235084 4.63 -74.09 1
Brasilia Brazil 2260541 -15.78 -47.91 1
Bratislava Slovakia 422452 48.16 17.13 1
Brazzaville Congo 1326975 -4.25 15.26 1
Bridgetown Barbados 98725 13.11 -59.61 1
Brussels Belgium 1031925 50.83 4.33 1
Bucharest Romania 1862930 44.44 26.10 1
Budapest Hungary 1700019 47.51 19.08 1
Buenos Aires Argentina 11595183 -34.61 -58.37 1
Bujumbura Burundi 336561 -3.37 29.35 1
Cairo Egypt 7836243 30.06 31.25 1
Canberra Australia 324736 -35.31 149.13 1
Caracas Venezuela, Bolivarian Republic of 1808937 10.54 -66.93 1
Castries Saint Lucia 12904 14.03 -60.98 1
Cayenne French Guiana 62926 4.92 -52.34 1
Charlotte Amalie Virgin Islands, U.S. 10415 18.35 -64.94 1
Chisinau Moldova, Republic of 623671 47.03 28.83 1
Cockburn Town Turks and Caicos Islands 174 21.46 -71.14 1
Colombo Sri Lanka 649496 6.93 79.85 1
Conakry Guinea 1970382 9.55 -13.67 1
Copenhagen Denmark 1091978 55.68 12.57 1
Dakar Senegal 2406598 14.72 -17.48 1
Damascus Syrian Arab Republic 1580909 33.50 36.32 1
Dhaka Bangladesh 6724976 23.70 90.39 1
Dili Timor-Leste 163305 -8.57 125.58 1
Dodoma Tanzania, United Republic of 188150 -6.17 35.74 1
Doha Qatar 351381 25.30 51.51 1
Douglas Isle of Man 25621 54.15 -4.48 1
Dublin Ireland 1030431 53.33 -6.25 1
Dushanbe Tajikistan 538456 38.57 68.78 1
Dzaoudzi Mayotte 14558 -12.77 45.25 1
Fakaofo Tokelau 267 -9.38 -171.22 1
Fort-de-France Martinique 89233 14.60 -61.08 1
Freetown Sierra Leone 818709 8.49 -13.24 1
Gaborone Botswana 214412 -24.65 25.91 1
George Town Cayman Islands 30570 19.28 -81.39 1
Georgetown Guyana 236878 6.79 -58.16 1
Gibraltar Gibraltar 26404 36.14 -5.35 1
Guatemala Guatemala 1010253 14.63 -90.55 1
Ha Noi Viet Nam 1452055 21.03 105.84 1
Hamilton Bermuda 889 32.30 -64.79 1
Harare Zimbabwe 1575127 -17.82 31.05 1
Havanna Cuba 2163132 23.13 -82.39 1
Helsinki Finland 558341 60.17 24.94 1
Honiara Solomon Islands 57410 -9.43 159.91 1
Islamabad Pakistan 794431 33.72 73.06 1
Jakarta Indonesia 8556798 -6.18 106.83 1
Jamestown Saint Helena, Ascension and Tristan da Cunha 603 -15.92 -5.71 1
Jerusalem Israel 731731 31.78 35.22 1
Jibuti Djibouti 633884 11.56 43.15 1
Kabul Afghanistan 3120963 34.53 69.17 1
Kampala Uganda 1403619 0.32 32.58 1
Kathmandu Nepal 822930 27.71 85.31 1
Khartoum Sudan 2090001 15.58 32.52 1
Kiev Ukraine 2491404 50.43 30.52 1
Kigali Rwanda 800003 -1.94 30.06 1
Kingston Jamaica 585300 17.99 -76.80 1
Kingston Norfolk Island 890 -29.03 168.05 1
Kingstown Saint Vincent and the Grenadines 18160 13.16 -61.23 1
Kinshasa Congo, The Democratic Republic of the 8096254 -4.31 15.32 1
Koror Palau 11458 7.35 134.51 1
Kuala Lumpur Malaysia 1482359 3.16 101.71 1
Libreville Gabon 591356 0.39 9.45 1
Lilongwe Malawi 683477 -13.97 33.80 1
Lima Peru 7857121 -12.07 -77.05 1
Lisbon Portugal 508209 38.72 -9.14 1
Ljubljana Slovenia 254188 46.06 14.51 1
Lome Togo 737751 6.17 1.35 1
London United Kingdom 7489022 51.52 -0.10 1
Longyearbyen Svalbard and Jan Mayen 1263 78.21 15.61 1
Luanda Angola 2875277 -8.82 13.24 1
Lusaka Zambia 1306577 -15.42 28.29 1
Luxemburg Luxembourg 76380 49.62 6.12 1
Madrid Spain 3146804 40.42 -3.71 1
Malabo Equatorial Guinea 161409 3.74 8.79 1
Male Maldives 87154 4.17 73.50 1
Managua Nicaragua 990417 12.15 -86.27 1
Manama Bahrain 147894 26.21 50.58 1
Manila Philippines 10546511 14.62 120.97 1
Maputo Mozambique 1220167 -25.95 32.57 1
Maseru Lesotho 116268 -29.31 27.49 1
Mata'utu Wallis and Futuna 1310 -13.28 -176.13 1
Mbabane Eswatini 78740 -26.32 31.14 1
Mexico City Mexico 8659409 19.43 -99.14 1
Minsk Belarus 1747482 53.91 27.55 1
Mogadishu Somalia 2723378 2.05 45.33 1
Monaco-Ville Monaco 975 43.74 7.42 1
Monrovia Liberia 954458 6.31 -10.80 1
Montevideo Uruguay 1271664 -34.87 -56.17 1
Moroni Comoros 43704 -11.74 43.23 1
Moscow Russian Federation 10472629 55.75 37.62 1
Muscat Oman 24122 23.61 58.54 1
N'Djamena Chad 737281 12.11 15.05 1
Nairobi Kenya 2864667 -1.29 36.82 1
Nassau Bahamas 231519 25.06 -77.33 1
Ni Dilli India 321883 28.60 77.22 1
Niamey Niger 801297 13.52 2.12 1
Nicosia Cyprus 202488 35.16 33.38 1
Nicosia Cyprus 42372 35.18 33.37 1
Nouakchott Mauritania 731242 18.09 -15.98 1
Noumea New Caledonia 94751 -22.27 166.44 1
Nuku'alofa Tonga 23733 -21.14 -175.22 1
Nuuk Greenland 15243 64.18 -51.73 1
Oranjestad Aruba 30710 12.53 -70.03 1
Oslo Norway 821445 59.91 10.75 1
Ottawa Canada 885542 45.42 -75.71 1
Ouagadougou Burkina Faso 1119775 12.37 -1.53 1
Pago Pago American Samoa 4180 -14.24 -170.72 1
Palikir Micronesia, Federated States of 4552 6.92 158.16 1
Panama Panama 406070 8.97 -79.53 1
Papeete French Polynesia 26400 -17.52 -149.56 1
Paramaribo Suriname 224925 5.85 -55.20 1
Paris France 2141839 48.86 2.34 1
Phnum Penh Cambodia 1673131 11.57 104.92 1
Port Louis Mauritius 156760 -20.17 57.51 1
Port Moresby Papua New Guinea 289861 -9.48 147.18 1
Port Stanley Falkland Islands (Malvinas) 2269 -51.70 -57.82 1
Port of Spain Trinidad and Tobago 49764 10.66 -61.51 1
Port-au-Prince Haiti 1277104 18.54 -72.34 1
Porto Novo Benin 238199 6.48 2.63 1
Prague Czechia 1168374 50.08 14.43 1
Praia Cabo Verde 117342 14.93 -23.54 1
Pretoria South Africa 1687779 -25.73 28.22 1
Pyongyang Korea, Democratic People's Republic of 2992272 39.02 125.75 1
Quito Ecuador 1399814 -0.19 -78.50 1
Rabat Morocco 1688738 34.02 -6.84 1
Rangoon Myanmar 4572948 16.79 96.15 1
Reykjavik Iceland 114576 64.14 -21.92 1
Riga Latvia 738386 56.97 24.13 1
Rita Marshall Islands 21270 7.12 171.06 1
Riyadh Saudi Arabia 4328067 24.65 46.77 1
Road Town Virgin Islands, British 8613 18.43 -64.63 1
Rome Italy 2561181 41.89 12.50 1
Roseau Dominica 16577 15.30 -61.39 1
Saint George's Grenada 4315 12.06 -61.74 1
Saint Helier Jersey 28910 49.19 -2.11 1
Saint John's Antigua and Barbuda 25321 17.11 -61.85 1
Saint Peter Port Guernsey 16702 49.47 -2.55 1
Saint-Denis Réunion 137787 -20.87 55.46 1
Saint-Pierre Saint Pierre and Miquelon 6254 46.79 -56.18 1
San Jose Costa Rica 32187 10.97 -85.13 1
San Jose Costa Rica 339588 9.93 -84.08 1
San Juan Puerto Rico 417154 18.44 -66.13 1
San Marino San Marino 4624 43.94 12.43 1
San Salvador El Salvador 534409 13.69 -89.19 1
San'a Yemen 1921589 15.38 44.21 1
Santiago Chile 4893495 -33.46 -70.64 1
Santo Domingo Dominican Republic 2253437 18.48 -69.91 1
Sao Tome Sao Tome and Principe 63772 0.37 6.73 1
Sarajevo Bosnia and Herzegovina 737350 43.85 18.38 1
Singapore Singapore 3601745 1.30 103.85 1
Skopje North Macedonia 477493 42.00 21.47 1
Sofia Bulgaria 1166143 42.69 23.31 1
Seoul Korea, Republic of 10409345 37.56 126.99 1
Stockholm Sweden 1260712 59.33 18.07 1
Sucre Bolivia, Plurinational State of 232669 -19.06 -65.26 1
Susupe Northern Mariana Islands 2402 15.14 145.70 1
Taipei Taiwan, Province of China 2491662 25.02 121.45 1
Tallinn Estonia 392386 59.44 24.74 1
Tashkent Uzbekistan 1967879 41.31 69.30 1
Tbilisi Georgia 1038343 41.72 44.79 1
Tegucigalpa Honduras 872403 14.09 -87.22 1
Tehran Iran, Islamic Republic of 7160094 35.67 51.43 1
The Valley Anguilla 1435 18.22 -63.05 1
Thimphu Bhutan 74175 27.48 89.70 1
Tirana Albania 380403 41.33 19.82 1
Tokyo Japan 8372440 35.67 139.77 1
Torshavn Faroe Islands 13313 62.03 -6.80 1
Tripoli Libya 1164634 32.87 13.18 1
Tunis Tunisia 693294 36.84 10.22 1
Ulaanbaatar Mongolia 862842 47.93 106.91 1
Vaduz Liechtenstein 5248 47.14 9.53 1
Vaiaku Tuvalu 4835 -8.52 179.20 1
Valletta Malta 6748 35.91 14.52 1
Vatican City Holy See (Vatican City State) 767 41.90 12.46 1
Victoria Seychelles 22611 -4.62 55.45 1
Vienna Austria 1570976 48.22 16.37 1
Vientiane Lao People's Democratic Republic 199863 17.97 102.61 1
Vila Vanuatu 37141 -17.74 168.31 1
Vilnius Lithuania 542014 54.70 25.27 1
Warsaw Poland 1634441 52.26 21.02 1
Washington United States 548359 38.91 -77.02 1
Wellington New Zealand 182254 -41.28 174.78 1
Willemstad Bonaire, Sint Eustatius and Saba 98339 12.10 -68.93 1
Windhoek Namibia 277349 -22.56 17.09 1
Yamoussoukro Côte d'Ivoire 200103 6.82 -5.28 1
Yaounde Cameroon 1344617 3.87 11.52 1
Yaren Nauru 4587 -0.55 166.91 1
Yerevan Armenia 1090537 40.17 44.52 1
Zagreb Croatia 700717 45.80 15.97 1
al-'Ayun Western Sahara 188084 27.16 -13.20 1
al-Kuwayt Kuwait 63596 29.38 47.99 1

4.2.4 - Standardise Variable Values With Lookup Codes

This tutorial describes how a module from the costly R package can help you to use lookup codes to standardise variable values and thus facilitate partial automation of costing algorithms.

This below section renders a vignette article from the costly library. You can use the following links to:

Note. Parts of the workflow described in this article are common to steps explained in more detail in the article outlining the workflow using fuzzy logic and correspondence tables.

In brief

The steps described and explained in this vignette can also be (more succinctly) accomplished with the following code.

X <- CostlyCountries()
X <- renew(X,
           new_val_xx = add_default_currency_seed(X@CostlySeed_r4, include_1L_chr = "Country"), 
           what_1L_chr = "seed")
X <- renew(X, "jw", type_1L_chr = "slot", what_1L_chr = "logic") 
X <- renew(X, new_val_xx = make_country_correspondences("currencies"), what_1L_chr = "correspondences") 
X <- renew(X, T, type_1L_chr = "slot", what_1L_chr = "force") 
X <- ratify(X)
Y <- CostlyCurrencies()
Y <- renew(Y, new_val_xx = add_default_currency_seed(Y@CostlySeed_r4,
                                                     Ready4useDyad_r4 = X@results_ls$Country_Output_Lookup), 
           what_1L_chr = "seed")
Y <- ratify(Y, type_1L_chr = "Lookup")
Y <- renew(Y, T, type_1L_chr = "slot", what_1L_chr = "force") 
Y <- ratify(Y, type_1L_chr = "Lookup")

Create project

We begin by creating X, a CostlyCorrespondences module instance.

Supply seed dataset

We next create a CostlySeed module instance that includes a dataset containing our variable of interest (in this case, countries). The dataset needs to be paired with a dataset dictionary using the Ready4useDyad module from the ready4use R library. You can supply a custom standards dataset (a tibble), dictionary (a ready4use_dictionary) and the concept represented by our variable of interest using a command of the following format.

# Not run
# A <- CostlySeed(Ready4useDyad_r4 = Ready4useDyad(ds_tb = tibble::tibble(), dictionary_r3 = ready4use_dictionary()), include_chr = c("Country"), label_1L_chr = "Country")

The add_default_country_seed function will perform the previous step using values that pair the world.cities dataset of the maps R library with an appropriate dictionary and specifies countries as the concept we will be standardising.

We now add A to a new CostlyCorrespondences module instance Y, which we use to standardise the country concept variable using a fuzzy logic And correspondence tables workflow.

A@include_chr <- A@label_1L_chr <- "Country"
Y <- CostlyCountries(CostlySeed_r4 = A) %>%
  renew("jw", type_1L_chr = "slot", what_1L_chr = "logic") %>%
  renew(new_val_xx = make_country_correspondences("currencies"), what_1L_chr = "correspondences") %>%
  renew(T, type_1L_chr = "slot", what_1L_chr = "force") %>%
  ratify()

We now update X with the results Ready4useDyad from Y (a seed dataset for which country names have been standardised).

X <- renew(X, new_val_xx = CostlySeed(Ready4useDyad_r4 = Y@results_ls$Country_Output_Lookup), what_1L_chr = "seed") # 

We can now inspect the first few records from our labelled seed dataset.

renewSlot(X, "CostlySeed_r4@Ready4useDyad_r4", type_1L_chr = "label") %>%
exhibitSlot("CostlySeed_r4@Ready4useDyad_r4", display_1L_chr = "head", scroll_box_args_ls = list(width = "100%"))
Dataset
Country name Currency name Currency symbol Currency alphabetical ISO code (three letter) Currency's fractional unit Number of fractional units in basic unit
Afghanistan Afghan afghani ؋‎ AFN Pul 100
Albania Albanian lek Lek ALL Qintar 100
Algeria Algerian dinar DA DZD Centime 100
Andorra Euro EUR Cent 100
Angola Angolan kwanza Kz AOA Cêntimo 100
Anguilla Eastern Caribbean dollar \$ XCD Cent 100

We can also inspect the seed dataset’s dictionary.

exhibitSlot(X, "CostlySeed_r4@Ready4useDyad_r4", type_1L_chr = "dict", scroll_box_args_ls = list(width = "100%"))
Data Dictionary
Variable Category Description Class
State / Territory\[1\] Country Country name character
Currency\[1\]\[2\] Currency Currency name character
Symbol\[D\] orAbbrev.\[3\] Symbol Currency symbol character
ISO code\[2\] A3 Currency alphabetical ISO code (three letter) character
Fractionalunit Fractional Currency's fractional unit character
Numberto basic Number Number of fractional units in basic unit character

We specify the seed dataset concept that we are looking to standardise and the concept that we will use to lookup replacement values from the standards dataset.

X@CostlySeed_r4@label_1L_chr <- "Currency"
X@CostlySeed_r4@match_1L_chr <- "A3"

Specify standards

We can now create B, a CostlyStandards module instance that includes a dataset specifying the complete list of allowable variable values. In many cases using the ISO_4217 dataset from the ISOcodes library will be the optimal source of standardised names for currencies. Using the add_currency_standards function will pair this dataset with a dictionary.

We can inspect the first few cases of the labelled version of the standards dataset in B.

renewSlot(B, "Ready4useDyad_r4", type_1L_chr = "label") %>% 
  exhibitSlot("Ready4useDyad_r4", display_1L_chr = "head", scroll_box_args_ls = list(width = "100%"))
Dataset
Alpabetical currency code (three letters) Numeric currency code Currency name
AED 784 UAE Dirham
AFN 971 Afghani
ALL 008 Lek
AMD 051 Armenian Dram
ANG 532 Netherlands Antillean Guilder
AOA 973 Kwanza

We can also inspect the data dictionary contained in B.

exhibitSlot(B, "Ready4useDyad_r4", type_1L_chr = "dict", scroll_box_args_ls = list(width = "100%"))
Data Dictionary
Variable Category Description Class
Letter A3 Alpabetical currency code (three letters) character
Numeric N Numeric currency code character
Currency Currency Currency name character

We can now specifying both the concept (“Currency”) that specifies allowable values for our target variable and the concepts we plan to use for lookup matching (described below).

#B@include_chr <- c("Currency", "Letter")
B@label_1L_chr <- "Currency"
B@match_1L_chr <- "A3"

We now add B to X.

X <- renew(X, B, what_1L_chr = "standards")

Compare variable of interest values from seed and standards dataset.

Currently, the majority of our currency names need to be standardised. In many cases this may be due to something as simple as the use of lower case.

X <- ratify(X, new_val_xx = "identity")
X@results_ls$Currency_Output_Validation$Invalid_Values
#>   [1] "Afghan afghani"                          "Albanian lek"                            "Algerian dinar"                          "Angolan kwanza"                          "Argentine peso"                         
#>   [6] "Armenian dram"                           "Aruban florin"                           "Australian dollar"                       "Azerbaijani manat"                       "Bahamian dollar"                        
#>  [11] "Bahraini dinar"                          "Bangladeshi taka"                        "Barbadian dollar"                        "Belarusian ruble"                        "Belize dollar"                          
#>  [16] "Bermudian dollar"                        "Bhutanese ngultrum"                      "Bitcoin[4]"                              "Bolivian boliviano"                      "Bosnia and Herzegovina convertible mark"
#>  [21] "Botswana pula"                           "Brazilian real"                          "Brunei dollar"                           "Bulgarian lev"                           "Burmese kyat"                           
#>  [26] "Burundian franc"                         "Cambodian riel"                          "Canadian dollar"                         "Cape Verdean escudo"                     "Cayman Islands dollar"                  
#>  [31] "Central African CFA franc"               "CFP franc"                               "Chilean peso"                            "Colombian peso"                          "Comorian franc"                         
#>  [36] "Congolese franc"                         "Cook Islands dollar"                     "Costa Rican colón"                       "Cuban peso"                              "Czech koruna"                           
#>  [41] "Danish krone"                            "Djiboutian franc"                        "Dominican peso"                          "Eastern Caribbean dollar"                "Egyptian pound"                         
#>  [46] "Eritrean nakfa"                          "Ethiopian birr"                          "Falkland Islands pound"                  "Faroese króna"                           "Fijian dollar"                          
#>  [51] "Gambian dalasi"                          "Georgian lari"                           "Ghanaian cedi"                           "Gibraltar pound"                         "Guatemalan quetzal"                     
#>  [56] "Guernsey pound"                          "Guinean franc"                           "Guyanese dollar"                         "Haitian gourde"                          "Honduran lempira"                       
#>  [61] "Hong Kong dollar"                        "Hungarian forint"                        "Icelandic króna"                         "Indian rupee"                            "Indonesian rupiah"                      
#>  [66] "Iranian rial"                            "Iraqi dinar"                             "Israeli new shekel"                      "Jamaican dollar"                         "Japanese yen"                           
#>  [71] "Jersey pound"                            "Jordanian dinar"                         "Kazakhstani tenge"                       "Kenyan shilling"                         "Kiribati dollar[E]"                     
#>  [76] "Kuwaiti dinar"                           "Kyrgyz som"                              "Lao kip"                                 "Lebanese pound"                          "Lesotho loti"                           
#>  [81] "Liberian dollar"                         "Libyan dinar"                            "Macanese pataca"                         "Macedonian denar"                        "Malagasy ariary"                        
#>  [86] "Malawian kwacha"                         "Malaysian ringgit"                       "Maldivian rufiyaa"                       "Manx pound"                              "Mauritanian ouguiya"                    
#>  [91] "Mauritian rupee"                         "Mexican peso"                            "Moldovan leu"                            "Mongolian tögrög"                        "Moroccan dirham"                        
#>  [96] "Mozambican metical"                      "Namibian dollar"                         "Nepalese rupee"                          "Netherlands Antillean guilder"           "New Taiwan dollar"                      
#> [101] "New Zealand dollar"                      "Nicaraguan córdoba"                      "Nigerian naira"                          "Niue dollar[E]"                          "North Korean won"                       
#> [106] "Norwegian krone"                         "Omani rial"                              "Pakistani rupee"                         "Panamanian balboa"                       "Papua New Guinean kina"                 
#> [111] "Paraguayan guaraní"                      "Peruvian sol"                            "Philippine peso"                         "Pitcairn Islands dollar[E]"              "Polish złoty"                           
#> [116] "Qatari riyal"                            "Renminbi"                                "Romanian leu"                            "Russian ruble"                           "Rwandan franc"                          
#> [121] "Sahrawi peseta"                          "Saint Helena pound"                      "Samoan tālā"                             "São Tomé and Príncipe dobra"             "Saudi riyal"                            
#> [126] "Serbian dinar"                           "Seychellois rupee"                       "Sierra Leonean leone"                    "Singapore dollar"                        "Solomon Islands dollar"                 
#> [131] "Somali shilling"                         "South African rand"                      "South Korean won"                        "South Sudanese pound"                    "Sri Lankan rupee"                       
#> [136] "Sterling"                                "Sudanese pound"                          "Surinamese dollar"                       "Swazi lilangeni"                         "Swedish krona"                          
#> [141] "Swiss franc"                             "Syrian pound"                            "Tajikistani somoni"                      "Tanzanian shilling"                      "Thai baht"                              
#> [146] "Tongan paʻanga[K]"                       "Trinidad and Tobago dollar"              "Tunisian dinar"                          "Turkish lira"                            "Turkmenistani manat"                    
#> [151] "Tuvaluan dollar"                         "Ugandan shilling"                        "Ukrainian hryvnia"                       "United Arab Emirates dirham"             "United States dollar"                   
#> [156] "United States dollar[F]"                 "Uruguayan peso"                          "Uzbekistani sum"                         "Vanuatu vatu"                            "Venezuelan digital bolívar"             
#> [161] "Venezuelan sovereign bolívar"            "Vietnamese đồng"                         "West African CFA franc"                  "Yemeni rial"                             "Zambian kwacha"                         
#> [166] "Zimbabwe gold"                           "Zimbabwean dollar"

Standardised currency names not currently present in our seed dataset are as follows.

X@results_ls$Currency_Output_Validation$Absent_Values
#>   [1] "ADB Unit of Account"                                               "Afghani"                                                           "Algerian Dinar"                                                   
#>   [4] "Argentine Peso"                                                    "Armenian Dram"                                                     "Aruban Florin"                                                    
#>   [7] "Australian Dollar"                                                 "Azerbaijan Manat"                                                  "Bahamian Dollar"                                                  
#>  [10] "Bahraini Dinar"                                                    "Baht"                                                              "Balboa"                                                           
#>  [13] "Barbados Dollar"                                                   "Belarusian Ruble"                                                  "Belize Dollar"                                                    
#>  [16] "Bermudian Dollar"                                                  "Bolívar Soberano"                                                  "Boliviano"                                                        
#>  [19] "Bond Markets Unit European Composite Unit (EURCO)"                 "Bond Markets Unit European Monetary Unit (E.M.U.-6)"               "Bond Markets Unit European Unit of Account 17 (E.U.A.-17)"        
#>  [22] "Bond Markets Unit European Unit of Account 9 (E.U.A.-9)"           "Brazilian Real"                                                    "Brunei Dollar"                                                    
#>  [25] "Bulgarian Lev"                                                     "Burundi Franc"                                                     "Cabo Verde Escudo"                                                
#>  [28] "Canadian Dollar"                                                   "Cayman Islands Dollar"                                             "CFA Franc BCEAO"                                                  
#>  [31] "CFA Franc BEAC"                                                    "CFP Franc"                                                         "Chilean Peso"                                                     
#>  [34] "Codes specifically reserved for testing purposes"                  "Colombian Peso"                                                    "Comorian Franc"                                                   
#>  [37] "Congolese Franc"                                                   "Convertible Mark"                                                  "Cordoba Oro"                                                      
#>  [40] "Costa Rican Colon"                                                 "Cuban Peso"                                                        "Czech Koruna"                                                     
#>  [43] "Dalasi"                                                            "Danish Krone"                                                      "Denar"                                                            
#>  [46] "Djibouti Franc"                                                    "Dobra"                                                             "Dominican Peso"                                                   
#>  [49] "Dong"                                                              "East Caribbean Dollar"                                             "Egyptian Pound"                                                   
#>  [52] "El Salvador Colon"                                                 "Ethiopian Birr"                                                    "Falkland Islands Pound"                                           
#>  [55] "Fiji Dollar"                                                       "Forint"                                                            "Ghana Cedi"                                                       
#>  [58] "Gibraltar Pound"                                                   "Gold"                                                              "Gourde"                                                           
#>  [61] "Guarani"                                                           "Guinean Franc"                                                     "Guyana Dollar"                                                    
#>  [64] "Hong Kong Dollar"                                                  "Hryvnia"                                                           "Iceland Krona"                                                    
#>  [67] "Indian Rupee"                                                      "Iranian Rial"                                                      "Iraqi Dinar"                                                      
#>  [70] "Jamaican Dollar"                                                   "Jordanian Dinar"                                                   "Kenyan Shilling"                                                  
#>  [73] "Kina"                                                              "Kuna"                                                              "Kuwaiti Dinar"                                                    
#>  [76] "Kwanza"                                                            "Kyat"                                                              "Lao Kip"                                                          
#>  [79] "Lari"                                                              "Lebanese Pound"                                                    "Lek"                                                              
#>  [82] "Lempira"                                                           "Leone"                                                             "Liberian Dollar"                                                  
#>  [85] "Libyan Dinar"                                                      "Lilangeni"                                                         "Loti"                                                             
#>  [88] "Malagasy Ariary"                                                   "Malawi Kwacha"                                                     "Malaysian Ringgit"                                                
#>  [91] "Mauritius Rupee"                                                   "Mexican Peso"                                                      "Mexican Unidad de Inversion (UDI)"                                
#>  [94] "Moldovan Leu"                                                      "Moroccan Dirham"                                                   "Mozambique Metical"                                               
#>  [97] "Mvdol"                                                             "Naira"                                                             "Nakfa"                                                            
#> [100] "Namibia Dollar"                                                    "Nepalese Rupee"                                                    "Netherlands Antillean Guilder"                                    
#> [103] "New Israeli Sheqel"                                                "New Taiwan Dollar"                                                 "New Zealand Dollar"                                               
#> [106] "Ngultrum"                                                          "North Korean Won"                                                  "Norwegian Krone"                                                  
#> [109] "Ouguiya"                                                           "Pa’anga"                                                           "Pakistan Rupee"                                                   
#> [112] "Palladium"                                                         "Pataca"                                                            "Peso Convertible"                                                 
#> [115] "Peso Uruguayo"                                                     "Philippine Peso"                                                   "Platinum"                                                         
#> [118] "Pound Sterling"                                                    "Pula"                                                              "Qatari Rial"                                                      
#> [121] "Quetzal"                                                           "Rand"                                                              "Rial Omani"                                                       
#> [124] "Riel"                                                              "Romanian Leu"                                                      "Rufiyaa"                                                          
#> [127] "Rupiah"                                                            "Russian Ruble"                                                     "Rwanda Franc"                                                     
#> [130] "Saint Helena Pound"                                                "Saudi Riyal"                                                       "SDR (Special Drawing Right)"                                      
#> [133] "Serbian Dinar"                                                     "Seychelles Rupee"                                                  "Silver"                                                           
#> [136] "Singapore Dollar"                                                  "Sol"                                                               "Solomon Islands Dollar"                                           
#> [139] "Som"                                                               "Somali Shilling"                                                   "Somoni"                                                           
#> [142] "South Sudanese Pound"                                              "Sri Lanka Rupee"                                                   "Sucre"                                                            
#> [145] "Sudanese Pound"                                                    "Surinam Dollar"                                                    "Swedish Krona"                                                    
#> [148] "Swiss Franc"                                                       "Syrian Pound"                                                      "Taka"                                                             
#> [151] "Tala"                                                              "Tanzanian Shilling"                                                "Tenge"                                                            
#> [154] "The codes assigned for transactions where no currency is involved" "Trinidad and Tobago Dollar"                                        "Tugrik"                                                           
#> [157] "Tunisian Dinar"                                                    "Turkish Lira"                                                      "Turkmenistan New Manat"                                           
#> [160] "UAE Dirham"                                                        "Uganda Shilling"                                                   "Unidad de Fomento"                                                
#> [163] "Unidad de Valor Real"                                              "Unidad Previsional"                                                "Uruguay Peso en Unidades Indexadas (UI)"                          
#> [166] "US Dollar"                                                         "US Dollar (Next day)"                                              "Uzbekistan Sum"                                                   
#> [169] "Vatu"                                                              "WIR Euro"                                                          "WIR Franc"                                                        
#> [172] "Won"                                                               "Yemeni Rial"                                                       "Yen"                                                              
#> [175] "Yuan Renminbi"                                                     "Zambian Kwacha"                                                    "Zimbabwe Dollar"                                                  
#> [178] "Zloty"

Standardise variable values

We standardise the target variable values, specifying that we are using the lookup codes method and not the fuzzy-logic / correspondences method.

X <- ratify(X, type_1L_chr = "Lookup")

This significantly reduces the umber of non-standard values for our target variable.

X@results_ls$Currency_Output_Validation$Invalid_Values
#>  [1] "Bitcoin[4]"                 "Cook Islands dollar"        "Faroese króna"              "Guernsey pound"             "Jersey pound"               "Kiribati dollar[E]"         "Manx pound"                 "Niue dollar[E]"            
#>  [9] "Pitcairn Islands dollar[E]" "Sahrawi peseta"             "Tuvaluan dollar"            "Zimbabwe gold"              "Zimbabwean dollar"

If we wish we can remove the non-standardised values.

X <- renew(X, T, type_1L_chr = "slot", what_1L_chr = "force") 
X <- ratify(X, type_1L_chr = "Lookup")

We can no inspect our results a dataset for which the country names and currency names now conform to ISO standards.

X@results_ls$Currency_Output_Lookup %>%
  renew(type_1L_chr = "label") %>%
  exhibit(scroll_box_args_ls = list(width = "100%"))
Dataset
Country name Currency name Currency symbol Currency alphabetical ISO code (three letter) Currency's fractional unit Number of fractional units in basic unit
Afghanistan Afghani ؋‎ AFN Pul 100
Albania Lek Lek ALL Qintar 100
Algeria Algerian Dinar DA DZD Centime 100
Andorra Euro EUR Cent 100
Angola Kwanza Kz AOA Cêntimo 100
Anguilla East Caribbean Dollar \$ XCD Cent 100
Antigua and Barbuda East Caribbean Dollar \$ XCD Cent 100
Argentina Argentine Peso \$ ARS Centavo 100
Armenia Armenian Dram ֏ AMD Luma 100
Aruba Aruban Florin ƒ AWG Cent 100
Saint Helena, Ascension and Tristan da Cunha Saint Helena Pound £ SHP Penny 100
Australia Australian Dollar \$ AUD Cent 100
Austria Euro EUR Cent 100
Azerbaijan Azerbaijan Manat AZN Qəpik 100
Bahamas Bahamian Dollar \$ BSD Cent 100
Bahrain Bahraini Dinar BD BHD Fils 1000
Bangladesh Taka BDT Poisha 100
Barbados Barbados Dollar \$ BBD Cent 100
Belarus Belarusian Ruble Br BYN Kopeck 100
Belgium Euro EUR Cent 100
Belize Belize Dollar \$ BZD Cent 100
Benin CFA Franc BCEAO Fr XOF Centime 100
Bermuda Bermudian Dollar \$ BMD Cent 100
Bhutan Ngultrum Nu BTN Chetrum 100
Bhutan Indian Rupee INR Paisa 100
Bolivia, Plurinational State of Boliviano Bs BOB Centavo 100
Bonaire, Sint Eustatius and Saba US Dollar \$ USD Cent 100
Bosnia and Herzegovina Convertible Mark KM BAM Fening 100
Botswana Pula P BWP Thebe 100
Brazil Brazilian Real R\$ BRL Centavo 100
British Indian Ocean Territory US Dollar \$ USD Cent 100
Virgin Islands, British US Dollar \$ USD Cent 100
Brunei Darussalam Brunei Dollar \$ BND Sen 100
Brunei Darussalam Singapore Dollar \$ SGD Cent 100
Bulgaria Bulgarian Lev Lev BGN Stotinka 100
Burkina Faso CFA Franc BCEAO Fr XOF Centime 100
Burundi Burundi Franc Fr BIF Centime 100
Cambodia Riel KHR Sen 100
Cambodia US Dollar \$ USD Cent 100
Cameroon CFA Franc BEAC Fr XAF Centime 100
Canada Canadian Dollar \$ CAD Cent 100
Cabo Verde Cabo Verde Escudo \$ CVE Centavo 100
Cayman Islands Cayman Islands Dollar \$ KYD Cent 100
Central African Republic CFA Franc BEAC Fr XAF Centime 100
Chad CFA Franc BEAC Fr XAF Centime 100
Chile Chilean Peso \$ CLP Centavo 100
China Yuan Renminbi ¥ CNY Jiao\[G\] 10
Colombia Colombian Peso \$ COP Centavo 100
Comoros Comorian Franc Fr KMF Centime 100
Congo, The Democratic Republic of the Congolese Franc Fr CDF Centime 100
Congo CFA Franc BEAC Fr XAF Centime 100
Cook Islands New Zealand Dollar \$ NZD Cent 100
Costa Rica Costa Rican Colon CRC Céntimo 100
Côte d'Ivoire CFA Franc BCEAO Fr XOF Centime 100
Croatia Euro EUR Cent 100
Cuba Cuban Peso \$ CUP Centavo 100
Curaçao Netherlands Antillean Guilder ƒ ANG Cent 100
Cyprus Euro EUR Cent 100
Czechia Czech Koruna CZK Heller 100
Denmark Danish Krone kr DKK Øre 100
Djibouti Djibouti Franc Fr DJF Centime 100
Dominica East Caribbean Dollar \$ XCD Cent 100
Dominican Republic Dominican Peso \$ DOP Centavo 100
Timor-Leste US Dollar \$ USD Centavo 100
Ecuador US Dollar \$ USD Centavo 100
Egypt Egyptian Pound LE EGP Piastre\[B\] 100
El Salvador US Dollar \$ USD Cent 100
Equatorial Guinea CFA Franc BEAC Fr XAF Centime 100
Eritrea Nakfa Nkf ERN Cent 100
Estonia Euro EUR Cent 100
Eswatini Lilangeni L or E (pl.) SZL Cent 100
Eswatini Rand R ZAR Cent 100
Ethiopia Ethiopian Birr Br ETB Santim 100
Falkland Islands (Malvinas) Falkland Islands Pound £ FKP Penny 100
Falkland Islands (Malvinas) Pound Sterling £ GBP Penny 100
Faroe Islands Danish Krone kr DKK Øre 100
Fiji Fiji Dollar \$ FJD Cent 100
Finland Euro EUR Cent 100
France Euro EUR Cent 100
French Polynesia CFP Franc XPF Centime 100
French Southern Territories Euro EUR Cent 100
Gabon CFA Franc BEAC Fr XAF Centime 100
Gambia Dalasi D GMD Butut 100
Georgia Lari GEL Tetri 100
Germany Euro EUR Cent 100
Ghana Ghana Cedi GHS Pesewa 100
Gibraltar Gibraltar Pound £ GIP Penny 100
Gibraltar Pound Sterling £ GBP Penny 100
Greece Euro EUR Cent 100
Greenland Danish Krone kr DKK Øre 100
Grenada East Caribbean Dollar \$ XCD Cent 100
Guatemala Quetzal Q GTQ Centavo 100
Guernsey Pound Sterling £ GBP Penny 100
Guinea Guinean Franc Fr GNF Centime 100
Guinea-Bissau CFA Franc BCEAO Fr XOF Centime 100
Guyana Guyana Dollar \$ GYD Cent 100
Haiti Gourde G HTG Centime 100
Honduras Lempira L HNL Centavo 100
Hong Kong Hong Kong Dollar \$ HKD Cent 100
Hungary Forint Ft HUF Fillér 100
Iceland Iceland Krona kr ISK Eyrir 100
India Indian Rupee INR Paisa 100
Indonesia Rupiah Rp IDR Sen 100
Iran, Islamic Republic of Iranian Rial Rl or Rls (pl.) IRR Rial 1
Iraq Iraqi Dinar ID IQD Fils 1000
Ireland Euro EUR Cent 100
Isle of Man Pound Sterling £ GBP Penny 100
Israel New Israeli Sheqel ILS Agora 100
Italy Euro EUR Cent 100
Jamaica Jamaican Dollar \$ JMD Cent 100
Japan Yen ¥ JPY Sen\[C\] 100
Jersey Pound Sterling £ GBP Penny 100
Jordan Jordanian Dinar JD JOD Piastre\[H\] 100
Kazakhstan Tenge KZT Tıyn 100
Kenya Kenyan Shilling Sh or Shs (pl.) KES Cent 100
Kiribati Australian Dollar \$ AUD Cent 100
Korea, Democratic People's Republic of North Korean Won KPW Chon 100
Korea, Republic of Won KRW Jeon 100
Kuwait Kuwaiti Dinar KD KWD Fils 1000
Kyrgyzstan Som som KGS Tyiyn 100
Lao People's Democratic Republic Lao Kip LAK Att 100
Latvia Euro EUR Cent 100
Lebanon Lebanese Pound LL LBP Piastre 100
Lesotho Loti L or M (pl.) LSL Sente 100
Lesotho Rand R ZAR Cent 100
South Georgia and the South Sandwich Islands Falkland Islands Pound £ FKP Penny 100
South Georgia and the South Sandwich Islands Pound Sterling £ GBP Penny 100
Liberia Liberian Dollar \$ LRD Cent 100
Liberia US Dollar \$ USD Cent 100
Libya Libyan Dinar LD LYD Dirham 1000
Liechtenstein Swiss Franc Fr CHF Rappen 100
Lithuania Euro EUR Cent 100
Luxembourg Euro EUR Cent 100
Macao Pataca MOP\$ MOP Avo 100
Macao Hong Kong Dollar \$ HKD Cent 100
Madagascar Malagasy Ariary Ar MGA Iraimbilanja 5
Malawi Malawi Kwacha K MWK Tambala 100
Malaysia Malaysian Ringgit RM MYR Sen 100
Maldives Rufiyaa Rf MVR Laari 100
Mali CFA Franc BCEAO Fr XOF Centime 100
Malta Euro EUR Cent 100
Marshall Islands US Dollar \$ USD Cent 100
Mauritania Ouguiya UM MRU Khoums 5
Mauritius Mauritius Rupee Re or Rs (pl.) MUR Cent 100
Mexico Mexican Peso \$ MXN Centavo 100
Micronesia, Federated States of US Dollar \$ USD Cent 100
Moldova, Republic of Moldovan Leu Leu or Lei (pl.) MDL Ban 100
Monaco Euro EUR Cent 100
Mongolia Tugrik MNT Möngö 100
Montenegro Euro EUR Cent 100
Montserrat East Caribbean Dollar \$ XCD Cent 100
Morocco Moroccan Dirham DH MAD Centime 100
Mozambique Mozambique Metical Mt MZN Centavo 100
Myanmar Kyat K or Ks (pl.) MMK Pya 100
Namibia Namibia Dollar \$ NAD Cent 100
Namibia Rand R ZAR Cent 100
Nauru Australian Dollar \$ AUD Cent 100
Nepal Nepalese Rupee Re or Rs (pl.) NPR Paisa 100
Nepal Indian Rupee INR Paisa 100
Netherlands Euro EUR Cent 100
New Caledonia CFP Franc XPF Centime 100
New Zealand New Zealand Dollar \$ NZD Cent 100
Nicaragua Cordoba Oro C\$ NIO Centavo 100
Niger CFA Franc BCEAO Fr XOF Centime 100
Nigeria Naira NGN Kobo 100
Niue New Zealand Dollar \$ NZD Cent 100
North Macedonia Denar DEN MKD Deni 100
Norway Norwegian Krone kr NOK Øre 100
Oman Rial Omani RO OMR Baisa 1000
Pakistan Pakistan Rupee Re or Rs (pl.) PKR Paisa 100
Palau US Dollar \$ USD Cent 100
Palestine, State of New Israeli Sheqel ILS Agora 100
Palestine, State of Jordanian Dinar JD JOD Piastre\[H\] 100
Panama Balboa B/ PAB Centésimo 100
Panama US Dollar \$ USD Cent 100
Papua New Guinea Kina K PGK Toea 100
Paraguay Guarani PYG Céntimo 100
Peru Sol S/ PEN Céntimo 100
Philippines Philippine Peso PHP Sentimo 100
Pitcairn New Zealand Dollar \$ NZD Cent 100
Poland Zloty PLN Grosz 100
Portugal Euro EUR Cent 100
Qatar Qatari Rial QR QAR Dirham 100
Romania Romanian Leu Leu or Lei (pl.) RON Ban 100
Russian Federation Russian Ruble RUB Kopeck 100
Rwanda Rwanda Franc Fr RWF Centime 100
Bonaire, Sint Eustatius and Saba US Dollar \$ USD Cent 100
Western Sahara Moroccan Dirham DH MAD Centime 100
Saint Helena, Ascension and Tristan da Cunha Saint Helena Pound £ SHP Penny 100
Saint Helena, Ascension and Tristan da Cunha Pound Sterling £ GBP Penny 100
Saint Kitts and Nevis East Caribbean Dollar \$ XCD Cent 100
Saint Lucia East Caribbean Dollar \$ XCD Cent 100
Saint Pierre and Miquelon Euro EUR Cent 100
Saint Pierre and Miquelon Canadian Dollar \$ CAD Cent 100
Saint Vincent and the Grenadines East Caribbean Dollar \$ XCD Cent 100
Samoa Tala \$ WST Sene 100
Saint Barthélemy Euro EUR Cent 100
San Marino Euro EUR Cent 100
Sao Tome and Principe Dobra Db STN Cêntimo 100
Saudi Arabia Saudi Riyal Rl or Rls (pl.) SAR Halala 100
Senegal CFA Franc BCEAO Fr XOF Centime 100
Serbia Serbian Dinar DIN RSD Para 100
Seychelles Seychelles Rupee Re or Rs (pl.) SCR Cent 100
Sierra Leone Leone Le SLE Cent 100
Singapore Singapore Dollar \$ SGD Cent 100
Singapore Brunei Dollar \$ BND Sen 100
Bonaire, Sint Eustatius and Saba US Dollar \$ USD Cent 100
Sint Maarten (Dutch part) Netherlands Antillean Guilder ƒ ANG Cent 100
Slovakia Euro EUR Cent 100
Slovenia Euro EUR Cent 100
Solomon Islands Solomon Islands Dollar \$ SBD Cent 100
Somalia Somali Shilling Sh or Shs (pl.) SOS Cent 100
South Africa Rand R ZAR Cent 100
South Sudan South Sudanese Pound LS SSP Piaster 100
Spain Euro EUR Cent 100
Sri Lanka Sri Lanka Rupee Re or Rs (pl.) LKR Cent 100
Sudan Sudanese Pound LS SDG Piastre 100
Suriname Surinam Dollar \$ SRD Cent 100
Sweden Swedish Krona kr SEK Öre 100
Switzerland Swiss Franc Fr CHF Rappen\[J\] 100
Syrian Arab Republic Syrian Pound LS SYP Piastre 100
Taiwan, Province of China New Taiwan Dollar \$ TWD Cent 100
Tajikistan Somoni SM TJS Diram 100
Tanzania, United Republic of Tanzanian Shilling Sh or Shs (pl.) TZS Cent 100
Thailand Baht ฿ THB Satang 100
Togo CFA Franc BCEAO Fr XOF Centime 100
Tonga Pa'anga T\$ TOP Seniti 100
Trinidad and Tobago Trinidad and Tobago Dollar \$ TTD Cent 100
Tunisia Tunisian Dinar DT TND Millime 1000
Türkiye Turkish Lira TRY Kuruş 100
Turkmenistan Turkmenistan New Manat m TMT Tenge 100
Turks and Caicos Islands US Dollar \$ USD Cent 100
Tuvalu Australian Dollar \$ AUD Cent 100
Uganda Uganda Shilling Sh or Shs (pl.) UGX (none) (none)
Ukraine Hryvnia UAH Kopeck 100
United Arab Emirates UAE Dirham Dh or Dhs (pl.) AED Fils 100
United Kingdom Pound Sterling £ GBP Penny 100
United States US Dollar \$ USD Cent\[A\] 100
Uruguay Peso Uruguayo \$ UYU Centésimo 100
Uzbekistan Uzbekistan Sum soum UZS Tiyin 100
Vanuatu Vatu VT VUV Cent 100
Holy See (Vatican City State) Euro EUR Cent 100
Venezuela, Bolivarian Republic of Bolívar Soberano Bs.S VES Céntimo 1
Venezuela, Bolivarian Republic of Bolívar Soberano Bs.D VED Céntimo 100
Venezuela, Bolivarian Republic of US Dollar \$ USD Cent 100
Viet Nam Dong VND Hào\[L\] 10
Wallis and Futuna CFP Franc XPF Centime 100
Yemen Yemeni Rial Rl or Rls (pl.) YER Fils 100
Zambia Zambian Kwacha K ZMW Ngwee 100
Zimbabwe US Dollar \$ USD Cent 100

4.2.5 - Score health utility

Using modules from the scorz R package, individual responses to a multi-attribute utility instrument survey can be converted into health utility total scores. This tutorial describes how to do for adolescent AQoL-6D health utility.

This below section renders a vignette article from the scorz library. You can use the following links to:

Note: This vignette is illustrated with fake data. The dataset explored in this example should not be used to inform decision-making. Some of the methods illustrated in this AQoL-6D vignette can also be used to score other health utility instruments - see a vignette about scoring EQ-5D.

AQoL-6D scoring

To derive a health utility score from the raw responses to a multi-attribute utility instrument it is necessary to implement a scoring algorithm. Scoring algorithms for the Assessment of Quality of Life Six Dimension (AQoL-6D) are publicly available in SPSS format (https://www.aqol.com.au/index.php/scoring-algorithms).

However, to include scoring algorithms in reproducible research workflows, it is desirable to have these algorithms available in open science languages such as R. The scorz package includes ready4 framework model modules of the ready4 youth mental health economic model that provide R implementations of the adult and adolescent versions of the AQoL-6D scoring algorithms.

Ingest data

To begin, we ingest an unscored dataset as an instance of the Ready4useDyad from the ready4use package. In this case we download our data from a remote repository.

X <- ready4use::Ready4useRepos(dv_nm_1L_chr = "fakes",
                               dv_ds_nm_1L_chr = "https://doi.org/10.7910/DVN/W95KED",
                               dv_server_1L_chr = "dataverse.harvard.edu") %>%
  ingest(fls_to_ingest_chr = "ymh_clinical_dyad_r4",
         metadata_1L_lgl = F) 

To make the ingested dataset easier to interpret, we can add labels from the dictionary.

X <- X %>%
  renew(type_1L_chr = "label")

We can now inspect our ingested dataset using the exhibit method.

exhibit(X,
        display_1L_chr = "head",
         scroll_box_args_ls = list(width = "100%"))
Dataset
Unique client identifier Round of data collection Date of data collection Age Gender Sex at birth Sexual orientation Aboriginal or Torres Strait Islander Country Of birth Speaks English at home Native English speaker Education and employment status Relationship status Service centre name Primary diagnosis Clinical stage Kessler Psychological Distress Scale (6 Dimension) Patient Health Questionnaire Behavioural Activation for Depression Scale Generalised Anxiety Disorder Scale Overall Anxiety Severity and Impairment Scale Screen for Child Anxiety Related Disorders Social and Occupational Functioning Assessment Scale Assessment of Quality of Life (6 Dimension) question 1 Assessment