OSCR

Decomposing the neurocomputational mechanisms of deontological moral preferences.

Code ↔ Paper

1 match between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 1 match
  1. [1] § Methods › Computational modeling and model comparison ↔ code/modeling/model6_wrapper_code.R, lines 60–110 · score 0.57 · Model fitting, Chain, LOOIC, RStan

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

R · 163 lines · 5.5 KB · no license · 1 match

  1. rm(list=ls())
  2. # use behav data
  3. library(dplyr)
  4. library(loo)
  5. library(rstan)
  6. ALLDATA = read.csv("all_behav_data.csv")
  7. ALLDATA$con[ALLDATA$con == "many_default"] = 1
  8. ALLDATA$con[ALLDATA$con == "no_default"] = -1
  9. ALLDATA$con[ALLDATA$con == "one_default"] = 0
  10. ALLDATA$outcome[ALLDATA$outcome == "many"] = 1
  11. ALLDATA$outcome[ALLDATA$outcome == "one"] = 0
  12. ALLDATA$outcome[ALLDATA$outcome == ""] = -1
  13. ALLDATA$con <- sapply(ALLDATA$con, as.numeric)
  14. ALLDATA$outcome <- sapply(ALLDATA$outcome, as.numeric)
  15. #complete_rows <- complete.cases(ALLDATA[, colnames])
  16. #ALLDATA <- ALLDATA[complete_rows, ]
  17. #ALLDATA = ALLDATA%>%filter(outcome != -1)
  18. allSubjs = unique(ALLDATA$subject)
  19. N = length(allSubjs)
  20. T = table(ALLDATA$subject)
  21. Tsubj = as.vector(T)
  22. maxTrials <- max(Tsubj)
  23. many_pain <- array(0, c(N, maxTrials))
  24. many_num <- array(0, c(N, maxTrials))
  25. one_pain <- array(0, c(N, maxTrials))
  26. default_op <- array(0, c(N, maxTrials))
  27. chosen_op <- array(-1, c(N, maxTrials))
  28. for ( i in 1:N) {
  29. curSubj <- allSubjs[i]
  30. useTrials <- Tsubj[i]
  31. tmp <- subset(ALLDATA, ALLDATA$sub == curSubj)
  32. many_pain[i, 1:useTrials] <- tmp$many_pain
  33. many_num[i, 1:useTrials] <- tmp$many_num
  34. one_pain[i, 1:useTrials] <- tmp$one_pain
  35. default_op[i, 1:useTrials] <- tmp$con
  36. chosen_op[i, 1:useTrials] <- tmp$outcome
  37. }
  38. dataList <- list(
  39. N = N,
  40. T = maxTrials,
  41. Tsubj = Tsubj,
  42. many_pain = many_pain,
  43. many_num = many_num,
  44. one_pain = one_pain,
  45. default_op = default_op,
  46. chosen_op = chosen_op
  47. )
  48. ############model fitting###########################
  49. Model6 = stan("./Rawlsian_project/code/modeling/Model6.stan", data = dataList, pars = c('alpha', 'phi','tau', 'mu_alpha', 'mu_phi','mu_tau',
  50. 'Many_utility', 'One_utility', 'Chosen_utility',
  51. 'Unchosen_utility', 'log_lik', 'y_pred'),
  52. iter = 2000, warmup = 1000, chains = 4, cores = 5)
  53. ####################################################
  54. lik_Model6 <- loo::extract_log_lik(Model6, parameter_name = 'log_lik')
  55. ######################
  56. LOOIC_6<- loo::loo(lik_Model6, cores = 5)
  57. LOOIC_comparison <- print(compare(x = list(LOOIC_6)))
  58. #save(Model6, LOOIC_comparison, file ='model6_fitting.RData')
  59. traceplot(Model6, "alpha")
  60. traceplot(Model6, "phi")
  61. traceplot(Model6, "tau")
  62. stan_plot(Model6, "alpha", show_density=T)
  63. stan_plot(Model6, "phi", show_density=T)
  64. stan_plot(Model6, "tau", show_density=T)
  65. parVals <- rstan::extract(Model6, permuted = TRUE)
  66. alpha_list = apply(parVals$alpha, 2, mean)
  67. phi_list = apply(parVals$phi, 2, mean)
  68. mean_outcome = ALLDATA %>%
  69. dplyr::group_by(subject) %>%
  70. dplyr::summarise(meanoutcome = mean(outcome, na.rm = TRUE))
  71. mean_outcome = mean_outcome$meanoutcome
  72. param = as.data.frame(cbind(subid, alpha_list, phi_list, mean_outcome))
  73. write.csv(param, file = '/home/zohyos7/project_cpt/modeling/paramlist_Model6.csv', row.names = TRUE)
  74. Many_utility = apply(parVals[['Many_utility']], c(2,3), mean)
  75. One_utility = apply(parVals[['One_utility']], c(2,3), mean)
  76. Chosen_utility = apply(parVals[['Chosen_utility']], c(2,3), mean)
  77. Unchosen_utility = apply(parVals[['Unchosen_utility']], c(2,3), mean)
  78. write.csv(Many_utility, file = 'many_utility.csv', row.names = FALSE)
  79. write.csv(One_utility, file = 'one_utility.csv', row.names = FALSE)
  80. write.csv(Chosen_utility, file = 'chosen_utility.csv', row.names = FALSE)
  81. write.csv(Unchosen_utility, file = 'unchosen_utility.csv', row.names = FALSE)
  82. #Many_utility
  83. #One_utility
  84. parameters <- rstan::extract(Model6)
  85. parameters$y_pred[parameters$y_pred == -1] = NA
  86. y_pred_mean = apply(parameters$y_pred, c(2,3), mean)
  87. dim(y_pred_mean)
  88. y_pred_mean_sub = apply(y_pred_mean, 1 , mean, na.rm = T)
  89. chosen_op <- chosen_op
  90. chosen_op[chosen_op == -1] <- NA
  91. chosen_op
  92. chosen_op_mean_sub = apply(chosen_op, 1, mean, na.rm = T)
  93. chosen_op_mean_sub
  94. cor.test(y_pred_mean_sub, chosen_op_mean_sub)
  95. plot(y_pred_mean_sub*100, chosen_op_mean_sub*100)
  96. real_pred = cbind(y_pred_mean_sub*100, chosen_op_mean_sub*100)
  97. colnames(real_pred) <- c('predicted_choice', 'actual_choice')
  98. real_pred = data.frame(real_pred)
  99. ggplot(data = real_pred, aes(x = actual_choice, y = predicted_choice)) + geom_point(shape= 21, size = 2.5, stroke = 1, color = "skyblue", fill = '#3CAEA3',alpha = 0.7) +
  100. scale_color_distiller(palette = "RdPu") + theme_classic()+
  101. scale_y_continuous(labels = function(x) paste0(x, "%"))+ # Add percent sign
  102. scale_x_continuous(labels = function(x) paste0(x, "%"))+ # Add percent sign
  103. labs(x = "actual choice (percent of choosing MANY)", y = "predicted choice (percent of choosing MANY)")+ #add labels
  104. theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())+
  105. theme(plot.title = element_blank())+
  106. theme(axis.text = element_text(size = 11, color="black"))+ # Axis text
  107. theme(axis.line = element_line(color="black", size = 0.5))+
  108. theme(axis.ticks = element_line(size = 0.3))+
  109. theme(axis.title = element_text(size = 11))+ # Axis title text
  110. theme(axis.title.y = element_text(margin = margin(t = 0, r = 5, b = 0, l = 0)))+
  111. theme(axis.title.x = element_text(margin = margin(t = 5, r = 0, b = 10, l = 0)))+
  112. theme(legend.position = "right")+ # Legend on right
  113. theme(legend.text = element_text(size = 11))+ # Increase legend text size.
  114. theme(legend.key.size = unit(0.7, "cm"))+ # Make legend box larger
  115. theme(legend.title = element_blank()) # Remove legend title
  116. y_pred_mean_sub*100
  117. chosen_op_mean_sub*100

