OSCR

Oxytocin modulates the neurocomputational mechanisms engaged in learning rank relationships in social networks.

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] § Materials and Methods › Behavioral Analysis. ↔ behavior data/oxtfmri.R, lines 564–625 · score 0.65 · linear mixed model, lme4, LMM, lmer, RT, Block

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 · 657 lines · 36 KB · no license · 1 match

  1. rm(list = ls())
  2. library(plyr)
  3. library(dplyr)
  4. library(tibble)
  5. library(tidyr)
  6. library(ggplot2)
  7. library(fpc)
  8. library(car)
  9. library(ez)
  10. library(HH)
  11. library(reshape)
  12. library(RColorBrewer)
  13. library(Rmisc)
  14. library(sjstats)
  15. library(gridExtra)
  16. library(lme4)
  17. library(nlme)
  18. library(utils)
  19. library(phia)
  20. library(pastecs)
  21. library(psych)
  22. library(ggpubr)
  23. library(ggsignif)
  24. library(emmeans)
  25. library(reshape)
  26. library(stringr)
  27. library(pbkrtest)
  28. library(EMAtools)
  29. library(lmerTest)
  30. library(remotes)
  31. library(parallel)
  32. library(broom)
  33. library(MuMIn)
  34. library(rlist)
  35. library(ggplot2)
  36. library(grImport)
  37. library(Rcpp)
  38. library(magick)
  39. library(grid)
  40. library(DMwR2)
  41. library(effsize)
  42. library(effects)
  43. library(report)
  44. library(TMB)
  45. library(sjPlot)
  46. library(sjmisc)
  47. library(psycho)
  48. library(parameters)
  49. library(performance)
  50. library(prediction)
  51. library(ggeffects)
  52. library(Cairo)
  53. library(xlsx)
  54. library(rJava)
  55. library(XLConnect)
  56. library(openxlsx)
  57. library(patchwork)
  58. library(scales)
  59. library(jsonlite)
  60. library(purrr)
  61. library(data.table)
  62. library(rio)
  63. library(cowplot)
  64. library(ggalt)
  65. library(tidyr)
  66. library(ggpattern)
  67. library(readxl)
  68. library(StanHeaders)
  69. library(qpcR)
  70. library(rlist)
  71. library(r2symbols)
  72. library(wesanderson)
  73. '%!in%' <- function(x,y)!('%in%'(x,y))
  74. # OT: sub
  75. # 3,4,5,6,8,10,14,15,19,[20],21,(22),25,29,30,31,32,33,37,38,39,40,41,43,46,50,51,53,56,60,61
  76. # Placebo: sub
  77. # 1,2,7,9,11,12,13,16,17,18,23,24,26,27,28,34,35,36,42,44,[45],47,48,49,52,54,55,57,58,59
  78. # sub47, has 4 runs, delete the 3rd
  79. # sub22---delete
  80. # sub20,45 --delete perfome
  81. ############ LEARN #############
  82. ####1. simple contrast coding ####
  83. #however,it's not work in some factor() related lmer.
  84. learndata_long3$Group = ordered(learndata_long3$Group, levels=c('Oxytocin','Placebo'))
  85. learndata_long3$S_O = ordered(learndata_long3$S_O, levels=c('Self','Other'))
  86. learndata_long3$Hierarchy1st = ordered(learndata_long3$Hierarchy1st, levels=c("Superior","Intermediate", "Inferior"))
  87. learndata_long3$Hierarchy2nd = ordered(learndata_long3$Hierarchy2nd, levels=c("Superior","Intermediate", "Inferior",'Unrelated'))
  88. learndata_long3$LR3rd = ordered(learndata_long3$LR3rd, levels=c('Greater than','Equal','Less than'))
  89. learndata_long3$Familiarity = ordered(learndata_long3$Familiarity, levels=c('Related','Unrelated'))
  90. #rename colname in contrast #!!!***name! not contrast it self!!!!2022
  91. colnames(attr(learndata_long3$Group, "contrasts")) <- c(" (PB)")
  92. colnames(attr(learndata_long3$S_O, "contrasts")) <- c(" (Others)")
  93. colnames(attr(learndata_long3$Hierarchy1st, "contrasts")) <- c(" (Sup > Inter)"," (Inf > Inter)")
  94. colnames(attr(learndata_long3$Hierarchy2nd, "contrasts")) <- c(" (Superior)"," (Inferior)"," (Unrelated)")
  95. colnames(attr(learndata_long3$LR3rd, "contrasts")) <- c(" (Greater)"," (Less)")
  96. colnames(attr(learndata_long3$Familiarity, "contrasts"))<- c(" (Related)")
  97. # 1.1 different with ramdon choice
  98. #block 4 starts to learn
  99. xtabs(~Block ,learndata_long33) #1390 1392 1390 1390 1392 1391 1392 1390 1391 [1390/2=695]
  100. try=xtabs(~(Block==7)+ ACC,learndata_long33)[2,] #true 0 1
  101. Trainramdon<-as.data.frame(matrix(nrow=9,ncol=2))
  102. for (i in 1:9)
  103. {Trainramdon[i,1]<- xtabs(~(Block==i)+ ACC,learndata_long33)[2,1]
  104. Trainramdon[i,2]<- xtabs(~(Block==i)+ ACC,learndata_long33)[2,2]}
  105. Trainramdonlist<-as.data.frame(matrix(nrow=length(unique(learndata_long33$Listname)),ncol=2))
  106. listnamenum=c('List23','List24','List25','List31','List32', 'List35','List36','List37','List43','List44',
  107. 'List26','List27','List38','List39',
  108. 'List28','List29','List30','List33', 'List34', 'List40','List41','List42','List45','List46') #unique(learndata_long33$Listname)
  109. for (i in 1:length(listnamenum))
  110. {Trainramdonlist[i,1]<- xtabs(~(Listname==listnamenum[i])+ ACC,learndata_long33)[2,1]
  111. Trainramdonlist[i,2]<- xtabs(~(Listname==listnamenum[i])+ ACC,learndata_long33)[2,2]}
  112. Trainchis<- list()
  113. for (ii in 1:length(listnamenum))
  114. {Trainchis$'X-squared'[ii]<- chisq.test(rbind(Trainramdonlist[ii,],c(522*2/3,522*1/3)))
  115. Trainchis$p[ii]<- chisq.test(rbind(Trainramdonlist[ii,],c(348,174)))[3] }
  116. ### ACC numeric ####
  117. # 2021.4--derivsFdrop2int2drop
  118. vNglmernew<-list()
  119. vNglmernew[["derivsF"]]<-glmer(ACC~Group*S_O*Block*Hierarchy1st+ (1| Subject),data = learndata_long33, glmerControl(calc.derivs = F,optCtrl = list(maxfun=1e5)),family="binomial")
  120. vNglmernew[["derivsFdrop2int"]] <-update(vNglmernew[["derivsF"]], .~. -Group:S_O:Block:Hierarchy1st- Group:S_O:Hierarchy1st -Group:S_O:Block -Group:Block:Hierarchy1st -S_O:Block:Hierarchy1st ) # -2*2
  121. vNglmernew[["derivsFdrop2int2drop"]] <-update(vNglmernew[["derivsFdrop2int"]], .~. -Group:S_O -Group:Hierarchy1st -S_O:Block) #final!!!***
  122. #without block 1 guess--
  123. vNglmernew[["derivsFnob1"]]<-glmer(ACC~Group*S_O*Block*Hierarchy1st+ (1| Subject),data = learndata_long33[which(learndata_long33$Block != 1 ),],
  124. glmerControl(calc.derivs = F,optCtrl = list(maxfun=1e5)),family="binomial")
  125. vNglmernew[["derivsFdrop2intnob1"]] <-update(vNglmernew[["derivsFnob1"]], .~. -Group:S_O:Block:Hierarchy1st- Group:S_O:Hierarchy1st -Group:S_O:Block -Group:Block:Hierarchy1st -S_O:Block:Hierarchy1st ) # -2*2
  126. vNglmernew[["derivsFdrop2int2dropnob1"]] <-update(vNglmernew[["derivsFdrop2intnob1"]], .~. -Group:S_O -Group:Hierarchy1st -S_O:Block) #final!!!***
  127. #session for emmeans
  128. vNglmernew[["derivsS"]]<-glmer(ACC~Group*S_O*Session*Hierarchy1st+ (1| Subject),data = learndata_long33, glmerControl(calc.derivs = F,optCtrl = list(maxfun=1e5)),family="binomial")
  129. vNglmernew[["derivsSd1"]]<- update(vNglmernew[["derivsS"]], .~. -Group:S_O:Session:Hierarchy1st- Group:S_O:Hierarchy1st -Group:S_O:Session -Group:Session:Hierarchy1st -S_O:Session:Hierarchy1st )
  130. vNglmernew[["derivsSd2"]]<- update(vNglmernew[["derivsSd1"]], .~. -Group:S_O -Group:Hierarchy1st -S_O:Session) #***
  131. summary(vNglmernew[["derivsFdrop2int2drop"]])
  132. ### results ACC Nglmernew ####
  133. vNglmernew=vNglmernew[sort(names(vNglmernew))]
  134. vNglmernewAICSIN=cbind(sapply(vNglmernew,AIC),sapply(vNglmernew,BIC),sapply(vNglmernew,isSingular)) %>% as.data.frame()
  135. vNglmernewAICSIN<- vNglmernewAICSIN[order(vNglmernewAICSIN$V1),] #blocksubl3 13505.00 1
  136. vNglmernewsum=lapply(vNglmernew,summary)
  137. vNglmernewAnova=lapply(within(vNglmernew, rm(Null)),Anova) #must fixed
  138. vNglmernewanova=lapply(vNglmernew,anova)
  139. vNglmernewPCA=lapply(vNglmernew,rePCA) # proportion of variance in subject or other random effects
  140. vNglmernewcorr=lapply(vNglmernew,VarCorr) #random effects variance in std.dev whose small~0 !same PCA
  141. vNglmernewcohend=lapply(vNglmernew,function(i) {rbind(c(0,0,0),lme.dscore(i,learndata_long33, type="lme4"))}) # effect size Cohen's D
  142. #odds ratios
  143. vNglmernewse=lapply(vNglmernew,function(i) {sqrt(diag(vcov(i)))}) # se
  144. vNglmernewconfint=list() # estimated beita~
  145. vNglmernewconfintodd=list() # odds ratios~
  146. Est=list()
  147. LL=list() #%95
  148. UL=list()
  149. for (i in 1:length(vNglmernew)){
  150. vNglmernewconfint[[i]]= cbind( Est=fixef(vNglmernew[[i]]),LL=fixef(vNglmernew[[i]]) -1.96 * vNglmernewse[[i]],UL=fixef(vNglmernew[[i]]) +1.96 * vNglmernewse[[i]]) %>%
  151. as.data.frame()
  152. names(vNglmernewconfint)[i]=names(vNglmernew)[i]
  153. vNglmernewconfintodd[[i]]= exp(vNglmernewconfint[[i]]) %>% plyr::rename(c("Est" = "Odds ratios", 'LL'='Odds LL', 'UL'='Odds UL'))
  154. names(vNglmernewconfintodd)[i]=names(vNglmernew)[i] } # odds ratios~
  155. #result combine
  156. #cat(paste("'",names(vNglmernewpara[[i]]),"'", sep = "", collapse = ", "))
  157. vNglmernewpara=list()
  158. vNglmernewperform=list()
  159. for (i in 1:length(vNglmernew)){
  160. vNglmernewpara[[i]]= cbind(model_parameters(vNglmernew[[i]],effects="fixed", exponentiate = T),vNglmernewconfintodd[[i]],vNglmernewcohend[[i]] ) %>% # b~p + odds +cohend
  161. mutate_if(is.numeric, round, digits=3)
  162. names(vNglmernewpara)[i]=names(vNglmernew)[i]
  163. for (j in 1:nrow(vNglmernewpara[[i]])) {
  164. if(vNglmernewpara[[i]]$p[j] < 0.001 ){vNglmernewpara[[i]]$Coefficient[j] <- paste(vNglmernewpara[[i]]$Coefficient[j], c('***'))}
  165. else if(0.001 <= vNglmernewpara[[i]]$p[j] & vNglmernewpara[[i]]$p[j] < 0.01 ){vNglmernewpara[[i]]$Coefficient[j] <- paste(vNglmernewpara[[i]]$Coefficient[j], c('**'))}
  166. else if(0.01 < vNglmernewpara[[i]]$p[j]& vNglmernewpara[[i]]$p[j] < 0.05 ){vNglmernewpara[[i]]$Coefficient[j] <- paste(vNglmernewpara[[i]]$Coefficient[j], c('*'))}
  167. # else {vNglmernewpara[[i]]$p[j] <- paste(vNglmernewpara[[i]]$p[j],c('')) }
  168. }
  169. vNglmernewpara[[i]]$Parameter<-str_replace_all(vNglmernewpara[[i]]$Parameter,c(":"=" × "))
  170. # vNglmernewpara[[i]]$Parameter<-str_replace_all(vNglmernewpara[[i]]$Parameter,c(
  171. # "Hierarchy1st1" = "Hierarchy: Superior","Hierarchy1st2" = "Hierarchy: Inferior","S_O1"="S_O: Self",
  172. # "Hierarchy2nd1" = "Hierarchy: Superior","Hierarchy2nd2" = "Hierarchy: Inferior","Hierarchy2nd3" = "Hierarchy: Unrelated",
  173. # "Familiarity1" = "Inner Group: Related","Group1" ="Group: Oxytocin"))
  174. vNglmernewpara[[i]]<-subset(vNglmernewpara[[i]], select=names(vNglmernewpara[[i]])!='df_error')
  175. vNglmernewperform[[i]]= model_performance(vNglmernew[[i]]) %>% #AIC~
  176. mutate_if(is.numeric, round, digits=3)
  177. names(vNglmernewperform)[i]=names(vNglmernew)[i]
  178. }
  179. listsumlearnACC <- do.call("rbind", lapply(vNglmernewpara[c('derivsFdrop2int2drop',"derivsFdrop2int", "derivsF")],
  180. function(i) {as.data.frame(i,col.names =names(vNglmernewpara$derivsFdrop))}))
  181. ### pair test marginal effect
  182. #odds ratios!!!
  183. #1. hierachy ----|2021.4--derivsFdrop2int2drop --no
  184. derivsFdropHier1=emmeans(vNglmernew$derivsFdrop2int2drop,pairwise ~ "Hierarchy1st", type = "response", reverse = TRUE)
  185. CIderivsFdropHier1= confint(derivsFdropHier1,level = .95, type = "response") #all
  186. hier1mainodds= cbind(as.data.frame(derivsFdropHier1$contrasts),CIderivsFdropHier1$contrasts[names(CIderivsFdropHier1$contrasts) %in% c( "asymp.LCL" , "asymp.UCL" )]) %>%
  187. mutate_if(is.numeric, round, digits=3)
  188. #1. hierachy ----|2022.7--derivsSd2
  189. derivsFdropHierDB1=emmeans(vNglmernew$derivsSd2,pairwise ~ "Hierarchy1st", type = "response", reverse = TRUE)
  190. CIderivsFdropHierDB1= confint(derivsFdropHierDB1,level = .95, type = "response") #all
  191. hier1mainoddsDB1= cbind(as.data.frame(derivsFdropHierDB1$contrasts),CIderivsFdropHierDB1$contrasts[names(CIderivsFdropHierDB1$contrasts) %in% c( "asymp.LCL" , "asymp.UCL" )]) %>%
  192. mutate_if(is.numeric, round, digits=3)
  193. #1.1 SO
  194. derivsFdropSO1=emmeans(vNglmernew$derivsFdrop2int2drop,pairwise ~ "S_O", type = "response", reverse = TRUE) #odds ratios!!!
  195. CIderivsFdropSO1= confint(derivsFdropSO1,level = .95, type = "response") #all
  196. SO1mainodds= cbind(as.data.frame(derivsFdropSO1$contrasts),CIderivsFdropSO1$contrasts[names(CIderivsFdropSO1$contrasts) %in% c( "asymp.LCL" , "asymp.UCL" )]) %>%
  197. mutate_if(is.numeric, round, digits=3)
  198. emmeans(vNglmernew$derivsFdrop2int2drop,pairwise ~ Group|S_O, type = "response", reverse = TRUE) #no
  199. emmeans(vNglmernew$derivsFdrop2int2drop,pairwise ~ S_O|Group, type = "response", reverse = TRUE) #** both
  200. #2. group*block
  201. derivsFdropgrpbloc1=emmeans(vNglmernew$derivsFdrop2int2drop, pairwise~ Group|Block, at = list(Block = c(1:9)), type = "response", reverse = TRUE) #every all~
  202. CIderivsFdropgrpbloc1= confint(derivsFdropgrpbloc1,level = .95, type = "response") #no!
  203. grpblo1odds= cbind(as.data.frame(derivsFdropgrpbloc1$contrasts),CIderivsFdropgrpbloc1$contrasts[names(CIderivsFdropgrpbloc1$contrasts) %in% c( "asymp.LCL" , "asymp.UCL" )]) %>%
  204. mutate_if(is.numeric, round, digits=3)
  205. emmeans(vNglmernew$derivsFdrop2int2drop, pairwise~ Group:Block, at = list(Block = c(-16)), type = "response", reverse = TRUE) # *?
  206. emmeans(vNglmernew$derivsFdrop2int2drop,pairwise ~ Group:Block, type = "response", reverse = TRUE) #
  207. #3. SO*hier ----|2022.7--derivsSd2
  208. derivsFdropSohierDB1=emmeans(vNglmernew$derivsSd2, pairwise~ S_O|Hierarchy1st, type = "response", reverse = TRUE)
  209. CIderivsFdropSohierDB1= confint(derivsFdropSohierDB1,level = .95, type = "response") #intermediate
  210. Sohier1oddsDB= cbind(as.data.frame(derivsFdropSohierDB1$contrasts),CIderivsFdropSohierDB1$contrasts[names(CIderivsFdropSohierDB1$contrasts) %in% c( "asymp.LCL" , "asymp.UCL" )]) %>%
  211. mutate_if(is.numeric, round, digits=3)
  212. #4. hierachy*block
  213. derivsFdrophierbloc1=emmeans(vNglmernew$derivsFdrop2int2drop, pairwise~ Hierarchy1st|Block, at = list(Block = c(1:9)), type = "response", reverse = TRUE) #every all~
  214. CIderivsFdrophierbloc1= confint(derivsFdrophierbloc1,level = .95, type = "response") # except blo1 super&infer + blo8/9 inter&inferior
  215. hierblo1odds= cbind(as.data.frame(derivsFdrophierbloc1$contrasts),CIderivsFdrophierbloc1$contrasts[names(CIderivsFdrophierbloc1$contrasts) %in% c( "asymp.LCL" , "asymp.UCL" )]) %>%
  216. mutate_if(is.numeric, round, digits=3)
  217. #5.all in block
  218. derivsFdropbloc1=emmeans(vNglmernew$derivsFdrop2int2drop, pairwise~ Block, type = "response", at = list(Block = c(1:9))) #every all~
  219. CIderivsFdropbloc1= confint(derivsFdropbloc1,level = .95, type = "response")
  220. GlmerpairACCtrain= rbind.fill(hier1mainodds,SO1mainodds,grpblo1odds,Sohier1odds,hierblo1odds)
  221. for (j in 1:nrow(GlmerpairACCtrain)) {
  222. if(GlmerpairACCtrain$p.value[j] < 0.001 ){GlmerpairACCtrain$odds.ratio[j] <- paste(GlmerpairACCtrain$odds.ratio[j], c('***'))}
  223. else if(0.001 <= GlmerpairACCtrain$p.value[j] & GlmerpairACCtrain$p.value[j] < 0.01 ){GlmerpairACCtrain$odds.ratio[j] <- paste(GlmerpairACCtrain$odds.ratio[j], c('**'))}
  224. else if(0.01 < GlmerpairACCtrain$p.value[j]& GlmerpairACCtrain$p.value[j] < 0.05 ){GlmerpairACCtrain$odds.ratio[j] <- paste(GlmerpairACCtrain$odds.ratio[j], c('*'))}
  225. }
  226. ## main effect -A:B1/B2-
  227. convNglmernew= vector("list",length(vNglmernew))
  228. convFac= vector("list",length(names(ref_grid(vNglmernew[[length(vNglmernew)]])@levels)))
  229. for (i in 1:length(vNglmernew)){
  230. for (j in 1:length(names(ref_grid(vNglmernew[[i]])@levels))) {
  231. convFac[[j]]=emmeans(vNglmernew[[i]], as.formula(paste("pairwise ~",names(ref_grid(vNglmernew[[i]])@levels)[j])), adjust ="bonf")
  232. names(convFac)[j]=names(ref_grid(vNglmernew[[i]])@levels)[j]} #onelmer1[j]~ update the emmeans name!
  233. convNglmernew[[i]]=convFac
  234. names(convNglmernew)[i]=names(vNglmernew)[i] }
  235. ## interaction effect: simple effects-- A1/A2:B1/B2
  236. intervNglmernew= vector("list",length(vNglmernew))
  237. intervFac= vector("list",length(names(ref_grid(vNglmernew[[length(vNglmernew)]])@levels)))
  238. for (i in 1:length(vNglmernew)){
  239. for (j in 1:length(names(ref_grid(vNglmernew[[i]])@levels))) {
  240. intervFac[[j]]=joint_tests(vNglmernew[[i]], as.formula(paste("by='",names(ref_grid(vNglmernew[[i]])@levels)[j],"'", sep = "")))
  241. names(intervFac)[j]=names(ref_grid(vNglmernew[[i]])@levels)[j]}
  242. intervNglmernew[[i]]=intervFac
  243. names(intervNglmernew)[i]=names(vNglmernew)[i]}
  244. ####RT numeric####
  245. vNlmerRT<- list()
  246. vNlmerRT[["derivsF"]]<-lmerTest::lmer(RT~Group*S_O*Block*Hierarchy1st+ (1| Subject),data = learndata_long33,REML = F)
  247. vNlmerRT[["derivsFdrop2int"]]<-update(vNlmerRT[["derivsF"]], .~. -Group:S_O:Block:Hierarchy1st - S_O:Hierarchy1st:Block - Group:S_O:Hierarchy1st- Group:Block:Hierarchy1st -Group:S_O:Block) # but no main effect, the interaction is weird
  248. vNlmerRT[["derivsFdrop2int2drop"]]<-update(vNlmerRT[["derivsFdrop2int"]], .~. -Group:Hierarchy1st-Group:S_O ) # final!*** and group show marginal
  249. vNlmerRT[["derivsFdrop2int2drop1"]]<-update(vNlmerRT[["derivsFdrop2int2drop"]], .~. -Block:Hierarchy1st) # final!*** and group show marginal
  250. vNlmerRT[["derivsF"]]<-lmerTest::lmer(RT~Group*S_O*Block*Hierarchy1st+ (1| Subject),data = learndata_long33,REML = F)
  251. vNlmerRT[["derivsFdrop2int"]]<-update(vNlmerRT[["derivsF"]], .~. -Group:S_O:Block:Hierarchy1st - S_O:Hierarchy1st:Block - Group:S_O:Hierarchy1st- Group:Block:Hierarchy1st -Group:S_O:Block) # but no main effect, the interaction is weird
  252. vNlmerRT[["derivsFdrop2int2drop"]]<-update(vNlmerRT[["derivsFdrop2int"]], .~. -Group:Hierarchy1st-Group:S_O ) # final!*** and group show marginal
  253. vNlmerRT[["derivsFdrop2int2drop1"]]<-update(vNlmerRT[["derivsFdrop2int2drop"]], .~. -Block:Hierarchy1st) # final!*** and group show marginal
  254. ### results RT Nlmer ####
  255. vNlmerRT=vNlmerRT[sort(names(vNlmerRT))]
  256. vNlmerRTAICSIN=cbind(sapply(vNlmerRT,AIC),sapply(vNlmerRT,BIC),sapply(vNlmerRT,isSingular)) %>% as.data.frame()
  257. vNlmerRTAICSIN<- vNlmerRTAICSIN[order(vNlmerRTAICSIN$V1),]
  258. vNlmerRTsum=lapply(vNlmerRT,summary)
  259. vNlmerRTAnova=lapply(vNlmerRT,Anova)
  260. vNlmerRTanova=lapply(vNlmerRT,anova)
  261. vNlmerRTPCA=lapply(vNlmerRT,rePCA) # proportion of variance in subject or other random effects
  262. vNlmerRTcorr=lapply(vNlmerRT,VarCorr) # small~0 !same PCA
  263. vNlmerRTcohend=lapply(vNlmerRT,function(i) {rbind(c(0,0,0),lme.dscore(i,learndata_long33, type="lme4"))}) # effect size cohend
  264. #ODDS
  265. vNglmernewseRT=lapply(vNlmerRT,function(i) {sqrt(diag(vcov(i)))}) # se
  266. vNglmernewconfintRT=list() # estimated beita~
  267. vNglmernewconfintoddRT=list() # odds ratios~
  268. Est=list()
  269. LL=list() #%95
  270. UL=list()
  271. for (i in 1:length(vNlmerRT)){
  272. vNglmernewconfintRT[[i]]= cbind( Est=fixef(vNlmerRT[[i]]),LL=fixef(vNlmerRT[[i]]) -1.96 * vNglmernewseRT[[i]],UL=fixef(vNlmerRT[[i]]) +1.96 * vNglmernewseRT[[i]]) %>%
  273. as.data.frame()
  274. names(vNglmernewconfintRT)[i]=names(vNlmerRT)[i]
  275. vNglmernewconfintoddRT[[i]]= exp(vNglmernewconfintRT[[i]]) %>% plyr::rename(c("Est" = "Odds ratios", 'LL'='Odds LL', 'UL'='Odds UL'))
  276. names(vNglmernewconfintoddRT)[i]=names(vNlmerRT)[i]
  277. vNlmerRTcohend[[i]]=plyr::rename(vNlmerRTcohend[[i]],c("t" = "cohedt")) #double t in cohed so rename
  278. } # odds ratios~
  279. vNglmernewRTpara=list()
  280. vNglmernewperformRT=list()
  281. for (i in 1:length(vNlmerRT)){
  282. vNglmernewRTpara[[i]]= cbind(model_parameters(vNlmerRT[[i]],effects="fixed"),vNglmernewconfintoddRT[[i]],vNlmerRTcohend[[i]] )%>%
  283. mutate_if(is.numeric, round, digits=3)
  284. names(vNglmernewRTpara)[i]=names(vNlmerRT)[i]
  285. for (j in 1:nrow(vNglmernewRTpara[[i]])) {
  286. if(vNglmernewRTpara[[i]]$p[j] < 0.001 ){vNglmernewRTpara[[i]]$Coefficient[j] <- paste(vNglmernewRTpara[[i]]$Coefficient[j], c('***'))}
  287. else if(0.001 <= vNglmernewRTpara[[i]]$p[j] & vNglmernewRTpara[[i]]$p[j] < 0.01 ){vNglmernewRTpara[[i]]$Coefficient[j] <- paste(vNglmernewRTpara[[i]]$Coefficient[j], c('**'))}
  288. else if(0.01 < vNglmernewRTpara[[i]]$p[j]& vNglmernewRTpara[[i]]$p[j] < 0.05 ){vNglmernewRTpara[[i]]$Coefficient[j] <- paste(vNglmernewRTpara[[i]]$Coefficient[j], c('*'))}
  289. else {vNglmernewRTpara[[i]]$p[j] <- paste(vNglmernewRTpara[[i]]$p[j],c('')) }}
  290. vNglmernewRTpara[[i]]$Parameter<-str_replace_all(vNglmernewRTpara[[i]]$Parameter,c(":"=" × "))
  291. vNglmernewRTpara[[i]]<-subset(vNglmernewRTpara[[i]], select=names(vNglmernewRTpara[[i]])!='df_error')
  292. vNglmernewperformRT[[i]]= model_performance(vNlmerRT[[i]]) %>% #AIC~
  293. mutate_if(is.numeric, round, digits=3)
  294. names(vNglmernewperformRT)[i]=names(vNlmerRT)[i]}
  295. ### pair test marginal effect |2021.10--derivsF no
  296. emm_options((pbkrtest.limit = 30000))
  297. #1. hierachy ,pbkrtest.limit = 12518 ajust='bonferroni',
  298. derivsFdropHier1RT=emmeans(vNlmerRT$derivsFdrop2int2drop1,pairwise ~ "Hierarchy1st", type = "response", reverse = TRUE) #ESTIMATE
  299. CIderivsFdropHier1RT= confint(derivsFdropHier1RT,level = .95, type = "response") #all
  300. hier1mainoddsRT= cbind(as.data.frame(derivsFdropHier1RT$contrasts),CIderivsFdropHier1RT$contrasts[names(CIderivsFdropHier1RT$contrasts) %in% c( "asymp.LCL" , "asymp.UCL" )]) %>%
  301. mutate_if(is.numeric, round, digits=3)
  302. #2. group*block
  303. derivsFdropgrpbloc1RT=emmeans(vNlmerRT$derivsFdrop2int2drop1, pairwise~ Group|Block, at = list(Block = c(1:9)), type = "response", reverse = TRUE) #every all~
  304. CIderivsFdropgrpbloc1RT= confint(derivsFdropgrpbloc1RT,level = .95, type = "response") #no!
  305. grpblo1oddsRT= cbind(as.data.frame(derivsFdropgrpbloc1RT$contrasts),CIderivsFdropgrpbloc1RT$contrasts[names(CIderivsFdropgrpbloc1RT$contrasts) %in% c( "asymp.LCL" , "asymp.UCL" )]) %>%
  306. mutate_if(is.numeric, round, digits=3)
  307. #3. SO*group
  308. derivsFdropSogrp1RT=emmeans(vNlmerRT$derivsFdrop2int2drop1, pairwise~ S_O|Group, type = "response", reverse = TRUE)
  309. CIderivsFdropSogrp1RT= confint(derivsFdropSogrp1RT,level = .95, type = "response") #intermediate
  310. Sogrp1oddsRT= cbind(as.data.frame(derivsFdropSogrp1RT$contrasts),CIderivsFdropSogrp1RT$contrasts[names(CIderivsFdropSogrp1RT$contrasts) %in% c( "asymp.LCL" , "asymp.UCL" )]) %>%
  311. mutate_if(is.numeric, round, digits=3)
  312. #3.1 SO*hierachy
  313. derivsFdropSohier1RT=emmeans(vNlmerRT$derivsFdrop2int2drop1, pairwise~ S_O|Hierarchy1st, type = "response", reverse = TRUE)
  314. CIderivsFdropSohier1RT= confint(derivsFdropSohier1RT,level = .95, type = "response") #intermediate
  315. Sohier1oddsRT= cbind(as.data.frame(derivsFdropSohier1RT$contrasts),CIderivsFdropSohier1RT$contrasts[names(CIderivsFdropSohier1RT$contrasts) %in% c( "asymp.LCL" , "asymp.UCL" )]) %>%
  316. mutate_if(is.numeric, round, digits=3)
  317. #4. SO*block
  318. derivsFdropSObloc1RT=emmeans(vNlmerRT$derivsFdrop2int2drop1, pairwise~ S_O|Block, at = list(Block = c(1:9)), type = "response", reverse = TRUE) #every all~
  319. CIderivsFdropSObloc1RT= confint(derivsFdropSObloc1RT,level = .95, type = "response") # except blo1 super&infer + blo8/9 inter&inferior
  320. SOblo1oddsRT= cbind(as.data.frame(derivsFdropSObloc1RT$contrasts),CIderivsFdropSObloc1RT$contrasts[names(CIderivsFdropSObloc1RT$contrasts) %in% c( "asymp.LCL" , "asymp.UCL" )]) %>%
  321. mutate_if(is.numeric, round, digits=3) #blo5
  322. #5. group*block*SO
  323. derivsFdropgrpSOgrpbloc1RT=emmeans(vNlmerRT$derivsFdrop2int2drop1, pairwise~ S_O|Group|Block, at = list(Block = c(1:9)), type = "response", reverse = TRUE) #every all~
  324. CIderivsFdropSOgrpbloc1RT= confint(derivsFdropgrpSOgrpbloc1RT,level = .95, type = "response") #no!
  325. SOgrpblo1oddsRT= cbind(as.data.frame(derivsFdropgrpSOgrpbloc1RT$contrasts),CIderivsFdropSOgrpbloc1RT$contrasts[names(CIderivsFdropSOgrpbloc1RT$contrasts) %in% c( "asymp.LCL" , "asymp.UCL" )]) %>%
  326. mutate_if(is.numeric, round, digits=3)
  327. GlmerpairRTtrain= rbind.fill(hier1mainoddsRT,grpblo1oddsRT,Sogrp1oddsRT,SOblo1oddsRT,SOgrpblo1oddsRT,Sohier1oddsRT)
  328. for (j in 1:nrow(GlmerpairRTtrain)) {
  329. if(GlmerpairRTtrain$p.value[j] < 0.001 ){GlmerpairRTtrain$estimate[j] <- paste(GlmerpairRTtrain$estimate[j], c('***'))}
  330. else if(0.001 <= GlmerpairRTtrain$p.value[j] & GlmerpairRTtrain$p.value[j] < 0.01 ){GlmerpairRTtrain$estimate[j] <- paste(GlmerpairRTtrain$estimate[j], c('**'))}
  331. else if(0.01 < GlmerpairRTtrain$p.value[j]& GlmerpairRTtrain$p.value[j] < 0.05 ){GlmerpairRTtrain$estimate[j] <- paste(GlmerpairRTtrain$estimate[j], c('*'))}
  332. }
  333. #####…………………………##########
  334. ############ TEST #############
  335. ####1. simple contrast coding ####
  336. testdata_long3$Group = ordered(testdata_long3$Group, levels=c('Oxytocin','Placebo'))
  337. testdata_long3$S_O = ordered(testdata_long3$S_O, levels=c('Self','Other'))
  338. testdata_long3$THierarchy1st = ordered(testdata_long3$THierarchy1st, levels=c('Intermediate','1RankInterval', '2RankInterval', '3RankInterval'))
  339. testdata_long3$THierarchy2nd = ordered(testdata_long3$THierarchy2nd, levels=c('Superior', 'Intermediate', 'Inferior', 'Mix') )
  340. testdata_long3$TR3rd = ordered(testdata_long3$TR3rd, levels=c('Greater than','Equal','Less than'))
  341. contrasts(testdata_long3$Group)=solve(t(matrix(c(1/2,1/2, 1,-1), ncol=2)))[,2] # Oxytocin -0.5 Placebo 0.5 #lib{YawMMF}contr.simple(2)
  342. contrasts(testdata_long3$S_O)=solve(t(matrix(c(1/2,1/2, 1,-1), ncol=2)))[,2] # Self -0.5 Other 0.5 #
  343. contrasts(testdata_long3$Block)=contr.simple(9) #2-1 ~
  344. contrasts(testdata_long3$THierarchy1st)=solve(t(matrix(c(1/4,1/4,1/4,1/4, -1,1,0,0, -1,0,1,0, -1,0,0,1), ncol=4)))[,2:4]
  345. contrasts(testdata_long3$THierarchy2nd)=solve(t(matrix(c(1/4,1/4,1/4,1/4, 1,-1,0,0, 0,-1,1,0, 0,-1,0,1), ncol=4)))[,2:4]
  346. contrasts(testdata_long3$TR3rd)=solve(t(matrix(c(1/3,1/3,1/3, 1,-1,0, 0,-1,1), ncol=3)))[,2:3]
  347. #rename colname in contrast
  348. colnames(attr(testdata_long3$Group, "contrasts")) <- c(" (PB)")
  349. colnames(attr(testdata_long3$S_O, "contrasts")) <- c(" (Others)")
  350. colnames(attr(testdata_long3$THierarchy1st, "contrasts")) <- c(" (1RankInterval)"," (2RankInterval)"," (3RankInterval)")
  351. colnames(attr(testdata_long3$THierarchy2nd, "contrasts")) <- c(" (Superior)"," (Inferior)"," (Mix)")
  352. colnames(attr(testdata_long3$TR3rd, "contrasts")) <- c(" (Greater)"," (Less)")
  353. testdata_long3[c("Block","Group","S_O","THierarchy1st","THierarchy2nd","TR3rd")]=
  354. lapply(testdata_long3[c("Block","Group","S_O","THierarchy1st","THierarchy2nd","TR3rd")], as.factor)
  355. #### Treat as numeric####
  356. testdata_long33=testdata_long3
  357. testdata_long33$Block = as.numeric(testdata_long33$Block)
  358. ###ACC numeric####
  359. #
  360. vNglmertest<- list()
  361. #only self--Grop*block*self | 2021.4 final**
  362. vNglmertest[["derivsFS"]]<-glmer(ACC~Group*S_O*Block+ (1| Subject),data = testdata_long33, glmerControl(calc.derivs = F,optCtrl = list(maxfun=1e5)),family="binomial")
  363. vNglmertest[["derivsFSdrop"]]<-update(vNglmertest[["derivsFS"]], .~.- Group:S_O:Block-S_O:Block) #good!
  364. vNglmertest[["Tinterval1st"]]<-glmer(ACC~Group*S_O*Block*TRANK1st+ (1| Subject),data = testdata_long33, glmerControl(calc.derivs = F,optCtrl = list(maxfun=1e5)),family="binomial")
  365. vNglmertest[["Tinterval1stdrop"]]<-update(vNglmertest[["Tinterval1st"]], .~. -Group:S_O -S_O:TRANK1st
  366. -Group:S_O:Block -Group:S_O:TRANK1st - Group:Block:TRANK1st -S_O:Block:TRANK1st - Group:S_O:Block:TRANK1st) #
  367. ### results ACC test Nglmer report ####
  368. vNglmertest=vNglmertest[sort(names(vNglmertest))]
  369. vNglmertestAICSIN=cbind(sapply(vNglmertest,AIC),sapply(vNglmertest,BIC),sapply(vNglmertest,isSingular)) %>% as.data.frame()
  370. vNglmertestAICSIN<- vNglmertestAICSIN[order(vNglmertestAICSIN$V1),] #blocksubl3 13505.00 1
  371. vNglmertestsum=lapply(vNglmertest,summary)
  372. vNglmertestAnova=lapply(within(vNglmertest, rm(Null)),Anova) #must fixed
  373. vNglmertestanova=lapply(vNglmertest,anova)
  374. vNglmertestPCA=lapply(vNglmertest,rePCA) # proportion of variance in subject or other random effects
  375. vNglmertestcorr=lapply(vNglmertest,VarCorr) #random effects variance in std.dev whose small~0 !same PCA
  376. vNglmertestcohend=lapply(vNglmertest,function(i) {rbind(c(0,0,0),lme.dscore(i,testdata_long33, type="lme4"))}) # effect size cohend
  377. #vNglmertestACC= lapply(vNglmertest,model_performance)
  378. #odds ratios
  379. vNglmertestse=lapply(vNglmertest,function(i) {sqrt(diag(vcov(i)))}) # se
  380. vNglmertestconfint=list() # estimated beita~
  381. vNglmertestconfintodd=list() # odds ratios~
  382. Est=list()
  383. LL=list() #%95
  384. UL=list()
  385. for (i in 1:length(vNglmertest)){
  386. vNglmertestconfint[[i]]= cbind( Est=fixef(vNglmertest[[i]]),LL=fixef(vNglmertest[[i]]) -1.96 * vNglmertestse[[i]],UL=fixef(vNglmertest[[i]]) +1.96 * vNglmertestse[[i]]) %>%
  387. as.data.frame()
  388. names(vNglmertestconfint)[i]=names(vNglmertest)[i]
  389. vNglmertestconfintodd[[i]]= exp(vNglmertestconfint[[i]]) %>% plyr::rename(c("Est" = "Odds ratios", 'LL'='Odds LL', 'UL'='Odds UL'))
  390. names(vNglmertestconfintodd)[i]=names(vNglmertest)[i] } # odds ratios~95
  391. vNglmertestpara=list()
  392. vNglmertestperform=list()
  393. for (i in 1:length(vNglmertest)){
  394. vNglmertestpara[[i]]= cbind(model_parameters(vNglmertest[[i]],effects="fixed", exponentiate = T),vNglmertestconfintodd[[i]],vNglmertestcohend[[i]] ) %>% # b~p + odds +cohend
  395. mutate_if(is.numeric, round, digits=3)
  396. names(vNglmertestpara)[i]=names(vNglmertest)[i]
  397. for (j in 1:nrow(vNglmertestpara[[i]])) {
  398. if(vNglmertestpara[[i]]$p[j] < 0.001 ){vNglmertestpara[[i]]$Coefficient[j] <- paste(vNglmertestpara[[i]]$Coefficient[j], c('***'))}
  399. else if(0.001 <= vNglmertestpara[[i]]$p[j] & vNglmertestpara[[i]]$p[j] < 0.01 ){vNglmertestpara[[i]]$Coefficient[j] <- paste(vNglmertestpara[[i]]$Coefficient[j], c('**'))}
  400. else if(0.01 < vNglmertestpara[[i]]$p[j]& vNglmertestpara[[i]]$p[j] < 0.05 ){vNglmertestpara[[i]]$Coefficient[j] <- paste(vNglmertestpara[[i]]$Coefficient[j], c('*'))}
  401. else {vNglmertestpara[[i]]$p[j] <- paste(vNglmertestpara[[i]]$p[j],c('')) }}
  402. vNglmertestpara[[i]]$Parameter<-str_replace_all(vNglmertestpara[[i]]$Parameter,c(":"=" × "))
  403. vNglmertestpara[[i]]<-subset(vNglmertestpara[[i]], select=names(vNglmertestpara[[i]])!='df_error')
  404. vNglmertestperform[[i]]= model_performance(vNglmertest[[i]]) %>% #AIC~
  405. mutate_if(is.numeric, round, digits=3)
  406. names(vNglmertestperform)[i]=names(vNglmertest)[i]
  407. }
  408. listsumtestACC <- do.call("rbind", vNglmertestpara)
  409. listAICtestACC <-rbind.fill(vNglmertestperform)
  410. row.names(listAICtestACC)<- names(vNglmertestperform)
  411. ### pair test marginal
  412. ##odds ratio !!
  413. #1. group*block |derivsFSdrop---2021.10
  414. derivsFdropgrpbloctest1=emmeans(vNglmertest$derivsFSdrop, pairwise~ Group|Block, at = list(Block = c(1:9)), type = "response", reverse = TRUE) #every all~
  415. CIderivsFdropgrpbloctest1= confint(derivsFdropgrpbloctest1,level = .95, type = "response") #no!
  416. grpblo1oddstest= cbind(as.data.frame(derivsFdropgrpbloctest1$contrasts),CIderivsFdropgrpbloctest1$contrasts[names(CIderivsFdropgrpbloctest1$contrasts) %in% c("asymp.LCL", "asymp.UCL")]) %>%
  417. mutate_if(is.numeric, round, digits=3)
  418. #2.group*SO
  419. derivsFdropSogrptest1=emmeans(vNglmertest$derivsFSdrop, pairwise~ S_O|Group, type = "response", reverse = TRUE)
  420. CIderivsFdropSogrptest1= confint(derivsFdropSogrptest1,level = .95, type = "response") #intermediate
  421. Sogrp1oddstest= cbind(as.data.frame(derivsFdropSogrptest1$contrasts),CIderivsFdropSogrptest1$contrasts[names(CIderivsFdropSogrptest1$contrasts) %in% c("asymp.LCL", "asymp.UCL")]) %>%
  422. mutate_if(is.numeric, round, digits=3)
  423. GlmerpairACCtest= rbind.fill(grpblo1oddstest,Sogrp1oddstest)
  424. for (j in 1:nrow(GlmerpairACCtest)) {
  425. if(GlmerpairACCtest$p.value[j] < 0.001 ){GlmerpairACCtest$odds.ratio[j] <- paste(GlmerpairACCtest$odds.ratio[j], c('***'))}
  426. else if(0.001 <= GlmerpairACCtest$p.value[j] & GlmerpairACCtest$p.value[j] < 0.01 ){GlmerpairACCtest$odds.ratio[j] <- paste(GlmerpairACCtest$odds.ratio[j], c('**'))}
  427. else if(0.01 < GlmerpairACCtest$p.value[j]& GlmerpairACCtest$p.value[j] < 0.05 ){GlmerpairACCtest$odds.ratio[j] <- paste(GlmerpairACCtest$odds.ratio[j], c('*'))}
  428. }
  429. describetestACCRT=rBind(describeBy(testdata_long33~Group, mat=TRUE),describeBy(testdata_long33~S_O, mat=TRUE))
  430. set_theme(base = theme_classic(), axis.textsize = .9)
  431. PACCtest_LRSodds= plot_model(vNglmertest$derivsFSdrop, type = "est",wrap.labels = 50, axis.lim = c(0.1,5),show.values = TRUE, show.intercept = T, value.offset = .3,colors = c("blue","red"),title = '',
  432. axis.labels = rev(c("(Intercept)", "Group (PB)","S_O (Others)","Block" , "Group (PB) × S_O (Others)","Group (PB) × Block" ))) # value.size = 2,
  433. pACC_Test=c('PACCtest_LRSodds')
  434. lapply(pACC_Test,function(x){ggsave(file=paste("D:/fmriOT/faststone/",x,"png",sep="."),dpi = 300, width =14, height = 10, units = "cm",type="cairo",get(x))})
  435. #t1st interval
  436. plot_model(vNglmertest$Tinterval1stdrop, type = "est",wrap.labels = 50, axis.lim = c(0.1,5),show.values = TRUE, show.intercept = T, value.offset = .3,colors = c("blue","red"),title = '') # value.size = 2,
  437. plot_model(vNglmertest$Tinterval1st, type = "est",wrap.labels = 50, axis.lim = c(0.1,5),show.values = TRUE, show.intercept = T, value.offset = .3,colors = c("blue","red"),title = '') # value.size = 2,
  438. ####RT numeric####
  439. # LMM(Linear Mixed Model) with ML
  440. testdata_long33$RT=as.numeric(testdata_long33$RT)
  441. vNlmertestRT<- list()
  442. vNlmertestRT[["derivsFS"]]<-lmerTest::lmer(RT~Group*S_O*Block+ (1| Subject),data = testdata_long33, REML = F )
  443. vNlmertestRT[["derivsFSdrop"]]<-update(vNlmertestRT[["derivsFS"]], .~.- Group:S_O:Block-S_O:Group) #good!
  444. ### RT Nlmer report results ####
  445. vNlmertestRT=vNlmertestRT[sort(names(vNlmertestRT))]
  446. vNlmertestRTAICSIN=cbind(sapply(vNlmertestRT,AIC),sapply(vNlmertestRT,BIC),sapply(vNlmertestRT,isSingular)) %>% as.data.frame()
  447. vNlmertestRTAICSIN<- vNlmertestRTAICSIN[order(vNlmertestRTAICSIN$V1),]
  448. vNlmertestRTsum=lapply(vNlmertestRT,summary)
  449. vNlmertestRTAnova=lapply(vNlmertestRT,Anova)
  450. vNlmertestRTanova=lapply(vNlmertestRT,anova)
  451. vNlmertestRTPCA=lapply(vNlmertestRT,rePCA) # proportion of variance in subject or other random effects
  452. vNlmertestRTcorr=lapply(vNlmertestRT,VarCorr) # small~0 !same PCA
  453. vNlmertestRTcohend=lapply(vNlmertestRT,function(i) {rbind(c(0,0,0),lme.dscore(i,testdata_long33, type="lme4"))}) # effect size cohend
  454. #ODDS
  455. vNglmertestseRT=lapply(vNlmertestRT,function(i) {sqrt(diag(vcov(i)))}) # se
  456. vNglmertestconfintRT=list() # estimated beita~
  457. vNglmertestconfintoddRT=list() # odds ratios~
  458. Est=list()
  459. LL=list() #%95
  460. UL=list()
  461. for (i in 1:length(vNlmertestRT)){
  462. vNglmertestconfintRT[[i]]= cbind( Est=fixef(vNlmertestRT[[i]]),LL=fixef(vNlmertestRT[[i]]) -1.96 * vNglmertestseRT[[i]],UL=fixef(vNlmertestRT[[i]]) +1.96 * vNglmertestseRT[[i]]) %>%
  463. as.data.frame()
  464. names(vNglmertestconfintRT)[i]=names(vNlmertestRT)[i]
  465. vNglmertestconfintoddRT[[i]]= exp(vNglmertestconfintRT[[i]]) %>% plyr::rename(c("Est" = "Odds ratios", 'LL'='Odds LL', 'UL'='Odds UL'))
  466. names(vNglmertestconfintoddRT)[i]=names(vNlmertestRT)[i]
  467. vNlmertestRTcohend[[i]]=plyr::rename(vNlmertestRTcohend[[i]],c("t" = "cohedt")) #double t in cohed so rename
  468. } # odds ratios~
  469. vNglmertestRTpara=list()
  470. vNglmertestperformRT=list()
  471. for (i in 1:length(vNlmertestRT)){
  472. vNglmertestRTpara[[i]]= cbind(model_parameters(vNlmertestRT[[i]],effects="fixed"),vNglmertestconfintoddRT[[i]],vNlmertestRTcohend[[i]] )%>%
  473. mutate_if(is.numeric, round, digits=3)
  474. names(vNglmertestRTpara)[i]=names(vNlmertestRT)[i]
  475. for (j in 1:nrow(vNglmertestRTpara[[i]])) {
  476. if(vNglmertestRTpara[[i]]$p[j] < 0.001 ){vNglmertestRTpara[[i]]$Coefficient[j] <- paste(vNglmertestRTpara[[i]]$Coefficient[j], c('***'))}
  477. else if(0.001 <= vNglmertestRTpara[[i]]$p[j] & vNglmertestRTpara[[i]]$p[j] < 0.01 ){vNglmertestRTpara[[i]]$Coefficient[j] <- paste(vNglmertestRTpara[[i]]$Coefficient[j], c('**'))}
  478. else if(0.01 < vNglmertestRTpara[[i]]$p[j]& vNglmertestRTpara[[i]]$p[j] < 0.05 ){vNglmertestRTpara[[i]]$Coefficient[j] <- paste(vNglmertestRTpara[[i]]$Coefficient[j], c('*'))}
  479. else {vNglmertestRTpara[[i]]$p[j] <- paste(vNglmertestRTpara[[i]]$p[j],c('')) }}
  480. vNglmertestRTpara[[i]]$Parameter<-str_replace_all(vNglmertestRTpara[[i]]$Parameter,c(":"=" × "))
  481. vNglmertestRTpara[[i]]<-subset(vNglmertestRTpara[[i]], select=names(vNglmertestRTpara[[i]])!='df_error')
  482. vNglmertestperformRT[[i]]= model_performance(vNlmertestRT[[i]]) %>% #AIC~
  483. mutate_if(is.numeric, round, digits=3)
  484. names(vNglmertestperformRT)[i]=names(vNlmertestRT)[i]
  485. }
  486. listsumtestRT <- do.call("rbind",vNglmertestRTpara)
  487. listAICtestRT <-rbind.fill(vNglmertestperformRT[c( "derivsFS","derivsFSdrop")])
  488. row.names(listAICtestRT)<-c( "derivsFS","derivsFSdrop")
  489. ### pair test marginal effect
  490. emm_options((pbkrtest.limit = 30000))
  491. #1. group*block
  492. #derivsFS --2021.10--no
  493. derivsFdropgrpbloc1RTtest=emmeans(vNlmertestRT$derivsFSdrop, pairwise~ Group|Block, at = list(Block = c(1:9)), type = "response", reverse = TRUE) #every all~
  494. CIderivsFdropgrpbloc1RTtest= confint(derivsFdropgrpbloc1RTtest,level = .95, type = "response") #no!
  495. grpblo1oddsRTtest= cbind(as.data.frame(derivsFdropgrpbloc1RTtest$contrasts),CIderivsFdropgrpbloc1RTtest$contrasts[names(CIderivsFdropgrpbloc1RTtest$contrasts) %in% c( "asymp.LCL" , "asymp.UCL" )]) %>%
  496. mutate_if(is.numeric, round, digits=3)
  497. #4. SO*block
  498. derivsFdropSObloc1RTtest=emmeans(vNlmertestRT$derivsFSdrop, pairwise~ S_O|Block, at = list(Block = c(1:9)), type = "response", reverse = TRUE) #every all~
  499. CIderivsFdropSObloc1RTtest= confint(derivsFdropSObloc1RTtest,level = .95, type = "response") #
  500. SOblo1oddsRTtest= cbind(as.data.frame(derivsFdropSObloc1RTtest$contrasts),CIderivsFdropSObloc1RTtest$contrasts[names(CIderivsFdropSObloc1RTtest$contrasts) %in% c( "asymp.LCL" , "asymp.UCL" )]) %>%
  501. mutate_if(is.numeric, round, digits=3) #blo5
  502. GlmerpairRTtest= rbind.fill(grpblo1oddsRTtest,SOblo1oddsRTtest)
  503. for (j in 1:nrow(GlmerpairRTtest)) {
  504. if(GlmerpairRTtest$p.value[j] < 0.001 ){GlmerpairRTtest$estimate[j] <- paste(GlmerpairRTtest$estimate[j], c('***'))}
  505. else if(0.001 <= GlmerpairRTtest$p.value[j] & GlmerpairRTtest$p.value[j] < 0.01 ){GlmerpairRTtest$estimate[j] <- paste(GlmerpairRTtest$estimate[j], c('**'))}
  506. else if(0.01 < GlmerpairRTtest$p.value[j]& GlmerpairRTtest$p.value[j] < 0.05 ){GlmerpairRTtest$estimate[j] <- paste(GlmerpairRTtest$estimate[j], c('*'))}
  507. }
  508. #
  509. set_theme(base = theme_classic(), axis.textsize = .9)
  510. PRT_TRFSodds=plot_model(vNlmertestRT$derivsFSdrop, type = "est",wrap.labels = 50,axis.lim = c(-1,3),value.size = 4, show.values = TRUE, show.intercept = T, value.offset = .3,colors = c("blue","red"),title = '',
  511. axis.labels = rev(c('(Intercept)','Group (PB)','S_O (Others)','Block', 'Group (PB) × Block', 'S_O (Others) × Block')))

