| Title: | Tools for Analysing EQ5D Surveys |
|---|---|
| Description: | Provides helper functions to calculate various metrics relating to the analysis of EQ5D surveys. |
| Authors: | Crown Copyright [cph, fnd], Tim Taylor [aut, cre] (ORCID: <https://orcid.org/0000-0002-8587-7113>), Edwin van Leeuwen [ctb] |
| Maintainer: | Tim Taylor <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.2.9001 |
| Built: | 2026-06-03 09:48:59 UTC |
| Source: | https://github.com/TimTaylor/qalytools |
We define an <EQ5D> object as a data frame meeting the following criteria:
It contains columns that represent dimensions from the EQ5D survey specification as well as a column representing the Visual Analogue Score.
It contains a column that acts as a unique respondent identifier and another that identifies different surveys over time. Together these should uniquely identify a response and no combination should be duplicated within the data frame.
<EQ5D3L>, <EQ5D5L> and <EQ5DY3L> objects are defined as a subclass of
EQ5D objects with the additional restriction that the corresponding
dimension columns in x are either NA or whole numbers bounded below by 1
and above by 3 or 5 (depending on the survey type).
as_eq5d5l( x, respondentID, surveyID, mobility, self_care, usual, pain, anxiety, vas, ... ) as_eq5d3l( x, respondentID, surveyID, mobility, self_care, usual, pain, anxiety, vas, ... ) as_eq5dy3l( x, respondentID, surveyID, mobility, self_care, usual, pain, anxiety, vas, ... )as_eq5d5l( x, respondentID, surveyID, mobility, self_care, usual, pain, anxiety, vas, ... ) as_eq5d3l( x, respondentID, surveyID, mobility, self_care, usual, pain, anxiety, vas, ... ) as_eq5dy3l( x, respondentID, surveyID, mobility, self_care, usual, pain, anxiety, vas, ... )
x |
A data frame like object. |
respondentID |
|
surveyID |
|
mobility |
|
self_care |
|
usual |
|
pain |
|
anxiety |
|
vas |
|
... |
Not currently used. |
A tibble like <EQ5D3L>, <EQ5D5L> or <EQ5DY3L>
object.
data(eq5d3l_example) as_eq5d3l( eq5d3l_example, respondentID = "respondentID", surveyID = "surveyID", mobility = "MO", self_care = "SC", usual = "UA", pain = "PD", anxiety = "AD", vas = "vas" )data(eq5d3l_example) as_eq5d3l( eq5d3l_example, respondentID = "respondentID", surveyID = "surveyID", mobility = "MO", self_care = "SC", usual = "UA", pain = "PD", anxiety = "AD", vas = "vas" )
Coerce data frames to utility objects
A utility object contains is a data frame that meets the following criteria:
It contains a column that acts as a unique respondent identifier and another that identifies different surveys over time.
It contains additional columns that represent the country, type and value of a utility that has previously been calculated.
Together, Each combination of respondent identifier, survey identifier, utility country and utility type should be unique and not duplicated across rows.
as_utility(x, respondentID, surveyID, country, type, value)as_utility(x, respondentID, surveyID, country, type, value)
x |
|
respondentID |
|
surveyID |
|
country |
|
type |
|
value |
|
A tibble like <utility> object.
Generic function that lists value sets available.
available_valuesets(x, ...) ## Default S3 method: available_valuesets(x, ...) ## S3 method for class 'EQ5D5L' available_valuesets(x, ...) ## S3 method for class 'EQ5D3L' available_valuesets(x, ...) ## S3 method for class 'EQ5DY3L' available_valuesets(x, ...) ## S3 method for class 'character' available_valuesets(x, ...)available_valuesets(x, ...) ## Default S3 method: available_valuesets(x, ...) ## S3 method for class 'EQ5D5L' available_valuesets(x, ...) ## S3 method for class 'EQ5D3L' available_valuesets(x, ...) ## S3 method for class 'EQ5DY3L' available_valuesets(x, ...) ## S3 method for class 'character' available_valuesets(x, ...)
x |
An R object. |
... |
Further arguments passed to or from other methods. |
available_valuesets() returns the available valuesets from the
eq5d package. It is an s3
generic that wraps the eq5d::valuesets() function providing additional
methods for eq5d and character objects.
For character objects, the input is expected to be the survey type with
various forms permitted:
"eq5d5l", "EQ5D5L", "eq-5d-5l", "EQ-5D-5L", "5L", "5l"
"eq5d3l", "EQ5D3L", "eq-5d-3l", "EQ-5D-3L", "3L", "3l"
"eq5dy3l" , "EQ5DY3L" , "eq-5d-y-3l" , "EQ-5D-Y-3L" , "Y3L" , "y3l"
If called with no arguments value sets for all available version, type and country combination are returned.
A tibble containing the available value sets for the given object or survey type.
data(eq5d3l_example) dat <- as_eq5d3l( eq5d3l_example, respondentID = "respondentID", surveyID = "surveyID", mobility = "MO", self_care = "SC", usual = "UA", pain = "PD", anxiety = "AD", vas = "vas" ) available_valuesets(dat) available_valuesets("eq5d5l")data(eq5d3l_example) dat <- as_eq5d3l( eq5d3l_example, respondentID = "respondentID", surveyID = "surveyID", mobility = "MO", self_care = "SC", usual = "UA", pain = "PD", anxiety = "AD", vas = "vas" ) available_valuesets(dat) available_valuesets("eq5d5l")
Generic function that calculates the limitation of survey responses across response dimensions. Here we define a limitation to be a dimension value not equal to 1. Methods are provided for EQ5D objects.
calculate_limitation(x, ...) ## Default S3 method: calculate_limitation(x, ...) ## S3 method for class 'EQ5D' calculate_limitation(x, ...)calculate_limitation(x, ...) ## Default S3 method: calculate_limitation(x, ...) ## S3 method for class 'EQ5D' calculate_limitation(x, ...)
x |
An R object. |
... |
Further arguments passed to or from other methods. |
A tibble of the fraction of individuals without limitation.
data(eq5d3l_example) dat <- as_eq5d3l( eq5d3l_example, respondentID = "respondentID", surveyID = "surveyID", mobility = "MO", self_care = "SC", usual = "UA", pain = "PD", anxiety = "AD", vas = "vas" ) calculate_limitation(dat)data(eq5d3l_example) dat <- as_eq5d3l( eq5d3l_example, respondentID = "respondentID", surveyID = "surveyID", mobility = "MO", self_care = "SC", usual = "UA", pain = "PD", anxiety = "AD", vas = "vas" ) calculate_limitation(dat)
calculate_pchc() calculates the Paretian Classification of Health Change
(PCHC) in an individuals health state between two surveys. It wraps the
eq5d::pchc() function providing methods for EQ5D objects.
calculate_pchc(pre, post, no.problems = TRUE, by.dimension = FALSE)calculate_pchc(pre, post, no.problems = TRUE, by.dimension = FALSE)
pre |
An EQ5D object for a single survey. |
post |
An EQ5D object for a single survey. |
no.problems |
boolean. Summarise 11111 "No change" subjects in a "No problems" group. |
by.dimension |
boolean. Summarise results by each EQ-5D dimension rather than by the whole dataset. |
For by.dimension = FALSE:
A data frame with columns 'Change', 'Number' and 'Percent'.
For by.dimension = TRUE:
A data frame with columns 'Dimension', 'Change', 'Number' and 'Percent'.
data(eq5d3l_example) dat <- as_eq5d3l( eq5d3l_example, respondentID = "respondentID", surveyID = "surveyID", mobility = "MO", self_care = "SC", usual = "UA", pain = "PD", anxiety = "AD", vas = "vas" ) grp1 <- subset(dat, Group == "Group1") grp2 <- subset(dat, Group == "Group2") calculate_pchc(grp1, grp2) calculate_pchc(grp1, grp2, by.dimension = TRUE)data(eq5d3l_example) dat <- as_eq5d3l( eq5d3l_example, respondentID = "respondentID", surveyID = "surveyID", mobility = "MO", self_care = "SC", usual = "UA", pain = "PD", anxiety = "AD", vas = "vas" ) grp1 <- subset(dat, Group == "Group1") grp2 <- subset(dat, Group == "Group2") calculate_pchc(grp1, grp2) calculate_pchc(grp1, grp2, by.dimension = TRUE)
Generic for calculating quality of life years (QALY) metrics for EQ5D survey respondents.
calculate_qalys(x, ...) ## Default S3 method: calculate_qalys(x, ...) ## S3 method for class 'EQ5D' calculate_qalys( x, time_index, type, country, units = c("days", "weeks", "months", "quarters", "years"), baseline_survey = NULL, ... ) ## S3 method for class 'utility' calculate_qalys( x, time_index, units = c("days", "weeks", "months", "quarters", "years"), baseline_survey = NULL, ... )calculate_qalys(x, ...) ## Default S3 method: calculate_qalys(x, ...) ## S3 method for class 'EQ5D' calculate_qalys( x, time_index, type, country, units = c("days", "weeks", "months", "quarters", "years"), baseline_survey = NULL, ... ) ## S3 method for class 'utility' calculate_qalys( x, time_index, units = c("days", "weeks", "months", "quarters", "years"), baseline_survey = NULL, ... )
x |
An R object. |
... |
Further arguments passed to or from other methods. |
time_index |
Name of variable in x representing the relative time within the survey framework. |
type |
Method type(s) used for calculating the value sets. For EQ5D3L inputs this can be:
For EQ5D5L inputs this can be:
|
country |
Value set countries to use. |
units |
The units of the Note that the output will always be a QALY (i.e years) irrespective of the unit input. |
baseline_survey |
(optional) Either a If a data frame, it must have at least two columns; one for the respondentID
(with name matching that in |
The methods provided for utility and EQ5D objects, return two metrics by default:
Firstly, a raw QALY. This is the area under the utility curve scaled to
the proportion of the year it corresponds to.
Secondly, a loss_v_fullhealth value. This represents the loss from
perfect health which is calculated by assuming all dimensions are 1
to calculate a full health QALY value.
Optionally, a third metric can also be returned, loss_v_baseline. This
represents the loss from a specified baseline utility value.
A tibble.
If a character string baseline_survey argument is given then this must match
a surveyID to match against. In this situation the survey is still
included in the unadjusted, raw, calculation, prior to the calculation of
loss.
Alternatively the baseline_survey argument can be specified as a data frame
with a column corresponding to the respondentID and another representing the
associated utility. Optionally columns corresponding to the utility country
and utility type can be included to allow more granular comparisons. For this
specification of baseline, it is not included in the unadjusted, raw,
calculation.
data(EQ5D5L_surveys) dat <- as_eq5d5l( EQ5D5L_surveys, surveyID = "surveyID", respondentID = "respondentID", mobility = "mobility", self_care = "self_care", usual = "usual", pain = "pain", anxiety = "anxiety", vas = "vas" ) calculate_qalys( dat, time_index = "time_index", type = "VT", country = c("Denmark", "France") )data(EQ5D5L_surveys) dat <- as_eq5d5l( EQ5D5L_surveys, surveyID = "surveyID", respondentID = "respondentID", mobility = "mobility", self_care = "self_care", usual = "usual", pain = "pain", anxiety = "anxiety", vas = "vas" ) calculate_qalys( dat, time_index = "time_index", type = "VT", country = c("Denmark", "France") )
Generic function that calculates EQ5D index scores for given value sets.
calculate_utility(x, type, country, ...) ## Default S3 method: calculate_utility(x, type, country, ...) ## S3 method for class 'EQ5D5L' calculate_utility( x, type = "VT", country = "England", drop = TRUE, age = NULL, sex = NULL, ... ) ## S3 method for class 'EQ5D3L' calculate_utility( x, type = "VT", country = "England", drop = TRUE, age = NULL, sex = NULL, ... ) ## S3 method for class 'EQ5DY3L' calculate_utility( x, type = "VT", country = "England", drop = TRUE, age = NULL, sex = NULL, ... ) add_utility(x, type, country, ...) ## Default S3 method: add_utility(x, type, country, ...) ## S3 method for class 'EQ5D5L' add_utility(x, type = "VT", country = "England", age = NULL, sex = NULL, ...) ## S3 method for class 'EQ5D3L' add_utility(x, type = "VT", country = "England", age = NULL, sex = NULL, ...) ## S3 method for class 'EQ5DY' add_utility(x, type = "VT", country = "England", age = NULL, sex = NULL, ...)calculate_utility(x, type, country, ...) ## Default S3 method: calculate_utility(x, type, country, ...) ## S3 method for class 'EQ5D5L' calculate_utility( x, type = "VT", country = "England", drop = TRUE, age = NULL, sex = NULL, ... ) ## S3 method for class 'EQ5D3L' calculate_utility( x, type = "VT", country = "England", drop = TRUE, age = NULL, sex = NULL, ... ) ## S3 method for class 'EQ5DY3L' calculate_utility( x, type = "VT", country = "England", drop = TRUE, age = NULL, sex = NULL, ... ) add_utility(x, type, country, ...) ## Default S3 method: add_utility(x, type, country, ...) ## S3 method for class 'EQ5D5L' add_utility(x, type = "VT", country = "England", age = NULL, sex = NULL, ...) ## S3 method for class 'EQ5D3L' add_utility(x, type = "VT", country = "England", age = NULL, sex = NULL, ...) ## S3 method for class 'EQ5DY' add_utility(x, type = "VT", country = "England", age = NULL, sex = NULL, ...)
x |
An R object. |
type |
Method type(s) used for calculating the value sets. For EQ5D3L inputs this can be:
For EQ5D5L inputs this can be:
|
country |
Value set countries to use. |
... |
Further arguments passed to or from other methods. |
drop |
If TRUE (default), only columns corresponding to the surveyID and
respondentID are kept from the input |
age |
Column in Only used if |
sex |
Column in Only used if Column entries must be one of "Male", "M", "Female" or "F" (case insensitive). |
calculate_utility() returns the utility index scores for a given object
and value set combination. Methods that wrap functionality of the
eq5d package are provided for
EQ5D objects.
add_utility() is a wrapper around calculate_utility() which keeps all
columns of the input data x.
A data frame of utility values linked to responses.
The methods for EQ5D objects expect type and country to be of
the same length but will recycle those of length one to a common size.
available_valuesets() for the method / country combinations available for
each survey type.
data(eq5d3l_example) dat <- as_eq5d3l( eq5d3l_example, respondentID = "respondentID", surveyID = "surveyID", mobility = "MO", self_care = "SC", usual = "UA", pain = "PD", anxiety = "AD", vas = "vas" ) calculate_utility(dat, type = "TTO", country = c("UK", "Germany"))data(eq5d3l_example) dat <- as_eq5d3l( eq5d3l_example, respondentID = "respondentID", surveyID = "surveyID", mobility = "MO", self_care = "SC", usual = "UA", pain = "PD", anxiety = "AD", vas = "vas" ) calculate_utility(dat, type = "TTO", country = c("UK", "Germany"))
Methods to convert an EQ5D object to a data frame, tibble or data.table.
## S3 method for class 'EQ5D' as.data.frame(x, row.names, optional, ...) ## S3 method for class 'EQ5D' as.data.table(x, keep.rownames, ...) ## S3 method for class 'EQ5D' as_tibble(x, ..., .rows, .name_repair, rownames)## S3 method for class 'EQ5D' as.data.frame(x, row.names, optional, ...) ## S3 method for class 'EQ5D' as.data.table(x, keep.rownames, ...) ## S3 method for class 'EQ5D' as_tibble(x, ..., .rows, .name_repair, rownames)
x |
An EQ5D object. |
row.names |
Not used. |
optional |
Not used. |
... |
Not used. |
keep.rownames |
Not used. |
.rows |
Not used. |
.name_repair |
Not used. |
rownames |
Not used. |
An appropriate representation of the data frame underlying the EQ5D object. Only column names are preserved with all other attributes, including row names, dropped.
Apart from x no other parameters are used and they are only present
in the method signatures for compatibility with the underlying generic.
A dataset containing dimensions and grouping for 200 observations. Data was obtained from the eq5d package on 2022-06-15, with additional variables added for package compatibility.
eq5d3l_exampleeq5d3l_example
A tibble with 200 rows and 6 variables:
Unique respondent identifier
Unique survey identifier
Mobility dimension valuea
Self-care dimension values
Usual activities dimension values
Pain/discomfort dimension values
Anxiety/depression dimension values
Observation group
VAS score
Relative time within survey framework
https://github.com/fragla/eq5d/raw/master/inst/extdata/eq5d3l_example.xlsx
A dataset containing dimension values and vas score for 1000 respondents across 10 surveys. Data was synthetically generated.
EQ5D5L_surveysEQ5D5L_surveys
A tibble with 10000 rows and 11 variables:
Survey ID
Respondent ID
Respondent sex
Respondent age
Mobility dimension
Self-care dimension
Usual activities dimension
Pain/discomfort dimension
Anxiety/depression dimension
VAS score
Relative time within survey framework
Random roolean variable
Provides a summary of dimension values by survey ID.
## S3 method for class 'EQ5D' summary(object, ..., tidy = FALSE)## S3 method for class 'EQ5D' summary(object, ..., tidy = FALSE)
object |
An EQ5D object. |
... |
Not currently used. |
tidy |
Should results be returned as single, "tidy", table in long format? If |