R/loadData.R

# load data for CFS, 2AFC, Short Study Lists, FB, Q

#source("D:/Documents/R/fns.R")

#setwd("D:/documents/UMass/summer/2016/cfs_bayes")
#dir.home <- getwd()


require(dplyr)

dataFile <- file.path(dir.home, "data", 'cfs_afc_ss1_wFB_Q_noCheck.dat')
# find the data that was generated from the matlab files
data_test <- read.csv(dataFile)

dataFile <- file.path(dir.home, "data", 'cfs_afc_ss1_wFB_Q_noCheck_study.dat')
# find the data that was generated from the matlab files
data_study <- read.csv(dataFile)

# join by subject, and item
d <- inner_join(x=data_test,y=data_study, by=c('whichItem','subject')) %>%
  rename(., condition=condition.x) %>%
  mutate(., pas1 = plyr::mapvalues(studyResp, from=0:9, to=c(-1,3,2,1,0,0,1,2,3,NA))) %>%
  mutate(., pas2 = plyr::mapvalues(studyResp2, from=0:9, to=c(-1,3,2,1,0,0,1,2,3,NA))) %>%
  mutate(., condition = plyr::mapvalues(condition, from=1:4, to=c('not studied','word','cfs','binocular'))) %>%
  filter(., whichResp != NA | whichResp != 2)



itemsPre = unique(d$whichItem)
itemsPost = 1:128

d <- mutate(d, whichItem = plyr::mapvalues(whichItem, from=itemsPre, to=itemsPost))

nS <- lapply(d, FUN = max, na.rm=TRUE)

# add 1 to study resp because participants were instructed to use 0-3
nS$pas1 <- nS$pas1+1
nS$nPerCond <- nS$nItems / nS$nConds
nS$nStudy <- nS$nTrials * nS$nPresent
nS$whichItem <- length(unique(d$whichItem))

d <- mutate(d, pas1 = plyr::mapvalues(pas1, from=c(-1,NA), c('NR','fNS'))) %>%
  mutate(., pas2 = plyr::mapvalues(pas2, from=c(-1,NA), c('NR','fNS'))) %>%
  mutate(., condition=factor(condition,levels=c('not studied','word','cfs','binocular')))

#
# d[,c('subject','condition','whichItem','studyResp','studyResp2','pas1','pas2','list')] <-
#   lapply(d[,c('subject','condition','whichItem','studyResp','studyResp2','pas1','pas2','list')],
#          FUN=factor)



# don't want PAS as a factor, because there are
# vastly different numbers of each kind of response
# Do I want condition as factor? if it were, that would
# seem to make stronger claims (justified) about higher levels
# leading to higher recall rates
studyConds <- c("not studied","word","cfs","binoc")
cols <- c('black', 'cornflowerblue', 'darkgoldenrod1', 'red')
pasResps <- c("0","1","2","3")


cutoff = 3 # only look at CFS with PAS 2 or 1
nPresent = 2 # presented 3 times


# clean up
rm(data_study, data_test)
psadil/cfsBayes documentation built on May 24, 2017, 12:17 p.m.