Title: | Error Grid Analysis |
---|---|
Description: | Functions for assigning Clarke or Parkes (Consensus) error grid zones to blood glucose values, and for plotting both types of error grids in both mg/mL and mmol/L units. |
Authors: | Daniel Schmolze [aut, cre], Sergei Mihhailov [ctb] |
Maintainer: | Daniel Schmolze <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.0.0 |
Built: | 2024-12-21 06:39:23 UTC |
Source: | CRAN |
Clarke and Parkes (Consensus) error grid analysis
referenceVals
and testVals
are assumed to contain
paired glucose values from a reference method and a test method,
respectively. unit
contains info on the unit of measurement. Two
options exist: "gram"
for mg/dL and "mol"
for mmol/l
with "gram"
applied by default. The discrepancy between the two values
is used to place the pair into a Clarke error grid zone according to the
criteria described in the original paper by Clarke et. al. (see reference below).
getClarkeZones(referenceVals, testVals, unit = "gram")
getClarkeZones(referenceVals, testVals, unit = "gram")
referenceVals |
A vector of glucose values obtained via the reference method. |
testVals |
A vector of glucose values obtained via a non-reference
method (e.g. a new meter). The values in this vector are paired with those
in |
unit |
A string specifying the units of measurement. This should be either
|
A character vector is returned, with each element being one of
"A"
, "B"
, "C"
, "D"
, or "E"
.
Clarke, W. L., D. Cox, L. A. Gonder-Frederick, W. Carter, and S. L. Pohl. "Evaluating Clinical Accuracy of Systems for Self-Monitoring of Blood Glucose." Diabetes Care 10, no. 5 (September 1, 1987): 622-28.
zones <- getClarkeZones (glucose_data$ref / 18, glucose_data$test / 18, unit="mol") # counts table(zones) # percentages round (table (zones) / length (zones) * 100, digits=2)
zones <- getClarkeZones (glucose_data$ref / 18, glucose_data$test / 18, unit="mol") # counts table(zones) # percentages round (table (zones) / length (zones) * 100, digits=2)
referenceVals
and testVals
are assumed to contain
paired glucose values from a reference method and a test method,
respectively. The discrepancy between the two values, as well as the
type of error grid desired (Type 1 or Type 2 diabetes), is used to place the
pair into a Parkes (Consensus) error grid zone, according to the
criteria described in the second reference below. unit
contains info
on the unit of measurement. Two options exist: "gram"
for mg/dL and
"mol"
for mmol/l with "gram"
applied by default.
getParkesZones(referenceVals, testVals, type = 1, unit = "gram")
getParkesZones(referenceVals, testVals, type = 1, unit = "gram")
referenceVals |
A vector of glucose values obtained via the reference method. |
testVals |
A vector of glucose values obtained via a non-reference
method (e.g. a new meter). The values in this vector are paired with those
in |
type |
An integer (1 or 2) specifying whether to obtain zones for Type 1 or Type 2 diabetes. Defaults to 1. |
unit |
A string specifying the units of measurement. This should be either
|
A character vector is returned, with each element being one of
"A"
, "B"
, "C"
, "D"
, or "E"
.
Parkes, J. L., S. L. Slatin, S. Pardo, and B.H. Ginsberg. "A New Consensus Error Grid to Evaluate the Clinical Significance of Inaccuracies in the Measurement of Blood Glucose." Diabetes Care 23, no. 8 (August 2000): 1143-48
Pfutzner, Andreas, David C. Klonoff, Scott Pardo, and Joan L. Parkes. "Technical Aspects of the Parkes Error Grid." Journal of Diabetes Science and Technology 7, no. 5 (September 2013): 1275-81
zones <- getParkesZones(glucose_data$ref, glucose_data$test) # counts table(zones) # percentages round (table (zones) / length (zones) * 100, digits=2)
zones <- getParkesZones(glucose_data$ref, glucose_data$test) # counts table(zones) # percentages round (table (zones) / length (zones) * 100, digits=2)
A dataset containing 5072 paired reference method and test method glucose values (in mg/dL).
glucose_data
glucose_data
A data frame with 5072 rows and 2 variables:
Reference method glucose value, in mg/dL
Test method glucose value, in mg/dL
The data is from a modified clinical dataset.
The function uses ggplot
to draw the
Clarke error grid lines according to the criteria described in the
original publication by Clarke et. al. (see reference below). If zones
have not already been assigned via the zones
parameter, the
function getClarkeZones
is called first. The values in
referenceVals
and testVals
are then superimposed as a scatter
plot. Some basic plot parameters can be specified as arguments, but the
return value can also be stored and modified further before plotting
(see examples and vignette).
plotClarkeGrid(referenceVals, testVals, title = "Clarke Error Grid", xlab = "", ylab = "", linesize = 0.5, linetype = "solid", linecolor = "black", linealpha = 0.6, pointsize = 2, pointalpha = 1, zones = NA, unit = "gram")
plotClarkeGrid(referenceVals, testVals, title = "Clarke Error Grid", xlab = "", ylab = "", linesize = 0.5, linetype = "solid", linecolor = "black", linealpha = 0.6, pointsize = 2, pointalpha = 1, zones = NA, unit = "gram")
referenceVals |
A vector of glucose values obtained via the reference method. |
testVals |
A vector of glucose values obtained via a non-reference
method (e.g. a new meter). The values in this vector are paired with those
in |
title |
The main plot title. Defaults to "Clarke Error Grid". |
xlab |
The x-axis label. Defaults to "Reference Glucose Concentration (mg/dL)". |
ylab |
The y-axis label. Defaults to "Test Glucose Concentration (mg/dL)". |
linesize |
The size to be used when drawing the zone lines. The
acceptable values are the same as for |
linetype |
The type of line to be used when drawing the zone lines. The
acceptable values are the same as for |
linecolor |
The color of the zone lines. The acceptable values are the
same as for |
linealpha |
The alpha (transparency) level to be used when drawing
the zone lines. The acceptable values are the same as for
|
pointsize |
The size to be used when plotting the glucose data points.
The acceptable values are the same as for |
pointalpha |
The alpha (transparency) level to be used when plotting
the glucose data points. The acceptable values are the same as for
|
zones |
An optional character vector specifying the Clarke zones
for each paired value. If this is not supplied, |
unit |
A string specifying the units of measurement. This should be either
|
A ggplot
object is returned. If the return
value is not assigned, a plot is drawn.
Clarke, W. L., D. Cox, L. A. Gonder-Frederick, W. Carter, and S. L. Pohl. "Evaluating Clinical Accuracy of Systems for Self-Monitoring of Blood Glucose." Diabetes Care 10, no. 5 (September 1, 1987): 622-28.
library(ggplot2) # default plotClarkeGrid(glucose_data$ref, glucose_data$test) # with options plotClarkeGrid(glucose_data$ref, glucose_data$test, pointsize=1.5, pointalpha=0.6, linetype="dashed") # store return value and modify ceg <- plotClarkeGrid(glucose_data$ref, glucose_data$test) ceg + theme_gray() + theme(plot.title = element_text(size = rel(2), colour = "blue"))
library(ggplot2) # default plotClarkeGrid(glucose_data$ref, glucose_data$test) # with options plotClarkeGrid(glucose_data$ref, glucose_data$test, pointsize=1.5, pointalpha=0.6, linetype="dashed") # store return value and modify ceg <- plotClarkeGrid(glucose_data$ref, glucose_data$test) ceg + theme_gray() + theme(plot.title = element_text(size = rel(2), colour = "blue"))
The function uses ggplot
to draw the
Parkes (consensus) error grid lines according to the criteria described in
the publications listed in the References section (see below). If zones
have not already been assigned via the zones
parameter, the
function getParkesZones
is called first. The values in
referenceVals
and testVals
are then superimposed as a scatter
plot. Some basic plot parameters can be specified as arguments, but the
return value can also be stored and modified further before plotting
(see examples and vignette).
plotParkesGrid(referenceVals, testVals, type = 1, title = "", xlab = "", ylab = "", linesize = 0.5, linetype = "solid", linecolor = "black", linealpha = 0.6, pointsize = 2, pointalpha = 1, zones = NA, unit = "gram")
plotParkesGrid(referenceVals, testVals, type = 1, title = "", xlab = "", ylab = "", linesize = 0.5, linetype = "solid", linecolor = "black", linealpha = 0.6, pointsize = 2, pointalpha = 1, zones = NA, unit = "gram")
referenceVals |
A vector of glucose values obtained via the reference method. |
testVals |
A vector of glucose values obtained via a non-reference
method (e.g. a new meter). The values in this vector are paired with those
in |
type |
An integer (1 or 2) specifying whether to plot the grid for Type 1 or Type 2 diabetes. Defaults to 1. |
title |
The main plot title. Defaults to "Parkes (Consensus) Error Grid for Type [type] Diabetes". |
xlab |
The x-axis label. Defaults to "Reference Glucose Concentration (mg/dL)". |
ylab |
The y-axis label. Defaults to "Test Glucose Concentration (mg/dL)". |
linesize |
The size to be used when drawing the zone lines. The
acceptable values are the same as for |
linetype |
The type of line to be used when drawing the zone lines. The
acceptable values are the same as for |
linecolor |
The color of the zone lines. The acceptable values are the
same as for |
linealpha |
The alpha (transparency) level to be used when drawing
the zone lines. The acceptable values are the same as for
|
pointsize |
The size to be used when plotting the glucose data points.
The acceptable values are the same as for |
pointalpha |
The alpha (transparency) level to be used when plotting
the glucose data points. The acceptable values are the same as for
|
zones |
An optional character vector specifying the Clarke zones
for each paired value. If this is not supplied, |
unit |
A string specifying the units of measurement. This should be either
|
A ggplot
object is returned. If the return
value is not assigned, a plot is drawn.
Parkes, J. L., S. L. Slatin, S. Pardo, and B.H. Ginsberg. "A New Consensus Error Grid to Evaluate the Clinical Significance of Inaccuracies in the Measurement of Blood Glucose." Diabetes Care 23, no. 8 (August 2000): 1143-48
Pfutzner, Andreas, David C. Klonoff, Scott Pardo, and Joan L. Parkes. "Technical Aspects of the Parkes Error Grid." Journal of Diabetes Science and Technology 7, no. 5 (September 2013): 1275-81
library(ggplot2) # default plotParkesGrid(glucose_data$ref, glucose_data$test) # with options plotParkesGrid(glucose_data$ref, glucose_data$test, pointsize=2, pointalpha=0.5, linesize=2, linealpha=0.3, linetype="dotdash") # store return value and modify peg <- plotParkesGrid(glucose_data$ref, glucose_data$test, type=2) peg + theme_gray() + theme(plot.title = element_text(size = rel(2), colour = "red"))
library(ggplot2) # default plotParkesGrid(glucose_data$ref, glucose_data$test) # with options plotParkesGrid(glucose_data$ref, glucose_data$test, pointsize=2, pointalpha=0.5, linesize=2, linealpha=0.3, linetype="dotdash") # store return value and modify peg <- plotParkesGrid(glucose_data$ref, glucose_data$test, type=2) peg + theme_gray() + theme(plot.title = element_text(size = rel(2), colour = "red"))