This package provides reusable code for the analysis of risk & ambiguity task data, as developed by the Yale Decision Neuroscience Lab.
Simple invoke library(levylab.RNA) in your R session or your R code.
install.package('devtools')library(devtools)devtools::install_github('YaleDecisionNeuro/levylab.RNA')
For extracting model-based features, you will also need to install nlopt.
The analysis scripts in this repository expect a tidy CSV file with particular columns. Here's how you can get it from our current projects:
- From the root folder of PsychTaskFramework, run
exportTaskData(nameOfYourTask, outputFile). The script expects that your data are saved intasks/nameOfYourTask/data/; if they aren't, put them there. - Run
importFromPTF(outputFile).
- Get all the raw
.matfiles together in a single directory - let's call itoriginDirectory. - Run
importFromRawMat(file)on each.matfile in the repository.
- Merge all the .edat2 files in the task folder with E-Merge. (This will require a prior installation of E-Prime, even though you should be able to do this without an activated license.)
- Open the newly created merged file with E-DataAid and Save as/Export as "SPSS and StatView".
- Read in the exported file with R:
importFromEprimeSPSSExport(filename, choiceColumnName = "choice", discardOriginalColumns = FALSE). - Drop the columns that you don't need manually, or import with
discardOriginalColumns = FALSE. - Use or export to CSV as needed.
Run getModelFreeEstimates(decision_data) on a clean R&A data frame.
Run getModelBasedEstimates(decision_data) on a clean R&A data frame.
- Save the clean R&A data frame as CSV with
write.csv(clean.df, paste0('clean/', filename), row.names = FALSE). - Locate the matlab files with
system.file("matlab", "fit_matlab_model.m", package = "levylab.RNA"). - Change the clean choice file location in that file accordingly and run in Matlab.