# Functions file to map EQ5D-3L <--> EQ5D-5L
# Jessica Forsyth April 2026
# Sheffield Centre for Health and Related Research, University of Sheffield
setwd(dirname(rstudioapi::getActiveDocumentContext()$path))
source("eq5d_mapping-functions.R")
# check library dependencies
load_libraries()
# trials
test_data <- read.csv("test April2026.csv", fileEncoding="UTF-8-BOM")
## fun_map instructions
# output = "3L" if converting from 5L to 3L, "5L" if converting from 3L to 5L
# input_df = dataframe of 3L/5L data for conversion
# age_col = the name of the column containing the age data within input_df
# male_col = the name of the column containing sex info within input_df
# qol_cols = the name of the column(s) containing the EQ5D data for conversion (either individual domain data or utility value) within input_df
# bwidth = band width (number or character to set as default values)
# country = either a single country or a vector of two countries for conversion
# country 1 = country of data to be converted
# country 2 = country for which data should be converted to
# fname_out = optional, if you want to save the converted utilities as a csv file.
# examples where domains are given converting from 3L to 5L
fun_map(output="5L", test_data[1,], "age", "male", qol_col="util3L", bwidth="default", country=c("UK","UK"))
fun_map(output="5L", test_data[2,], "age", "male", qol_col="util3L", bwidth=0.1, country=c("UK","UK"))
fun_map(output="5L", test_data[3,], "age", "male", qol_col="util3L", bwidth="default", country=c("UK","UK"))
fun_map(output="5L", test_data[4,], "age", "male", qol_col="util3L", bwidth=0.1, country=c("UK","UK"))
fun_map(output="5L", test_data[5,], "age", "male", qol_col=c("Y3_1", "Y3_2", "Y3_3", "Y3_4", "Y3_5"), bwidth=0, country=c("UK","UK"))
fun_map(output="5L", test_data[6,], "age", "male", qol_col=c("Y3_1", "Y3_2", "Y3_3", "Y3_4", "Y3_5"), bwidth=0, country=c("UK","UK"))
fun_map(output="5L", test_data[7,], "age", "male", qol_col="util3L", bwidth=0, country=c("UK","UK"))