oxtfmri.R, no license · at the source

Overview

Authors: Jiawei Liu1,2,3,4, Chen Qu1,2, Rémi Philippe3,4, Siying Li1,2,5, Edmund Derrington3,4, Jean-Claude Dreher3,4
  1. Key Laboratory of Brain, Cognition and Education Sciences (South China Normal University), Ministry of Education, Guangzhou 510631, China
  2. School of Psychology, Center for Studies of Psychological Application, and Guangdong Key Laboratory of Mental Health and Cognitive Science, South China Normal University, Guangzhou 510631, China
  3. Laboratory of Neuroeconomics, Institut des Sciences Cognitives Marc Jeannerod, CNRS, Lyon 69675, France
  4. Université Claude Bernard Lyon 1, Lyon 69100, France
  5. Faculty of Education, Northeast Normal University, Changchun 130024, China
Dates: received 25 February 2026; accepted 30 April 2026; published online 15 June 2026; in print 23 June 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1073/pnas.2606871123 · PMID 42296342 · PMCID PMC13291526 · OpenAlex W7164835576
Open access: hybrid, a free copy (OpenAlex)
Status: code verified
Categories: human (organism)
Methods: Statistics, Preprocessing, fMRI & imaging
Keywords: oxytocin, social hierarchy, social memory, reinforcement learning
MeSH: Hierarchy, Social*, Learning*, Oxytocin*, Social Networking*, Adult, Amygdala, Female, Humans, Magnetic Resonance Imaging, Male, Memory, Prefrontal Cortex, Young Adult (* major topic)
Topic: Neuroendocrine regulation and behavior (Social Psychology, Psychology), according to OpenAlex
Funding: Agence Nationale de la Recherche (ANR-24-CE37-4261, ANR-21-CE37-0032, ANR-11-IDEX-007, ANR-11-LABX-0042); South China Normal University (22JJD19000)
Citations: not cited yet (Europe PMC); 60 references in the paper

