1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- ---
- title: "Blocked vs. Interleaved: How range contexts modulate time perception and its EEG signatures"
- author: "Cemre Baykan, Xiuna Zhu, Artyom Zinchenko, Zhuanghua Shi"
- date: "August 2023"
- ---
- ```{r setup, include=FALSE}
- knitr::opts_chunk$set(echo = TRUE)
- source('preproc_data.R')
- ```
- ```{r}
- m_dat= data_beh %>% dplyr::group_by(SubName,targetDur, cond, group) %>%
- dplyr::summarise(n = n(),m_err = mean(rep_err), se_err = sd(rep_err)/ sqrt(n))
- mm_dat= m_dat %>% dplyr::group_by(targetDur, cond, group) %>%
- dplyr::summarise(n = n(),mm_err = mean(m_err), mse_err = sd(m_err)/ sqrt(n))
- ```
- ```{r}
- m_dat_sub= m_dat %>% dplyr::group_by(SubName, cond, group) %>%
- dplyr::summarise(n = n(),mm_err = mean(m_err), mse_err = sd(m_err)/ sqrt(n))
- m_dat_sub %>% dplyr::group_by(cond, group) %>%
- dplyr::summarise(n = n(),mmm_err = mean(mm_err), mse_err = sd(mm_err)/ sqrt(n))
- ```
- ###plot
- ```{r}
- fig_mRep_exp1 = ggplot(mm_dat,
- aes(targetDur, mm_err, group = interaction(cond, group), color = cond)) +
- geom_point(size = 0.8) + geom_hline(yintercept = 0, linetype="dashed")+
- geom_line(data = mm_dat, size=0.8) +
- geom_errorbar(aes(ymin = mm_err- mse_err , ymax = mm_err + mse_err), width = 0.02) +
- theme_new + scale_color_manual(values = colors_plot) +
- theme(strip.background = element_blank()) +
- scale_x_continuous(breaks= c(400, 570, 800,1200,1700,2400), labels=c("400","566","800","1200","1700","2400"))+
- scale_y_continuous(breaks= c(-200, -100, 0,100,200), labels=c("-200","-100","0","100","200"))+
- labs(x = 'Target interval (ms)', y = 'Reproduction error (ms)', shape= '', color='')+ theme(legend.position=c(0.9,0.95))+ggtitle("")+
- theme(plot.title =element_text(size=12,face='bold'))
- #ggsave(file.path('figures','fig_beh.png'), fig_mRep_exp1, width = 4.3, height = 2.7)
- fig_mRep_exp1
- ```
- # LMM
- ```{r}
- m_dat$targetDur_n= m_dat$targetDur-1200
- m_dat$cond = as.factor(m_dat$cond)
- m_dat$group = as.factor(m_dat$group)
- m_dat= m_dat%>% dplyr::mutate(group= factor(group,levels=c("Upper","Lower")))
- contrasts(m_dat$cond) = contr.Sum(levels(m_dat$cond))
- contrasts(m_dat$group) = contr.Sum(levels(m_dat$group))
- ```
- ```{r}
- # fit the linear mixed model
- lmm2 = lmer(m_err ~ targetDur_n+ cond+ group+
- targetDur_n:cond + cond:group + # fixed effect and interaction
- (1|SubName), # random effect
- data = m_dat)
- #output as table
- tab_model(lmm2, p.val = 'kr') # Kenward-Roger approximation, alternative 'satterthwaite' approxmiation
- ```
|