Skip to content

OxfordIHTM/solutions-assessing-agreement-between-two-methods

Repository files navigation

Statistical methods for assessing agreement between two methods of clinical measurement - Solutions

License for code License for text Publish tutorial notes pages-build-deployment DOI

This is a solutions repository for the exercise on Statistical methods for assessing agreement between two methods of clinical measurement in the Open and Reproducible Science in R module of the MSc in International Health and Tropical Medicine.


Instructions for the assignment

The following tasks have been setup to help students get familiar with functional programming in R.

The students are expected to go through the tasks and appropriately write R code/script to fulfill the tasks and/or to answer the question/s being asked within the tasks. R code/script should be written inside a single R file named ba.R and saved in the project’s root directory.

This exercise is based on:

Bland, J. M. & Altman, DouglasG. Statistical Methods For Assessing Agreement Between Two Methods Of Clinical Measurement. Lancet 327, 307–310 (1986).

The dataset used in the paper can be accessed from the teaching_datasets repository. The URL to the .dat file is https://raw.githubusercontent.com/OxfordIHTM/teaching_datasets/main/ba.dat.

The ba dataset contains peak expiratory flow rate (PEFR) measurements (in litres per minute) taken with a Wright peak flow metre (Wright) and a Mini-Wright peak flow metre (Mini-Wright). This is the same data that is presented in the referenced Lancet article above.


Task 1: Read the dataset

Read the ba.dat dataset from the GitHub URL provided above by creating a function that will download the dataset from the given URL and then read that dataset into R.


Task 2: Calculate the metrics needed for a Bland and Altman plot

Create a function that will calculate the following metrics required by the Bland and Altman plot as described in the article referenced above:

  • Mean of the per subject measurements made by the Wright and the Mini-Wright;

  • Difference between the per subject measurements made by the Wright and the Mini-Wright;

  • Mean of the difference between the per subject measurements made by the Wright and the Mini-Wright; and,

  • Lower and upper limits of agreement between the per subject measurements made by the Wright and the Mini-Wright.


Task 3: Create a Bland and Altman plot

Develop a function that creates a Bland and Altman plot as described in the article.


Solutions

A solutions script named functions.R is found in this repository. The script provides various possible solutions for each of the tasks above.

A solutions script named ba.R is found in this repository. The script provides an example R script workflow that utilises the functions created in functions.R to perform the required analysis and plotting.

The solutions can also be viewed as an HTML document that shows the code solutions alongside text that provides step-by-step explanation of what the solution is doing. The HTML document can be read here.


License

All of the written material is made available under the Creative Commons - Attribution - NonCommercial 4.0 International license (CC-BY-NC-4.0), while any code is made available under the GNU General Public License Version 3.0 license (GPL-3.0).

About

Statistical methods for assessing agreement between two methods of clinical measurement - Solutions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages