SHARE
TWEET

Untitled

a guest Sep 6th, 2019 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. data_path <-"C:/Users/willidon/Box Sync/ICC/RawData/Study1-Stroop"
  2. files_t1 <- list.files(data_path, pattern = "*1.csv")
  3. files_t2 <- list.files(data_path, pattern = "*2.csv")
  4.  
  5.  
  6.  
  7. long_stroop <- foreach(i=seq_along(files_t1), .combine = "rbind") %do% {
  8.   # For time 1
  9.   tmp_t1 <- read.csv(file.path(data_path, files_t1[i]), header = F) %>%
  10.     mutate(subj_num = i,
  11.            time = 1)
  12.   # For time 2 (about 3 weeks apart)
  13.   tmp_t2 <- read.csv(file.path(data_path, files_t2[i]), header = F) %>%
  14.     mutate(subj_num = i,
  15.            time = 2)
  16.   # Condition (0 = congruent, 1=neutral, 2=incongruent),
  17.   # Correct (1) or incorrect (0),
  18.   # Reaction time is in seconds
  19.   names(tmp_t1)[1:6] <- names(tmp_t2)[1:6] <- c("Block", "Trial", "Unused",
  20.                                                 "Condition", "Correct", "RT")
  21.   rbind(tmp_t1, tmp_t2)
  22. }
  23.  
  24.  
  25. t1 <- long_stroop %>% filter(time == 1,
  26.                              Condition != 1,
  27.                              Correct ==1 & RT < 2 & RT > 0.2) %>%
  28.   mutate(time1 = 1, time2 = 0, cond = ifelse(Condition == 0, 0, 1 ))
  29.  
  30.  
  31.  
  32. t2 <- long_stroop %>% filter(time == 2,
  33.                              Condition != 1,
  34.                              Correct ==1 & RT < 2 & RT > 0.2) %>%
  35.   mutate(time1 = 0, time2 = 1, cond = ifelse(Condition == 0, 0, 1 ))
  36.  
  37. mvn_data <-  rbind.data.frame(t1, t2)
  38.  
  39.  
  40.  
  41.  
  42. library(brms)
  43. fit_mem <- brm(bf(RT ~ 0 +  time1 + time1:cond + time2 + time2:cond +
  44.                   (0 +  time1 + time1:cond + time2 + time2:cond | C |subj_num),  
  45.                   sigma ~ 0 +  time1 + time1:cond + time2 + time2:cond +
  46.                     (0 +  time1 + time1:cond + time2 + time2:cond | C | subj_num)),
  47.                 data = mvn_data, cores = 2, chains = 2, iter = 3000, inits = 0)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top