model6_wrapper_code.R, no license · at the source

Overview

Authors: Yoonseo Zoh1, Soyeon Kim2, Hackjin Kim3, M J Crockett1,4, Woo-Young Ahn2,5,6
  1. Department of Psychology, Princeton University, Princeton, NJ, USA
  2. Department of Psychology, Seoul National University, Seoul 08826, Korea
  3. School of Psychology, Korea University, Seoul, Korea
  4. University Center for Human Values, Princeton University, Princeton, NJ, USA
  5. Department of Brain and Cognitive Sciences, Seoul National University, Seoul, Korea
  6. AI Institute, Seoul National University, Seoul, Korea
Institutions: Princeton University (United States); Seoul National University (South Korea); Korea University (South Korea)
Journal: PNAS nexus, volume 5, issue 4, article pgag074
Dates: received 20 October 2025; accepted 5 March 2026; published online 7 April 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1093/pnasnexus/pgag074 · PMID 41969575 · PMCID PMC13064635 · OpenAlex W4415823290
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: human (organism)
Methods: Statistics, fMRI & imaging, Machine learning
Topic: Psychology of Moral and Emotional Judgment (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Funding: National Research Foundation (BK21 FOUR); Seoul National University (RS2021-II211343); National Research Foundation of Korea (RS-2024-00435727, RS-2022-KH125035, 5199990314123, RS-2021-II211343, RS-2025-00516410); Korea Foundation for Advanced Studies
Citations: not cited yet (Europe PMC); 61 references in the paper
Research resources: which is based on “Nipype” 1.2.0 RRID:SCR_002502

Abstract

Research on the neurocomputational mechanisms of moral judgment has typically focused on contrasting “utilitarian” preferences to impartially maximize aggregate welfare and “deontological” preferences that judge the morality of actions based on rules. However, there has been little work to decompose the cognitive subcomponents of deontological preferences. Here, we investigated the neurocomputational mechanisms underlying two types of deontological preferences (Rawlsian and Kantian) and their contrast with utilitarian preferences in an incentivized moral dilemma task. Participants repeatedly decided how to allocate harm between a single individual (“the one”) and a group of three to four individuals (“the group”). The task distinguished preferences for Rawlsian, Kantian, and utilitarian strategies by quantifying trade-offs among active harm, concern for the worst-off individual, and overall utility. Behaviorally, participants favored the Rawlsian strategy, preferring to impose more harm overall rather than disproportionately harm the one individual. Computational modeling revealed two dissociable dimensions of individual variability in Rawlsian preferences: (i) minimizing the maximum amount of harm delivered to a single person and (ii) subjective threshold of acceptable amount of harm imposed on one person. The combination of univariate and multivariate functional MRI analyses revealed the engagement of distinct brain regions in these two dimensions of Rawlsian preferences, which respectively mapped onto activity in mentalizing and valuation networks. Our results reveal the neurocomputational mechanisms guiding trade-offs between the welfare of one versus a larger group and highlight distinct roles for the mentalizing and valuation networks in shaping Rawlsian moral preferences.

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 1 match between paragraphs and lines of code.

OSF 2huxq

License: none: the authors keep all their rights
State: the link answers, verified on 29 September 2026
Evidence: files inventoried
Languages: R (3), Python (2), Stan (1)
Size: 25 files, 6 scripts
Software Heritage: not checked
Found in: “Data Availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: Stan (3 files), NumPy (2 files), pandas (2 files), PsychoPy (2 files), tidyverse (2 files), emmeans (1 file), ggplot2 (1 file), ggpubr (1 file), rstatix (1 file)
Availability: 1 check, the latest on 29 September 2026: the link answers (HTTP 200)
  • 29 September 2026: the link answers (HTTP 200)
6 files
At the source: osf.io/2huxq/

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;
  • 6 scripts, each with its path and the digest of its content;
  • 1 match 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

Behavioral data, analysis scripts, computational modeling, task code, and unthresholded statistical maps of fMRI data have been deposited in the OSF repository and are publicly available at https://osf.io/2huxq/ (60) (https://doi.org/10.17605/osf.io/2huxq).

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, 29 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 5 authors, 4 funders, 29 references, 1 RRID.

Cite

This paper

Zoh, Y., Kim, S., Kim, H., Crockett, M. J., & Ahn, W.-Y. (2026). Decomposing the neurocomputational mechanisms of deontological moral preferences. PNAS nexus, 5(4), pgag074. https://doi.org/10.1093/pnasnexus/pgag074

BibTeX

@article{zoh2026decomposing,
author = {Zoh, Yoonseo and Kim, Soyeon and Kim, Hackjin and Crockett, M J and Ahn, Woo-Young},
title = {{Decomposing the neurocomputational mechanisms of deontological moral preferences}},
journal = {PNAS nexus},
year = {2026},
month = apr,
volume = {5},
number = {4},
pages = {pgag074},
publisher = {Oxford University Press},
issn = {2752-6542},
doi = {10.1093/pnasnexus/pgag074},
url = {https://doi.org/10.1093/pnasnexus/pgag074},
pmid = {41969575},
pmcid = {PMC13064635}
}

RIS

TY - JOUR
AU - Zoh, Yoonseo
AU - Kim, Soyeon
AU - Kim, Hackjin
AU - Crockett, M J
AU - Ahn, Woo-Young
TI - Decomposing the neurocomputational mechanisms of deontological moral preferences
T2 - PNAS nexus
J2 - PNAS Nexus
PY - 2026
DA - 2026/04/07
VL - 5
IS - 4
SP - pgag074
SN - 2752-6542
PB - Oxford University Press
DO - 10.1093/pnasnexus/pgag074
UR - https://doi.org/10.1093/pnasnexus/pgag074
LA - en
ER -

CSL-JSON

{
"id": "10.1093/pnasnexus/pgag074",
"type": "article-journal",
"title": "Decomposing the neurocomputational mechanisms of deontological moral preferences",
"container-title": "PNAS nexus",
"author": [
{
"family": "Zoh",
"given": "Yoonseo"
},
{
"family": "Kim",
"given": "Soyeon"
},
{
"family": "Kim",
"given": "Hackjin"
},
{
"family": "Crockett",
"given": "M J"
},
{
"family": "Ahn",
"given": "Woo-Young"
}
],
"container-title-short": "PNAS Nexus",
"volume": "5",
"issue": "4",
"page": "pgag074",
"DOI": "10.1093/pnasnexus/pgag074",
"PMID": "41969575",
"PMCID": "PMC13064635",
"ISSN": "2752-6542",
"publisher": "Oxford University Press",
"URL": "https://doi.org/10.1093/pnasnexus/pgag074",
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
7
]
]
}
}

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.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 America
In common: PsychoPy, rstatix, emmeans, 5 other tools
[2] doi:10.1038/s41467-026-73865-9 [code]
Histamine shapes the neurocomputational dynamics of human learning.
Journal: Nature communications
In common: PsychoPy, rstatix, emmeans, 5 other tools
[3] doi:10.1523/eneuro.0076-26.2026 [code]
Exogenously Driven Neural Reactivation of Spatially Matching Visual Working-Memory Contents.
Journal: eNeuro
In common: PsychoPy, rstatix, emmeans, 5 other tools
[4] doi:10.1126/sciadv.aec9291 [code]
Computational mechanisms of perception in autism revealed using games inspired by rodent operant tasks.
Journal: Science advances
In common: Stan, rstatix, emmeans, 3 other tools
[5] doi:10.1186/s13229-026-00730-3 [code]
Predicting emotional valence in autism: a preregistered study in the Bayesian Brain framework.
Journal: Molecular autism
In common: Stan, rstatix, ggpubr, 4 other tools
[6] doi:10.1038/s41467-026-76675-1 [code]
Long-read proteogenomic atlas of human neuronal differentiation reveals isoform diversity informing neurodevelopmental risk mechanisms.
Journal: Nature communications
In common: rstatix, emmeans, ggpubr, 4 other tools
[7] doi:10.1093/bioinformatics/btag592 [code]
Network-based stratification of allele-specific expression reveals patient subgroups in Huntington's disease.
Journal: Bioinformatics (Oxford, England)
In common: rstatix, emmeans, ggpubr, 4 other tools
[8] doi:10.1093/braincomms/fcag255 [code]
Impaired consolidation of spatial memory during sleep in patients with leucine-rich glioma-inactivated 1-associated limbic encephalitis.
Journal: Brain communications
In common: rstatix, emmeans, ggpubr, 4 other tools
[9] doi:10.1016/j.isci.2026.116047 [code]
Deciding to simulate: Cognitive mechanisms of predicting the decisions of others.
Journal: iScience
In common: Stan, rstatix, emmeans, 2 other tools
[10] doi:10.34133/csbj.0042 [code]
Using Steady-State Visual Evoked Potentials to Characterize Wide-Ranging Retinopathy Linked to &lt;i&gt;CRB1&lt;/i&gt;: Implications for Clinical Trials.
Journal: Computational and structural biotechnology journal
In common: PsychoPy, emmeans, ggplot2, 3 other tools

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.

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: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.