knitr::opts_chunk$set(echo = TRUE)
This vignette article is abridged and modified version of another article on predicting Quality Adjusted Life Years with youthu.
This article illustrates how to make QALY predictions using a dataset in wide format with no health-utility measures but containing two psychological measures (GAD-7 and PHQ-9).
If not already installed it will be necessary to install the youthu
R library. As youthu
is not yet available on CRAN, it will be necessary to install it directly from its GitHub repository using an R package like remotes
or devtools
.
# Uncomment and run if installation is required. # utils::install.packages("devtools") # devtools::install_github("ready4-dev/youthu")
We now load the libraries we will be using in subsequent steps. Note, both the ready4
, ready4show
and ready4use
ready4 framework libraries will have been installed automatically when youthu
was installed. The specific
readyforwhatsnext module library and dplyr
, purrr
, stringr
and tidyr
CRAN libraries will have been installed at the same time.
library(ready4) library(ready4show) library(ready4use) library(specific) library(youthu)
We begin by specifying the sources for our data. In this example, our data sources are online repositories.
X <- Ready4useRepos(dv_nm_1L_chr = "fakes", dv_ds_nm_1L_chr = "https://doi.org/10.7910/DVN/HJXYKQ", dv_server_1L_chr = "dataverse.harvard.edu", gh_repo_1L_chr = "ready4-dev/youthu", gh_tag_1L_chr = "v0.0.0.91125")
We can now inspect the dataset we will be using to make predictions. As this is a demonstration article we are going to create a custom synthetic dataset. Our first step in doing so is to ingest a preexisting synthetic dataset (in long format) using the method explained in another vignette article
data_tb <- ingest(X, fls_to_ingest_chr = c("ymh_phq_gad_tb"), metadata_1L_lgl = F)
# Alternatively # data_tb <- ingest(X, fls_to_ingest_chr = c("ymh_clinical_tb"), metadata_1L_lgl = F) # data_tb <- data_tb %>% dplyr:: select(c("fkClientID", "round", # "d_interview_date", # "gad7_total", "phq9_total")) %>% # tidyr::pivot_wider(names_from = c("round"), # values_from = c("d_interview_date", "gad7_total", "phq9_total")) %>% # dplyr::rename_with(~stringr::str_replace(.x,"_Baseline","_t1") %>% # stringr::str_replace("_Follow-up","_t2") %>% # stringr::str_replace("_total",""))
Our resulting dataset has unique IDs for each participant (character class), timestamps for each data collection timepoint (Date class variables) and GAD-7 and PHQ-9 scores for each timepoint (integer class).
data_tb %>% head() %>% ready4show::print_table(caption_1L_chr = "Dataset", output_type_1L_chr = "HTML")
We retrieve details of relevant AQoL-6D mapping models for wither of the predictors we plan on using. How these models were derived is described in a pre-print and details of model performance is included in catalogues available in an open access data repository.
mdls_lup <- get_mdls_lup(ttu_dv_dss_tb = get_ttu_dv_dss("TTU"), utility_type_chr = "AQoL-6D", mdl_predrs_in_ds_chr = c("GAD7 total score", "PHQ9 total score"))
mdls_lup[,c(1,2,5)] %>% ready4show::print_table(caption_1L_chr = "Available models", output_type_1L_chr = "HTML")
We select our preferred model and retrieve summary data about the model's predictor variables.
predictors_lup <- get_predictors_lup(mdls_lup = mdls_lup, mdl_nm_1L_chr = "GAD7_PHQ9_1_OLS_CLL")
exhibit(predictors_lup)
To be used with the mapping models available to us, our prediction dataset needs to be in long format. We perform the necessary transformation.
data_tb <- transform_ds_to_long(data_tb, predictors_chr = c("gad7", "phq9"), msrmnt_date_var_nm_1L_chr = "d_interview_date", round_var_nm_1L_chr = "When")
We drop records where we are missing data for either GAD7 or PHQ9 at either timepoint.
data_tb <- transform_ds_to_drop_msng(data_tb, predictors_chr = c("gad7", "phq9"), uid_var_nm_1L_chr = "fkClientID")
We now predict AQoL-6D health utility for each case with complete data.
predn_ds_ls <- make_predn_metadata_ls(data_tb, id_var_nm_1L_chr = "fkClientID", msrmnt_date_var_nm_1L_chr = "d_interview_date", predr_vars_nms_chr = c(GAD7 = "gad7", PHQ9 = "phq9"), round_var_nm_1L_chr = "When", round_bl_val_1L_chr = "t1", utl_var_nm_1L_chr = "AQoL6D_HU", mdls_lup = mdls_lup, mdl_nm_1L_chr = "GAD7_PHQ9_1_OLS_CLL") data_tb <- add_utl_predn(data_tb, new_data_is_1L_chr = "Predicted", predn_ds_ls = predn_ds_ls)
Finally, we derive QALY predictions from the health utility measures at both time-points.
data_tb <- data_tb %>% add_qalys_to_ds(predn_ds_ls = predn_ds_ls, include_predrs_1L_lgl = F, reshape_1L_lgl = T)
data_tb %>% head() %>% ready4show::print_table(caption_1L_chr = "Final dataset", output_type_1L_chr = "HTML", scroll_box_args_ls = list(width = "100%"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.