Deciding to simulate: Cognitive mechanisms of predicting the decisions of others.
3 blocks of code here have a permanent identifier (oscr:b:…), listed with the matches below: citable for good, with a page of its own. Select a match and press Cite to copy it. What a block identifier is.
The 4 matches
- [1] § STAR★Methods › Quantification and statistical analysis › Computational modeling ↔ Modelling code + output/EUDM_heurtest.Rmd, lines 14 to 71 · score 0.58 · probability matching, drift rate, Diffusion, DDM, heur, threshold · block
oscr:b:2F9NAS6N2C3A3-6· Report a mismatch - [2] § STAR★Methods › Quantification and statistical analysis › Computational modeling ↔ Modelling code + output/parameter_recovery.Rmd, lines 53 to 156 · score 0.56 · highest negative log, likelihood, simulated, fitting, posterior, RT · block
oscr:b:BN6294WNSMDAS-G· Report a mismatch - [3] § Results › Modeling results ↔ Modelling code + output/EUDM_heurtest.Rmd, lines 14 to 71 · score 0.54 · probability matching, drift rate, DDM, accumulation, heur, simulated · block
oscr:b:2F9NAS6N2C3A3-6· Report a mismatch - [4] § STAR★Methods › Quantification and statistical analysis › Computational modeling ↔ Modelling code + output/posterior_predictive_check.Rmd, lines 56 to 118 · score 0.50 · posterior predictive check, iteration, simulated, RT, risky, probability · block
oscr:b:K357V16CV3R4A-E· Report a mismatch
Paper
Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
R Markdown · 505 lines · 20 KB · no license · 2 matches
- ```{r}
- library(readxl)
- library(tidyverse)
- library(ggplot2)
- library(rstan)
- library(DescTools)
- library(bayestestR)
- library(ggdist)
- options(mc.cores = parallel::detectCores())
- rstan_options(auto_write = TRUE)
- ```
- ```{r}
- #set up a function to simulate data using a basic DDM (i.e., one that ignores trial-to-trial information)
- gen_trial_heurDM <- function(options, drift_rate, threshold, ndt, rel_sp, noise_constant=1, dt=0.001, max_rt=10) {
- n_trials <- length(options$magnitude)
- acc <- rep(NA, n_trials)
- rt <- rep(NA, n_trials)
- max_tsteps <- max_rt/dt
- if (length(drift_rate)==1){
- drift_rate = rep(drift_rate,n_trials)
- }
- # initialize the diffusion process
- tstep <- 0
- x <- rep(rel_sp*threshold, n_trials) # vector of accumulated evidence at t=tstep
- ongoing <- rep(TRUE, n_trials) # have the accumulators reached the bound?
- # start accumulating
- while (sum(ongoing) > 0 & tstep < max_tsteps) {
- x[ongoing] <- x[ongoing] + rnorm(mean=drift_rate[ongoing]*dt,
- sd=noise_constant*sqrt(dt),
- n=sum(ongoing))
- tstep <- tstep + 1
- # ended trials
- ended_correct <- (x >= threshold)
- ended_incorrect <- (x <= 0)
- # store results and filter out ended trials
- if(sum(ended_correct) > 0) {
- acc[ended_correct & ongoing] <- 1
- rt[ended_correct & ongoing] <- dt*tstep + ndt
- ongoing[ended_correct] <- FALSE
- }
- if(sum(ended_incorrect) > 0) {
- acc[ended_incorrect & ongoing] <- 0
- rt[ended_incorrect & ongoing] <- dt*tstep + ndt
- ongoing[ended_incorrect] <- FALSE
- }
- }
- return (data.frame(trial=seq(1, n_trials), accuracy=acc, rt=rt, RM=options$magnitude, RP=options$probability, SM=options$safe_magnitude,drift_rate=drift_rate,threshold=threshold,ndt=ndt,starting_point=rel_sp))
- }
- #simulate data for X participant, with a constant drift rate (corresponding to a probability matching-like response strategy)
- options <- read_excel("K:/options_MP.xlsx")
- drifts <- c(-0.6,-0.2,0.2,0.6)
- npart <- 200
- for(d in drifts){
- for (i in 1:npart){
- sim_part_data <- gen_trial_heurDM(options, drift_rate=d, threshold=2.25, ndt=0.65, rel_sp=0.5)
- sim_part_data$participant = i
- sim_part_data$minRT <- min(sim_part_data$rt)
- #print(c(mean(sim_part_data$accuracy),mean(sim_part_data$rt[sim_part_data$accuracy==1]),mean(sim_part_data$rt[sim_part_data$accuracy==0])))
- assign(paste('sim_part_data',i, sep=''),sim_part_data)
- }
- rm(sim_part_data)
- df_list <- mget(ls(pattern = "^sim_part_data"))
- assign(paste('df_list_drift',d,sep=''),df_list)
- rm(df_list)
- }
- df_list <- mget(ls(pattern = "^df_list"))
- ```
- ```{r}
- all_rhats_below_1.1 <- function(fit_object) {
- all(summary(fit_object)$summary[,"Rhat"] < 1.1, na.rm = TRUE)
- }
- fit_and_save_model <- function(stan_file, data_for_stan, fit_obj_name, save_path, chains=4, iter=2000, warmup=750) {
- fit <- stan(file=stan_file, data=data_for_stan, chains=chains, iter=iter, warmup=warmup)
- assign(fit_obj_name, fit, envir = .GlobalEnv)
- save(list=fit_obj_name, file=save_path)
- return(fit)
- }
- # ---------- Model Specifications ----------
- model_specs <- list(
- EU = list(suffix="_EU", stan_file="K:/Erik/noncentered_EUDM_decor.stan"),
- heur = list(suffix="_heur", stan_file="K:/Erik/noncentered_heurDM.stan")
- )
- for (i in 1:length(seq_along(df_list))) {
- sim_data <- bind_rows(df_list[[i]])
- sim_data = filter(sim_data,!is.na(accuracy)==TRUE & rt>0.2)
- sim_data$accuracy_recoded = sim_data$accuracy
- sim_data[sim_data$accuracy==0, "accuracy_recoded"] = -1
- sim_data <- sim_data %>%
- group_by(participant) %>%
- mutate(participant = cur_group_id())
- minRT <- summarize(sim_data,minRT=min(rt))
- sim_data_for_stan = list(
- N = dim(sim_data)[1],
- L = length(unique(sim_data$participant)),
- accuracy = sim_data$accuracy_recoded,
- rt = sim_data$rt,
- RM = sim_data$RM,
- SM = sim_data$SM,
- RP = sim_data$RP/100,
- participant = sim_data$participant,
- minRT = minRT$minRT
- )
- fit_base_name <- paste0("fit_",substr(names(df_list)[i], 9, nchar(names(df_list)[i])))
- for (modspec in model_specs) {
- suffix <- modspec$suffix
- stan_file <- modspec$stan_file
- fit_obj_name <- paste0(fit_base_name, suffix)
- save_path <- paste0("K:/Erik/heurtest/", fit_obj_name, ".RData")
- attempt <- 1
- repeat {
- if (file.exists(save_path)) {
- load(save_path) # loads fit_obj_name variable into environment
- fit_object <- get(fit_obj_name)
- if (all_rhats_below_1.1(fit_object)) {
- message(sprintf("Rhat < 1.1 for %s, skipping fit.", fit_obj_name))
- rm(list=fit_obj_name, envir=.GlobalEnv)
- gc()
- break
- } else {
- message(sprintf("Rhat >= 1.1 for %s, refitting (attempt %d)...", fit_obj_name, attempt))
- }
- } else {
- message(sprintf("No RData for %s, fitting...", fit_obj_name))
- }
- # Fit and save
- fit_object <- fit_and_save_model(stan_file, sim_data_for_stan, fit_obj_name, save_path)
- if (all_rhats_below_1.1(fit_object)) {
- rm(list=fit_obj_name, envir=.GlobalEnv)
- gc()
- break
- } else {
- rm(list=fit_obj_name, envir=.GlobalEnv)
- gc()
- attempt <- attempt + 1
- # Optional: set a limit to avoid infinite loops
- # if(attempt > 10) stop(sprintf("Failed to fit %s after 10 attempts.", fit_obj_name))
- }
- }
- }
- }
- pars = c("mu_threshold","mu_ndt","mu_starting_point","mu_drift_scaling","mu_gamma","mu_alpha","sd_threshold","sd_ndt","sd_starting_point","sd_drift_scaling","sd_gamma","sd_alpha","z_drift_scaling[1]","z_threshold[1]","z_ndt[1]","z_starting_point[1]","z_gamma[1]","z_alpha[1]")
- ```
- ```{r}
- #perform LOO comparison to see which model wins
- library(loo)
- path <- "K:/Erik/heurtest/"
- files <- list.files(path = path, pattern = "^fit_drift", full.names = TRUE)
- #Parse drift value and model name from filenames
- extract_info <- function(filename) {
- fname <- basename(filename)
- m <- regexec("fit_drift(-?)([0-9.]+)_([A-Za-z]+)\\.RData", fname)
- parts <- regmatches(fname, m)[[1]]
- drift_val <- as.numeric(paste0(parts[2], parts[3]))
- list(
- drift = drift_val,
- model = parts[4],
- file = filename,
- fitname = gsub("\\.RData$", "", fname)
- )
- }
- info_list <- lapply(files, extract_info)
- info_df <- do.call(rbind, lapply(info_list, as.data.frame))
- rownames(info_df) <- NULL
- unique_drifts <- unique(info_df$drift)
- for (dr in unique_drifts) {
- sub <- info_df[info_df$drift == dr, ]
- if (!all(c("heur", "EU") %in% sub$model)) next
- sub <- sub[match(c("heur", "EU"), sub$model), ]
- loo_results <- list()
- names_models <- as.character(sub$model)
- for (i in 1:2) {
- load(sub$file[i]) # Object(s) loaded into the workspace
- fit <- get(as.character(sub$fitname[i]))
- ll <- extract_log_lik(fit)
- loo_results[[names_models[i]]] <- loo(ll)
- rm(list = as.character(sub$fitname[i]))
- }
- loo_compare <- loo_compare(loo_results$heur, loo_results$EU)
- drift_str <- if (dr < 0) paste0("neg", abs(dr)) else as.character(dr)
- assign(paste0("result_loo_", drift_str), list(
- drift = dr,
- loo_results = loo_results,
- loo_compare = loo_compare
- ))
- }
- # Clean workspace except loo results and needed variables
- all_objects <- ls()
- keep <- c("files", grep("^result_loo_", all_objects, value = TRUE))
- rm(list = setdiff(all_objects, keep))
- gc()
- save.image("K:/Erik/heurtest/loo_comparison_heur.RData")
- ```
- ```{r}
- #print out LOO values
- load(paste0("K:/Erik/heurtest/loo_comparison_heur.RData"))
- loo_objects <- ls(pattern = "^result_loo_")
- # Iterate over each object name, retrieve the object, and print the entire content
- for (obj_name in loo_objects) {
- cat("\nObject Name:", obj_name, "\n")
- # Retrieve the object
- loo_object <- get(obj_name)
- # Check if the object has a suitable method to be coerced into a data frame
- if (is.list(loo_object)) {
- print(loo_object$loo_compare)
- } else {
- # Fallback plan to just print if nothing else
- print(loo_object)
- }
- }
- ```
- ```{r}
- #extract the posteriors from the EUDM for the different conditions
- path = "K:/Erik/heurtest/"
- pars = c("mu_threshold","mu_ndt","mu_starting_point","mu_drift_scaling","mu_alpha","sd_threshold","sd_ndt","sd_starting_point","sd_drift_scaling","sd_alpha","z_threshold","z_ndt","z_starting_point","z_drift_scaling","z_alpha","threshold_sbj","ndt_sbj","starting_point_sbj","drift_scaling_sbj","alpha_sbj","threshold_gl","ndt_gl","starting_point_gl","drift_scaling_gl","alpha_gl","log_lik")
- files <- list.files(path = path, pattern = "_EU", full.names = TRUE)
- for (ind in 1:length(files)){
- load(files[ind])
- name <- substr(files[ind], 18, nchar(files[ind])-6)
- post <- extract(get(name),pars=pars)
- assign(paste0("post_",substr(files[ind], 27, nchar(files[ind])-9)),post)
- all_objects <- ls()
- keep <- c("files","pars",grep("^post_", all_objects, value = TRUE))
- rm(list = setdiff(all_objects, keep))
- }
- save.image(paste0(path,"EUDM_posteriors_heur.RData"))
- ```
- ```{r paged.print=FALSE}
- load(paste0(path,"EUDM_posteriors_heur.RData"))
- #getting the descriptive stats for the posterior parameter values
- cond <- c("post_-0.2","post_-0.6","post_0.2","post_0.6")
- for (ind in 1:length(cond)){
- posteriors <- get(cond[ind])
- params <- data.frame(matrix(NA,nrow=6,ncol=4))
- for (i in 1:5){
- params[i,1] <- mean(posteriors[[i+20]])
- params[i,2] <- sd(posteriors[[i+20]])
- params[i,3] <- as.numeric(hdi(posteriors[[i+20]])[2])
- params[i,4] <- as.numeric(hdi(posteriors[[i+20]])[3])
- }
- colnames(params) <- c("mean","sd","HDIl","HDIu")
- assign(paste0("params_",substr(cond[ind],6,nchar(cond[ind]))),params)
- }
- #group-level
- objects <- ls(pattern = "^params_")
- # Iterate over each object name, retrieve the object, and print the entire content
- for (obj_name in objects) {
- cat("\nObject Name:", obj_name, "\n")
- # Retrieve the object
- param_object <- get(obj_name)
- row.names(param_object) <- c("threshold","ndt","starting point","drift scaling","alpha")
- # Fallback plan to just print if nothing else
- print(param_object)
- }
- ```
- ```{r}
- #visualizing the parameters from each condition
- params <- c("threshold_gl", "ndt_gl", "starting_point_gl",
- "drift_scaling_gl", "alpha_gl")
- post_names <- ls(pattern = "^post_")
- draw_list <- lapply(post_names, function(obj_name) {
- lst <- get(obj_name)
- drift <- sub("post_", "", obj_name)
- df <- as.data.frame(lst[params]) # dataframe with param columns
- df$draw <- 1:nrow(df) # keep draw index for melting if needed
- df$condition <- drift
- df
- })
- combined_df <- bind_rows(draw_list)
- # Reshape to long format: each row is one posterior draw for one parameter and one condition
- long_df <- combined_df %>%
- pivot_longer(cols = all_of(params), names_to = "parameter", values_to = "value") %>%
- select(-draw) # Can keep 'draw' if you want to track draw index
- long_df$parameter <- factor(long_df$parameter, levels = params)
- long_df$condition <- factor(long_df$condition,levels = c(-0.6,-0.2,0.2,0.6))
- long_df <- filter(long_df,condition!="names")
- summary_df <- long_df %>%
- group_by(parameter, condition) %>%
- mean_qi(value, .width = 0.95) %>%
- rename(
- Mean = value,
- HDI_lower = .lower,
- HDI_upper = .upper
- )
- colors <- c("brown", "orange", "blue", "darkblue") # or any palette you prefer
- plot_pars <- ggplot(long_df, aes(x = value, y = condition, color = condition, fill = condition)) +
- # Crossbars for mean & interval
- geom_crossbar(data = summary_df,
- aes(x = Mean, y = condition, xmin = HDI_lower, xmax = HDI_upper, fill = condition),
- fatten = 3, width = 0.5, color = "black", alpha = 0.5,
- position = position_dodge2(width = 0.6)) +
- # For axis scaling hack (optional, see below)
- geom_point(alpha = 0, show.legend = FALSE) +
- # A red vertical line at x = 0 for reference
- scale_color_manual(values = colors) +
- scale_fill_manual(values = colors) +
- facet_wrap(~parameter, scales = "free_x", nrow = length(unique(long_df$parameter)), strip.position = "left") +
- labs(
- x = "Posterior value",
- y = "Condition (drift rate)"
- ) +
- theme_bw() +
- theme(
- strip.text.y = element_text(angle = 0, size = 13),
- axis.text.y = element_text(size = 13),
- axis.text.x = element_text(size = 12),
- axis.title.x = element_text(size = 15, margin = margin(t = 10)),
- legend.text = element_text(size = 12),
- legend.title = element_text(size = 13),
- strip.background = element_blank()
- )
- ggsave("K:/Erik/heurtest/heur_parameters.png", device = "png", plot = plot_pars, dpi = 300, height = 10, width = 6.5)
- ```
- ```{r}
- #testing for between-stage group differences
- for (cond in 1:7){
- if (cond==1){
- cond1 <- "control1"
- cond2 <- "control0"
- } else if (cond==2){
- cond1 <- "controlneutral1"
- cond2 <- "controlneutral0"
- } else if (cond==3){
- cond1 <- "main1"
- cond2 <- "main0"
- } else if (cond==4){
- cond1 <- "main2"
- cond2 <- "main0"
- } else if (cond==5){
- cond1 <- "controlneutral1"
- cond2 <- "control1"
- } else if (cond==6){
- cond1 <- "main1"
- cond2 <- "control1"
- } else if (cond==7){
- cond1 <- "main2"
- cond2 <- "control1"
- }
- threshold_dif_LP <- get(paste0("post_",cond1,"LP"))$threshold_gl - get(paste0("post_",cond2,"LP"))$threshold_gl
- ndt_dif_LP <- get(paste0("post_",cond1,"LP"))$ndt_gl - get(paste0("post_",cond2,"LP"))$ndt_gl
- starting_point_dif_LP <- get(paste0("post_",cond1,"LP"))$starting_point_gl - get(paste0("post_",cond2,"LP"))$starting_point_gl
- drift_scaling_dif_LP <- get(paste0("post_",cond1,"LP"))$drift_scaling_gl - get(paste0("post_",cond2,"LP"))$drift_scaling_gl
- alpha_dif_LP <- get(paste0("post_",cond1,"LP"))$alpha_gl - get(paste0("post_",cond2,"LP"))$alpha_gl
- threshold_dif_HP <- get(paste0("post_",cond1,"HP"))$threshold_gl - get(paste0("post_",cond2,"HP"))$threshold_gl
- ndt_dif_HP <- get(paste0("post_",cond1,"HP"))$ndt_gl - get(paste0("post_",cond2,"HP"))$ndt_gl
- starting_point_dif_HP <- get(paste0("post_",cond1,"HP"))$starting_point_gl - get(paste0("post_",cond2,"HP"))$starting_point_gl
- drift_scaling_dif_HP <- get(paste0("post_",cond1,"HP"))$drift_scaling_gl - get(paste0("post_",cond2,"HP"))$drift_scaling_gl
- alpha_dif_HP <- get(paste0("post_",cond1,"HP"))$alpha_gl - get(paste0("post_",cond2,"HP"))$alpha_gl
- combined_df <- rbind(
- data.frame(Parameter = "threshold", Difference = threshold_dif_LP),
- data.frame(Parameter = "ndt", Difference = ndt_dif_LP),
- data.frame(Parameter = "starting point", Difference = starting_point_dif_LP),
- data.frame(Parameter = "drift scaling", Difference = drift_scaling_dif_LP),
- data.frame(Parameter = "alpha", Difference = alpha_dif_LP),
- data.frame(Parameter = "threshold", Difference = threshold_dif_HP),
- data.frame(Parameter = "ndt", Difference = ndt_dif_HP),
- data.frame(Parameter = "starting point", Difference = starting_point_dif_HP),
- data.frame(Parameter = "drift scaling", Difference = drift_scaling_dif_HP),
- data.frame(Parameter = "alpha", Difference = alpha_dif_HP)
- )
- combined_df$risk_group <- c(rep(0,length(combined_df$Parameter)/2),rep(2,length(combined_df$Parameter)/2))
- summary_df <- combined_df %>%
- group_by(risk_group,Parameter) %>%
- summarize(
- Mean = mean(Difference),
- HDI_lower = round(quantile(Difference, 0.025),3),
- HDI_upper = round(quantile(Difference, 0.975),3)
- )
- assign(paste0("summary_df_",cond1,"-",cond2),summary_df)
- #a "hacky" way to fix the x-axis scale for each parameter across panels, by inserting the endpoint values into the corresponding dataset
- risk_group <- c(rep(0,10),rep(2,10))
- Parameter <- rep(unique(combined_df$Parameter)[1:5],4)
- Difference <- rep(c(-0.2,-0.125,-0.15,-0.05,-1,0.75,0.01,0.2,0.01,3
- ),2)
- limits <- data.frame(Parameter,Difference,risk_group)
- combined_df <- rbind(combined_df,limits)
- if (cond1=="control0"){
- name1 <- "adaptation (self)"
- } else if (cond1=="control1"){
- name1 <- "post-adaptation (self)"
- } else if (cond1=="controlneutral0"){
- name1 <- "adaptation (self)"
- } else if (cond1=="controlneutral1"){
- name1 <- "risk-average other"
- } else if (cond1=="main0"){
- name1 <- "adaptation (self)"
- } else if (cond1=="main1"){
- name1 <- "risk-averse other"
- } else if (cond1=="main2"){
- name1 <- "risk-seeking other"
- }
- if (cond2=="control0"){
- name2 <- "adaptation (self)"
- } else if (cond2=="control1"){
- name2 <- "post-adaptation (self)"
- } else if (cond2=="controlneutral0"){
- name2 <- "adaptation (self)"
- } else if (cond2=="controlneutral1"){
- name2 <- "risk-average other"
- } else if (cond2=="main0"){
- name2 <- "adaptation (self)"
- } else if (cond2=="main1"){
- name2 <- "risk-averse other"
- } else if (cond2=="main2"){
- name2 <- "risk-seeking other"
- }
- colors <- c('#f1e6c1','#c8f1c8')
- # plot_pars <- ggplot(combined_df, aes(x = Difference, y = Parameter,color=as.factor(risk_group))) +
- # #geom_point(data = summary_df, aes(x = Mean), size = 3,alpha=2) +
- # geom_crossbar(data = summary_df, aes(x = Mean, y = Parameter, xmin = HDI_lower, xmax = HDI_upper,fill=as.factor(risk_group)), fatten = 3, width = 0.75,color="black",alpha=0.5,position=position_dodge2(width=0.5)) +
- # geom_vline(xintercept = 0, color = "black", linetype = "dashed") +
- # #geom_errorbar(data = summary_df, aes(x = Mean, y = Parameter, xmin = HDI_lower, xmax = HDI_upper), width = 0.3,) +
- # scale_color_manual(values = colors, labels = c('Low probability', 'High probability')) +
- # scale_fill_manual(values = colors, labels = c('Low probability', 'High probability')) +
- # facet_grid(Parameter ~ ., scales = "free_y", space = "free_y") +
- # labs(x = paste0("Difference ",name1," - \n",name2), y = NULL) +
- # theme_bw() +
- # xlim(c(-0.9,2.7)) +
- # labs(fill="Risk group") +
- # theme(strip.text = element_blank(),
- # axis.text.y=element_text(size=11),
- # axis.text.x=element_text(size=11),
- # axis.title.x=element_text(size=13,margin = margin(t = 10)),
- # legend.text=element_text(size=11),
- # legend.title=element_text(size=13)
- # )
- # ggsave(paste0("dif_",cond1,"-",cond2,".png"), device = "png", plot = plot_pars, dpi = 300, height = 5, width = 6)
- plot_pars <- ggplot(combined_df, aes(x = Difference, y = Parameter,color=as.factor(risk_group))) +
- #geom_point(data = summary_df, aes(x = Mean), size = 3,alpha=2) +
- geom_crossbar(data = summary_df, aes(x = Mean, y = Parameter, xmin = HDI_lower, xmax = HDI_upper,fill=as.factor(risk_group)), fatten = 3, width = 0.75,color="black",alpha=0.5,position=position_dodge2(width=0.5)) +
- geom_vline(xintercept = 0, color = "red", linewidth=1.5, linetype = "dashed") +
- geom_point(alpha=0,show.legend=FALSE) + #part of the "hack" solution to fix the x-axis scale across panels (because it takes into account values created in "limits" above)
- #geom_errorbar(data = summary_df, aes(x = Mean, y = Parameter, xmin = HDI_lower, xmax = HDI_upper), width = 0.3,) +
- scale_color_manual(values = colors, labels = c('Low probability', 'High probability')) +
- scale_fill_manual(values = colors, labels = c('Low probability', 'High probability')) +
- facet_wrap(~ Parameter, scales = "free", nrow = length(unique(combined_df$Parameter)),
- drop = TRUE) +
- labs(x = paste0("Difference ",name1," - \n",name2), y = NULL) +
- theme_bw() +
- labs(fill="Risk group") +
- theme(strip.text = element_blank(),
- axis.text.y=element_text(size=13),
- axis.text.x=element_text(size=12),
- axis.title.x=element_text(size=15,margin = margin(t = 10)),
- legend.text=element_text(size=12),
- legend.title=element_text(size=13)
- )
- ggsave(paste0("dif_",cond1,"-",cond2,".png"), device = "png", plot = plot_pars, dpi = 300, height = 7, width = 6.5)
- }
- ```
EUDM_heurtest.Rmd, no license · at the source
Overview
- Department of Psychology and Hamburg Center of Neural and Cognitive Systems, University of Hamburg, Von-Melle Park 11, 20146 Hamburg, Germany
- Paris Brain Institute - ICM, Hôpital de la Pitié-Salpêtrière, 47 Boulevard de l’Hôpital, 75013 Paris, France
Abstract
Existing behavioral and neural evidence suggests that people rely on mental simulation when predicting others’ decisions. If true, making predictions with a biased decision system should result in biased predictions. We tested this idea directly by biasing participants’ risk valuation through adaptation to either high- or low-probability contexts and then asking them to predict the choices of three distinct agents (risk-average, risk-averse, risk-seeking). The adaptation manipulation biased participants’ predictions for the risk-average and risk-averse agents, suggesting simulation with their own (biased) decision process when predicting these agents. In contrast, there was no adaptation effect for the risk-seeking agent. Similarly, participants’ own risk tendencies correlated with predictions for the risk-average and risk-averse, but not the risk-seeking agent. Drift diffusion modeling analyses showed that this adaptation bias was the result of changes in participants’ risk valuation parameter. Overall, these findings support simulation-based prediction while suggesting a modulating role of the other person’s characteristics.
Reproduced under the paper's license (CC BY), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 4 matches between paragraphs and lines of code.
OSF svyma
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
- 27 September 2026: the link answers (HTTP 200)
10 files
- Behavioural data + behavioural analysis code/
data_analysis_behav.Rmd , R, 1,140 lines - Modelling code + output/
EUDM_heurtest.Rmd , R, 505 lines, 2 matches - Modelling code + output/
fit_models_stan.Rmd , R, 400 lines - Modelling code + output/
noncentered_EUDM_decor.s , Stan, 137 linestan - Modelling code + output/
noncentered_EVDM.stan , Stan, 127 lines - Modelling code + output/
noncentered_PTDM_decor.s , Stan, 151 linestan - Modelling code + output/
noncentered_heurDM.stan , Stan, 111 lines - Modelling code + output/
parameter_recovery.Rmd , R, 243 lines, 1 match - Modelling code + output/
posterior_parameters_vis , R, 504 lines.Rmd - Modelling code + output/
posterior_predictive_che , R, 681 lines, 1 matchck.Rmd
The paper's code and data availability statement is in the Data section.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 10 scripts, each with its path and the digest of its content;
- 4 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
No dataset and no data link were found in the paper.
Data and code availability
The behavioral data and code used for all analyses in this study are available at Open Science Framework: https://
Reproduced under the paper's license (CC BY), from the paper cited above.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 1, 27 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 3 authors, 3 keywords, 3 funders, 74 references.
Cite
This paper
Stuchlý, E., Bavard, S., & Gluth, S. (2026). Deciding to simulate: Cognitive mechanisms of predicting the decisions of others. iScience, 29(7), 116047. https://
BibTeX
@article{stuchly2026deci
author = {Stuchlý, Erik and Bavard, Sophie and Gluth, Sebastian},
title = {{Deciding to simulate: Cognitive mechanisms of predicting the decisions of others}},
journal = {iScience},
year = {2026},
month = jun,
volume = {29},
number = {7},
pages = {116047},
publisher = {Elsevier},
issn = {2589-0042},
doi = {10.1016/
url = {https://
pmid = {42389597},
pmcid = {PMC13319925}
}
RIS
TY - JOUR
AU - Stuchlý, Erik
AU - Bavard, Sophie
AU - Gluth, Sebastian
TI - Deciding to simulate: Cognitive mechanisms of predicting the decisions of others
T2 - iScience
J2 - iScience
PY - 2026
DA - 2026/
VL - 29
IS - 7
SP - 116047
SN - 2589-0042
PB - Elsevier
DO - 10.1016/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1016/
"type": "article-journal",
"title": "Deciding to simulate: Cognitive mechanisms of predicting the decisions of others",
"container-title": "iScience",
"author": [
{
"family": "Stuchlý",
"given": "Erik"
},
{
"family": "Bavard",
"given": "Sophie"
},
{
"family": "Gluth",
"given": "Sebastian"
}
],
"container-title-short":
"volume": "29",
"issue": "7",
"page": "116047",
"DOI": "10.1016/
"PMID": "42389597",
"PMCID": "PMC13319925",
"ISSN": "2589-0042",
"publisher": "Elsevier",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
6,
24
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1371/journal.pbio.3003079 [code]
- Dorsomedial and ventromedial prefrontal cortex lesions differentially impact social influence and temporal discounting.Journal: PLoS biologyIn common: Stan, easystats, rstatix, 5 other tools, cognitive, 4 references
- [2] doi:10.7554/elife.103846 [code]
- Overt visual attention modulates decision-related signals in the frontal cortex.Journal: eLifeIn common: lmerTest, lme4, ggplot2, 1 other tool, cognitive, 7 references
- [3] doi:10.1186/s11689-025-09651-3 [code]
- The association between infant EEG aperiodic exponent and the trajectory of restricted and repetitive behaviors for toddlers with and without autism.Journal: Journal of neurodevelopmental disordersIn common: afex, Stan, easystats, 6 other tools
- [4] doi:10.1007/s42113-025-00258-4 [code]
- Recurrent Neural Network Exploration Strategies During Reinforcement Learning Depend on Network Capacity.Journal: Computational brain & behaviorIn common: afex, Stan, easystats, 5 other tools, 1 reference
- [5] doi:10.1126/sciadv.aec9291 [code]
- Computational mechanisms of perception in autism revealed using games inspired by rodent operant tasks.Journal: Science advancesIn common: afex, Stan, easystats, 5 other tools, cognitive
- [6] doi:10.1038/s41366-023-01370-w [code]
- A randomized controlled trial investigating the effect of liraglutide on self-reported liking and neural responses to food stimuli in participants with obesity.Journal: International journal of obesity (2005)In common: afex, Stan, easystats, 5 other tools
- [7] doi:10.3758/s13415-025-01285-1 [code]
- People display consistent recency and primacy effects in behavior and neural activity across perceptual and value-based judgments.Journal: Cognitive, affective & behavioral neuroscienceIn common: Stan, rstatix, ggplot2, 1 other tool, cognitive, 4 references
- [8] doi:10.1073/pnas.2603114123 [code]
- The human hippocampus can pattern separate memories by meaning.Journal: Proceedings of the National Academy of Sciences of the United States of AmericaIn common: afex, easystats, rstatix, 5 other tools, cognitive
- [9] doi:10.1093/scan/nsag018 [code]
- Shared effects of the opioid antagonist naltrexone on first-hand and empathic pain.Journal: Social cognitive and affective neuroscienceIn common: afex, easystats, rstatix, 4 other tools, 1 reference
- [10] doi:10.1038/s42003-025-08600-z [code]
- Enhancing visual perception by modulating prestimulus alpha and beta power with tRNS.Journal: Communications biologyIn common: afex, easystats, rstatix, 4 other tools, cognitive, 1 reference
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 10 scripts, and 4 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:10ffe671c33ab7b3…
Add the badge to the code's README
If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.
Markdown
<!-- oscr-badge:start -->
[](https://openscicode.org/badge/doi/10.1016/j.isci.2026.116047)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/doi/10.1016/j.isci.2026.116047.svg
:target: https://openscicode.org/badge/doi/10.1016/j.isci.2026.116047
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1016/j.isci.2026.116047"><img src="https://openscicode.org/badge/doi/10.1016/j.isci.2026.116047.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.
Report a mismatch between the code and the paper · Report a code error (signed in)
Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.
Report a reproduction failure (signed in)
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
