This repository contains the code to reproduce the simulation study in
the paper
“Assessing systematic measurement changes in single-wave study data: A
simulation study”.
The study compares seven statistical methods for quantifying systematic changes in a sequence of measurements across different settings:
- Autoregressive integrated moving average (ARIMA)
- Fused lasso signal approximator (FLSA)
- Generalized additive model (GAM)
- Locally weighted scatterplot smoothing (LOWESS)
- Moving average (MA)
- Pruned exact linear time (PELT)
- Piecewise regression (PR)
The simulation results can be interactively explored via an accompanying Shiny application. The source code for the app is available in a separate GitHub repository.
functions/: Contains function definitions for 01_simulation_study.R:- algorithms.R: Statistical methods
- problems.R: Simulation settings
renv/: Contains project-specific environment configuration files.results/: Contains all outputs of the simulation study, including figures, tables, and supplementary data. Raw results are stored in res.rds.01_simulation_study.R: Runs the simulation study using thebatchtoolsR package. Results are saved in res.rds02_visualizations.R: Generates figures and tables for the main manuscript and supplementary_data_1.pdf.03_supplementary_data_2.R: Creates the supplementary Excel file supplementary_data_2.xlsx containing bias and mean squared error for different settings.04_supplementary_data_3.Rmd: R Markdown to create supplementary_data_3.pdf with the output from the Shiny application.renv.lock: Records package versions.
To reproduce the simulation study, run
01_simulation_study.R. This executes the
simulations and saves the results to results/res.rds.
To recreate the figures and tables for the main manuscript and
supplementary_data_1.pdf, run
02_visualizations.R. This saves the figures and
supplementary figures under results/figures and the tables under
results/tables.
To recreate the supplementary files supplementary_data_2.xlsx and supplementary_data_3.pdf, run 03_supplementary_data_2.R and 04_supplementary_data_3.Rmd, respectively.
Note: It is not necessary to run the simulation study to create the figures, tables, or supplementary data, as the results are already stored in
results/res.rds.
This project uses the renv R package to ensure reproducible R
environments. The exact package versions used for the simulation study
are recorded in renv.lock. To restore the environment and
install all required packages:
Clone the repository (or download the ZIP) to save renv.lock locally.
Open the project in R (e.g. in RStudio). Make sure renv.lock is in the project root directory.
Install renv if not already installed.
install.packages("renv")Restore the project library using renv.lock
renv::restore()