Main content
Home
Menu
Code and data for the delegated inter-temporal choice task, accompanying the manuscript:
Zhilin Su*, Mona M. Garvert, Lei Zhang, Sanjay Manohar, Todd A. Vogel, Louisa Thomas, Joshua H. Balsters, Masud Husain, Matthew A. J. Apps, & Patricia L. Lockwood*. (2024). Older adults are relatively more susceptible to impulsive social influence than young adults. Communications Psychology. https://doi.org/10.1038/s44271-024-00134-0
This repository contains:
root
├─ data # behavioural data and plots
├─ plots
├─ stanfit # stanfit objects
├─ scripts # R and Stan code to run the analyses and produce figures
├─ helper_functions
├─ stan_model
Note: To properly run all the scripts, you may need to set the root of this repository as your working directory in R.
Installation
All behavioural analyses were performed using R (v4.2.1) in RStudio (v2023.06.2). Installation guides can be found at https://posit.co/download/rstudio-desktop/.
Model fitting and comparison were performed using Stan (v2.32) and the RStan (v2.21.7) package in RStudio. Installation guides can be found at https://mc-stan.org/users/interfaces/.
All these installations should only take a few minutes to complete.
Preparation
0 - Data
Data for the social discounting task collected through MATLAB have been extracted and aggregated according to age groups into sd_ya_preference-uncertainty.mat
& sd_ya_k-values.mat
(for young adults), sd_oa_preference-uncertainty.mat
& sd_oa_k-values.mat
(for older adults), and data-variable-names.mat
& k-variable-names.mat
(meanings of each column).
Other self-reported data were stored in questionnaires.csv
.
1 - Data conversion
Run the script reshape_data.R
to convert MATLAB arrays from .mat
files into R 3D arrays, for the subsequent analyses and modelling using R and Stan.
The output file should be sd_data.RData
.
Model fitting
1 - Bayesian modelling with Stan
Run the R scripts run_*1_model_*2.R
to call the corresponding Stan scripts to perform Bayesian modelling.
*1: four candidate models:
kt
: Preference-temperature (KT) model.ku0
: Preference-uncertainty (KU) model without any noise parameter.ku1
: KU model with a self-noise parameter.ku2
: KU model with an other-noise parameter.
*2: self
/other
blocks.
The output files would be the stanfit
objects stored in the .rds
format.
Depending on the efficiency of the hardware, running the models may take anywhere from minutes to hours.
Note: see the following documentation for characteristics of Bayesian modelling that may depend on specific hardware and software used to run the code.
2 - Model comparison
Run the R script model-fitting.R
to compare the model performances using the Leave-One-Out information criterion (LOO-IC) score. It also generates the corresponding plot (Figure 1C).
3 - Parameter recovery
Run the R script parameter_recovery.R
to perform the process of parameter recovery for the winning model (i.e., KU model #0). It also generates the corresponding plot (Figure 1D).
4 - Posterior predictive checks
Run the R script posterior_predictive_checks.R
to perform posterior predictive checks for the winning model (i.e., KU model #0). It also generates the corresponding plot (Figure S1).
Behavioural analyses
1 - Signed Kullback–Leibler divergence (DKL)
Run the R script kl_divergence.R
to calculates the signed KL divergence by utilising posterior samples generated by the winning model.
The output files would be ku0_kld_ya.RData
and ku0_kld_oa.RData
.
Note: To calculate the signed DKL for different age groups, you may need to change the value of pop
in the script.
2 - Behavioural analyses
Run the R script analysis.R
to generate plots and conduct all the behavioural analyses included in the manuscript. The code is well-documented and should be self-explanatory.
Several linear mixed-effects models and simulation-based analyses are being used, which may extend the time needed to complete the analyses.
Page permissions have changed
Your browser should refresh shortly…
Renaming wiki...
Wiki page deleted
Press Confirm to return to the project wiki home page.
Connected to the collaborative wiki
This page is currently connected to the collaborative wiki. All edits made will be visible to contributors with write permission in real time. Changes will be stored but not published until you click the "Save" button.
Connecting to the collaborative wiki
This page is currently attempting to connect to the collaborative wiki. You may continue to make edits. Changes will not be saved until you press the "Save" button.
Collaborative wiki is unavailable
The collaborative wiki is currently unavailable. You may continue to make edits. Changes will not be saved until you press the "Save" button.
Browser unsupported
Your browser does not support collaborative editing. You may continue to make edits. Changes will not be saved until you press the "Save" button.

Start managing your projects on the OSF today.
Free and easy to use, the Open Science Framework supports the entire research lifecycle: planning, execution, reporting, archiving, and discovery.
Copyright © 2011-2025
Center for Open Science
|
Terms of Use
|
Privacy Policy
|
Status
|
API
TOP Guidelines
|
Reproducibility Project: Psychology
|
Reproducibility Project: Cancer Biology