Skip to content

zhilinsu/social-influence_ageing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

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 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.


License

This license (CC BY-NC 4.0) gives you the right to re-use and adapt, as long as you note any changes you made, and provide a link to the original source. Read here for more details.

Releases

No releases published

Packages

No packages published