Title: | Bland-Altman Method Comparison |
Version: | 0.6.0 |
Date: | 2024-06-09 |
Description: | Carries out Bland Altman analyses (also known as a Tukey mean-difference plot) as described by JM Bland and DG Altman in 1986 <doi:10.1016/S0140-6736(86)90837-8>. This package was created in 2015 as existing Bland-Altman analysis functions did not calculate confidence intervals. This package was created to rectify this, and create reproducible plots. This package is also available as a module for the 'jamovi' statistical spreadsheet (see https://www.jamovi.org for more information). |
Depends: | R (≥ 3.2.0) |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
URL: | https://github.com/deepankardatta/blandr/ |
BugReports: | https://github.com/deepankardatta/blandr/issues |
Imports: | glue, ggplot2, knitr, stringr, jmvcore (≥ 0.8.5), markdown, rmarkdown |
Suggests: | testthat |
SystemRequirements: | pandoc (>=1.12.3) |
VignetteBuilder: | knitr |
Collate: | 'blandr.data.preparation.r' 'blandr.dataset.fibre.r' 'blandr.dataset.sbp.r' 'blandr.dataset.o2sats.r' 'blandr.dataset.pefr.r' 'blandr.dataset.load.r' 'blandr.plot.ggplot.r' 'blandr.plot.rplot.r' 'blandr.plot.limits.r' 'blandr.statistics.r' 'blandr.draw.r' 'blandr.output.text.r' 'blandr.display.and.draw.r' 'blandr.display.and.plot.r' 'blandr.method.comparison.r' 'blandr.output.report.r' 'blandr.plot.normality.r' 'blandr.plot.qq.r' 'blandr.plot.r' 'blandr.statistics.formula.R' 'jamovibaanalysis.b.R' 'jamovibaanalysis.h.R' 'jamovibaplothistogram.b.R' 'jamovibaplothistogram.h.R' 'jamovibaplotqq.b.R' 'jamovibaplotqq.h.R' 'jamovibastats.b.R' 'jamovibastats.h.R' 'print.blandr.R' |
RoxygenNote: | 7.3.1 |
Language: | en-GB |
NeedsCompilation: | no |
Packaged: | 2024-06-09 11:49:37 UTC; deepankardatta |
Author: | Deepankar Datta [aut, cre], Jonathon Love [ctb] |
Maintainer: | Deepankar Datta <deepankar.datta@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2024-06-09 20:40:02 UTC |
Sample PEFR comparison data from Bland-Altman (1986)
Description
This is the sample PEFR data set from the 1986 Lancet paper written by Bland and Altman. I do not claim any copyright on the data - this is meant to allow testing of the function. I encourage future package authors to use the .rda file if they so wish.
Usage
data("bland.altman.PEFR.1986")
Format
A data frame with 17 observations on the following 4 variables.
WrightFirst
a numeric vector
WrightSecond
a numeric vector
MiniWrightFirst
a numeric vector
MiniWrightSecond
a numeric vector
References
Bland, J. M., & Altman, D. (1986). Statistical methods for assessing agreement between two methods of clinical measurement. The Lancet, 327(8476), 307-310. PMID:2868172. http://dx.doi.org/10.1016/S0140-6736(86)90837-8
Examples
data(bland.altman.PEFR.1986)
Data preparation for method comparison analysis
Description
Prepares the data and runs error checks before the calling function runs whatever method analysis mode is wants.
Usage
blandr.data.preparation(method1, method2, sig.level)
Arguments
method1 |
A list of numbers. |
method2 |
A list of numbers. |
sig.level |
Significance level. Is not optional in this function, as the calling package should have a default value to pass if needed |
Value
method.comparison A data frame of paired values. These have been data checked, and empty rows omitted, from the originally supplied data.
Author(s)
Deepankar Datta deepankar.datta@gmail.com
Examples
# Generates two random measurements
measurement1 <- rnorm(100)
measurement2 <- rnorm(100)
# Calls the function - do note that this function was really
# meant to be called from other functions and not a stand-alone funtion
blandr.data.preparation( measurement1 , measurement2, sig.level=0.95 )
Function to load D'arbela mean velocity of circumferential fibre shortening dataset from internet
Description
Loads the D'arbela mean velocity of circumferential fibre shortening dataset from Martin Bland's website.
Usage
blandr.dataset.fibre()
Value
converted.from.dct A data frame containing the dataset
Note
The function converts the STATA DCT data format into a data frame that R can process.
Author(s)
Deepankar Datta deepankar.datta@gmail.com
References
https://www-users.york.ac.uk/~mb55/datasets/pefr.dct - The D'arbela mean velocity of circumferential fibre shortening dataset from Martin Bland's website
https://www-users.york.ac.uk/~mb55/datasets/datasets.htm - Martin Bland's example data-set webpage
Bland JM, Altman DG. (1986) Statistical methods for assessing agreement between two methods of clinical measurement. Lancet i, 307-310.
Examples
blandr.dataset.fibre()
pefr.data <- blandr.dataset.fibre()
Function to load example data sets
Description
Loads example data sets from the internet.
Usage
blandr.dataset.load(dataset.name)
Arguments
dataset.name |
Loads the requisite data set. See the description for further details. |
Value
example.dataset A data frame containing the requisite dataset
Note
Dataset 1 ("1","PEFR","pefr") - Bland Altman PEFR dataset (from blandr.dataset.pefr
)
Dataset 2 ("2","o2sats","sealey") - Selaey oxygen saturations dataset (from blandr.dataset.o2sats
)
Dataset 3 ("3","fibre","darbela") - D'arbela mean velocity of circumferential fibre shortening dataset (from blandr.dataset.fibre
)
Dataset 4 ("4","sbp","close") - Close systolic blood pressure dataset (from blandr.dataset.sbp
)
Author(s)
Deepankar Datta deepankar.datta@gmail.com
Examples
blandr.dataset.load( "pefr" )
pefr.data <- blandr.dataset.load( "pefr" )
Function to load Bland-Altman oxygen saturation dataset from internet
Description
Loads the Bland-Altman oxygen saturation dataset from Martin Bland's website.
Usage
blandr.dataset.o2sats()
Value
converted.from.dct A data frame containing the dataset
Note
The function converts the STATA DCT data format into a data frame that R can process.
Author(s)
Deepankar Datta deepankar.datta@gmail.com
References
https://www-users.york.ac.uk/~mb55/datasets/sealey.dct - The oxygen saturation dataset from Martin Bland's website
https://www-users.york.ac.uk/~mb55/datasets/datasets.htm - Martin Bland's example data-set webpage
Bland JM, Altman DG. (1986) Statistical methods for assessing agreement between two methods of clinical measurement. Lancet i, 307-310.
Examples
blandr.dataset.o2sats()
pefr.data <- blandr.dataset.o2sats()
Function to load Bland-Altman PEFR dataset from internet
Description
Loads the Bland-Altman PEFR dataset from Martin Bland's website.
Usage
blandr.dataset.pefr()
Value
converted.from.dct A data frame containing the dataset
Note
The function converts the STATA DCT data format into a data frame that R can process.
Author(s)
Deepankar Datta deepankar.datta@gmail.com
References
https://www-users.york.ac.uk/~mb55/datasets/pefr.dct - The PEFR dataset from Martin Bland's website
https://www-users.york.ac.uk/~mb55/datasets/datasets.htm - Martin Bland's example data-set webpage
Bland JM, Altman DG. (1986) Statistical methods for assessing agreement between two methods of clinical measurement. Lancet i, 307-310.
Examples
blandr.dataset.pefr()
pefr.data <- blandr.dataset.pefr()
Function to load Close systolic blood pressure dataset from internet
Description
Loads the Close systolic blood pressure dataset from Martin Bland's website.
Usage
blandr.dataset.sbp()
Value
converted.from.dct A data frame containing the dataset
Note
The function converts the STATA DCT data format into a data frame that R can process.
Author(s)
Deepankar Datta deepankar.datta@gmail.com
References
https://www-users.york.ac.uk/~mb55/datasets/pefr.dct - The Close systolic blood pressure dataset from Martin Bland's website
https://www-users.york.ac.uk/~mb55/datasets/datasets.htm - Martin Bland's example data-set webpage
Bland JM, Altman DG. (1995) Comparing methods of measurement: why plotting difference against standard method is misleading. Lancet, 346, 1085-7.
Examples
blandr.dataset.sbp()
pefr.data <- blandr.dataset.sbp()
Bland-Altman display and draw for R
Description
Stub function: calls both the display and plots functions (in that order). Uses the same parameters as the plot and display functions to allow easy all-in-one use.
This function may be deprecated in future, as you really can use the functions easily separately.
Usage
blandr.display.and.draw(
method1,
method2,
plotter = "ggplot",
method1name = "Method 1",
method2name = "Method 2",
plotTitle = "Bland-Altman plot for comparison of 2 methods",
sig.level = 0.95,
annotate = FALSE,
ciDisplay = TRUE,
ciShading = FALSE,
normalLow = FALSE,
normalHigh = FALSE,
lowest_y_axis = FALSE,
highest_y_axis = FALSE,
point_size = 0.8
)
Arguments
method1 |
A list of numbers. |
method2 |
A list of numbers. |
plotter |
(Optional- default='ggplot') Selects which graphics engine to use to plot the Bland-Altman charts. 2 options are 'ggplot' or 'rplot'. If unknown parameter sent, will default to 'ggplot' |
method1name |
(Optional) Plotting name for 1st method, default 'Method 1' |
method2name |
(Optional) Plotting name for 2nd method, default 'Method 2' |
plotTitle |
(Optional) Title name, default 'Bland-Altman plot for comparison of 2 methods' |
sig.level |
(Optional) Two-tailed significance level. Expressed from 0 to 1. Defaults to 0.95. |
annotate |
(Optional) TRUE/FALSE switch to provides annotations to plot, default=FALSE |
ciDisplay |
(Optional) TRUE/FALSE switch to plot confidence intervals for bias and limits of agreement, default=TRUE |
ciShading |
(Optional) TRUE/FALSE switch to plot confidence interval shading to plot, default=TRUE |
normalLow |
(Optional) If there is a normal range, entering a continuous variable will plot a vertical line on the plot to indicate its lower boundary |
normalHigh |
(Optional) If there is a normal range, entering a continuous variable will plot a vertical line on the plot to indicate its higher boundary |
lowest_y_axis |
(Optional) Defaults to NULL If given a continuous variable will use this as the lower boundary of the y axis. Useful if need multiple plots with equivalent y-axes. |
highest_y_axis |
(Optional) Defaults to NULL If given a continuous variable will use this as the upper boundary of the y axis. Useful if need multiple plots with equivalent y-axes. |
point_size |
(Optional) Size of marker for each dot. Default is cex=0.8 |
Author(s)
Deepankar Datta deepankar.datta@gmail.com
Examples
# Generates two random measurements
measurement1 <- rnorm(100)
measurement2 <- rnorm(100)
# Generates a plot, with no optional arguments
blandr.display.and.draw( measurement1 , measurement2 )
# Generates a plot, with title
blandr.display.and.draw( measurement1 , measurement2 , plotTitle = 'Bland-Altman example plot' )
(DEPRECATED) Bland-Altman display and plot for R
Description
(DEPRECATED) Re-directs to blandr.display.and.draw
Usage
blandr.display.and.plot(
method1,
method2,
method1name = "Method 1",
method2name = "Method 2",
plotTitle = "Bland-Altman plot for comparison of 2 methods",
sig.level = 0.95,
annotate = FALSE,
ciDisplay = TRUE,
ciShading = FALSE,
normalLow = FALSE,
normalHigh = FALSE,
lowest_y_axis = FALSE,
highest_y_axis = FALSE,
point_size = 0.8
)
Arguments
method1 |
A list of numbers. |
method2 |
A list of numbers. |
method1name |
(Optional) Plotting name for 1st method, default 'Method 1' |
method2name |
(Optional) Plotting name for 2nd method, default 'Method 2' |
plotTitle |
(Optional) Title name, default 'Bland-Altman plot for comparison of 2 methods' |
sig.level |
(Optional) Two-tailed significance level. Expressed from 0 to 1. Defaults to 0.95. |
annotate |
(Optional) TRUE/FALSE switch to provides annotations to plot, default=FALSE |
ciDisplay |
(Optional) TRUE/FALSE switch to plot confidence intervals for bias and limits of agreement, default=TRUE |
ciShading |
(Optional) TRUE/FALSE switch to plot confidence interval shading to plot, default=TRUE |
normalLow |
(Optional) If there is a normal range, entering a continuous variable will plot a vertical line on the plot to indicate its lower boundary |
normalHigh |
(Optional) If there is a normal range, entering a continuous variable will plot a vertical line on the plot to indicate its higher boundary |
lowest_y_axis |
(Optional) Defaults to NULL If given a continuous variable will use this as the lower boundary of the y axis. Useful if need multiple plots with equivalent y-axes. |
highest_y_axis |
(Optional) Defaults to NULL If given a continuous variable will use this as the upper boundary of the y axis. Useful if need multiple plots with equivalent y-axes. |
point_size |
(Optional) Size of marker for each dot. Default is cex=0.8 |
Author(s)
Deepankar Datta deepankar.datta@gmail.com
Bland-Altman drawing function for R
Description
Bland-Altman drawing function. Depends on the blandr.statistics function in the package. Will generate a plot via the standard R plotting functions.
Usage
blandr.draw(
method1,
method2,
method1name = "Method 1",
method2name = "Method 2",
plotTitle = "Bland-Altman plot for comparison of 2 methods",
sig.level = 0.95,
LoA.mode = 1,
annotate = FALSE,
ciDisplay = TRUE,
ciShading = TRUE,
normalLow = FALSE,
normalHigh = FALSE,
lowest_y_axis = FALSE,
highest_y_axis = FALSE,
point_size = 0.8,
overlapping = FALSE,
plotter = "ggplot",
x.plot.mode = "means",
y.plot.mode = "difference",
plotProportionalBias = FALSE,
plotProportionalBias.se = TRUE,
assume.differences.are.normal = TRUE
)
Arguments
method1 |
A vector of numbers corresponding to the results from method 1. |
method2 |
A vector of numbers corresponding to the results from method 2. |
method1name |
(Optional) Plotting name for 1st method, default 'Method 1' |
method2name |
(Optional) Plotting name for 2nd method, default 'Method 2' |
plotTitle |
(Optional) Title name, default 'Bland-Altman plot for comparison of 2 methods' |
sig.level |
(Optional) Two-tailed significance level. Expressed from 0 to 1. Defaults to 0.95. |
LoA.mode |
(Optional) Switch to change how accurately the limits of agreement (LoA) are calculated from the bias and its standard deviation. The default is LoA.mode=1 which calculates LoA with the more accurate 1.96x multiplier. LoA.mode=2 uses the 2x multiplier which was used in the original papers. This should really be kept at default, except to double check calculations in older papers. |
annotate |
(Optional) TRUE/FALSE switch to provides annotations to plot, default=FALSE |
ciDisplay |
(Optional) TRUE/FALSE switch to plot confidence intervals for bias and limits of agreement, default=TRUE |
ciShading |
(Optional) TRUE/FALSE switch to plot confidence interval shading to plot, default=TRUE |
normalLow |
(Optional) If there is a normal range, entering a continuous variable will plot a vertical line on the plot to indicate its lower boundary |
normalHigh |
(Optional) If there is a normal range, entering a continuous variable will plot a vertical line on the plot to indicate its higher boundary |
lowest_y_axis |
(Optional) Defaults to NULL If given a continuous variable will use this as the lower boundary of the y axis. Useful if need multiple plots with equivalent y-axes. |
highest_y_axis |
(Optional) Defaults to NULL If given a continuous variable will use this as the upper boundary of the y axis. Useful if need multiple plots with equivalent y-axes. |
point_size |
(Optional) Size of marker for each dot. Default is cex=0.8 |
overlapping |
(Optional) TRUE/FALSE switch to increase size of plotted point if multiple values using ggplot's geom_count, default=FALSE. Not currently recommend until I can tweak the graphics to make them better |
plotter |
(Optional- default='ggplot') Selects which graphics engine to use to plot the Bland-Altman charts. 2 options are 'ggplot' or 'rplot'. If unknown parameter sent, will default to 'ggplot' |
x.plot.mode |
(Optional) Switch to change x-axis from being plotted by means (="means") or by either 1st method (="method1") or 2nd method (="method2"). Default is "means". Anything other than "means" will switch to default mode. |
y.plot.mode |
(Optional) Switch to change y-axis from being plotted by difference (="difference") or by proportion magnitude of measurements (="proportion"). Default is "difference". Anything other than "proportional" will switch to default mode. |
plotProportionalBias |
(Optional) TRUE/FALSE switch. Plots a proportional bias line. Default is FALSE. |
plotProportionalBias.se |
(Optional) TRUE/FALSE switch. If proportional bias line is drawn, switch to plot standard errors. See stat_smooth for details. Default is TRUE. |
assume.differences.are.normal |
(Optional, not operationally used currently) Assume the difference of means has a normal distribution. Will be used to build further analyses |
Note
Started 2015-11-14
Last update 2015-11-19
Originally designed for LAVAS and CVLA
Author(s)
Deepankar Datta deepankar.datta@gmail.com
Examples
# Generates two random measurements
measurement1 <- rnorm(100)
measurement2 <- rnorm(100)
# Generates a plot, with no optional arguments
blandr.draw( measurement1 , measurement2 )
# Generates a plot, using the in-built R graphics
blandr.draw( measurement1 , measurement2 , plotter = 'rplot' )
# Generates a plot, with title changed
blandr.draw( measurement1 , measurement2 , plotTitle = 'Bland-Altman example plot' )
# Generates a plot, with title changed, and confidence intervals off
blandr.draw( measurement1 , measurement2 , plotTitle = 'Bland-Altman example plot' ,
ciDisplay = FALSE , ciShading = FALSE )
Bland-Altman method comparison
Description
Everyone likes graphs, lines and T-tests. This uses the data provided to generate simple tests whilst trying to explain why they should be treated with caution in method comparison studies. This is hopefully the first step in getting people to use the Bland-Altman functions as I suspect everyone will try to do these tests anyway.
Usage
blandr.method.comparison(method1, method2, sig.level = 0.95)
Arguments
method1 |
A list of numbers. |
method2 |
A list of numbers. |
sig.level |
(Optional) Two-tailed significance level. Expressed from 0 to 1. Defaults to 0.95. |
Author(s)
Deepankar Datta deepankar.datta@gmail.com
References
Based on: (1) Bland, J. M., & Altman, D. (1986). Statistical methods for assessing agreement between two methods of clinical measurement. The Lancet, 327(8476), 307-310. http://dx.doi.org/10.1016/S0140-6736(86)90837-8
Linnet K., Limitations of the paired t-test for evaluation of method comparison data. Clin Chem. 1999 Feb;45(2):314-5. PMID: 9931067
Zaki R, Bulgiba A, Ismail R, Ismail NA. Statistical Methods Used to Test for Agreement of Medical Instruments Measuring Continuous Variables in Method Comparison Studies: A Systematic Review PLoS ONE 2012 7(5): e37908. doi: 10.1371/journal.pone.0037908
Examples
# Generates two random measurements
measurement1 <- rnorm(100)
measurement2 <- rnorm(100)
# Call the function
blandr.method.comparison( measurement1 , measurement2 )
Bland-Altman report generator
Description
Generates a report for the Bland-Altman statistics using rMarkdown and Shiny.
Usage
blandr.output.report(method1, method2)
Arguments
method1 |
A list of numbers for the first method |
method2 |
A list of numbers for the second method |
Note
Use the function to generate a report. You can also take the .Rmd file to customise it and create
your own report. Or use rMarkdown to save the contents. I couldn't add this to the function as it's
not allowed in CRAN. On the other hand a full Shiny app would take too long. So this is a stop-gap way
of creating this function. Hopefully I can improve it in the future
Author(s)
Deepankar Datta deepankar.datta@gmail.com
Examples
# NOT RUN
# Generates two random measurements
# measurement1 <- rnorm(100)
# measurement2 <- rnorm(100)
# blandr.output.report( measurement1 , measurement2 )
#
# Use this to manually run the rmarkdown template
# However specify where the template is
# Also define your methods as method1 and method2 exactly
# For a reason I can't fathom (or how the list of parameters is constructed)
# not naming them method1 and method2 makes them invisible to the rMarkdown document
#
# rmarkdown::run( file = "blandr_report_template.Rmd" ,
# render_args = list( runtime = "shiny" ,
# params = list( method1 = method1 ,
# method2 = method2 ) ) )
# END OF NOT RUN
(DEPRECATED) Bland-Altman summary statistics display function
Description
(DEPRECATED) Displays results of Bland-Altman analysis in a nicer text format. Relies on the blandr.statistics function in the package.
Usage
blandr.output.text(method1, method2, sig.level = 0.95)
Arguments
method1 |
A list of numbers. |
method2 |
A list of numbers. |
sig.level |
(Optional) Two-tailed significance level. Expressed from 0 to 1. Defaults to 0.95. |
Author(s)
Deepankar Datta deepankar.datta@gmail.com
Examples
# Generates two random measurements
measurement1 <- rnorm(100)
measurement2 <- rnorm(100)
# Displays basic statistics for the two measurements in a readable form
blandr.output.text( measurement1 , measurement2 )
(DEPRECATED) Bland-Altman drawing function for R
Description
(DEPRECATED) Re-directs to blandr.draw.r
Usage
blandr.plot(
method1,
method2,
plotter = "ggplot",
method1name = "Method 1",
method2name = "Method 2",
plotTitle = "Bland-Altman plot for comparison of 2 methods",
sig.level = 0.95,
annotate = FALSE,
ciDisplay = TRUE,
ciShading = TRUE,
normalLow = FALSE,
normalHigh = FALSE,
lowest_y_axis = FALSE,
highest_y_axis = FALSE,
point_size = 0.8
)
Arguments
method1 |
A vector of numbers corresponding to the results from method 1. |
method2 |
A vector of numbers corresponding to the results from method 2. |
plotter |
(Optional- default='ggplot') Selects which graphics engine to use to plot the Bland-Altman charts. 2 options are 'ggplot' or 'rplot'. If unknown parameter sent, will default to 'ggplot' |
method1name |
(Optional) Plotting name for 1st method, default 'Method 1' |
method2name |
(Optional) Plotting name for 2nd method, default 'Method 2' |
plotTitle |
(Optional) Title name, default 'Bland-Altman plot for comparison of 2 methods' |
sig.level |
(Optional) Two-tailed significance level. Expressed from 0 to 1. Defaults to 0.95. |
annotate |
(Optional) TRUE/FALSE switch to provides annotations to plot, default=FALSE |
ciDisplay |
(Optional) TRUE/FALSE switch to plot confidence intervals for bias and limits of agreement, default=TRUE |
ciShading |
(Optional) TRUE/FALSE switch to plot confidence interval shading to plot, default=TRUE |
normalLow |
(Optional) If there is a normal range, entering a continuous variable will plot a vertical line on the plot to indicate its lower boundary |
normalHigh |
(Optional) If there is a normal range, entering a continuous variable will plot a vertical line on the plot to indicate its higher boundary |
lowest_y_axis |
(Optional) Defaults to NULL If given a continuous variable will use this as the lower boundary of the y axis. Useful if need multiple plots with equivalent y-axes. |
highest_y_axis |
(Optional) Defaults to NULL If given a continuous variable will use this as the upper boundary of the y axis. Useful if need multiple plots with equivalent y-axes. |
point_size |
(Optional) Size of marker for each dot. Default is cex=0.8 |
Author(s)
Deepankar Datta deepankar.datta@gmail.com
Bland-Altman plotting function, using ggplot2
Description
Draws a Bland-Altman plot using data calculated using the other functions, using ggplot2
Usage
blandr.plot.ggplot(
statistics.results,
method1name = "Method 1",
method2name = "Method 2",
plotTitle = "Bland-Altman plot for comparison of 2 methods",
ciDisplay = TRUE,
ciShading = TRUE,
normalLow = FALSE,
normalHigh = FALSE,
overlapping = FALSE,
x.plot.mode = "means",
y.plot.mode = "difference",
plotProportionalBias = FALSE,
plotProportionalBias.se = TRUE,
assume.differences.are.normal = TRUE
)
Arguments
statistics.results |
A list of statistics generated by the blandr.statistics function: see the function's return list to see what variables are passed to this function |
method1name |
(Optional) Plotting name for 1st method, default "Method 1" |
method2name |
(Optional) Plotting name for 2nd method, default "Method 2" |
plotTitle |
(Optional) Title name, default "Bland-Altman plot for comparison of 2 methods" |
ciDisplay |
(Optional) TRUE/FALSE switch to plot confidence intervals for bias and limits of agreement, default is TRUE |
ciShading |
(Optional) TRUE/FALSE switch to plot confidence interval shading to plot, default is TRUE |
normalLow |
(Optional) If there is a normal range, entering a continuous variable will plot a vertical line on the plot to indicate its lower boundary |
normalHigh |
(Optional) If there is a normal range, entering a continuous variable will plot a vertical line on the plot to indicate its higher boundary |
overlapping |
(Optional) TRUE/FALSE switch to increase size of plotted point if multiple values using ggplot's geom_count, default=FALSE. Not currently recommend until I can tweak the graphics to make them better |
x.plot.mode |
(Optional) Switch to change x-axis from being plotted by means (="means") or by either 1st method (="method1") or 2nd method (="method2"). Default is "means". Anything other than "means" will switch to default mode. |
y.plot.mode |
(Optional) Switch to change y-axis from being plotted by difference (="difference") or by proportion magnitude of measurements (="proportion"). Default is "difference". Anything other than "proportional" will switch to default mode. |
plotProportionalBias |
(Optional) TRUE/FALSE switch. Plots a proportional bias line. Default is FALSE. |
plotProportionalBias.se |
(Optional) TRUE/FALSE switch. If proportional bias line is drawn, switch to plot standard errors. See stat_smooth for details. Default is TRUE. |
assume.differences.are.normal |
(Optional, not operationally used currently) Assume the difference of means has a normal distribution. Will be used to build further analyses |
Value
ba.plot Returns a ggplot data set that can then be plotted
Author(s)
Deepankar Datta deepankar.datta@gmail.com
Examples
# Generates two random measurements
measurement1 <- rnorm(100)
measurement2 <- rnorm(100)
# Generates a ggplot
# Do note the ggplot function wasn't meant to be used on it's own
# and is generally called via the bland.altman.display.and.draw function
# Passes data to the blandr.statistics function to generate Bland-Altman statistics
statistics.results <- blandr.statistics( measurement1 , measurement2 )
# Generates a ggplot, with no optional arguments
blandr.plot.ggplot( statistics.results )
# Generates a ggplot, with title changed
blandr.plot.ggplot( statistics.results , plotTitle = "Bland-Altman example plot" )
# Generates a ggplot, with title changed, and confidence intervals off
blandr.plot.ggplot( statistics.results , plotTitle = "Bland-Altman example plot" ,
ciDisplay = FALSE , ciShading = FALSE )
Bland-Altman plot limits for R
Description
Works out plot limits for the Bland-Altman plots. Depends on the blandr.statistics function in the package.
Usage
blandr.plot.limits(
statistics.results,
lowest_y_axis = FALSE,
highest_y_axis = FALSE
)
Arguments
statistics.results |
A list of statistics generated by the blandr.statistics function: see the function's return list to see what variables are passed to this function |
lowest_y_axis |
(Optional) Defaults to NULL If given a continuous variable will use this as the lower boundary of the y axis. Useful if need multiple plots with equivalent y-axes. |
highest_y_axis |
(Optional) Defaults to NULL If given a continuous variable will use this as the upper boundary of the y axis. Useful if need multiple plots with equivalent y-axes. |
Value
x_upper The upper limit of the X-axis
x_lower The lower limit of the X-axis
y_upper The upper limit of the Y-axis
y_lower The lower limit of the Y-axis
Author(s)
Deepankar Datta deepankar.datta@gmail.com
Examples
# Generates two random measurements
measurement1 <- rnorm(100)
measurement2 <- rnorm(100)
# Passes data to the blandr.statistics function to generate Bland-Altman statistics
statistics.results <- blandr.statistics( measurement1 , measurement2 )
# Calls the function
blandr.plot.limits( statistics.results )
Bland-Altman histogram and density plot
Description
Generates a combined histogram and density curve for Bland-Altman differences
Usage
blandr.plot.normality(statistics.results)
Arguments
statistics.results |
A list of statistics generated by the blandr.statistics function: see the function's return list to see what variables are passed to this function |
Author(s)
Deepankar Datta deepankar.datta@gmail.com
Bland-Altman differences QQ plot
Description
Generates a QQ plot for Bland-Altman differences
Usage
blandr.plot.qq(statistics.results)
Arguments
statistics.results |
A list of statistics generated by the blandr.statistics function: see the function's return list to see what variables are passed to this function |
Author(s)
Deepankar Datta deepankar.datta@gmail.com
Bland-Altman plotting function, using basic R drawing functions
Description
Draws a Bland-Altman plot using data calculated using the other functions, using the in-built R graphics
Usage
blandr.plot.rplot(
statistics.results,
plot.limits,
method1name = "Method 1",
method2name = "Method 2",
plotTitle = "Bland-Altman plot for comparison of 2 methods",
annotate = FALSE,
ciDisplay = TRUE,
ciShading = TRUE,
normalLow = FALSE,
normalHigh = FALSE,
point_size = 0.8
)
Arguments
statistics.results |
A list of statistics generated by the blandr.statistics function: see the function's return list to see what variables are passed to this function |
plot.limits |
A list of statistics generated by the blandr.plot.limits function to define the extent of the x- and y- axes: see the function's return list to see what variables are passed to this function |
method1name |
(Optional) Plotting name for 1st method, default 'Method 1' |
method2name |
(Optional) Plotting name for 2nd method, default 'Method 2' |
plotTitle |
(Optional) Title name, default 'Bland-Altman plot for comparison of 2 methods' |
annotate |
(Optional) TRUE/FALSE switch to provides annotations to plot, default=FALSE |
ciDisplay |
(Optional) TRUE/FALSE switch to plot confidence intervals for bias and limits of agreement, default=TRUE |
ciShading |
(Optional) TRUE/FALSE switch to plot confidence interval shading to plot, default=TRUE |
normalLow |
(Optional) If there is a normal range, entering a continuous variable will plot a vertical line on the plot to indicate its lower boundary |
normalHigh |
(Optional) If there is a normal range, entering a continuous variable will plot a vertical line on the plot to indicate its higher boundary |
point_size |
(Optional) Size of marker for each dot. Default is cex=0.8 |
Author(s)
Deepankar Datta deepankar.datta@gmail.com
Examples
# Generates two random measurements
measurement1 <- rnorm(100)
measurement2 <- rnorm(100)
# Generates a basic plot
# Do note the blandr.plot.rplot function wasn't meant to be used on it's own
# and is generally called via the bland.altman.display.and.draw function
# Passes data to the blandr.statistics function to generate Bland-Altman statistics
statistics.results <- blandr.statistics( measurement1 , measurement2 )
# Passed data to the blandr.plot.limits function to generate plot limits
plot.limits <- blandr.plot.limits( statistics.results )
# Generates a basic plot, with no optional arguments
blandr.plot.rplot( statistics.results , plot.limits )
# Generates a basic plot, with title changed
blandr.plot.rplot( statistics.results , plot.limits , plotTitle = 'Bland-Altman example plot' )
# Generates a basic plot, with title changed, and confidence intervals off
blandr.plot.rplot( statistics.results , plot.limits , plotTitle = 'Bland-Altman example plot' ,
ciDisplay = FALSE , ciShading = FALSE )
Bland-Altman statistics for R
Description
Bland-Altman analysis function for R. Package created as existing
functions don't suit my needs, and don't generate 95\
for bias and limits of agreement. This base function calculates the basic
statistics, and generates return values which can be used in the related
blandr.display
and bland.altamn.plot
functions. However
the return results can be used to generate a custom chart if desired.
Usage
blandr.statistics(method1, method2, sig.level = 0.95, LoA.mode = 1)
Arguments
method1 |
Either a formula, or a vector of numbers corresponding to the results from method 1. |
method2 |
A vector of numbers corresponding to the results from method 2. Only needed if |
sig.level |
(Optional) Two-tailed significance level. Expressed from 0 to 1. Defaults to 0.95. |
LoA.mode |
(Optional) Switch to change how accurately the limits of agreement (LoA) are calculated from the bias and its standard deviation. The default is LoA.mode=1 which calculates LoA with the more accurate 1.96x multiplier. LoA.mode=2 uses the 2x multiplier which was used in the original papers. This should really be kept at default, except to double check calculations in older papers. |
Value
An object of class 'blandr' is returned. This is a list with the following elements:
means |
List of arithmetic mean of the two methods |
differences |
List of differences of the two methods |
method1 |
Returns the 'method1' list in the data frame if further evaluation is needed |
method2 |
Returns the 'method2' list in the data frame if further evaluation is needed |
sig.level |
Significance level supplied to the function |
sig.level.convert.to.z |
Significance level convert to Z value |
bias |
Bias of the two methods |
biasUpperCI |
Upper confidence interval of the bias (based on significance level) |
biasLowerCI |
Lower confidence interval of the bias (based on significance level) |
biasStdDev |
Standard deviation for the bias |
biasSEM |
Standard error for the bias |
LOA_SEM |
Standard error for the limits of agreement |
upperLOA |
Upper limit of agreement |
upperLOA_upperCI |
Upper confidence interval of the upper limit of agreement |
upperLOA_lowerCI |
Lower confidence interval of the upper limit of agreement |
lowerLOA |
Lower limit of agreement |
lowerLOA_upperCI |
Upper confidence interval of the lower limit of agreement |
lowerLOA_lowerCI |
Lower confidence interval of the lower limit of agreement |
proportion |
Differences/means*100 |
no.of.observations |
Number of observations |
regression.equation |
A regression equation to help determine if there is any proportional bias |
regression.fixed.slope |
The slope value of the regression equation |
regression.fixed.intercept |
The intercept value of the regression equation |
Note
The function will give similar answers when used on the original Bland-Altman PEFR data sets. They won't be exactly the same as (a) for 95\
The function depends on paired values.
It currently only can currently work out fixed bias.
Improvements for the future: proportional bias charts will need further work
Started 2015-11-14
Last update 2016-02-04
Originally designed for LAVAS and CVLA
Author(s)
Deepankar Datta deepankar.datta@gmail.com
References
Based on: (1) Bland, J. M., & Altman, D. (1986). Statistical methods for assessing agreement between two methods of clinical measurement. The Lancet, 327(8476), 307-310. http://dx.doi.org/10.1016/S0140-6736(86)90837-8
Confidence interval work based on follow-up paper: (2) Altman, D. G., & Bland, J. M. (2002). Commentary on quantifying agreement between two methods of measurement. Clinical chemistry, 48(5), 801-802. http://www.clinchem.org/content/48/5/801.full.pdf
Examples
# Generates two random measurements
measurement1 <- rnorm(100)
measurement2 <- rnorm(100)
# Generates Bland-Altman statistics data of the two measurements
blandr.statistics( measurement1 , measurement2 )
Bland-Altman statistics for R - submitting data as a formula
Description
If data is supplied as a formula, the function interprets it and then passes it through to the main blandr.statistics function.
Usage
blandr.statistics.formula(formula, data = parent.frame(), ...)
Arguments
formula |
A formula, to be eventually passed to the blandr.statistics function |
data |
A data frame |
... |
other arguments. |
Note
This was initially packaged in the same file as the blandr.statistics function. Changes to R package checks made it easier to separate it out, but functionally it has not changed.
Author(s)
Deepankar Datta deepankar.datta@gmail.com
Examples
# Generates two random measurements
measurement1 <- rnorm(100)
measurement2 <- rnorm(100)
# Generates Bland-Altman statistics data of the two measurements using the formula interface
blandr.statistics.formula( measurement2 ~ measurement1 )
# Example with a real data set
blandr.statistics.formula( Method.B ~ Method.A, data = giavarina.2015 )
Sample comparison data from Giavarina (2015)
Description
This is sample comparison data, taken from Giavarina's 2015 paper on Bland-Altman analysis. The data is from table 1 of the paper. I do not claim any copyright on the data - this is meant to allow testing of the function. I encourage future package authors to use the .rda file if they so wish.
Usage
data("giavarina.2015")
Format
A data frame with 30 observations on the following 5 variables.
Method.A
a numeric vector
Method.B
a numeric vector
Mean
a numeric vector
Difference
a numeric vector
Diff.Mean.Proportion
a factor with levels
References
Giavarina D. Understanding Bland Altman analysis. Biochemia Medica. 2015;25(2):141-151. doi:10.11613/BM.2015.015.
Examples
data(giavarina.2015)
Bland-Altman Analysis
Description
Bland-Altman Analysis
Usage
jamoviBAanalysis(
data,
method1,
method2,
ciDisplay = TRUE,
ciShading = TRUE,
plotProportionalBias = FALSE,
plotProportionalBias.se = TRUE,
overlapping = FALSE
)
Arguments
data |
. |
method1 |
. |
method2 |
. |
ciDisplay |
. |
ciShading |
. |
plotProportionalBias |
. |
plotProportionalBias.se |
. |
overlapping |
. |
Value
A results object containing:
results$table | a table | ||||
results$plot | an image | ||||
Tables can be converted to data frames with asDF
or as.data.frame
. For example:
results$table$asDF
as.data.frame(results$table)
Differences Histogram and Density Curve
Description
Differences Histogram and Density Curve
Usage
jamoviBAplotHistogram(data, method1, method2)
Arguments
data |
. |
method1 |
. |
method2 |
. |
Value
A results object containing:
results$plot | an image | ||||
Differences Q-Q Plot
Description
Differences Q-Q Plot
Usage
jamoviBAplotQQ(data, method1, method2)
Arguments
data |
. |
method1 |
. |
method2 |
. |
Value
A results object containing:
results$plot | an image | ||||
Bland-Altman Raw Statistics
Description
Bland-Altman Raw Statistics
Usage
jamoviBAstats(data, method1, method2)
Arguments
data |
. |
method1 |
. |
method2 |
. |
Value
A results object containing:
results$text | a preformatted | ||||
Print method for blandr
objects
Description
Compactly print the statistics used to construct a Bland-Altman plot
Usage
## S3 method for class 'blandr'
print(x, digits = getOption("digits"), ...)
Arguments
x |
the results from |
digits |
number of significant digits to be used. |
... |
other arguments. |
Author(s)
Deepankar Datta deepankar.datta@gmail.com
Examples
results = blandr.statistics.formula(Method.B ~ Method.A, data = giavarina.2015)
results