-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
246 lines (185 loc) · 13.3 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
---
output:
md_document:
variant: markdown_github
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
[![Last-changedate](https://img.shields.io/badge/last%20change-`r gsub('-', '--', Sys.Date())`-brightgreen.svg)](https://github.com/bramzandbelt/cmdsddfeitc/commits/master)
[![minimal R version](https://img.shields.io/badge/R%3E%3D-`r as.character(getRversion())`-brightgreen.svg)](https://cran.r-project.org/)
[![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.3258148.svg)](https://zenodo.org/badge/doi/10.5281/zenodo.3258148.svg)
[![Code licence](https://img.shields.io/github/license/mashape/apistatus.svg)](http://choosealicense.com/licenses/mit/)
[![ORCiD](https://img.shields.io/badge/ORCiD-0000--0002--6491--1247-green.svg)](https://orcid.org/0000-0002-6491-1247)
# cmdsddfeitc - Research compendium for the report on the cognitive mechanisms of the defer-speedup and date-delay framing effects in intertemporal choice by Zandbelt
## Compendium DOI
[DOI: 10.5281/zenodo.3258148](https://doi.org/10.5281/zenodo.3258148)
The files at the URL above will generate the results as found in the preprint. The files hosted at [https://github.com/bramzandbelt/cmdsddfeitc/](https://github.com/bramzandbelt/cmdsddfeitc/) are the development versions and may have changed since the preprint was published.
## Author of this repository
Bram Zandbelt ([[email protected]](mailto:[email protected]))
## Published in:
TBA
<!-- TODO: Add PsyArXiv DOI and Bibliography -->
## Overview
The packagae `cmdsddfeitc` is a research compendium of the research project _Cognitive Mechanisms of the Defer-Speedup and Date-Delay Framing Effects in Intertemporal Choice_ by Bram Zandbelt. This project was conducted at the Donders Institute, Radboud University / Radboucumc, Nijmegen, the Netherlands, and registered at the Donders Centre for Cognitive Neuroimaging under project number 3017051.01 (DCCN PI: Roshan Cools).
This research compendium contains all data, code, and text associated with the above-mentioned publication and is organized as follows:
```
.
├── R
├── analysis
│ ├── bash
│ └── notebooks
├── data
│ ├── derivatives
│ └── raw
├── documents
│ ├── content
│ └── context
├── figures
│ ├── 03_computational_modeling_analysis
│ ├── 04_sanity_check_control_trial_performance
│ ├── 05_eda_grp
│ ├── 06_model_comparison_grp
│ ├── 07_observed_vs_predicted_performance_grp
│ ├── 08_analysis_of_model_parameters
│ └── 09_sanity_check_effect_framing_on_model_predicted_auc
├── man
├── metadata
│ └── raw
├── packrat
│ ├── lib
│ ├── lib-R
│ ├── lib-ext
│ └── src
└── reports
│ ├── 01_preprocessing_idv
│ ├── 02_eda_idv
│ ├── 03_computational_modeling_analysis_idv
│ ├── 04_sanity_check_control_trial_performance_grp
│ ├── 05_eda_grp
│ ├── 06_model_comparison_grp
│ ├── 07_observed_vs_predicted_performance_grp
│ ├── 08_analysis_of_model_parameters_grp
│ └── 09_sanity_check_effect_framing_on_model_predicted_auc_grp
``
The `R/` directory contains:
- R code specific to the present project; functions are organized into files (e.g. functions for plotting are in `plot_functions.R`)
The `analysis/` directory contains:
- R Markdown notebooks implementing the analyses (`notebooks/` directory), numbered in the order in which they should be run;
- shell scripts running the R Markdown notebooks with appropriate parameters, if any (`bash/` directory).
The `data/` directory contains:
- the raw performance data (`raw/` directory);
- the data derived from the raw data (`derivatives/` directory), organized by notebook name.
The `documents/` directory contains:
- documents describing the content of the experimental data (`content/` directory), such as codebooks;
- documents describing the context of the data (`context/` directory), such as ethics documents, data management plan, and preregistration;
- documents related to the report of this research project (`manuscript/` directory).
The `figures/` directory contains:
- visualizations of descriptive and inferential statistics, organized by notebook name.
The `man/` directory contains:
- documentation of objects inside the package, generated by `roxygen2`.
The `packrat/` directory contains:
- R packages the research compendium depends on; for more info see [https://rstudio.github.io/packrat/](https://rstudio.github.io/packrat/).
The `reports/` directory contains:
- static HTML versions of the knitted R Markdown notebooks, organized by notebook name.
Finally, this research compendium is associated with a number of online objects, including:
| object | archived version | development version |
| ------ | -------------------------------- | -------------------------------- |
| preregistration | [https://osf.io/rzqh9/](https://osf.io/rzqh9/) | NA |
| data management plan | [https://doi.org/10.6084/m9.figshare.4720978](https://doi.org/10.6084/m9.figshare.4720978) | NA |
| stimulus presentation code | [https://doi.org/10.5281/zenodo.3243777](https://doi.org/10.5281/zenodo.3243777) | [github.com/bramzandbelt/itch_time_framing_task](github.com/bramzandbelt/itch_time_framing_task) |
| cognitive modeling code | [https://doi.org/10.5281/zenodo.3243806](https://doi.org/10.5281/zenodo.3243806) | [https://github.com/bramzandbelt/itchmodel](https://github.com/bramzandbelt/itchmodel) |
## How to use
This repository is organized as an R package, called `cmdsddfeitc`. The R package structure was used to help manage dependencies, to take advantage of continuous integration for automated code testing and documentation, and to be able to follow a standard format for file organization. The package `cmdsddfeitc` depends on other R packages and non-R programs, which are listed below under [Dependencies](#Dependencies).
To download the package source as you see it on GitHub, for offline browsing, use this line at the shell prompt (assuming you have Git installed on your computer):
Install `cmdsddfeitc` package from Github:
- From R:
```
devtools::install_github("bramzandbelt/cmdsddfeitc")
```
- From the command line:
```
git clone https://github.com/bramzandbelt/cmdsddfeitc.git
```
Once the download is complete, open the file `cmdsddfeitc.Rproj` in RStudio to begin working with the package and compendium files. To reproduce all analyses, run the shell script `analysis/bash/run_all_analyses.sh`. This will run all RMarkdown notebooks in correct order. Note, however, that this will _not_ reproduce the computational modeling analyses performed in the document `03_computational_modeling_analysis.Rmd`), only the result of the optimizations. This is because optimization of all 708 models (59 participants (defer-speedup, N = 28; date-delay, N = 31), 6 parameterizations, 2 architectures) was done on a computer cluster and would take simply too long to run on a regular computer. In order to reproduce the computational modeling analyses, run `03_computational_modeling_analysis.Rmd` as a parameterized report with argument `optimize=TRUE`.
### Parameterization of analysis notebooks
The analyses can be customized, by specifying a number of parameters. Below is an overview of the parameters that can be set and the notebooks in which they are used.
* `participant_id`: the participant identifier (ranging from 1 to 93);
* `task`: the task from which to process the data:
* `defer_speedup`: intertemporal choice task with neutral, defer, and speedup frames;
* `date_delay`: intertemporal choice task with delay and date frames;
* `visualize`: whether or not to visualize the results (e.g. set to `FALSE` when fitting the model to the data);
* `optimize`: whether or not to optimize the parameter values (i.e. set to `FALSE` when only visualizing the data);
* `pars_from_file`: whether to use parameter values stored on disk (i.e. set to `TRUE` when visualizing the data)
* `algorithm`: specification of the optimization algorithm:
* `DEoptim`: differential evolution algorithm with (lower and upper) bound constraints;
* `DEoptimR`: differential evolution algorithm with (lower and upper) bound and nonlinear constraints (i.e. ensuring that P(LL choice|SS amount = 0) > 0.75 and P(LL choice| SS amount = LL amount) < 0.25);
* `model_name`: name of the model class to fit to the data, can be any of the following:
* `DDM`: Drift-diffusion model (fits choices and response times);
* `DFT_CRT`: Decision field theory (fits choices and response times);
* `DFT_C`: Decision field theory (fits choices only);
* `parameterization`: name of the parameterization to fit to the data:
* `time_scaling`: lets `\kappa` parameter of the time function vary between frames;
* `value_scaling`: lets `\mu` parameter of the value function vary between frames;
* `time_and_value_scaling`: lets `\kappa` parameter of the time function and `\mu` parameter of the value function vary between frames;
* `time_scaling_t0`: lets `\kappa` parameter of the time function and non-decision time (`t0`) vary between frames;
* `value_scaling_t0`: lets `\mu` parameter of the value function and non-decision time (`t0`) vary between frames;
* `time_and_value_scaling_t0`: lets `\kappa` parameter of the time function, `\mu` parameter of the value function, and non-decision time (`t0`) vary between frames;
* `bound_setting`: controls the lower and upper bounds on the model parameters:
* `standard`: uses parameter bounds specified in the preregistration document;
* `wide`: uses wider parameter bounds, allowing parameters values to account for 'reverse' framing effects (e.g. more LL choices for delay than date frames);
* `max_iter`: maximum iterations performed before optimization algorithm stops;
* `rel_tol`: tolerance of the optimization algorithm's stopping criterion;
* `n_pop_per_free_param`: number of population members per free parameter (see `NP` in `DEoptimR::JDEoptim` and `DEoptim::DEoptim.control`).
These parameter are used in the following analysis notebooks (indicated by their number only)
| parameter | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 |
| :--------------------- | -- | -- | -- | -- | -- | -- | -- | -- | -- |
| `participant_id` | X | X | X | | | | | | |
| `task` | | | | X | X | X | X | X | X |
| `visualize` | X | X | X | | | | | | |
| `optimize` | | | X | | | | | | |
| `pars_from_file` | | | X | | | | | | |
| `algorithm` | | | X | | | X | X | X | X |
| `model_name` | | | X | | | | | | |
| `parameterization` | | | X | | | | | | |
| `bound_setting` | | | X | | | | | | |
| `max_iter` | | | X | | | | | | |
| `rel_tol` | | | X | | | | | | |
| `n_pop_per_free_param` | | | X | | | | | | |
## Licenses
Manuscript: CC-BY-4.0 [http://creativecommons.org/licenses/by/4.0/](http://creativecommons.org/licenses/by/4.0/)
Code: MIT [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT), year: 2019, copyright holder: Bram B. Zandbelt
## Dependencies
Below is the output of `sessionInfo()`, showing version information about R, the OS, and attached or loaded packages:
```{r Gather session info}
sessionInfo()
```
Packrat takes care of dependencies.
Model optimization (notebook) was performed in R 3.5.1. on the Donders Institute computer cluster.
## Acknowledgment
This research project was funded through European Union’s Horizon 2020 research and innovation programme under the Marie Skłodowska-Curie grant agreement No. 703141 to Bram B. Zandbelt and through a Vici grant from the Netherlands Organization for Scientific Research (NWO; grant number 453-14-015) to Roshan Cools. I thank Roshan Cools (RC) for financial support and constructive feedback. I thank Ben Marwick for inspiration on [how to create, organize, and describe research compendia](https://github.com/benmarwick/researchcompendium).
## Contributor roles
We specify the contribution of all people involved in the research (contributing non-authors included), according to the [Contributor Role Taxonomy](https://www.casrai.org/credit/).
| | BBZ | RC |
| ---------------------------- | --- | --- |
| Conceptualization | X | - |
| Methodology | X | - |
| Software | X | - |
| Validation | X | - |
| Formal analysis | X | - |
| Investigation | X | - |
| Resources | X | - |
| Data curation | X | - |
| Writing - original draft | X | - |
| Writing - review and editing | X | - |
| Visualization | X | - |
| Supervision | X | - |
| Project administration | X | - |
| Funding acquisition | X | X |
## Contact
[Bram B. Zandbelt](mailto:[email protected])