Main content

Home

Menu

Loading wiki pages...

View
Wiki Version:
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: 1. `kt`: Preference-temperature (KT) model. 2. `ku0`: Preference-uncertainty (KU) model without any noise parameter. 3. `ku1`: KU model with a self-noise parameter. 4. `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](https://mc-stan.org/docs/reference-manual/reproducibility.html) 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 (*D<sub>KL</sub>*)** 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 *D<sub>KL</sub>* 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.
OSF does not support the use of Internet Explorer. For optimal performance, please switch to another browser.
Accept
This website relies on cookies to help provide a better user experience. By clicking Accept or continuing to use the site, you agree. For more information, see our Privacy Policy and information on cookie use.
Accept
×

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.