Working memory (WM) performance differs between individuals and also fluctuates within individuals as they navigate daily life. However, many analytical approaches overlook these dynamic patterns. In this project, we sought to characterize WM as it naturally varies across everyday contexts by integrating laboratory-based assessments with ambulatory measures of physical activity and momentary cognitive performance. We implemented a hierarchical Bayesian framework that estimated subject‑specific parameters for mean WM level, precision, momentary performance shifts, and an individual-specific cosinor component to model circadian rhythmicity in WM performance. WM scores were modeled using a Beta likelihood to reflect their bounded nature. Time‑stable predictors were specified as influences on mean level and precision, while time‑varying predictors were modeled as moment‑level deviations from each individual’s expected trajectory. This structure allowed us to incorporate age, physical fitness, and laboratory WM performance as stable covariates, and to include daily-life factors such as sleep quality, physical activity, affect, cognitive strain, and perceived stress as potential drivers of momentary fluctuations.
This repository contains the code for data processing, analysis and visualization, written in Julia. It is intended to serve as a non-ambiguous documentation of our approach and as a starting point or reference for future studies in this research area.
Follow the instructions on https://julialang.org/install/ to download and install Julia (if you have not already). Then clone this repository and open it in Julia.
The following Julia package manager commands must be executed from the project directory to install the required packages.
activate .instantiateThis installs all required dependencies.
To run the model, you need a DataFrame df, containing at least :Subject, :WorkingMemoryScore, :TimeInHours, and all columns referenced in a, b, c and z. See, for example, the CSV package for how to read a file into a DataFrame. Then you can simply call the fit_model function with the desired covariates.
fit_model(df, "Example"; ; a = [:Age], b = [], c = [], z = [:PhysicalActivity])Also check out the docstrings in the src folder for more information and the code in scripts/analysis.jl for how to analyze and visualize the result.
Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) – GRK2739/2 – Project Nr. 447089431 – Research Training Group: KD²School – Designing Biosignal-Adaptive Systems for Decision-Making Processes
Funded in part within the Heidelberg Karlsruhe Strategic Partnership – HEiKA by the Federal Ministry of Education and Research (BMBF) and the Baden-Württemberg Ministry of Science as part of the Excellence Strategy of the German Federal and State Governments