Self-allocation bias in performance-based cooperative decisions is driven by self-interest rather than distorted performance encoding.
A correction to this paper has been published: the notice, 42627763, from Europe PMC.
The 3 matches
- [1] § Behavioral results › The self-allocation bias and its link to less reliance on performance. ↔ GA_analysis_plot_code.R, lines 1242 to 1283 · score 0.77 · OforO, OforS, SforO, SforS, allocation target, additive · Report a mismatch
- [2] § Methods › Experimental procedures › Experimental design in additional Experiment 3. ↔ GA_analysis_plot_code.R, lines 1242 to 1283 · score 0.73 · OforO, OforS, SforO, SforS, irrelevant · Report a mismatch
- [3] § Methods › Behavioral data analysis ↔ GA_analysis_plot_code.R, lines 92 to 136 · score 0.52 · inflated beta, emmeans, post hoc, LOO, brms, multilevel models · 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 · 1,769 lines · 65 KB · no license · 3 matches
- ###### GA behavioral analysis
- ## ------------------------ Initialization -------------------------------------
- ## setting
- rm(list= ls())
- library(tidyverse)
- library(ggplot2)
- library(brms)
- library(emmeans)
- library(sjPlot)
- library(svglite)
- library(ggpubr)
- library(cowplot)
- library(bayestestR)
- library(papaja)
- setwd(".../Behavioral_data")
- ## color
- light = c("#b2df8a","#decbe4")
- dark = c("#4bb14b","#967cb9")
- color_four = c("#4bb14b","#b2df8a","#decbe4","#967cb9")
- contribution_color = c("#fbb4ae","#ccebc5","#b3cde3")
- ## -------------------Experiment 1 and 2 ---------------------------------------------
- ## ------------------ load and prepare data ------------------------------------
- ## load data Experiment 1
- Exp1_data <- read.csv(".../Exp1_data.csv", header = TRUE)
- # factorize variables
- Exp1_data$task <-factor(Exp1_data$task,c('Simple','Additive','Disjunctive'))
- Exp1_data$winorloss<-factor(Exp1_data$winorloss,levels = c('Rewards','Losses'))
- Exp1_data$condition <-factor(Exp1_data$condition,levels = c('Self-relevant','Self-irrelevant'))
- # add svo score
- SVOdataExp1 <-read.csv(".../Exp1_SVOscore.csv", header = TRUE)
- Exp1_data <- Exp1_data %>%
- left_join(SVOdataExp1, by = "subject") %>%
- mutate(experiment = 'Experiment1')
- # if control analysis:
- # filter(!subject %in% c(32, 46, 55, 56, 57))
- ## load data Experiment 2
- Exp2_data <- read.csv(".../Exp2_data.csv", header = TRUE)
- Exp2_data$task<-factor(Exp2_data$task,levels = c('Simple','Additive','Disjunctive'))
- Exp2_data$winorloss<-factor(Exp2_data$winorloss, levels = c('Rewards','Losses'))
- Exp2_data$condition<-factor(Exp2_data$condition, levels = c('Self-relevant','Self-irrelevant'))
- # add svo score
- SVOdataExp2 <-read.csv(".../Exp2_SVOscore.csv", header = TRUE)
- Exp2_data <- Exp2_data %>%
- left_join(SVOdataExp2, by = "subject") %>%
- mutate(experiment = 'Experiment2')
- # if control analysis:
- # filter(!subject %in% c(118,119,125,132,134,139,141,143))
- ## combine data
- # combine in trial level
- combinedData <- rbind(Exp1_data,Exp2_data)
- combinedData <- combinedData %>%
- filter(winorloss == "Rewards") %>%
- mutate(contribution = case_when((performance1 >= threshold & performance2 < threshold)~"Player1 only",
- (performance2 >= threshold & performance1 < threshold)~"Player2 only",
- TRUE ~"Both")) %>%
- dplyr::select(subject,trial,task,condition,contribution,allocation_ratio,performance_ratio,shapley_ratio,SVOscore,experiment)
- combinedData[,5]<-factor(combinedData[,5],levels = c('Player1 only','Both','Player2 only'))
- combinedData$SVOscore_z <- scale(combinedData$SVOscore)
- ## -------------- model 1: task * condition ------------------------------------
- ## model fitting
- # task * condition
- fit_zoib_tc <- brm(
- bf(
- allocation_ratio ~ task * condition + (1 | subject)
- ),
- data = combinedData,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_tc)
- saveRDS(fit_zoib_tc, file = "multilevel_model/output/fit_zoib_tc.rds")
- # task + condition
- fit_zoib_tc_noInt <- brm(
- bf(
- allocation_ratio ~ task + condition + (1 | subject)
- ),
- data = combinedData,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_tc_noInt)
- saveRDS(fit_zoib_tc_noInt, file = "multilevel_model/output/fit_zoib_tc_noInt.rds")
- ## save model output
- fit_zoib_tc <- readRDS("multilevel_model/output/fit_zoib_tc.rds")
- summary(fit_zoib_tc)
- coef_table <- as.data.frame(summary(fit_zoib_tc)$fixed)
- coef_table <- round(coef_table, 2)
- write.csv(coef_table, "multilevel_model/output/tables/TabS1-1_fit_zoib_tc.csv", row.names = TRUE)
- ## compare model
- fit_zoib_tc <- readRDS("multilevel_model/output/fit_zoib_tc.rds")
- fit_zoib_tc_noInt <- readRDS("multilevel_model/output/fit_zoib_tc_noInt.rds")
- loo_compare(loo(fit_zoib_tc), loo(fit_zoib_tc_noInt)) #diff 2*SE
- # post hoc
- emm <- emmeans(fit_zoib_tc, ~ task * condition, type = "response")
- plot(emm)
- pairs(emm, by = "condition")
- pairs(emm, by = "task")
- contrast(emm, "pairwise")
- emm_2 <-emm %>% summary() %>% as.data.frame() %>%
- mutate(across(where(is.numeric), ~ round(.x, 2)))
- write.csv(emm_2, "multilevel_model/output/tables/TabS1-3_emms.csv", row.names = TRUE)
- # plot
- tc <- conditional_effects(fit_zoib_tc, effects = "task:condition")
- p <- plot(tc, plot = FALSE)[[1]]
- p +
- scale_color_manual(values = dark) +
- scale_fill_manual(values = dark) +
- theme_classic() +
- theme(text = element_text(size = 15)) +
- xlab("Task type") +
- ylab("Allocation Ratio")
- ## ------------- model 2: task * condition * SVO score ------------------------------------------
- # task * condition * SVOscore
- fit_zoib_tc_SVO <- brm(
- bf(
- allocation_ratio ~ task * condition * SVOscore_z + (1 | subject)
- ),
- data = combinedData,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_tc_SVO)
- saveRDS(fit_zoib_tc_SVO, file = "multilevel_model/output/fit_zoib_tc_SVO.rds")
- # compare model
- loo_compare(loo(fit_zoib_tc), loo(fit_zoib_tc_noInt), loo(fit_zoib_tc_SVO))
- # post hoc
- fit_zoib_tc_SVO <- readRDS("multilevel_model/output/fit_zoib_tc_SVO.rds")
- summary(fit_zoib_tc_SVO)
- coef_table <- as.data.frame(summary(fit_zoib_tc_SVO)$fixed)
- coef_table <- round(coef_table, 2)
- write.csv(coef_table, "multilevel_model/output/tables/TabS2-1_fit_zoib_tc_SVO.csv", row.names = TRUE)
- post_summary <- describe_posterior(fit_zoib_tc_SVO)
- tab_df(post_summary,
- title = "Posterior Estimates",
- file = "multilevel_model/output/fit_zoib_tc_SVO.html")
- slopes_SVO <- emtrends(fit_zoib_tc_SVO, ~ condition | task, var = "SVOscore_z")
- pairs(slopes_SVO)
- emm_2 <- slopes_SVO %>% summary() %>% as.data.frame() %>%
- mutate(across(where(is.numeric), ~ round(.x, 2)))
- write.csv(emm_2, "multilevel_model/output/tables/TabS2-3_emms.csv", row.names = TRUE)
- st <- conditional_effects(fit_zoib_tc_SVO,
- effects = "SVOscore_z:condition",
- conditions = list(task = c("Simple", "Additive", "Disjunctive")))
- p <- plot(st, plot = FALSE)[[1]]
- p + scale_color_manual(values = dark) +
- scale_fill_manual(values = dark) +
- theme_classic()+
- theme(text = element_text(size = 15))+
- xlab("SVOscore (z-score)")+
- ylab("Allocation Ratio") +
- facet_wrap(~task, labeller = labeller(task = c("Simple", "Additive", "Disjunctive"))) # custom facet names
- ## ----- model 3: performance ratio * task + performance ratio * condition -----
- ## model fitting
- # three way interaction
- fit_zoib_3way <- brm(
- bf(
- allocation_ratio ~ performance_ratio * task * condition + (1 | subject)
- ),
- data = combinedData,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_3way)
- saveRDS(fit_zoib_3way, file = "multilevel_model/output/fit_zoib_3way.rds")
- # two way interaction
- fit_zoib_2way <- brm(
- bf(
- allocation_ratio ~ performance_ratio * task + performance_ratio * condition + (1 | subject)
- ),
- data = combinedData,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_2way)
- saveRDS(fit_zoib_2way, file = "multilevel_model/output/fit_zoib_2way.rds")
- # no interaction
- fit_zoib_noInt <- brm(
- bf(
- allocation_ratio ~ performance_ratio + task + condition + (1 | subject)
- ),
- data = combinedData,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_noInt)
- saveRDS(fit_zoib_noInt, file = "multilevel_model/output/fit_zoib_noInt.rds")
- ## Compare model
- fit_zoib_3way <- readRDS("multilevel_model/output/fit_zoib_3way.rds")
- fit_zoib_2way <- readRDS("multilevel_model/output/fit_zoib_2way.rds")
- fit_zoib_noInt <- readRDS("multilevel_model/output/fit_zoib_noInt.rds")
- three_way_model <- loo(fit_zoib_3way)
- two_way_model <- loo(fit_zoib_2way)
- no_int_model <- loo(fit_zoib_noInt)
- loo_compare(three_way_model, two_way_model, no_int_model) #diff 2*SE
- ## post hoc
- # get the best model
- fit_zoib <- readRDS("multilevel_model/output/fit_zoib_2way.rds")
- summary(fit_zoib)
- coef_table <- as.data.frame(summary(fit_zoib)$fixed)
- coef_table <- round(coef_table, 2)
- write.csv(coef_table, "multilevel_model/output/tables/TabS3-1_fit_zoib.csv", row.names = TRUE)
- post_summary <- describe_posterior(fit_zoib)
- tab_df(post_summary,
- title = "Posterior Estimates",
- file = "multilevel_model/output/fit_zoib_2way.html")
- slopes_task <- emtrends(fit_zoib, ~ task, var = "performance_ratio")
- pairs(slopes_task)
- slopes_cond <- emtrends(fit_zoib, ~ condition, var = "performance_ratio")
- pairs(slopes_cond)
- emm_2 <- slopes_cond %>% summary() %>% as.data.frame() %>%
- mutate(across(where(is.numeric), ~ round(.x, 2)))
- write.csv(emm_2, "multilevel_model/output/tables/TabS3-2_emms.csv", row.names = TRUE)
- plot(fit_zoib, variable = c("b_performance_ratio"))
- plot(fit_zoib, variable = c("b_taskDisjunctive"))
- plot(fit_zoib, variable = c("b_conditionSelfMirrelevant"))
- pt <- conditional_effects(fit_zoib, effects = "performance_ratio:task")
- p1 <- plot(pt, plot = FALSE)[[1]]
- p1 + scale_color_manual(values = c( "grey85", "grey50","black")) +
- scale_fill_manual(values = c( "grey85", "grey50","black")) +
- theme_classic()+
- theme(text = element_text(size = 15))+
- xlab("Performance Ratio")+
- ylab("Allocation Ratio")
- pc <- conditional_effects(fit_zoib, effects = "performance_ratio:condition")
- p_2c <- plot(pc, plot = FALSE)[[1]]+
- scale_color_manual(values = dark) +
- scale_fill_manual(values = dark) +
- theme_bw() +
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.text.x = element_text(size = 15),
- axis.text.y = element_text(size = 15),
- panel.spacing.x = unit(0.8, "lines"),
- legend.text=element_text(size=15))+
- xlab("Relative Performance")+
- ylab("Relative Allocation")
- p_2c
- ## ------------------- plot Figure 2A,2B,2C ------------------------------------------
- # get data
- # combine two datasets and exclude loss trials
- combinedData_sub <- combinedData %>%
- filter(!is.na(allocation_ratio)) %>%
- dplyr::select(experiment,task,subject,condition,allocation_ratio,SVOscore_z) %>%
- group_by(experiment,task,subject,condition) %>%
- dplyr::summarize(mean_allocation_ratio = mean(allocation_ratio),
- SVOscore_z = first(SVOscore_z)) %>%
- select(experiment, task,condition, subject, mean_allocation_ratio, SVOscore_z)
- combinedData_sub$subject <- as.factor(combinedData_sub$subject)
- # plot Figure 2B
- p_2a <- ggplot(combinedData_sub, aes(x = condition, y = mean_allocation_ratio, fill = condition)) +
- geom_bar(stat = "summary", fun = "mean", colour = "black", position = "dodge") +
- geom_line(aes(group = subject),color = 'darkgray') +
- geom_point(aes(group = subject), shape = 21, color = 'darkgray') +
- stat_summary(fun.data = mean_cl_normal, na.rm =TRUE,
- geom = "errorbar", width = .2)+
- geom_hline(yintercept = 0.5,linetype="dashed", color = "black") +
- facet_grid(~task) +
- scale_fill_manual(values = dark) +
- theme_bw()+
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- axis.text.x = element_blank(),
- axis.ticks.x = element_blank(),
- axis.text.y = element_text(size = 15),
- plot.title = element_text(hjust = 0.5),
- legend.text=element_text(size=15)) +
- ylab("Relative allocation") +
- xlab(" ") +
- labs(fill = "Self-relevance")
- p_2a
- # plot Figure 2B
- p_2b<-combinedData_sub %>%
- ggplot(aes(x=SVOscore_z, y=mean_allocation_ratio, color=condition)) +
- geom_point(shape = 20,size=5,alpha = 0.5) +
- theme_bw() +
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.text.x = element_text(size = 15),
- axis.text.y = element_text(size = 15),
- panel.spacing.x = unit(0.8, "lines"),
- legend.text=element_text(size=15))+
- #legend.position="none")+
- geom_smooth(method=lm, se = FALSE)+
- #stat_cor()+
- facet_grid(~task,scales = "free")+
- #scale_shape_manual(values=c(3, 16))+
- #geom_vline(xintercept = 22.45,linetype="dashed", color = "black") +
- scale_color_manual(values=dark)+
- xlab("SVO score (z-scored)")+
- ylab("Relative allocation")+
- labs(color = "Self-relevance")
- p_2b
- ## -------------- model 4: contribution diff -----------------------------------
- # calculate the differnece between self-relevant and self-irrelevant based on trial
- combinedData_contribution <- combinedData %>%
- pivot_wider(id_cols = c(experiment,subject,SVOscore_z,SVOscore,trial,task,contribution,performance_ratio),
- names_from = condition,
- values_from = allocation_ratio) %>%
- mutate(difference = `Self-relevant` - `Self-irrelevant`)
- ## model fitting
- fit_gaussian_c_diff <- brm(
- bf(
- difference ~ contribution + (1 | subject)
- ),
- data = combinedData_contribution,
- family = gaussian(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_gaussian_c_diff)
- saveRDS(fit_gaussian_c_diff, file = "output/fit_gaussian_c_diff.rds")
- ## post hoc
- fit_gaussian_c_diff <- readRDS("multilevel_model/output/fit_gaussian_c_diff.rds")
- summary(fit_gaussian_c_diff)
- coef_table <- as.data.frame(summary(fit_gaussian_c_diff)$fixed)
- coef_table <- round(coef_table, 2)
- write.csv(coef_table, "multilevel_model/output/tables/TabS4-2_fit_zoib.csv", row.names = TRUE)
- post_summary <- describe_posterior(fit_gaussian_c_diff)
- tab_df(post_summary,
- title = "Posterior Estimates",
- file = "multilevel_model/output/fit_gaussian_c_diff.html")
- emm <- emmeans(fit_gaussian_c_diff, ~ contribution, type = "response")
- contrast(emm, "pairwise")
- emm_2 <- emm %>% summary() %>% as.data.frame() %>%
- mutate(across(where(is.numeric), ~ round(.x, 2)))
- write.csv(emm_2, "multilevel_model/output/tables/TabS4-3_emms.csv", row.names = TRUE)
- gaussian_c_diff <- conditional_effects(fit_gaussian_c_diff, effects = "contribution")
- p <- plot(gaussian_c_diff, plot = FALSE)[[1]]+
- aes(color = contribution, fill = contribution)
- p +
- scale_color_manual(values = contribution_color) +
- scale_fill_manual(values = contribution_color) +
- theme_classic() +
- theme(text = element_text(size = 15)) +
- xlab("Contribution") +
- ylab("Self-allocation Bias")
- ## ------------- model 5: including SVO score ---------------------------------
- # contribution*SVOscore_z
- fit_gaussian_c_diff_SVO <- brm(
- bf(
- difference ~ contribution * SVOscore_z + (1 | subject)
- ),
- data = combinedData_contribution,
- family = gaussian(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_gaussian_c_diff_SVO)
- saveRDS(fit_gaussian_c_diff_SVO, file = "output/fit_gaussian_c_diff_SVO.rds")
- ## compare model
- # get model
- fit_gaussian_c_diff <- readRDS("output/fit_gaussian_c_diff.rds")
- fit_gaussian_c_diff_SVO <- readRDS("output/fit_gaussian_c_diff_SVO.rds")
- # check distribution
- # pp_check(fit_gaussian_c_diff_SVO, type = "dens_overlay")
- loo_compare(loo(fit_gaussian_c_diff), loo(fit_gaussian_c_diff_SVO))
- ## post hoc
- fit_gaussian_c_diff_SVO <- readRDS("multilevel_model/output/fit_gaussian_c_diff_SVO.rds")
- post_summary <- describe_posterior(fit_gaussian_c_diff_SVO)
- tab_df(post_summary,
- title = "Posterior Estimates",
- file = "multilevel_model/output/fit_gaussian_c_diff_SVO.html")
- slopes_SVO <- emtrends(fit_gaussian_c_diff_SVO, ~ contribution, var = "SVOscore_z")
- pairs(slopes_SVO)
- emm_2 <- slopes_SVO %>% summary() %>% as.data.frame() %>%
- mutate(across(where(is.numeric), ~ round(.x, 2)))
- write.csv(emm_2, "multilevel_model/output/tables/TabS4-5_emms.csv", row.names = TRUE)
- c_diff_svo <- conditional_effects(fit_gaussian_c_diff_SVO,
- effects = "SVOscore_z:contribution")
- p <- plot(c_diff_svo, plot = FALSE)[[1]]
- p + scale_color_manual(values = contribution_color) +
- scale_fill_manual(values = contribution_color) +
- theme_classic()+
- theme(text = element_text(size = 15))+
- xlab("SVOscore (z-score)")+
- ylab("Allocation Ratio")
- ## post hoc
- emm <- emmeans(fit_gaussian_c_diff_SVO, ~ contribution, type = "response")
- contrast(emm, "pairwise")
- gaussian_c_diff <- conditional_effects(fit_gaussian_c_diff_SVO, effects = "contribution")
- p <- plot(gaussian_c_diff, plot = FALSE)[[1]] +
- aes(color = contribution, fill = contribution)
- p +
- scale_color_manual(values = contribution_color) +
- scale_fill_manual(values = contribution_color) +
- theme_classic() +
- theme(text = element_text(size = 15)) +
- xlab("Contribution") +
- ylab("Self-allocation Bias")
- ## ---------------------- plot Figure 3B 3C ------------------------------------
- combinedData_contribution_sub <- combinedData_contribution %>%
- filter(!is.na(difference)) %>%
- dplyr::select(experiment,task,subject,contribution,difference,SVOscore_z) %>%
- group_by(experiment,subject,contribution) %>%
- dplyr::summarize(mean_diff = mean(difference),
- SVOscore_z = first(SVOscore_z)) %>%
- select(experiment,contribution, subject, mean_diff, SVOscore_z)
- combinedData_contribution_sub$subject <- as.factor(combinedData_contribution_sub$subject)
- # plot 3B
- p_3b<-ggplot(combinedData_contribution_sub, aes(x = contribution, y = mean_diff, fill = contribution)) +
- geom_bar(stat = "summary", fun = "mean", colour = "black")+
- geom_point(aes(group = subject), shape = 21, color = 'darkgray') +
- stat_summary(fun.data = mean_cl_normal, na.rm =TRUE,
- geom = "errorbar", width = .2)+
- scale_fill_manual(values = contribution_color) +
- theme_bw()+
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- axis.ticks.x = element_blank(),
- axis.text.y = element_text(size = 15)) +
- ylab("Self allocation bias") +
- xlab(" ")
- p_3b
- # plot 3c
- p_3c <- combinedData_contribution_sub %>%
- ggplot(aes(x=SVOscore_z, y=mean_diff, color=contribution)) +
- geom_point(shape = 20,size=5,alpha = 0.8) +
- theme_bw() +
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.text.x = element_text(size = 15),
- axis.text.y = element_text(size = 15),
- panel.spacing.x = unit(0.8, "lines"),
- )+
- #legend.position = "none"
- geom_smooth(method=lm, se = FALSE)+
- scale_color_manual("Contribution",values=contribution_color)+
- # stat_cor(p.accuracy = 0.001,size = 6)+
- xlab("SVO score (z-scored)")+ylab("Self allocation bias")
- p_3c
- ## -------------- Experiment 1 and 2 separately -------------------------------
- ## -------------- model S1: task * condition ------------------------------------
- ## prepare data
- exp1Data <- combinedData %>%
- filter(experiment == "Experiment1")
- exp2Data <- combinedData %>%
- filter(experiment == "Experiment2")
- ## model fitting
- # exp1
- fit_zoib_tc_exp1 <- brm(
- bf(
- allocation_ratio ~ task * condition + (1 | subject)
- ),
- data = exp1Data,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_tc_exp1)
- saveRDS(fit_zoib_tc_exp1, file = "output/exp1_fit_zoib_tc.rds")
- # exp2
- fit_zoib_tc_exp2 <- brm(
- bf(
- allocation_ratio ~ task * condition + (1 | subject)
- ),
- data = exp2Data,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_tc_exp2)
- saveRDS(fit_zoib_tc_exp2, file = "output/exp2_fit_zoib_tc.rds")
- ## post hoc
- # get the interaction model
- fit_zoib_tc_exp1 <- readRDS("multilevel_model/output/exp1_fit_zoib_tc.rds")
- summary(fit_zoib_tc_exp1)
- coef_table <- as.data.frame(summary(fit_zoib_tc_exp1)$fixed)
- coef_table <- round(coef_table, 2)
- write.csv(coef_table, "multilevel_model/output/tables/TabS1-4_fit_zoib_tc.csv", row.names = TRUE)
- fit_zoib_tc_exp2 <- readRDS("multilevel_model/output/exp2_fit_zoib_tc.rds")
- summary(fit_zoib_tc_exp2)
- coef_table <- as.data.frame(summary(fit_zoib_tc_exp2)$fixed)
- coef_table <- round(coef_table, 2)
- write.csv(coef_table, "multilevel_model/output/tables/TabS1-7_fit_zoib_tc.csv", row.names = TRUE)
- # exp1
- emm <- emmeans(fit_zoib_tc_exp1, ~ task * condition, type = "response")
- plot(emm)
- pairs(emm, by = "condition")
- pairs(emm, by = "task")
- contrast(emm, "pairwise")
- emm_2 <-emm %>% summary() %>% as.data.frame() %>%
- mutate(across(where(is.numeric), ~ round(.x, 2)))
- write.csv(emm_2, "multilevel_model/output/tables/TabS1-6_emms.csv", row.names = TRUE)
- tc_exp1 <- conditional_effects(fit_zoib_tc_exp1, effects = "task:condition")
- p <- plot(tc_exp1, plot = FALSE)[[1]]
- p +
- scale_color_manual(values = dark) +
- scale_fill_manual(values = dark) +
- theme_classic() +
- theme(text = element_text(size = 15)) +
- xlab("Task type") +
- ylab("Allocation Ratio") +
- ggtitle("Experiment 1")
- # exp2
- emm <- emmeans(fit_zoib_tc_exp2, ~ task * condition, type = "response")
- plot(emm)
- pairs(emm, by = "condition")
- pairs(emm, by = "task")
- contrast(emm, "pairwise")
- emm_2 <-emm %>% summary() %>% as.data.frame() %>%
- mutate(across(where(is.numeric), ~ round(.x, 2)))
- write.csv(emm_2, "multilevel_model/output/tables/TabS1-9_emms.csv", row.names = TRUE)
- tc_exp2 <- conditional_effects(fit_zoib_tc_exp2, effects = "task:condition")
- p <- plot(tc_exp2, plot = FALSE)[[1]]
- p +
- scale_color_manual(values = dark) +
- scale_fill_manual(values = dark) +
- theme_classic() +
- theme(text = element_text(size = 15)) +
- xlab("Task type") +
- ylab("Allocation Ratio") +
- ggtitle("Experiment 2")
- # ------------- model S2: including SVO score ------------------------------------------
- # task * condition * SVOscore
- fit_zoib_tc_SVO_exp1 <- brm(
- bf(
- allocation_ratio ~ task * condition * SVOscore_z + (1 | subject)
- ),
- data = exp1Data,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_tc_SVO_exp1)
- saveRDS(fit_zoib_tc_SVO_exp1, file = "output/exp1_fit_zoib_tc_SVO.rds")
- # exp2
- fit_zoib_tc_SVO_exp2 <- brm(
- bf(
- allocation_ratio ~ task * condition * SVOscore_z + (1 | subject)
- ),
- data = exp2Data,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_tc_SVO_exp2)
- saveRDS(fit_zoib_tc_SVO_exp2, file = "output/exp2_fit_zoib_tc_SVO.rds")
- # post hoc
- fit_zoib_tc_SVO_exp1 <- readRDS("multilevel_model/output/exp1_fit_zoib_tc_SVO.rds")
- summary(fit_zoib_tc_SVO_exp1)
- coef_table <- as.data.frame(summary(fit_zoib_tc_SVO_exp1)$fixed)
- coef_table <- round(coef_table, 2)
- write.csv(coef_table, "multilevel_model/output/tables/TabS2-4_fit_zoib_tc_SVO.csv", row.names = TRUE)
- fit_zoib_tc_SVO_exp2 <- readRDS("multilevel_model/output/exp2_fit_zoib_tc_SVO.rds")
- summary(fit_zoib_tc_SVO_exp2)
- coef_table <- as.data.frame(summary(fit_zoib_tc_SVO_exp2)$fixed)
- coef_table <- round(coef_table, 2)
- write.csv(coef_table, "multilevel_model/output/tables/TabS2-7_fit_zoib_tc_SVO.csv", row.names = TRUE)
- # exp1
- slopes_SVO <- emtrends(fit_zoib_tc_SVO_exp1, ~ condition | task, var = "SVOscore_z")
- pairs(slopes_SVO)
- emm_2 <-slopes_SVO %>% summary() %>% as.data.frame() %>%
- mutate(across(where(is.numeric), ~ round(.x, 2)))
- write.csv(emm_2, "multilevel_model/output/tables/TabS2-6_emms.csv", row.names = TRUE)
- st <- conditional_effects(fit_zoib_tc_SVO_exp1,
- effects = "SVOscore_z:condition",
- conditions = list(task = c("Simple", "Additive", "Disjunctive")))
- p <- plot(st, plot = FALSE)[[1]]
- p + scale_color_manual(values = dark) +
- scale_fill_manual(values = dark) +
- theme_classic()+
- theme(text = element_text(size = 15))+
- xlab("SVOscore (z-score)")+
- ylab("Allocation Ratio") +
- ggtitle("Experiment 1") +
- facet_wrap(~task, labeller = labeller(task = c("Simple", "Additive", "Disjunctive"))) # custom facet names
- # exp2
- slopes_SVO <- emtrends(fit_zoib_tc_SVO_exp2, ~ condition | task, var = "SVOscore_z")
- pairs(slopes_SVO)
- emm_2 <-slopes_SVO %>% summary() %>% as.data.frame() %>%
- mutate(across(where(is.numeric), ~ round(.x, 2)))
- write.csv(emm_2, "multilevel_model/output/tables/TabS2-9_emms.csv", row.names = TRUE)
- st <- conditional_effects(fit_zoib_tc_SVO_exp2,
- effects = "SVOscore_z:condition",
- conditions = list(task = c("Simple", "Additive", "Disjunctive")))
- p <- plot(st, plot = FALSE)[[1]]
- p + scale_color_manual(values = dark) +
- scale_fill_manual(values = dark) +
- theme_classic()+
- theme(text = element_text(size = 15))+
- xlab("SVOscore (z-score)")+
- ylab("Allocation Ratio") +
- ggtitle("Experiment 2") +
- facet_wrap(~task, labeller = labeller(task = c("Simple", "Additive", "Disjunctive"))) # custom facet names
- ## ----- model S3: performance ratio * task + performance ratio * condition -----
- ## model fitting
- # exp1
- fit_zoib_2way_exp1 <- brm(
- bf(
- allocation_ratio ~ performance_ratio * task + performance_ratio * condition + (1 | subject)
- ),
- data = exp1Data,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_2way_exp1)
- saveRDS(fit_zoib_2way_exp1, file = "output/exp1_fit_zoib_2way.rds")
- # exp2
- fit_zoib_2way_exp2 <- brm(
- bf(
- allocation_ratio ~ performance_ratio * task + performance_ratio * condition + (1 | subject)
- ),
- data = exp2Data,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_2way_exp2)
- saveRDS(fit_zoib_2way_exp2, file = "output/exp2_fit_zoib_2way.rds")
- # post hoc
- fit_zoib_2way_exp1 <- readRDS("multilevel_model/output/exp1_fit_zoib_2way.rds")
- summary(fit_zoib_2way_exp1)
- coef_table <- as.data.frame(summary(fit_zoib_2way_exp1)$fixed)
- coef_table <- round(coef_table, 2)
- write.csv(coef_table, "multilevel_model/output/tables/TabS3-4_fit_zoib.csv", row.names = TRUE)
- fit_zoib_2way_exp2 <- readRDS("multilevel_model/output/exp2_fit_zoib_2way.rds")
- summary(fit_zoib_2way_exp2)
- coef_table <- as.data.frame(summary(fit_zoib_2way_exp2)$fixed)
- coef_table <- round(coef_table, 2)
- write.csv(coef_table, "multilevel_model/output/tables/TabS3-7_fit_zoib.csv", row.names = TRUE)
- #exp1
- slopes_task <- emtrends(fit_zoib_2way_exp1, ~ task, var = "performance_ratio")
- pairs(slopes_task)
- slopes_cond <- emtrends(fit_zoib_2way_exp1, ~ condition, var = "performance_ratio")
- pairs(slopes_cond)
- emm_2 <- slopes_cond %>% summary() %>% as.data.frame() %>%
- mutate(across(where(is.numeric), ~ round(.x, 2)))
- write.csv(emm_2, "multilevel_model/output/tables/TabS3-5_emms.csv", row.names = TRUE)
- plot(fit_zoib_2way_exp1, variable = c("b_performance_ratio"))
- plot(fit_zoib_2way_exp1, variable = c("b_taskDisjunctive"))
- plot(fit_zoib_2way_exp1, variable = c("b_conditionSelfMirrelevant"))
- pc <- conditional_effects(fit_zoib_2way_exp1, effects = "performance_ratio:condition")
- p_s2c <- plot(pc, plot = FALSE)[[1]] +
- scale_color_manual(values = dark) +
- scale_fill_manual(values = dark) +
- theme_bw() +
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.text.x = element_text(size = 15),
- axis.text.y = element_text(size = 15),
- panel.spacing.x = unit(0.8, "lines"),
- legend.text=element_text(size=15))+
- xlab("Performance Ratio")+
- ylab("Allocation Ratio")+
- ggtitle("Experiment 1")
- p_s2c
- pt <- conditional_effects(fit_zoib_2way_exp1, effects = "performance_ratio:task")
- p_s2d <- plot(pt, plot = FALSE)[[1]] +
- scale_color_manual(values = c( "grey85", "grey50","black")) +
- scale_fill_manual(values = c( "grey85", "grey50","black")) +
- theme_bw() +
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.text.x = element_text(size = 15),
- axis.text.y = element_text(size = 15),
- panel.spacing.x = unit(0.8, "lines"),
- legend.text=element_text(size=15))+
- xlab("Performance Ratio")+
- ylab("Allocation Ratio")+
- ggtitle("Experiment 1")
- p_s2d
- #exp2
- slopes_task <- emtrends(fit_zoib_2way_exp2, ~ task, var = "performance_ratio")
- pairs(slopes_task)
- slopes_cond <- emtrends(fit_zoib_2way_exp2, ~ condition, var = "performance_ratio")
- pairs(slopes_cond)
- emm_2 <- slopes_cond %>% summary() %>% as.data.frame() %>%
- mutate(across(where(is.numeric), ~ round(.x, 2)))
- write.csv(emm_2, "multilevel_model/output/tables/TabS3-8_emms.csv", row.names = TRUE)
- plot(fit_zoib_2way_exp2, variable = c("b_performance_ratio"))
- plot(fit_zoib_2way_exp2, variable = c("b_taskDisjunctive"))
- plot(fit_zoib_2way_exp2, variable = c("b_conditionSelfMirrelevant"))
- pc <- conditional_effects(fit_zoib_2way_exp2, effects = "performance_ratio:condition")
- p_s2g <- plot(pc, plot = FALSE)[[1]] +
- scale_color_manual(values = dark) +
- scale_fill_manual(values = dark) +
- theme_bw() +
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.text.x = element_text(size = 15),
- axis.text.y = element_text(size = 15),
- panel.spacing.x = unit(0.8, "lines"),
- legend.text=element_text(size=15))+
- xlab("Performance Ratio")+
- ylab("Allocation Ratio")+
- ggtitle("Experiment 2")
- p_s2g
- pt <- conditional_effects(fit_zoib_2way_exp2, effects = "performance_ratio:task")
- p_s2h <- plot(pt, plot = FALSE)[[1]] +
- scale_color_manual(values = c( "grey85", "grey50","black")) +
- scale_fill_manual(values = c( "grey85", "grey50","black")) +
- theme_bw() +
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.text.x = element_text(size = 15),
- axis.text.y = element_text(size = 15),
- panel.spacing.x = unit(0.8, "lines"),
- legend.text=element_text(size=15))+
- xlab("Performance Ratio")+
- ylab("Allocation Ratio")+
- ggtitle("Experiment 2")
- p_s2h
- ## --------------------------- plot Figure S2: Experiment 1 --------------------
- # plot Figure S2A
- Exp1_sub <- combinedData_sub %>%
- filter(experiment == "Experiment1")
- p_S2a <- ggplot(Exp1_sub, aes(x = condition, y = mean_allocation_ratio, fill = condition)) +
- geom_bar(stat = "summary", fun = "mean", colour = "black", position = "dodge") +
- geom_line(aes(group = subject),color = 'darkgray') +
- geom_point(aes(group = subject), shape = 21, color = 'darkgray') +
- stat_summary(fun.data = mean_cl_normal, na.rm =TRUE,
- geom = "errorbar", width = .2)+
- geom_hline(yintercept = 0.5,linetype="dashed", color = "black") +
- facet_grid(~task) +
- scale_fill_manual(values = dark) +
- theme_bw()+
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- axis.text.x = element_blank(),
- axis.ticks.x = element_blank(),
- axis.text.y = element_text(size = 15),
- plot.title = element_text(hjust = 0.5),
- legend.text=element_text(size=15)) +
- ylab("Relative allocation") +
- xlab(" ") +
- labs(fill = "Self-relevance", title = "Experiment 1")
- p_S2a
- # plot Figure S2B
- p_s2b<-Exp1_sub %>%
- ggplot(aes(x=SVOscore_z, y=mean_allocation_ratio, color=condition)) +
- geom_point(shape = 20,size=5,alpha = 0.5) +
- theme_bw() +
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.text.x = element_text(size = 15),
- axis.text.y = element_text(size = 15),
- panel.spacing.x = unit(0.8, "lines"),
- legend.text=element_text(size=15))+
- #legend.position="none")+
- geom_smooth(method=lm, se = FALSE)+
- #stat_cor()+
- facet_grid(~task,scales = "free")+
- #scale_shape_manual(values=c(3, 16))+
- #geom_vline(xintercept = 22.45,linetype="dashed", color = "black") +
- scale_color_manual(values=dark)+
- xlab("SVO score (z-scored)")+
- ylab("Relative allocation")+
- labs(color = "Self-relevance")
- p_s2b
- ## Experiment 2
- Exp2_sub <- combinedData_sub %>%
- filter(experiment == "Experiment2")
- # figure S2e
- p_S2e <- ggplot(Exp2_sub, aes(x = condition, y = mean_allocation_ratio, fill = condition)) +
- geom_bar(stat = "summary", fun = "mean", colour = "black", position = "dodge") +
- geom_line(aes(group = subject),color = 'darkgray') +
- geom_point(aes(group = subject), shape = 21, color = 'darkgray') +
- stat_summary(fun.data = mean_cl_normal, na.rm =TRUE,
- geom = "errorbar", width = .2)+
- geom_hline(yintercept = 0.5,linetype="dashed", color = "black") +
- facet_grid(~task) +
- scale_fill_manual(values = dark) +
- theme_bw()+
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- axis.text.x = element_blank(),
- axis.ticks.x = element_blank(),
- axis.text.y = element_text(size = 15),
- plot.title = element_text(hjust = 0.5),
- legend.text=element_text(size=15)) +
- ylab("Relative allocation") +
- xlab(" ") +
- labs(fill = "Self-relevance", title = "Experiment 2")
- p_S2e
- # plot Figure S2f
- p_s2f<-Exp2_sub %>%
- ggplot(aes(x=SVOscore_z, y=mean_allocation_ratio, color=condition)) +
- geom_point(shape = 20,size=5,alpha = 0.5) +
- theme_bw() +
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.text.x = element_text(size = 15),
- axis.text.y = element_text(size = 15),
- panel.spacing.x = unit(0.8, "lines"),
- legend.text=element_text(size=15))+
- #legend.position="none")+
- geom_smooth(method=lm, se = FALSE)+
- #stat_cor()+
- facet_grid(~task,scales = "free")+
- #scale_shape_manual(values=c(3, 16))+
- #geom_vline(xintercept = 22.45,linetype="dashed", color = "black") +
- scale_color_manual(values=dark)+
- xlab("SVO score (z-scored)")+
- ylab("Relative allocation")+
- labs(color = "Self-relevance")
- p_s2f
- ## -------------- model S4: contribution on diff -------------------------------
- ## prepare data
- # calculate the differnece between self-relevant and self-irrelevant based on trial
- combinedData_contribution <- combinedData %>%
- pivot_wider(id_cols = c(experiment,subject,SVOscore_z,SVOscore,trial,task,contribution,performance_ratio),
- names_from = condition,
- values_from = allocation_ratio) %>%
- mutate(difference = `Self-relevant` - `Self-irrelevant`)
- exp1Data_contribution <- combinedData_contribution %>%
- filter(experiment == "Experiment1")
- exp2Data_contribution <- combinedData_contribution %>%
- filter(experiment == "Experiment2")
- ## model fitting
- #exp1
- fit_gaussian_c_diff_exp1 <- brm(
- bf(
- difference ~ contribution + (1 | subject)
- ),
- data = exp1Data_contribution,
- family = gaussian(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_gaussian_c_diff_exp1)
- saveRDS(fit_gaussian_c_diff_exp1, file = "output/exp1_fit_gaussian_c_diff.rds")
- #exp2
- fit_gaussian_c_diff_exp2 <- brm(
- bf(
- difference ~ contribution + (1 | subject)
- ),
- data = exp2Data_contribution,
- family = gaussian(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_gaussian_c_diff_exp2)
- saveRDS(fit_gaussian_c_diff_exp2, file = "output/exp2_fit_gaussian_c_diff.rds")
- ## post hoc
- fit_gaussian_c_diff_exp1 <- readRDS("multilevel_model/output/exp1_fit_gaussian_c_diff.rds")
- summary(fit_gaussian_c_diff_exp1)
- coef_table <- as.data.frame(summary(fit_gaussian_c_diff_exp1)$fixed)
- coef_table <- round(coef_table, 2)
- write.csv(coef_table, "multilevel_model/output/tables/TabS4-7_fit_zoib.csv", row.names = TRUE)
- fit_gaussian_c_diff_exp2 <- readRDS("multilevel_model/output/exp2_fit_gaussian_c_diff.rds")
- summary(fit_gaussian_c_diff_exp2)
- coef_table <- as.data.frame(summary(fit_gaussian_c_diff_exp2)$fixed)
- coef_table <- round(coef_table, 2)
- write.csv(coef_table, "multilevel_model/output/tables/TabS4-12_fit_zoib.csv", row.names = TRUE)
- # exp1
- emm <- emmeans(fit_gaussian_c_diff_exp1, ~ contribution, type = "response")
- contrast(emm, "pairwise")
- emm_2 <- emm %>% summary() %>% as.data.frame() %>%
- mutate(across(where(is.numeric), ~ round(.x, 2)))
- write.csv(emm_2, "multilevel_model/output/tables/TabS4-8_emms.csv", row.names = TRUE)
- gaussian_c_diff <- conditional_effects(fit_gaussian_c_diff_exp1, effects = "contribution")
- p <- plot(gaussian_c_diff, plot = FALSE)[[1]]+
- aes(color = contribution, fill = contribution)
- p +
- scale_color_manual(values = contribution_color) +
- scale_fill_manual(values = contribution_color) +
- theme_classic() +
- theme(text = element_text(size = 15)) +
- xlab("Contribution") +
- ylab("Self-allocation Bias") +
- ggtitle("Experiment 1")
- #exp2
- emm <- emmeans(fit_gaussian_c_diff_exp2, ~ contribution, type = "response")
- contrast(emm, "pairwise")
- emm_2 <- emm %>% summary() %>% as.data.frame() %>%
- mutate(across(where(is.numeric), ~ round(.x, 2)))
- write.csv(emm_2, "multilevel_model/output/tables/TabS4-13_emms.csv", row.names = TRUE)
- gaussian_c_diff <- conditional_effects(fit_gaussian_c_diff_exp2, effects = "contribution")
- p <- plot(gaussian_c_diff, plot = FALSE)[[1]]+
- aes(color = contribution, fill = contribution)
- p +
- scale_color_manual(values = contribution_color) +
- scale_fill_manual(values = contribution_color) +
- theme_classic() +
- theme(text = element_text(size = 15)) +
- xlab("Contribution") +
- ylab("Self-allocation Bias") +
- ggtitle("Experiment 2")
- ## ------------- model S5: including SVO score ------------------------------------------
- # exp1
- fit_gaussian_c_diff_SVO_exp1 <- brm(
- bf(
- difference ~ contribution * SVOscore_z + (1 | subject)
- ),
- data = exp1Data_contribution,
- family = gaussian(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_gaussian_c_diff_SVO_exp1)
- saveRDS(fit_gaussian_c_diff_SVO_exp1, file = "output/exp1_fit_gaussian_c_diff_SVO.rds")
- #exp2
- fit_gaussian_c_diff_SVO_exp2 <- brm(
- bf(
- difference ~ contribution * SVOscore_z + (1 | subject)
- ),
- data = exp2Data_contribution,
- family = gaussian(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_gaussian_c_diff_SVO_exp2)
- saveRDS(fit_gaussian_c_diff_SVO_exp2, file = "output/exp2_fit_gaussian_c_diff_SVO.rds")
- ## post hoc
- #exp1
- fit_gaussian_c_diff_SVO_exp1 <- readRDS("multilevel_model/output/exp1_fit_gaussian_c_diff_SVO.rds")
- slopes_SVO <- emtrends(fit_gaussian_c_diff_SVO_exp1, ~ contribution, var = "SVOscore_z")
- pairs(slopes_SVO)
- emm_2 <- slopes_SVO %>% summary() %>% as.data.frame() %>%
- mutate(across(where(is.numeric), ~ round(.x, 2)))
- write.csv(emm_2, "multilevel_model/output/tables/TabS4-10_emms.csv", row.names = TRUE)
- c_diff_svo <- conditional_effects(fit_gaussian_c_diff_SVO_exp1,
- effects = "SVOscore_z:contribution")
- p <- plot(c_diff_svo, plot = FALSE)[[1]]
- p + scale_color_manual(values = contribution_color) +
- scale_fill_manual(values = contribution_color) +
- theme_classic()+
- theme(text = element_text(size = 15))+
- xlab("SVOscore (z-score)")+
- ylab("Allocation Ratio") +
- ggtitle("Experiment 1")
- #exp2
- fit_gaussian_c_diff_SVO_exp2 <- readRDS("multilevel_model/output/exp2_fit_gaussian_c_diff_SVO.rds")
- slopes_SVO <- emtrends(fit_gaussian_c_diff_SVO_exp2, ~ contribution, var = "SVOscore_z")
- pairs(slopes_SVO)
- emm_2 <- slopes_SVO %>% summary() %>% as.data.frame() %>%
- mutate(across(where(is.numeric), ~ round(.x, 2)))
- write.csv(emm_2, "multilevel_model/output/tables/TabS4-15_emms.csv", row.names = TRUE)
- slopes_SVO <- emtrends(fit_gaussian_c_diff_SVO_exp2, ~ contribution, var = "SVOscore_z")
- pairs(slopes_SVO)
- c_diff_svo <- conditional_effects(fit_gaussian_c_diff_SVO_exp2,
- effects = "SVOscore_z:contribution")
- p <- plot(c_diff_svo, plot = FALSE)[[1]]
- p + scale_color_manual(values = contribution_color) +
- scale_fill_manual(values = contribution_color) +
- theme_classic()+
- theme(text = element_text(size = 15))+
- xlab("SVOscore (z-score)")+
- ylab("Allocation Ratio") +
- ggtitle("Experiment 2")
- ## ---------------------- plot Figure S3 ------------------------------------
- exp1Data_contribution_sub <- combinedData_contribution_sub %>%
- filter(experiment == "Experiment1")
- exp2Data_contribution_sub <- combinedData_contribution_sub %>%
- filter(experiment == "Experiment2")
- ## experiment 1
- # plot S3a
- p_s3a<-ggplot(exp1Data_contribution_sub, aes(x = contribution, y = mean_diff, fill = contribution)) +
- geom_bar(stat = "summary", fun = "mean", colour = "black")+
- geom_point(aes(group = subject), shape = 21, color = 'darkgray') +
- stat_summary(fun.data = mean_cl_normal, na.rm =TRUE,
- geom = "errorbar", width = .2)+
- scale_fill_manual(values = contribution_color) +
- theme_bw()+
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- axis.ticks.x = element_blank(),
- axis.text.y = element_text(size = 15),
- legend.position = "none") +
- ylab("Self allocation bias") +
- xlab(" ")
- p_s3a
- # plot s3b
- p_s3b <- exp1Data_contribution_sub %>%
- ggplot(aes(x=SVOscore_z, y=mean_diff, color=contribution)) +
- geom_point(shape = 20,size=5,alpha = 0.8) +
- theme_bw() +
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.text.x = element_text(size = 15),
- axis.text.y = element_text(size = 15),
- panel.spacing.x = unit(0.8, "lines"),
- legend.position = "none")+
- geom_smooth(method=lm, se = FALSE)+
- scale_color_manual("Contribution",values=contribution_color)+
- # stat_cor(p.accuracy = 0.001,size = 6)+
- xlab("SVO score (z-scored)")+ylab("Self allocation bias")
- p_s3b
- ## experiment 2
- # plot S3c
- p_s3c<-ggplot(exp2Data_contribution_sub, aes(x = contribution, y = mean_diff, fill = contribution)) +
- geom_bar(stat = "summary", fun = "mean", colour = "black")+
- geom_point(aes(group = subject), shape = 21, color = 'darkgray') +
- stat_summary(fun.data = mean_cl_normal, na.rm =TRUE,
- geom = "errorbar", width = .2)+
- scale_fill_manual(values = contribution_color) +
- theme_bw()+
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- axis.ticks.x = element_blank(),
- axis.text.y = element_text(size = 15),
- legend.position = "none") +
- ylab("Self allocation bias") +
- xlab(" ")
- p_s3c
- # plot s3d
- p_s3d <- exp2Data_contribution_sub %>%
- ggplot(aes(x=SVOscore_z, y=mean_diff, color=contribution)) +
- geom_point(shape = 20,size=5,alpha = 0.8) +
- theme_bw() +
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.text.x = element_text(size = 15),
- axis.text.y = element_text(size = 15),
- panel.spacing.x = unit(0.8, "lines"),
- legend.position = "none" )+
- geom_smooth(method=lm, se = FALSE)+
- scale_color_manual("Contribution",values=contribution_color)+
- # stat_cor(p.accuracy = 0.001,size = 6)+
- xlab("SVO score (z-scored)")+ylab("Self allocation bias")
- p_s3d
- ## -------------- Plot: contribution * contribution -----------------------
- combinedData_conditionContribution_cub <- combinedData %>%
- filter(!is.na(allocation_ratio)) %>%
- dplyr::select(experiment,contribution,subject,condition,allocation_ratio,SVOscore_z) %>%
- group_by(experiment,contribution,subject,condition) %>%
- dplyr::summarize(mean_allocation_ratio = mean(allocation_ratio),
- SVOscore_z = first(SVOscore_z)) %>%
- select(experiment, contribution,condition, subject, mean_allocation_ratio, SVOscore_z)
- combinedData_conditionContribution_cub$subject <- as.factor(combinedData_conditionContribution_cub$subject)
- p_s3 <- ggplot(combinedData_conditionContribution_cub, aes(x = condition, y = mean_allocation_ratio, fill = condition)) +
- geom_bar(stat = "summary", fun = "mean", colour = "black", position = "dodge") +
- geom_line(aes(group = subject),color = 'darkgray') +
- geom_point(aes(group = subject), shape = 21, color = 'darkgray') +
- stat_summary(fun.data = mean_cl_normal, na.rm =TRUE,
- geom = "errorbar", width = .2)+
- geom_hline(yintercept = 0.5,linetype="dashed", color = "black") +
- facet_grid(~contribution) +
- scale_fill_manual(values = dark) +
- theme_bw()+
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- axis.text.x = element_blank(),
- axis.ticks.x = element_blank(),
- axis.text.y = element_text(size = 15),
- plot.title = element_text(hjust = 0.5),
- legend.text=element_text(size=15)) +
- ylab("Relative allocation") +
- xlab(" ") +
- labs(fill = "Self-relevance")
- p_s3
- ## ------------------- Experiment 3 --------------------------------------------
- ## ------------------- prepare data --------------------------------------------
- Exp3_data <- read.csv(".../Exp3_data.csv", header = TRUE)
- # add svo score
- SVOdataExp3 <-read.csv(".../Exp3_SVOscore.csv", header = TRUE)
- Exp3_data <- Exp3_data %>%
- left_join(SVOdataExp3, by = "subject") %>%
- mutate(experiment = 'Experiment3')
- Exp3_data <- Exp3_data %>%
- filter( winorloss=="Rewards") %>%
- mutate( contribution = case_when((performance1 >= threshold & performance2 < threshold)~"Player1 only",
- (performance2 >= threshold & performance1 < threshold)~"Player2 only",
- TRUE ~"Both"),
- p_source = case_when((condition == "SforS" | condition == "SforO") ~"Self-relevant",
- (condition == "OforS" | condition == "OforO") ~"Self-irrelevant"),
- a_target = case_when((condition == "SforS" | condition == "OforS") ~"Self-relevant",
- (condition == "SforO" | condition == "OforO") ~"Self-irrelevant")) %>%
- dplyr::select(subject,trial,task,condition,contribution,p_source, a_target, allocation_ratio,performance_ratio,SVOscore,experiment)
- # factorize variables
- Exp3_data$task <-factor(Exp3_data$task,c('Simple','Additive','Disjunctive'))
- Exp3_data$condition <- factor(Exp3_data$condition, c("SforS","OforS","SforO","OforO"))
- Exp3_data$p_source <- factor(Exp3_data$p_source,levels = c('Self-relevant','Self-irrelevant'))
- Exp3_data$a_target <- factor(Exp3_data$a_target,levels = c('Self-relevant','Self-irrelevant'))
- Exp3_data$contribution<-factor(Exp3_data$contribution,levels = c('Player1 only','Both','Player2 only'))
- Exp3_data$SVOscore_z <- scale(Exp3_data$SVOscore)
- ## ----------- model 1 task * performance source * allocation target -----------
- # task * performance source * allocation target
- fit_zoib_tpa <- brm(
- bf(
- allocation_ratio ~ task * p_source * a_target + (1 | subject)
- ),
- data = Exp3_data,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_tpa)
- saveRDS(fit_zoib_tpa, file = "output/exp3_fit_zoib_tpa.rds")
- # task + performance source + allocation target
- fit_zoib_tpa_noInt <- brm(
- bf(
- allocation_ratio ~ task + p_source + a_target + (1 | subject)
- ),
- data = Exp3_data,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_tpa_noInt)
- saveRDS(fit_zoib_tpa_noInt, file = "output/exp3_fit_zoib_tpa_noInt.rds")
- # allocation target
- fit_zoib_a <- brm(
- bf(
- allocation_ratio ~ a_target + (1 | subject)
- ),
- data = Exp3_data,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_a)
- saveRDS(fit_zoib_a, file = "output/exp3_fit_zoib_a.rds")
- ## compare model
- fit_zoib_tpa <- readRDS("multilevel_model/output/exp3_fit_zoib_tpa.rds")
- coef_table <- as.data.frame(summary(fit_zoib_tpa)$fixed)
- coef_table <- round(coef_table, 2)
- write.csv(coef_table, "multilevel_model/output/tables/TabS7-1_fit_zoib_tc.csv", row.names = TRUE)
- fit_zoib_tpa_noInt <- readRDS("output/exp3_fit_zoib_tpa_noInt.rds")
- fit_zoib_a <- readRDS("output/exp3_fit_zoib_a.rds")
- tpa_model <- loo(fit_zoib_tpa)
- tpa_noInt_model <- loo(fit_zoib_tpa_noInt)
- a_model <- loo(fit_zoib_a)
- loo_compare(tpa_model,tpa_noInt_model,a_model) #diff 2*SE
- ## post hoc
- # get the full model
- fit_zoib_tpa <- readRDS("multilevel_model/output/exp3_fit_zoib_tpa.rds")
- post_summary <- describe_posterior(fit_zoib_tpa)
- tab_df(post_summary,
- title = "Posterior Estimates",
- file = "multilevel_model/output/exp3_fit_zoib_tpa.html")
- # get the best model
- fit_zoib_a <- readRDS("multilevel_model/output/exp3_fit_zoib_a.rds")
- post_summary <- describe_posterior(fit_zoib_a)
- tab_df(post_summary,
- title = "Posterior Estimates",
- file = "multilevel_model/output/exp3_fit_zoib_a.html")
- summary(fit_zoib_a)
- # post hoc
- emm <- emmeans(fit_zoib_a, ~ a_target, type = "response")
- plot(emm)
- contrast(emm, "pairwise")
- # plot
- a <- conditional_effects(fit_zoib_a, effects = "a_target")
- p <- plot(a, plot = FALSE)[[1]]+
- aes(color = a_target)
- p +
- scale_color_manual(values = dark) +
- scale_fill_manual(values = dark) +
- theme_classic() +
- theme(text = element_text(size = 15)) +
- xlab("Allocation Target") +
- ylab("Allocation Ratio")
- ## post hoc
- # get the full model
- fit_zoib_tpa <- readRDS("multilevel_model/output/exp3_fit_zoib_tpa.rds")
- summary(fit_zoib_tpa)
- # post hoc
- emm <- emmeans(fit_zoib_tpa, ~ p_source|a_target, type = "response")
- plot(emm)
- contrast(emm, "pairwise")
- emm <- emmeans(fit_zoib_tpa, ~ a_target|p_source, type = "response")
- plot(emm)
- contrast(emm, "pairwise")
- # plot
- a <- conditional_effects(fit_zoib_tpa, effects = "p_source:a_target",
- conditions = list(task = c("Simple", "Additive", "Disjunctive")))
- p <- plot(a, plot = FALSE)[[1]]+
- aes(color = a_target)
- p +
- scale_color_manual(values = dark) +
- scale_fill_manual(values = dark) +
- theme_classic() +
- theme(text = element_text(size = 15)) +
- xlab("Performance source") +
- ylab("Allocation Ratio") +
- facet_wrap(~task, labeller = labeller(task = c("Simple", "Additive", "Disjunctive"))) # custom facet names
- ## ------------- model 2: task * p_source * a_target * SVO score ------------------------------------------
- # task * condition * SVOscore
- fit_zoib_tpa_SVO <- brm(
- bf(
- allocation_ratio ~ task * p_source * a_target * SVOscore_z + (1 | subject)
- ),
- data = Exp3_data,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_tpa_SVO)
- saveRDS(fit_zoib_tpa_SVO, file = "output/exp3_fit_zoib_tpa_SVO.rds")
- # a * SVOscore
- fit_zoib_a_SVO <- brm(
- bf(
- allocation_ratio ~ a_target * SVOscore_z + (1 | subject)
- ),
- data = Exp3_data,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_a_SVO)
- saveRDS(fit_zoib_a_SVO, file = "output/exp3_fit_zoib_a_SVO.rds")
- # compare model
- fit_zoib_tpa_SVO <- readRDS("multilevel_model/output/exp3_fit_zoib_tpa_SVO.rds")
- fit_zoib_a_SVO <- readRDS("multilevel_model/output/exp3_fit_zoib_a_SVO.rds")
- loo_compare( loo(fit_zoib_tpa_SVO), loo(fit_zoib_a_SVO))
- coef_table <- as.data.frame(summary(fit_zoib_a_SVO)$fixed)
- coef_table <- round(coef_table, 2)
- write.csv(coef_table, "multilevel_model/output/tables/TabS7-4_fit_zoib.csv", row.names = TRUE)
- # post hoc
- post_summary <- describe_posterior(fit_zoib_a_SVO)
- tab_df(post_summary,
- title = "Posterior Estimates",
- file = "multilevel_model/output/exp3_fit_zoib_a_SVO.html")
- slopes_SVO <- emtrends(fit_zoib_a_SVO, ~ a_target, var = "SVOscore_z")
- pairs(slopes_SVO)
- a_svo <- conditional_effects(fit_zoib_a_SVO,
- effects = "SVOscore_z:a_target")
- p <- plot(a_svo, plot = FALSE)[[1]]
- p + scale_color_manual(values = dark) +
- scale_fill_manual(values = dark) +
- theme_classic()+
- theme(text = element_text(size = 15))+
- xlab("SVOscore (z-score)")+
- ylab("Allocation Ratio")
- ## -------------------- model 3: performance ratio * a target -----------------
- ## model fitting
- fit_zoib_pa <- brm(
- bf(
- allocation_ratio ~ performance_ratio * a_target + (1 | subject)
- ),
- data = Exp3_data,
- family = zero_one_inflated_beta(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_zoib_pa)
- saveRDS(fit_zoib_pa, file = "output/exp3_fit_zoib_pa.rds")
- ## post hoc
- fit_zoib_pa <- readRDS("multilevel_model/output/exp3_fit_zoib_pa.rds")
- coef_table <- as.data.frame(summary(fit_zoib_pa)$fixed)
- coef_table <- round(coef_table, 2)
- write.csv(coef_table, "multilevel_model/output/tables/TabS7-5_fit_zoib.csv", row.names = TRUE)
- post_summary <- describe_posterior(fit_zoib_pa)
- tab_df(post_summary,
- title = "Posterior Estimates",
- file = "multilevel_model/output/exp3_fit_zoib_pa.html")
- slopes_a <- emtrends(fit_zoib_pa, ~ a_target, var = "performance_ratio")
- pairs(slopes_a)
- pa <- conditional_effects(fit_zoib_pa, effects = "performance_ratio:a_target")
- p_exp3_2c <- plot(pa, plot = FALSE)[[1]] +
- scale_color_manual(values = dark) +
- scale_fill_manual(values = dark) +
- theme_bw() +
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.text.x = element_text(size = 15),
- axis.text.y = element_text(size = 15),
- panel.spacing.x = unit(0.8, "lines"),
- legend.text=element_text(size=15))+
- xlab("Relative Performance")+
- ylab("Relative Allocation") +
- labs(color = "Allocation target", fill = "Allocation target")
- p_exp3_2c
- ## ---------------------- plot Figure exp3 2 A-C -------------------------------
- # data
- Exp3_data_sub <- Exp3_data %>%
- filter(!is.na(allocation_ratio)) %>%
- dplyr::select(experiment,task,subject,condition,allocation_ratio,SVOscore_z) %>%
- group_by(experiment,task,subject,condition) %>%
- dplyr::summarize(mean_allocation_ratio = mean(allocation_ratio),
- SVOscore_z = first(SVOscore_z)) %>%
- select(experiment, task,condition, subject, mean_allocation_ratio, SVOscore_z)
- Exp3_data_sub$subject <- as.factor(Exp3_data_sub$subject)
- p_exp3_2a <- ggplot(Exp3_data_sub, aes(x = condition, y = mean_allocation_ratio, fill = condition)) +
- geom_bar(stat = "summary", fun = "mean", colour = "black", position = "dodge") +
- # geom_line(aes(group = subject),color = 'gray') +
- geom_point(aes(group = subject), shape = 21, color = 'darkgray',size = 3) +
- stat_summary(fun.data = mean_cl_normal, na.rm =TRUE,
- geom = "errorbar", width = .2)+
- geom_hline(yintercept = 0.5,linetype="dashed", color = "black") +
- facet_grid(~task) +
- scale_fill_manual(values = color_four) +
- theme_bw()+
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- axis.text.x = element_blank(),
- axis.ticks.x = element_blank(),
- axis.text.y = element_text(size = 15),
- plot.title = element_text(hjust = 0.5),
- legend.text=element_text(size=15)) +
- ylab("Relative allocation") +
- xlab(" ") +
- labs(fill = "Self-relevance")
- p_exp3_2a
- p_exp3_2b<-Exp3_data_sub %>%
- ggplot(aes(x=SVOscore_z, y=mean_allocation_ratio, color=condition)) +
- geom_point(shape = 20,size=5,alpha = 0.5) +
- theme_bw() +
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.text.x = element_text(size = 15),
- axis.text.y = element_text(size = 15),
- panel.spacing.x = unit(0.8, "lines"),
- legend.text=element_text(size=15))+
- #legend.position="none")+
- geom_smooth(method=lm, se = FALSE)+
- #stat_cor()+
- facet_grid(~task,scales = "free")+
- #scale_shape_manual(values=c(3, 16))+
- scale_color_manual(values=color_four)+
- xlab("SVO score (z-scored)")+
- ylab("Relative allocation")+
- labs(color = "Allocation target")
- p_exp3_2b
- # plot Figure exp3 2b
- Exp3_data_sub <- Exp3_data %>%
- filter(!is.na(allocation_ratio)) %>%
- dplyr::select(experiment,task,subject,a_target,allocation_ratio,SVOscore_z) %>%
- group_by(experiment,task,subject,a_target) %>%
- dplyr::summarize(mean_allocation_ratio = mean(allocation_ratio),
- SVOscore_z = first(SVOscore_z)) %>%
- select(experiment, task,a_target, subject, mean_allocation_ratio, SVOscore_z)
- Exp3_data_sub$subject <- as.factor(Exp3_data_sub$subject)
- p_exp3_2b<-Exp3_data_sub %>%
- ggplot(aes(x=SVOscore_z, y=mean_allocation_ratio, color=a_target)) +
- geom_point(shape = 20,size=5,alpha = 0.5) +
- theme_bw() +
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.text.x = element_text(size = 15),
- axis.text.y = element_text(size = 15),
- panel.spacing.x = unit(0.8, "lines"),
- legend.text=element_text(size=15))+
- #legend.position="none")+
- geom_smooth(method=lm, se = FALSE)+
- #stat_cor()+
- facet_grid(~task,scales = "free")+
- #scale_shape_manual(values=c(3, 16))+
- scale_color_manual(values=dark)+
- xlab("SVO score (z-scored)")+
- ylab("Relative allocation")+
- labs(color = "Allocation target")
- p_exp3_2b
- ## -------------- model 4: contribution on diff -------------------------------
- ## prepare data
- # calculate the differnece between self-relevant and self-irrelevant based on trial
- Exp3_Data_contribution <- Exp3_data %>%
- pivot_wider(id_cols = c(subject,SVOscore_z,SVOscore,trial,task,contribution,performance_ratio, p_source),
- names_from = a_target,
- values_from = allocation_ratio) %>%
- mutate(difference = `Self-relevant` - `Self-irrelevant`)
- ## model fitting
- fit_gaussian_a_diff <- brm(
- bf(
- difference ~ contribution + (1 | subject)
- ),
- data = Exp3_Data_contribution,
- family = gaussian(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_gaussian_a_diff)
- saveRDS(fit_gaussian_a_diff, file = "output/exp3_fit_gaussian_a_diff.rds")
- ## post hoc
- fit_gaussian_a_diff <- readRDS("multilevel_model/output/exp3_fit_gaussian_a_diff.rds")
- post_summary <- describe_posterior(fit_gaussian_a_diff)
- tab_df(post_summary,
- title = "Posterior Estimates",
- file = "multilevel_model/output/exp3_fit_gaussian_a_diff.html")
- emm <- emmeans(fit_gaussian_a_diff, ~ contribution, type = "response")
- contrast(emm, "pairwise")
- gaussian_a_diff <- conditional_effects(fit_gaussian_a_diff, effects = "contribution")
- p <- plot(gaussian_a_diff, plot = FALSE)[[1]]+
- aes(color = contribution, fill = contribution)
- p +
- scale_color_manual(values = contribution_color) +
- scale_fill_manual(values = contribution_color) +
- theme_classic() +
- theme(text = element_text(size = 15)) +
- xlab("Contribution") +
- ylab("Self-allocation Bias")
- ## ------------- model 5: including SVO score ------------------------------------------
- fit_gaussian_a_diff_SVO <- brm(
- bf(
- difference ~ contribution * SVOscore_z + (1 | subject)
- ),
- data = Exp3_Data_contribution,
- family = gaussian(),
- chains = 8, cores = 8, iter = 3000, warmup = 1000
- )
- summary(fit_gaussian_a_diff_SVO)
- saveRDS(fit_gaussian_a_diff_SVO, file = "output/exp3_fit_gaussian_a_diff_SVO.rds")
- ## post hoc
- fit_gaussian_a_diff_SVO <- readRDS("multilevel_model/output/exp3_fit_gaussian_a_diff_SVO.rds")
- post_summary <- describe_posterior(fit_gaussian_a_diff_SVO)
- tab_df(post_summary,
- title = "Posterior Estimates",
- file = "multilevel_model/output/exp3_fit_gaussian_a_diff_SVO.html")
- slopes_SVO <- emtrends(fit_gaussian_a_diff_SVO, ~ contribution, var = "SVOscore_z")
- pairs(slopes_SVO)
- c_diff_svo <- conditional_effects(fit_gaussian_a_diff_SVO,
- effects = "SVOscore_z:contribution")
- p <- plot(c_diff_svo, plot = FALSE)[[1]]
- p + scale_color_manual(values = contribution_color) +
- scale_fill_manual(values = contribution_color) +
- theme_classic()+
- theme(text = element_text(size = 15))+
- xlab("SVOscore (z-score)")+
- ylab("Allocation Ratio")
- ## contribution data prep
- Exp3_Data_contribution_sub <- Exp3_Data_contribution %>%
- filter(!is.na(difference)) %>%
- dplyr::select(task,subject,contribution,difference,SVOscore_z) %>%
- group_by(subject,contribution) %>%
- dplyr::summarize(mean_diff = mean(difference),
- SVOscore_z = first(SVOscore_z)) %>%
- select(contribution, subject, mean_diff, SVOscore_z)
- Exp3_Data_contribution_sub$subject <- as.factor(Exp3_Data_contribution_sub$subject)
- # ---------------------------plot Figure exp3 2 DE------------------------------
- p_exp3_2d<-ggplot(Exp3_Data_contribution_sub, aes(x = contribution, y = mean_diff, fill = contribution)) +
- geom_bar(stat = "summary", fun = "mean", colour = "black")+
- geom_point(aes(group = subject), shape = 21, color = 'darkgray') +
- stat_summary(fun.data = mean_cl_normal, na.rm =TRUE,
- geom = "errorbar", width = .2)+
- scale_fill_manual(values = contribution_color) +
- theme_bw()+
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- axis.ticks.x = element_blank(),
- axis.text.y = element_text(size = 15),
- legend.position = "none") +
- ylab("Self allocation bias") +
- xlab(" ")
- p_exp3_2d
- # plot 2e
- p_exp3_2e <- Exp3_Data_contribution_sub %>%
- ggplot(aes(x=SVOscore_z, y=mean_diff, color=contribution)) +
- geom_point(shape = 20,size=5,alpha = 0.8) +
- theme_bw() +
- theme(text = element_text(size=20),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.text.x = element_text(size = 15),
- axis.text.y = element_text(size = 15),
- panel.spacing.x = unit(0.8, "lines"),
- legend.position = "none")+
- geom_smooth(method=lm, se = FALSE)+
- scale_color_manual("Contribution",values=contribution_color)+
- # stat_cor(p.accuracy = 0.001,size = 6)+
- xlab("SVO score (z-scored)")+ylab("Self allocation bias")
- p_exp3_2e
- ## ---------------------- ROI plots ------------------------------------------
- # dmPFC
- ROI_data <- read.csv(".../ROI_pmod_Main_effect_of_factor_2_12_28_52.csv", header = TRUE)
- # OFC r
- ROI_data <- read.csv(".../ROI_pmod_Main_effect_of_factor_2_40_48_-12.csv", header = TRUE)
- # OFC l
- ROI_data <- read.csv(".../ROI_pmod_Main_effect_of_factor_2_-42_50_-6.csv", header = TRUE)
- # TPJ r
- ROI_data <- read.csv(".../ROI_pmod_Main_effect_of_factor_2_44_-64_42.csv", header = TRUE)
- # TPJ l
- ROI_data <- read.csv(".../ROI_pmod_Main_effect_of_factor_2_-56_-64_30.csv", header = TRUE)
- # temporal r
- ROI_data <- read.csv(".../ROI_pmod_Main_effect_of_factor_2_64_-38_-4.csv", header = TRUE)
- ROI_data <- ROI_data %>%
- mutate(
- Condition = case_when(Contribution < 4~"Self-relevant", Contribution >= 4~"Self-irrelevant"),
- Contribution = case_when(Contribution == 1|Contribution == 4~"Both", Contribution == 2|Contribution == 5~"Player1 only",Contribution == 3|Contribution == 6~"Player2 only"),
- Subject = Subject + 100) %>%
- arrange(Contribution,Condition,Subject)
- ROI_data$Subject<-factor(ROI_data$Subject)
- ROI_data$Condition<-factor(ROI_data$Condition, levels = c('Self-relevant','Self-irrelevant'))
- ROI_data$Contribution<-factor(ROI_data$Contribution, levels = c('Player1 only','Both','Player2 only'))
- ROI_data_contribution <- ROI_data %>%
- group_by(Contribution, Subject) %>%
- dplyr::summarize(ROI_beta_mean = mean(ROI_beta)) %>%
- ungroup()
- # plot
- p_roi<-ggplot(ROI_data_contribution, aes(x = Contribution, y = ROI_beta_mean, fill = Contribution)) +
- geom_bar(stat = "summary", fun = "mean", colour = "black")+
- geom_point(aes(group = Subject), shape = 21, color = 'darkgray', size = 4) +
- stat_summary(fun.data = mean_cl_normal, na.rm =TRUE,
- geom = "errorbar", width = .2)+
- scale_fill_manual(values = contribution_color) +
- theme_bw()+
- theme(text = element_text(size=25),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- axis.ticks.x = element_blank(),
- axis.text.y = element_text(size = 25),
- legend.position = "none") +
- ylab("Beta estimates") +
- xlab(" ")
- p_roi
GA_analysis_plot_code.R, no license · at the source
Overview
- State Key Laboratory of Cognitive Neuroscience and Learning & IDG/McGovern Institute for Brain Research, Faculty of Psychology, Beijing Normal University, Beijing, China
- Section Social Neuroscience, Department of General Psychiatry, University of Heidelberg, Heidelberg, Germany
- Chinese Institute for Brain Research, Beijing, China
- Institute for Systems Neuroscience, University Medical Center Hamburg-Eppendorf, Hamburg, Germany
Abstract
Human cooperation often involves performing joint tasks, where success relies on how collective rewards are allocated among cooperating parties based on their individual performance and contribution to task outcomes. However, it remains unclear whether and how individual performance and contribution give rise to self-related biases in such allocation decisions. Here, we developed a novel performance-based social allocation task that manipulated how individual performance contributed to joint outcomes. Across two experiments, participants exhibited a robust self-allocation bias: they allocated more rewards to themselves and disproportionately disregarded their own performance, particularly when their performance did not causally contribute to the joint outcome. This self-allocation bias was amplified in individuals with stronger individualistic social preferences, as measured by social value orientation. At the neural level, self-relevant (versus self-irrelevant) allocation decisions were associated with increased activity in the medial prefrontal cortex extending into the anterior cingulate cortex, insula, and temporoparietal junction (TPJ). Moreover, the dorsomedial prefrontal cortex, lateral orbitofrontal cortex, and TPJ tracked trial-by-trial variations in relative performance as a function of contribution structure, independent of self-relevance. Together, these findings suggest that self-allocation bias in performance-based decisions is unlikely to arise from distorted neural encodings of performance. Instead, self-interest may shape how contribution-structured performance information is used in social-allocation choices, providing a more precise account of how self-serving behavior emerges in cooperative contexts.
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 3 matches between paragraphs and lines of code.
OSF afdqs
Availability: 1 check, the latest on 30 September 2026: the link answers (HTTP 200)
- 30 September 2026: the link answers (HTTP 200)
1 file
- GA_analysis_plot_code.R, R, 1,769 lines, 3 matches
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;
- 1 script, each with its path and the digest of its content;
- 3 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 Availability
All data and analysis codes related to this paper are available and archived in Open Science Framework at 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, 30 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 4 authors, 10 MeSH terms, 5 funders, 91 references, 1 integrity notice.
Cite
This paper
Zhang, S., Yong, X., Ma, Y., & Korn, C. W. (2026). Self-allocation bias in performance-based cooperative decisions is driven by self-interest rather than distorted performance encoding. PLoS biology, 24(3), e3003694. https://
BibTeX
@article{zhang2026self,
author = {Zhang, Sihui and Yong, Xue and Ma, Yina and Korn, Christoph W.},
title = {{Self-allocation bias in performance-based cooperative decisions is driven by self-interest rather than distorted performance encoding}},
journal = {PLoS biology},
year = {2026},
month = mar,
volume = {24},
number = {3},
pages = {e3003694},
publisher = {PLOS},
issn = {1544-9173},
doi = {10.1371/
url = {https://
pmid = {41886463},
pmcid = {PMC13020808}
}
RIS
TY - JOUR
AU - Zhang, Sihui
AU - Yong, Xue
AU - Ma, Yina
AU - Korn, Christoph W.
TI - Self-allocation bias in performance-based cooperative decisions is driven by self-interest rather than distorted performance encoding
T2 - PLoS biology
J2 - PLoS Biol
PY - 2026
DA - 2026/
VL - 24
IS - 3
SP - e3003694
SN - 1544-9173
PB - PLOS
DO - 10.1371/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1371/
"type": "article-journal",
"title": "Self-allocation bias in performance-based cooperative decisions is driven by self-interest rather than distorted performance encoding",
"container-title": "PLoS biology",
"author": [
{
"family": "Zhang",
"given": "Sihui"
},
{
"family": "Yong",
"given": "Xue"
},
{
"family": "Ma",
"given": "Yina"
},
{
"family": "Korn",
"given": "Christoph W."
}
],
"container-title-short":
"volume": "24",
"issue": "3",
"page": "e3003694",
"DOI": "10.1371/
"PMID": "41886463",
"PMCID": "PMC13020808",
"ISSN": "1544-9173",
"publisher": "PLOS",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
3,
26
]
]
}
}
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: easystats, emmeans, ggpubr, 2 other tools, cognitive, 8 references
- [2] doi:10.1038/s41586-025-08705-9 [code]
- Basis functions for complex social decisions in dorsomedial frontal cortex.Journal: NatureIn common: ggpubr, ggplot2, tidyverse, cognitive, 8 references
- [3] doi:10.1038/s42003-022-04329-1 [code]
- Behavioral and neuro-cognitive bases for emergence of norms and socially shared realities via dynamic interaction.Journal: Communications biologyIn common: brms, tidyverse, 8 references
- [4] doi:10.1093/scan/nsad023 [code]
- Mentalizing in an economic games context is associated with enhanced activation and connectivity in the left temporoparietal junction.Journal: Social cognitive and affective neuroscienceIn common: cognitive, 9 references
- [5] doi:10.3758/s13415-026-01425-1 [code]
- Mindful minds: How group identity shapes brain and behavior in social decision-making.Journal: Cognitive, affective & behavioral neuroscienceIn common: cognitive, 9 references
- [6] doi:10.1093/scan/nsag030 [code]
- Delaying rewards reduces egoism bias during prosocial acts.Journal: Social cognitive and affective neuroscienceIn common: easystats, emmeans, ggpubr, 2 other tools, cognitive, 4 references
- [7] doi:10.7554/elife.87271 [code]
- Acute stress reduces effortful prosocial behaviour.Journal: eLifeIn common: emmeans, cowplot, ggpubr, 2 other tools, cognitive, 4 references
- [8] doi:10.7554/elife.92539 [code]
- A neurocomputational account of the link between social perception and social action.Journal: eLifeIn common: cognitive, 8 references
- [9] doi: [code]
- Neural integration of affective prosodic and semantic cues in non-literal forms of speech understandingJournal: Imaging neuroscience (Cambridge, Mass.)In common: easystats, emmeans, cowplot, 3 other tools, cognitive, 3 references
- [10] doi:10.1038/s41467-025-67853-8 [code]
- Active disambiguation guides inferring controllability and cause in social interactions.Journal: Nature communicationsIn common: brms, ggpubr, ggplot2, 1 other tool, 4 references
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, 1 script, and 3 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:f7a46e9907f43665…
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.1371/journal.pbio.3003694)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/doi/10.1371/journal.pbio.3003694.svg
:target: https://openscicode.org/badge/doi/10.1371/journal.pbio.3003694
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1371/journal.pbio.3003694"><img src="https://openscicode.org/badge/doi/10.1371/journal.pbio.3003694.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.
