Title: | Type 2 Diabetes Risk Calculator |
---|---|
Description: | Calculate the risk of developing type 2 diabetes using risk prediction algorithms derived by 'ClinRisk'. |
Authors: | Benjamin G. Feakins [aut, cre]
|
Maintainer: | Benjamin G. Feakins <[email protected]> |
License: | AGPL-3 + file LICENSE |
Version: | 1.0-2 |
Built: | 2025-01-29 05:23:25 UTC |
Source: | https://github.com/feakster/qdiabetes |
This package calculates the risk of developing type 2 diabetes using risk prediction algorithms, which were initially derived by ClinRisk. Currently, these include QDiabetes-2013 and QDiabetes-2018, although older (and eventually more recent) versions of QDiabetes will be included in future releases.
The package consistes of four risk prediction functions for use in estimating the risk of developing type 2 diabetes:
QDR2013
- For estimating the 1–10-year risk using QDiabetes-2013.
QDR2018A
- For estimating the 10-year risk using QDiabetes-2018 (Model A).
QDR2018B
- For estimating the 10-year risk using QDiabetes-2018 (Model B).
QDR2018C
- For estimating the 10-year risk using QDiabetes-2018 (Model C).
The following variables are used by each risk prediction function present in this package:
Description | Variable | Type | QDR2013 |
QDR2018A |
QDR2018B |
QDR2018C |
Gender | sex |
character | x | x | x | x |
Age | age |
double | x | x | x | x |
Body mass index (BMI) | bmi |
double | x | x | x | x |
Ethnicity | ethn |
character | x | x | x | x |
Smoking status | smoke |
character | x | x | x | x |
Deprivation | tds |
double | x | x | x | x |
Fasting plasma glucose (FPG) | fpg |
double | x | |||
Glycated haemoglobin (HbA1c) | hba1c |
double | x | |||
Family history of diabetes | fhdm |
logical | x | x | x | x |
History of treated hypertension | htn |
logical | x | x | x | x |
History of cardiovascular disease | cvd |
logical | x | x | x | x |
History of gestational Diabetes | gdm |
logical | x | x | x | |
History of polycystic ovary syndrome | pcos |
logical | x | x | x | |
History of learning difficulties | learn |
logical | x | x | x | |
History of schizophrenia or bipolar affective disorder | psy |
logical | x | x | x | |
History of corticosteroid use | ster |
logical | x | x | x | x |
History of statin use | stat |
logical | x | x | x | |
History of use of 2nd generation antipsychotics | apsy |
logical | x | x | x | |
Survival time | surv |
integer | x |
NB: height (ht
) and weight (wt
) may be specified in place of body mass index (bmi
) in any of the above functions.
As per R's general coding sytax, factor or character values may be passed to any risk prediction function parameter where a character value is expected, so long as the factor variable label matches one of the expected character strings. Similarly, 0
or 1
many be used in place of FALSE
or TRUE
for any function parameter where a logical value is expected.
ClinRisk do not support of endorse this code. End users should see the original C source as the 'gold standard' open source implementation. Please note that the QDiabetes R package has been created as a research tool for scientific purposes only. The QDiabetes R package has not been granted Medicines and Healthcare products Regulatory Agency (MHRA) approval as a medical device, and hence, should not be used as part of any individualised risk assessment.
This project was funded by the National Institute for Health Research (NIHR) School for Primary Care Research (SPCR) [project number: 412]. The views expressed are those of the author(s) and not necessarily those of the NIHR or the Department of Health and Social Care.
Many of the default values used in the risk prediction functions of this package were selected to be representative of a UK population. These values are only intended to minimise the amount of typing required when using the risk prediction functions in an exploratory manner. They are unlikely to be useful in a research setting, and you would need to know the exact values to assign to all function parameters in order to make accurate risk predictions. Hence, while you can get risk preditions from the QDR2013
and QDR2018A
functions through the specification of only sex
, age
, and bmi
, you would be assuming White or missing ethnicity, non-smoking status, a Townsend deprivation score of 0, and the complete absence of any relevant medical history/conditions and concommitant drug therapies. In the case of QDR2013
, you would also be assuming that a 10-year risk window is desired.
Benjamin G. Feakins [email protected]
Hippisley-Cox, J., Coupland, C., Robson, J., Sheikh, A. and Brindle, P. (2009). Predicting risk of type 2 diabetes in England and Wales: prospective derivation and validation of QDScore. BMJ 338, b880. doi:10.1136/bmj.b880
Hippisley-Cox, J. and Coupland, C. (2017). Development and validation of QDiabetes-2018 risk prediction algorithm to estimate future risk of type 2 diabetes: cohort study. BMJ 359, j5019. doi:10.1136/bmj.j5019
getTDS
- For looking up Townsend deprivation scores from UK postcodes.
dat_qdr
- QDiabetes sample dataset.
### Simple usage ## QDiabetes-2013 QDR2013(sex = "Female", age = 76, ht = 1.65, wt = 70) QDR2013(sex = "Male", age = seq(25, 80, 5), bmi = 40, ethn = "Other", tds = 5) ## QDiabetes-2018 # Model A QDR2018A(sex = "Female", age = 76, ht = 1.65, wt = 70) QDR2018A(sex = "Male", age = seq(25, 80, 5), bmi = 40, ethn = "Other", tds = 5) # Model B (inc. FPG) QDR2018B(sex = "Female", age = 76, ht = 1.65, wt = 70, fpg = 4) QDR2018B(sex = "Male", age = 55, bmi = 40, fpg = 2:6, ethn = "BlackCaribbean") # Model C (inc. HbA1c) QDR2018C(sex = "Female", age = 76, ht = 1.65, wt = 70, hba1c = 25) QDR2018C(sex = "Male", age = 55, bmi = 40, hba1c = seq(15, 40, 5), ethn = "Chinese") ### Using postcodes to estimate Townsend deprivation scores ## QDiabetes-2013 QDR2013(sex = "Male", age = 65, bmi = 40, tds = getTDS("OX3 7LF")) QDR2013(sex = "Female", age = 60, bmi = 35, tds = getTDS(c("OX2 6NW", "OX2 6GG"))) ## QDiabetes-2018 # Model A QDR2018A(sex = "Male", age = 65, bmi = 40, tds = getTDS("OX3 7LF")) QDR2018A(sex = "Female", age = 60, bmi = 35, tds = getTDS(c("OX2 6NW", "OX2 6GG"))) # Model B (inc. FPG) QDR2018B(sex = "Male", age = 65, bmi = 40, fpg = 6, tds = getTDS("OX3 7LF")) QDR2018B(sex = "Female", age = 60, bmi = 35, fpg = 6, tds = getTDS(c("OX2 6NW", "OX2 6GG"))) # Model C (inc. HbA1c) QDR2018C(sex = "Male", age = 65, bmi = 40, hba1c = 42, tds = getTDS("OX3 7LF")) QDR2018C(sex = "Female", age = 60, bmi = 35, hba1c = 42, tds = getTDS(c("OX2 6NW", "OX2 6GG")))
### Simple usage ## QDiabetes-2013 QDR2013(sex = "Female", age = 76, ht = 1.65, wt = 70) QDR2013(sex = "Male", age = seq(25, 80, 5), bmi = 40, ethn = "Other", tds = 5) ## QDiabetes-2018 # Model A QDR2018A(sex = "Female", age = 76, ht = 1.65, wt = 70) QDR2018A(sex = "Male", age = seq(25, 80, 5), bmi = 40, ethn = "Other", tds = 5) # Model B (inc. FPG) QDR2018B(sex = "Female", age = 76, ht = 1.65, wt = 70, fpg = 4) QDR2018B(sex = "Male", age = 55, bmi = 40, fpg = 2:6, ethn = "BlackCaribbean") # Model C (inc. HbA1c) QDR2018C(sex = "Female", age = 76, ht = 1.65, wt = 70, hba1c = 25) QDR2018C(sex = "Male", age = 55, bmi = 40, hba1c = seq(15, 40, 5), ethn = "Chinese") ### Using postcodes to estimate Townsend deprivation scores ## QDiabetes-2013 QDR2013(sex = "Male", age = 65, bmi = 40, tds = getTDS("OX3 7LF")) QDR2013(sex = "Female", age = 60, bmi = 35, tds = getTDS(c("OX2 6NW", "OX2 6GG"))) ## QDiabetes-2018 # Model A QDR2018A(sex = "Male", age = 65, bmi = 40, tds = getTDS("OX3 7LF")) QDR2018A(sex = "Female", age = 60, bmi = 35, tds = getTDS(c("OX2 6NW", "OX2 6GG"))) # Model B (inc. FPG) QDR2018B(sex = "Male", age = 65, bmi = 40, fpg = 6, tds = getTDS("OX3 7LF")) QDR2018B(sex = "Female", age = 60, bmi = 35, fpg = 6, tds = getTDS(c("OX2 6NW", "OX2 6GG"))) # Model C (inc. HbA1c) QDR2018C(sex = "Male", age = 65, bmi = 40, hba1c = 42, tds = getTDS("OX3 7LF")) QDR2018C(sex = "Female", age = 60, bmi = 35, hba1c = 42, tds = getTDS(c("OX2 6NW", "OX2 6GG")))
A simulated sample dataset for exploring the use of the QDR2013
, QDR2018A
, QDR2018B
and QDR2018C
type 2 diabetes risk prediction functions of this package.
data("dat_qdr")
data("dat_qdr")
A data frame with 50 observations on the following 21 variables:
sex
A factor vector of genders. Possible values: "Female"
or "Male"
.
age
An integer vector of ages (years).
bmi
A double vector ofbody-mass indexes (kg/m^2).
ht
A double vector of heights (m).
wt
A double vector of weights (kg).
fpg
A double vector of fasting plasma glucose test results (mmol/L).
hba1c
A double vector of glycated haemoglobin test results (mmol/mol).
ethn
A factor vector of ethnicities. Possible values:
"WhiteNA"
(White or not stated)
"Indian"
(Indian)
"Pakistani"
(Pakistani)
"Bangladeshi"
(Bangladeshi)
"OtherAsian"
(Other Asian)
"BlackCaribbean"
(Black Caribbean)
"BlackAfrican"
(Black African)
"Chinese"
(Chinese)
"Other"
(Other ethnic group).
smoke
A factor vector of smoking statuses. Possible values:
"Non"
(Non-smoker)
"Ex"
(Ex-smoker)
"Light"
(Light smoker - less than 10 cigarettes per day)
"Moderate"
(Moderate smoker - 10 to 19 cigarettes per day)
"Heavy"
(Heavy smoker - 20 or more cigarettes per day).
postcode
A character vector of UK postcodes.
tds
A double vector of Townsend deprivation scores.
fhdm
A logical vector indicating family history of diabetes.
htn
A logical vector indicating history of hypertension.
cvd
A logical vector indicating history of cardiovascular disease.
gdm
A logical vector indicating history of gestational diabetes.
pcos
A logical vector indicating history of polycystic ovary syndrome.
learn
A logical vector indicating history of learning difficulties.
psy
A logical vector indicating history of shizophrenia or bipolar affective disorder.
ster
A logical vector indicating history of corticosteroid use.
stat
A logical vector indicating history of statin use.
apsy
A logical vector indicating history of 2nd generation antipsychotic use.
A simulated dataset containing the characteristics of 50 subjects (one per row). No relationships have been simulated between variables. The dataset contains no values or combinations of values that would result in warnings or errors from any of the risk prediction functions in this package. It exists purely to allow for testing and exploration of these functions.
Benjamin G. Feakins [email protected]
The dataset is simulated, except for the postcode
and tds
variables, which are key-value pairs randomly drawn from an Office for National Statistics dataset.
For more information on this dataset, see the documentation for the getTDS
function.
Contains OS data (C) Crown copyright and database right 2020
Contains Royal Mail data (C) Royal Mail copyright and database right 2020
Source: Office for National Statistics licensed under the Open Government Licence v.3.0
data(dat_qdr) str(dat_qdr)
data(dat_qdr) str(dat_qdr)
Convenient function to look up Townsend deprivation scores using UK postcodes, postcode prefixes, postcode suffixes or a regular expression.
getTDS(postcode, type = "full", squash = ifelse(type != "regex", FALSE, TRUE))
getTDS(postcode, type = "full", squash = ifelse(type != "regex", FALSE, TRUE))
postcode |
A vector of UK postcodes, postcode prefixes, postcode suffixes, or a regular expression. |
type |
A character string indicating the term provided in the |
"full"
— a full five–seven character postcode.
"prefix"
— a two–four character postcode prefix.
"suffix"
— a three character postcode suffix.
"regex"
— a regular expression, allowing any nature of postcode match.
squash |
a logical parameter indicating whether the scores returned should be aggregated into a single median value. |
getTDS
is a lookup function that queries a dataset of postcodes and Townsend deprivation scores.
This dataset was created by joining a dataset of postcodes to a dataset of Townsend deprivation scores, via output area codes.
Both data sets are made available by the Office for National Statistics under the Open Government License.
The postcode dataset was last updated in February 2019, while the dataset of Townsend deprivation scores uses values obtained from the 2011 UK census (matching the Townsend deprivation score dates used by ClinRisk in the derivation of the QDiabetes-2018 algorithms).
Townsend Deprivation Score.
Where type
is not set to "regex"
, the length and nature of the value returned are governed by the type
and squash
parameters:
When squash
is set to FALSE
(the default value) an output vector will be returned that is of equal length to the input vector. When squash
is set to TRUE
a numeric output of length one will be returned, comprising the median Townsend deprivation score from all matched postcodes.
As each postcode is only associated with a single output area, when type
is set to "full"
and squash
is set to FALSE
the Townsend deprivation scores returned will be the exact values associated with each linked output area.
As each postcode prefix or suffix may be associated with multiple output areas, when squash
is set to FALSE
and type
is set to "prefix"
or "suffix"
the median Townsend deprivation score per prefix/suffix will be returned.
PO Box codes have no associated Townsend deprivation scores and will not work as function inputs.
No Northern Ireland postcodes are present in the database searched by getTDS
as their use is governed by a separate, more restrictive license.
Contains OS data (C) Crown copyright and database right 2020
Contains Royal Mail data (C) Royal Mail copyright and database right 2020
Source: Office for National Statistics licensed under the Open Government Licence v.3.0
Benjamin G. Feakins [email protected]
UK Postcode-to-output-area data were obtained here from the Office for National Statistics.
Output-area-to-Townsend-deprivation-scores data were obtained here from the Office for National Statistics.
## Simple usage getTDS(postcode = "OX2 6GG") getTDS(postcode = c("OX2 6NW", "OX3 7LF")) ## Case & white space insensitive getTDS(postcode = c("OX37LF", "OX3 7LF", "ox37lf", "ox3 7lf")) ## Median Townsend Deprivaton Score per Postcode Prefix ## getTDS(postcode = paste0("OX", 1:9), type = "prefix") ## Median Overall Townsend Deprivation Score for a Set of Prefixes ## getTDS(postcode = paste0("OX", 1:9), type = "prefix", squash = TRUE) ## Median Townsend Deprivaton Score per Postcode Suffix ## getTDS(postcode = paste0(1:9, "AA"), type = "suffix") ## Median Overall Townsend Deprivation Score for a Set of Prefixes ## getTDS(postcode = paste0(1:9, "AA"), type = "suffix", squash = TRUE) ## Median Overall Townsend Deprivation Score for Postcodes Matching a Regular Expression ## getTDS(postcode = "^OX37[A-Z]{2}$", type = "regex")
## Simple usage getTDS(postcode = "OX2 6GG") getTDS(postcode = c("OX2 6NW", "OX3 7LF")) ## Case & white space insensitive getTDS(postcode = c("OX37LF", "OX3 7LF", "ox37lf", "ox3 7lf")) ## Median Townsend Deprivaton Score per Postcode Prefix ## getTDS(postcode = paste0("OX", 1:9), type = "prefix") ## Median Overall Townsend Deprivation Score for a Set of Prefixes ## getTDS(postcode = paste0("OX", 1:9), type = "prefix", squash = TRUE) ## Median Townsend Deprivaton Score per Postcode Suffix ## getTDS(postcode = paste0(1:9, "AA"), type = "suffix") ## Median Overall Townsend Deprivation Score for a Set of Prefixes ## getTDS(postcode = paste0(1:9, "AA"), type = "suffix", squash = TRUE) ## Median Overall Townsend Deprivation Score for Postcodes Matching a Regular Expression ## getTDS(postcode = "^OX37[A-Z]{2}$", type = "regex")
Calculate the risk of developing type 2 diabetes, using the QDiabetes-2013 algorithm.
QDR2013(sex, age, bmi, ht, wt, ethn = "WhiteNA", smoke = "Non", tds = 0, fhdm = FALSE, htn = FALSE, cvd = FALSE, ster = FALSE, surv = 10L)
QDR2013(sex, age, bmi, ht, wt, ethn = "WhiteNA", smoke = "Non", tds = 0, fhdm = FALSE, htn = FALSE, cvd = FALSE, ster = FALSE, surv = 10L)
sex |
Gender. Must be |
age |
Age, in years. Must be |
bmi |
Body-mass index, in kg/m^2. Must be |
ht |
Height, in m. Must be |
wt |
Weight, in kg. Must be |
ethn |
Ethnicity. Must be one of:
|
smoke |
Smoking status. Must be one of:
|
tds |
Townsend deprivation score. Must be |
fhdm |
Family history of diabetes in 1st degree relative. |
htn |
History of hypertension. |
cvd |
History of cardiovascular disease. |
ster |
History of use of corticosteroids. |
surv |
Time point at which the Kaplan-Meier cumulative survival estimate is used to calculate risk. Must be an integer value between 1 and 10. |
Risk (%) of type 2 diabetes.
The QDiabetes R package has been created as a research tool for scientific purposes only. The QDiabetes R package has not been granted Medicines and Healthcare products Regulatory Agency (MHRA) approval as a medical device, and hence, should not be used as part of any individualised risk assessment.
Benjamin G. Feakins [email protected]
https://svn.clinrisk.co.uk/opensource/qdiabetes/standard/
QDR2018A
- For estimating the 10-year risk using QDiabetes-2018 (Model A).
QDR2018B
- For estimating the 10-year risk using QDiabetes-2018 (Model B).
QDR2018C
- For estimating the 10-year risk using QDiabetes-2018 (Model C).
## Simple usage QDR2013(sex = "Female", age = 76, ht = 1.65, wt = 70) QDR2013(sex = "Male", age = seq(25, 80, 5), bmi = 40, ethn = "Other", tds = 5) QDR2013(sex = "Female", age = 65, bmi = 35, smoke = c("Non", "Ex", "Light"), fhdm = TRUE) ## Using postcodes to estimate Townsend deprivation scores QDR2013(sex = "Male", age = 65, bmi = 40, tds = getTDS("OX3 7LF")) QDR2013(sex = "Female", age = 60, bmi = 35, tds = getTDS(c("OX2 6NW", "OX2 6GG"))) ## Data frame usage data(dat_qdr) with(dat_qdr, QDR2013(sex = sex, age = age, bmi = bmi)) ## Plotting outputs age <- seq(25, 80, 5) risk_m <- QDR2013(sex = "Male", age = age, bmi = 40) risk_f <- QDR2013(sex = "Female", age = age, bmi = 40) oldpar <- par(no.readonly = TRUE) par(cex = 0.8, cex.sub = 0.8) plot.new() plot.window(xlim = range(age), ylim = range(pretty(c(risk_m, risk_f)))) axis(1, at = age) axis(2, at = pretty(c(risk_m, risk_f))) title( main = "Diabetes 10-year risk with age:\nQDiabetes-2013", sub = expression("BMI set to"~40*kg/m^2*", other variables set to defaults"), xlab = "Age (years)", ylab = "Risk (%)" ) lines(age, risk_m, type = "b", col = "navy", lwd = 1.5) lines(age, risk_f, type = "b", col = "red3", lwd = 1.5) legend("bottomright", legend = c("Male", "Female"), col = c("navy", "red3"), lty = 1, bty = "n") par(oldpar)
## Simple usage QDR2013(sex = "Female", age = 76, ht = 1.65, wt = 70) QDR2013(sex = "Male", age = seq(25, 80, 5), bmi = 40, ethn = "Other", tds = 5) QDR2013(sex = "Female", age = 65, bmi = 35, smoke = c("Non", "Ex", "Light"), fhdm = TRUE) ## Using postcodes to estimate Townsend deprivation scores QDR2013(sex = "Male", age = 65, bmi = 40, tds = getTDS("OX3 7LF")) QDR2013(sex = "Female", age = 60, bmi = 35, tds = getTDS(c("OX2 6NW", "OX2 6GG"))) ## Data frame usage data(dat_qdr) with(dat_qdr, QDR2013(sex = sex, age = age, bmi = bmi)) ## Plotting outputs age <- seq(25, 80, 5) risk_m <- QDR2013(sex = "Male", age = age, bmi = 40) risk_f <- QDR2013(sex = "Female", age = age, bmi = 40) oldpar <- par(no.readonly = TRUE) par(cex = 0.8, cex.sub = 0.8) plot.new() plot.window(xlim = range(age), ylim = range(pretty(c(risk_m, risk_f)))) axis(1, at = age) axis(2, at = pretty(c(risk_m, risk_f))) title( main = "Diabetes 10-year risk with age:\nQDiabetes-2013", sub = expression("BMI set to"~40*kg/m^2*", other variables set to defaults"), xlab = "Age (years)", ylab = "Risk (%)" ) lines(age, risk_m, type = "b", col = "navy", lwd = 1.5) lines(age, risk_f, type = "b", col = "red3", lwd = 1.5) legend("bottomright", legend = c("Male", "Female"), col = c("navy", "red3"), lty = 1, bty = "n") par(oldpar)
Calculate the 10-year risk of developing type 2 diabetes, using the A-variant of the QDiabetes-2018 algorithm. This variant does not use fasting plasma glucose or glycated haemoglobin A1c.
QDR2018A(sex, age, bmi, ht, wt, ethn = "WhiteNA", smoke = "Non", tds = 0, fhdm = FALSE, htn = FALSE, cvd = FALSE, gdm = FALSE, pcos = FALSE, learn = FALSE, psy = FALSE, ster = FALSE, stat = FALSE, apsy = FALSE)
QDR2018A(sex, age, bmi, ht, wt, ethn = "WhiteNA", smoke = "Non", tds = 0, fhdm = FALSE, htn = FALSE, cvd = FALSE, gdm = FALSE, pcos = FALSE, learn = FALSE, psy = FALSE, ster = FALSE, stat = FALSE, apsy = FALSE)
sex |
Gender. Must be |
age |
Age, in years. Must be |
bmi |
Body-mass index, in kg/m^2. Must be |
ht |
Height, in m. Must be |
wt |
Weight, in kg. Must be |
ethn |
Ethnicity. Must be one of:
|
smoke |
Smoking status. Must be one of:
|
tds |
Townsend deprivation score. Must be |
fhdm |
Family history of diabetes in 1st degree relative. |
htn |
History of hypertension. |
cvd |
History of cardiovascular disease. |
gdm |
History of gestational diabetes. |
pcos |
History of polycystic ovary syndrome. |
learn |
History of one or more conditions conveying learning difficulties. |
psy |
History of schizophrenia or bipolar affective disorder. |
ster |
History of use of corticosteroids. |
stat |
History of use of statins. |
apsy |
History of use of 2nd generation antipsychotics. |
Risk (%) of type 2 diabetes.
The QDiabetes R package has been created as a research tool for scientific purposes only. The QDiabetes R package has not been granted Medicines and Healthcare products Regulatory Agency (MHRA) approval as a medical device, and hence, should not be used as part of any individualised risk assessment.
Benjamin G. Feakins [email protected]
https://qdiabetes.org/2018/src.php
Hippisley-Cox, J. and Coupland, C. (2017). Development and validation of QDiabetes-2018 risk prediction algorithm to estimate future risk of type 2 diabetes: cohort study. BMJ 359, j5019. doi:10.1136/bmj.j5019
QDR2013
- For estimating the 1–10-year risk using QDiabetes-2013.
QDR2018B
- For estimating the 10-year risk using QDiabetes-2018 (Model B).
QDR2018C
- For estimating the 10-year risk using QDiabetes-2018 (Model C).
## Simple usage QDR2018A(sex = "Female", age = 76, ht = 1.65, wt = 70) QDR2018A(sex = "Male", age = seq(25, 80, 5), bmi = 40, ethn = "Other", tds = 5) QDR2018A(sex = "Female", age = 65, bmi = 35, smoke = c("Non", "Ex", "Light"), fhdm = TRUE) ## Using postcodes to estimate Townsend deprivation scores QDR2018A(sex = "Male", age = 65, bmi = 40, tds = getTDS("OX3 7LF")) QDR2018A(sex = "Female", age = 60, bmi = 35, tds = getTDS(c("OX2 6NW", "OX2 6GG"))) ## Data frame usage data(dat_qdr) with(dat_qdr, QDR2018A(sex = sex, age = age, bmi = bmi)) ## Plotting outputs age <- seq(25, 80, 5) risk_m <- QDR2018A(sex = "Male", age = age, bmi = 40) risk_f <- QDR2018A(sex = "Female", age = age, bmi = 40) oldpar <- par(no.readonly = TRUE) par(cex = 0.8, cex.sub = 0.8) plot.new() plot.window(xlim = range(age), ylim = range(pretty(c(risk_m, risk_f)))) axis(1, at = age) axis(2, at = pretty(c(risk_m, risk_f))) title( main = "Diabetes 10-year risk with age:\nQDiabetes-2018 (A-Variant)", sub = expression("BMI set to"~40*kg/m^2*", other variables set to defaults"), xlab = "Age (years)", ylab = "Risk (%)" ) lines(age, risk_m, type = "b", col = "navy", lwd = 1.5) lines(age, risk_f, type = "b", col = "red3", lwd = 1.5) legend("bottomright", legend = c("Male", "Female"), col = c("navy", "red3"), lty = 1, bty = "n") par(oldpar)
## Simple usage QDR2018A(sex = "Female", age = 76, ht = 1.65, wt = 70) QDR2018A(sex = "Male", age = seq(25, 80, 5), bmi = 40, ethn = "Other", tds = 5) QDR2018A(sex = "Female", age = 65, bmi = 35, smoke = c("Non", "Ex", "Light"), fhdm = TRUE) ## Using postcodes to estimate Townsend deprivation scores QDR2018A(sex = "Male", age = 65, bmi = 40, tds = getTDS("OX3 7LF")) QDR2018A(sex = "Female", age = 60, bmi = 35, tds = getTDS(c("OX2 6NW", "OX2 6GG"))) ## Data frame usage data(dat_qdr) with(dat_qdr, QDR2018A(sex = sex, age = age, bmi = bmi)) ## Plotting outputs age <- seq(25, 80, 5) risk_m <- QDR2018A(sex = "Male", age = age, bmi = 40) risk_f <- QDR2018A(sex = "Female", age = age, bmi = 40) oldpar <- par(no.readonly = TRUE) par(cex = 0.8, cex.sub = 0.8) plot.new() plot.window(xlim = range(age), ylim = range(pretty(c(risk_m, risk_f)))) axis(1, at = age) axis(2, at = pretty(c(risk_m, risk_f))) title( main = "Diabetes 10-year risk with age:\nQDiabetes-2018 (A-Variant)", sub = expression("BMI set to"~40*kg/m^2*", other variables set to defaults"), xlab = "Age (years)", ylab = "Risk (%)" ) lines(age, risk_m, type = "b", col = "navy", lwd = 1.5) lines(age, risk_f, type = "b", col = "red3", lwd = 1.5) legend("bottomright", legend = c("Male", "Female"), col = c("navy", "red3"), lty = 1, bty = "n") par(oldpar)
Calculate the 10-year risk of developing type 2 diabetes, using the B-variant of the QDiabetes-2018 algorithm. This variant includes all risk predictors present in the A-variant, with the addition of fasting plasma glucose.
QDR2018B(sex, age, bmi, ht, wt, fpg, ethn = "WhiteNA", smoke = "Non", tds = 0, fhdm = FALSE, htn = FALSE, cvd = FALSE, gdm = FALSE, pcos = FALSE, learn = FALSE, psy = FALSE, ster = FALSE, stat = FALSE, apsy = FALSE)
QDR2018B(sex, age, bmi, ht, wt, fpg, ethn = "WhiteNA", smoke = "Non", tds = 0, fhdm = FALSE, htn = FALSE, cvd = FALSE, gdm = FALSE, pcos = FALSE, learn = FALSE, psy = FALSE, ster = FALSE, stat = FALSE, apsy = FALSE)
sex |
Gender. Must be |
age |
Age, in years. Must be |
bmi |
Body-mass index, in kg/m^2. Must be |
ht |
Height, in m. Must be |
wt |
Weight, in kg. Must be |
fpg |
Fasting plasma glucose level, in mmol/L. Must be |
ethn |
Ethnicity. Must be one of:
|
smoke |
Smoking status. Must be one of:
|
tds |
Townsend deprivation score. Must be |
fhdm |
Family history of diabetes in 1st degree relative. |
htn |
History of hypertension. |
cvd |
History of cardiovascular disease. |
gdm |
History of gestational diabetes. |
pcos |
History of polycystic ovary syndrome. |
learn |
History of one or more conditions conveying learning difficulties. |
psy |
History of schizophrenia or bipolar affective disorder. |
ster |
History of use of corticosteroids. |
stat |
History of use of statins. |
apsy |
History of use of 2nd generation antipsychotics. |
Risk (%) of type 2 diabetes.
The QDiabetes R package has been created as a research tool for scientific purposes only. The QDiabetes R package has not been granted Medicines and Healthcare products Regulatory Agency (MHRA) approval as a medical device, and hence, should not be used as part of any individualised risk assessment.
Benjamin G. Feakins [email protected]
https://qdiabetes.org/2018/src.php
Hippisley-Cox, J. and Coupland, C. (2017). Development and validation of QDiabetes-2018 risk prediction algorithm to estimate future risk of type 2 diabetes: cohort study. BMJ 359, j5019. doi:10.1136/bmj.j5019
QDR2013
- For estimating the 1–10-year risk using QDiabetes-2013.
QDR2018A
- For estimating the 10-year risk using QDiabetes-2018 (Model A).
QDR2018C
- For estimating the 10-year risk using QDiabetes-2018 (Model C).
## Simple usage QDR2018B(sex = "Female", age = 76, ht = 1.65, wt = 70, fpg = 4) QDR2018B(sex = "Male", age = 55, bmi = 40, fpg = 2:6, ethn = "BlackCaribbean") QDR2018B(sex = "Female", age = 65, bmi = 35, fpg = 5, smoke = "Ex", cvd = c(FALSE, TRUE)) ## Using postcodes to estimate Townsend deprivation scores QDR2018B(sex = "Male", age = 65, bmi = 40, fpg = 6, tds = getTDS("OX3 7LF")) QDR2018B(sex = "Female", age = 60, bmi = 35, fpg = 6, tds = getTDS(c("OX2 6NW", "OX2 6GG"))) ## Data frame usage data(dat_qdr) with(dat_qdr, QDR2018B(sex = sex, age = age, bmi = bmi, fpg = fpg)) ## Plotting outputs fpg <- seq(2, 6.5, length.out = 10) risk_m <- QDR2018B(sex = "Male", age = 65, bmi = 40, fpg = fpg) risk_f <- QDR2018B(sex = "Female", age = 65, bmi = 40, fpg = fpg) oldpar <- par(no.readonly = TRUE) par(cex = 0.8, cex.sub = 0.8) plot.new() plot.window(xlim = range(fpg), ylim = range(pretty(c(risk_m, risk_f)))) axis(1, at = fpg) axis(2, at = pretty(c(risk_m, risk_f))) title( main = "Diabetes 10-year risk with fasting plasma glucose level:\nQDiabetes-2018 (B-Variant)", sub = expression("Age set to 65 years, BMI set to"~40*kg/m^2*", other variables set to defaults"), xlab = "Fasting Plasma Glucose (mmol/L)", ylab = "Risk (%)" ) lines(fpg, risk_m, type = "b", col = "navy", lwd = 1.5) lines(fpg, risk_f, type = "b", col = "red3", lwd = 1.5) legend("bottomright", legend = c("Male", "Female"), col = c("navy", "red3"), lty = 1, bty = "n") par(oldpar)
## Simple usage QDR2018B(sex = "Female", age = 76, ht = 1.65, wt = 70, fpg = 4) QDR2018B(sex = "Male", age = 55, bmi = 40, fpg = 2:6, ethn = "BlackCaribbean") QDR2018B(sex = "Female", age = 65, bmi = 35, fpg = 5, smoke = "Ex", cvd = c(FALSE, TRUE)) ## Using postcodes to estimate Townsend deprivation scores QDR2018B(sex = "Male", age = 65, bmi = 40, fpg = 6, tds = getTDS("OX3 7LF")) QDR2018B(sex = "Female", age = 60, bmi = 35, fpg = 6, tds = getTDS(c("OX2 6NW", "OX2 6GG"))) ## Data frame usage data(dat_qdr) with(dat_qdr, QDR2018B(sex = sex, age = age, bmi = bmi, fpg = fpg)) ## Plotting outputs fpg <- seq(2, 6.5, length.out = 10) risk_m <- QDR2018B(sex = "Male", age = 65, bmi = 40, fpg = fpg) risk_f <- QDR2018B(sex = "Female", age = 65, bmi = 40, fpg = fpg) oldpar <- par(no.readonly = TRUE) par(cex = 0.8, cex.sub = 0.8) plot.new() plot.window(xlim = range(fpg), ylim = range(pretty(c(risk_m, risk_f)))) axis(1, at = fpg) axis(2, at = pretty(c(risk_m, risk_f))) title( main = "Diabetes 10-year risk with fasting plasma glucose level:\nQDiabetes-2018 (B-Variant)", sub = expression("Age set to 65 years, BMI set to"~40*kg/m^2*", other variables set to defaults"), xlab = "Fasting Plasma Glucose (mmol/L)", ylab = "Risk (%)" ) lines(fpg, risk_m, type = "b", col = "navy", lwd = 1.5) lines(fpg, risk_f, type = "b", col = "red3", lwd = 1.5) legend("bottomright", legend = c("Male", "Female"), col = c("navy", "red3"), lty = 1, bty = "n") par(oldpar)
Calculate the 10-year risk of developing type 2 diabetes, using the C-variant of the QDiabetes-2018 algorithm. This variant includes all risk predictors present in the A-variant, with the addition of glycated haemoglobin A1c.
QDR2018C(sex, age, bmi, ht, wt, hba1c, ethn = "WhiteNA", smoke = "Non", tds = 0, fhdm = FALSE, htn = FALSE, cvd = FALSE, gdm = FALSE, pcos = FALSE, learn = FALSE, psy = FALSE, ster = FALSE, stat = FALSE, apsy = FALSE)
QDR2018C(sex, age, bmi, ht, wt, hba1c, ethn = "WhiteNA", smoke = "Non", tds = 0, fhdm = FALSE, htn = FALSE, cvd = FALSE, gdm = FALSE, pcos = FALSE, learn = FALSE, psy = FALSE, ster = FALSE, stat = FALSE, apsy = FALSE)
sex |
Gender. Must be |
age |
Age, in years. Must be |
bmi |
Body-mass index, in kg/m^2. Must be |
ht |
Height, in m. Must be |
wt |
Weight, in kg. Must be |
hba1c |
Glycated haemoglobin A1c level, in mmol/mol. Must be |
ethn |
Ethnicity. Must be one of:
|
smoke |
Smoking status. Must be one of:
|
tds |
Townsend deprivation score. Must be |
fhdm |
Family history of diabetes in 1st degree relative. |
htn |
History of hypertension. |
cvd |
History of cardiovascular disease. |
gdm |
History of gestational diabetes. |
pcos |
History of polycystic ovary syndrome. |
learn |
History of one or more conditions conveying learning difficulties. |
psy |
History of schizophrenia or bipolar affective disorder. |
ster |
History of use of corticosteroids. |
stat |
History of use of statins. |
apsy |
History of use of 2nd generation antipsychotics. |
Risk (%) of type 2 diabetes.
The QDiabetes R package has been created as a research tool for scientific purposes only. The QDiabetes R package has not been granted Medicines and Healthcare products Regulatory Agency (MHRA) approval as a medical device, and hence, should not be used as part of any individualised risk assessment.
Benjamin G. Feakins [email protected]
https://qdiabetes.org/2018/src.php
Hippisley-Cox, J. and Coupland, C. (2017). Development and validation of QDiabetes-2018 risk prediction algorithm to estimate future risk of type 2 diabetes: cohort study. BMJ 359, j5019. doi:10.1136/bmj.j5019
QDR2013
- For estimating the 1–10-year risk using QDiabetes-2013.
QDR2018A
- For estimating the 10-year risk using QDiabetes-2018 (Model A).
QDR2018B
- For estimating the 10-year risk using QDiabetes-2018 (Model B).
## Simple usage QDR2018C(sex = "Female", age = 76, ht = 1.65, wt = 70, hba1c = 25) QDR2018C(sex = "Male", age = 55, bmi = 40, hba1c = seq(15, 40, 5), ethn = "Chinese") QDR2018C(sex = "Female", age = 65, bmi = 35, hba1c = 30, smoke = "Ex", fhdm = c(FALSE, TRUE)) ## Using postcodes to estimate Townsend deprivation scores QDR2018C(sex = "Male", age = 65, bmi = 40, hba1c = 42, tds = getTDS("OX3 7LF")) QDR2018C(sex = "Female", age = 60, bmi = 35, hba1c = 42, tds = getTDS(c("OX2 6NW", "OX2 6GG"))) ## Data frame usage data(dat_qdr) with(dat_qdr, QDR2018C(sex = sex, age = age, bmi = bmi, hba1c = hba1c)) ## Plotting outputs hba1c <- seq(15, 42, length.out = 10) risk_m <- QDR2018C(sex = "Male", age = 65, bmi = 40, hba1c = hba1c) risk_f <- QDR2018C(sex = "Female", age = 65, bmi = 40, hba1c = hba1c) oldpar <- par(no.readonly = TRUE) par(cex = 0.8, cex.sub = 0.8) plot.new() plot.window(xlim = range(hba1c), ylim = range(pretty(c(risk_m, risk_f)))) axis(1, at = hba1c) axis(2, at = pretty(c(risk_m, risk_f))) title( main = "Diabetes 10-year risk with glycated haemoglobin level:\nQDiabetes-2018 (C-Variant)", sub = expression("Age set to 65 years, BMI set to"~40*kg/m^2*", other variables set to defaults"), xlab = expression("Haemoglobin"~A[1*c]~"(mmol/mol)"), ylab = "Risk (%)" ) lines(hba1c, risk_m, type = "b", col = "navy", lwd = 1.5) lines(hba1c, risk_f, type = "b", col = "red3", lwd = 1.5) legend("bottomright", legend = c("Male", "Female"), col = c("navy", "red3"), lty = 1, bty = "n") par(oldpar)
## Simple usage QDR2018C(sex = "Female", age = 76, ht = 1.65, wt = 70, hba1c = 25) QDR2018C(sex = "Male", age = 55, bmi = 40, hba1c = seq(15, 40, 5), ethn = "Chinese") QDR2018C(sex = "Female", age = 65, bmi = 35, hba1c = 30, smoke = "Ex", fhdm = c(FALSE, TRUE)) ## Using postcodes to estimate Townsend deprivation scores QDR2018C(sex = "Male", age = 65, bmi = 40, hba1c = 42, tds = getTDS("OX3 7LF")) QDR2018C(sex = "Female", age = 60, bmi = 35, hba1c = 42, tds = getTDS(c("OX2 6NW", "OX2 6GG"))) ## Data frame usage data(dat_qdr) with(dat_qdr, QDR2018C(sex = sex, age = age, bmi = bmi, hba1c = hba1c)) ## Plotting outputs hba1c <- seq(15, 42, length.out = 10) risk_m <- QDR2018C(sex = "Male", age = 65, bmi = 40, hba1c = hba1c) risk_f <- QDR2018C(sex = "Female", age = 65, bmi = 40, hba1c = hba1c) oldpar <- par(no.readonly = TRUE) par(cex = 0.8, cex.sub = 0.8) plot.new() plot.window(xlim = range(hba1c), ylim = range(pretty(c(risk_m, risk_f)))) axis(1, at = hba1c) axis(2, at = pretty(c(risk_m, risk_f))) title( main = "Diabetes 10-year risk with glycated haemoglobin level:\nQDiabetes-2018 (C-Variant)", sub = expression("Age set to 65 years, BMI set to"~40*kg/m^2*", other variables set to defaults"), xlab = expression("Haemoglobin"~A[1*c]~"(mmol/mol)"), ylab = "Risk (%)" ) lines(hba1c, risk_m, type = "b", col = "navy", lwd = 1.5) lines(hba1c, risk_f, type = "b", col = "red3", lwd = 1.5) legend("bottomright", legend = c("Male", "Female"), col = c("navy", "red3"), lty = 1, bty = "n") par(oldpar)