Abstract

The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.

Repository

Its files are read in the Code ↔ Paper reader above, with 1 match between paragraphs and lines of code.

OSF wjbpz

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Languages: MATLAB (6), R (1)
Size: 69 files, 7 scripts
Software Heritage: not checked
Found in: “Data, Materials, and Software Availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: broom (1 file), car (1 file), cowplot (1 file), data.table (1 file), easystats (1 file), emmeans (1 file), ggplot2 (1 file), ggpubr (1 file), lme4 (1 file), lmerTest (1 file), nlme (1 file), patchwork (1 file), psych (1 file), reshape2 (1 file), tidyverse (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
7 files

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

Code and data availability statement

The paper has a code and data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

Read it in the paper: doi.org/10.1073/pnas.2606871123.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 6 authors, 4 keywords, 13 MeSH terms, 2 funders, 53 references.

Cite

This paper

Liu, J., Qu, C., Philippe, R., Li, S., Derrington, E., & Dreher, J.-C. (2026). Oxytocin modulates the neurocomputational mechanisms engaged in learning rank relationships in social networks. Proceedings of the National Academy of Sciences of the United States of America, 123(25), e2606871123. https://doi.org/10.1073/pnas.2606871123

BibTeX

@article{liu2026oxytocin,
author = {Liu, Jiawei and Qu, Chen and Philippe, Rémi and Li, Siying and Derrington, Edmund and Dreher, Jean-Claude},
title = {{Oxytocin modulates the neurocomputational mechanisms engaged in learning rank relationships in social networks}},
journal = {Proceedings of the National Academy of Sciences of the United States of America},
year = {2026},
month = jun,
volume = {123},
number = {25},
pages = {e2606871123},
publisher = {National Academy of Sciences},
issn = {0027-8424},
doi = {10.1073/pnas.2606871123},
url = {https://doi.org/10.1073/pnas.2606871123},
pmid = {42296342},
pmcid = {PMC13291526}
}

RIS

TY - JOUR
AU - Liu, Jiawei
AU - Qu, Chen
AU - Philippe, Rémi
AU - Li, Siying
AU - Derrington, Edmund
AU - Dreher, Jean-Claude
TI - Oxytocin modulates the neurocomputational mechanisms engaged in learning rank relationships in social networks
T2 - Proceedings of the National Academy of Sciences of the United States of America
J2 - Proc Natl Acad Sci U S A
PY - 2026
DA - 2026/06/15
VL - 123
IS - 25
SP - e2606871123
SN - 0027-8424
PB - National Academy of Sciences
DO - 10.1073/pnas.2606871123
UR - https://doi.org/10.1073/pnas.2606871123
LA - en
ER -

CSL-JSON

{
"id": "10.1073/pnas.2606871123",
"type": "article-journal",
"title": "Oxytocin modulates the neurocomputational mechanisms engaged in learning rank relationships in social networks",
"container-title": "Proceedings of the National Academy of Sciences of the United States of America",
"author": [
{
"family": "Liu",
"given": "Jiawei"
},
{
"family": "Qu",
"given": "Chen"
},
{
"family": "Philippe",
"given": "Rémi"
},
{
"family": "Li",
"given": "Siying"
},
{
"family": "Derrington",
"given": "Edmund"
},
{
"family": "Dreher",
"given": "Jean-Claude"
}
],
"container-title-short": "Proc Natl Acad Sci U S A",
"volume": "123",
"issue": "25",
"page": "e2606871123",
"DOI": "10.1073/pnas.2606871123",
"PMID": "42296342",
"PMCID": "PMC13291526",
"ISSN": "0027-8424",
"publisher": "National Academy of Sciences",
"URL": "https://doi.org/10.1073/pnas.2606871123",
"language": "en",
"issued": {
"date-parts": [
[
2026,
6,
15
]
]
}
}

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.1126/sciadv.aec9291 [code]
Computational mechanisms of perception in autism revealed using games inspired by rodent operant tasks.
Journal: Science advances
In common: nlme, psych, easystats, 10 other tools
[2] doi:10.1038/s41398-026-04010-9 [code]
Bullying victimization and brain development: a longitudinal structural magnetic resonance imaging study from adolescence to early adulthood.
Journal: Translational psychiatry
In common: nlme, psych, easystats, 9 other tools
[3] doi:10.1016/j.isci.2026.116747 [code]
Age and loneliness relate to reduced trust learning and alterations in amygdala function.
Journal: iScience
In common: nlme, easystats, car, 8 other tools
[4] doi:10.1016/j.celrep.2026.117505 [code]
Impaired spatial coding and neuronal hyperactivity in the medial entorhinal cortex of aged APP knock-in mice.
Journal: Cell reports
In common: nlme, easystats, car, 8 other tools
[5] doi:10.1093/braincomms/fcag279 [code]
Network flexibility facilitates treatment-induced recovery in post-stroke aphasia.
Journal: Brain communications
In common: psych, easystats, car, 8 other tools
[6] doi:10.1002/hbm.70605 [code]
BrainEnrich: Revealing Biological Insights for Imaging-Derived Phenotypes Through Transcriptomic Enrichment.
Journal: Human brain mapping
In common: nlme, easystats, broom, 8 other tools
[7] doi:10.1016/j.neuroimage.2026.122115 [code]
Midfrontal theta power relates to response speeding following frustrative nonreward.
Journal: NeuroImage
In common: psych, easystats, car, 8 other tools
[8] doi:10.1038/s41467-026-73865-9 [code]
Histamine shapes the neurocomputational dynamics of human learning.
Journal: Nature communications
In common: easystats, car, broom, 8 other tools
[9] doi:10.1126/sciadv.aeb8106 [code]
A thyroid hormone-mediated opsin switch initiates metamorphosis in a proto-vertebrate.
Journal: Science advances
In common: easystats, car, broom, 8 other tools
[10] doi:10.1038/s41467-026-71415-x [code]
Regional BOLD variability reflects microstructural maturation and neuronal ensheathment in the preterm infant cortex.
Journal: Nature communications
In common: nlme, psych, easystats, 7 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.