Session 06 - Preregistration 2; Good coding practices
Overview
| Topic | Duration | Notes |
|---|---|---|
| Wrap-up Homework “Prereg” | 10 | Will discuss in detail with the consensus prereg |
| Prereg Intro | 30 | Slides |
| Advocatus Diaboli Game | 40 | |
| Good coding practices | 60 | Slides |
| Explain Homework | 20 |
Homework 1 (in groups): Prepare participant recruitment
- Group 1: Create text for SONA and text snippets for social media
- Group 2: Create visual flyers to share on social media
- Group 3: Think about channels for recruitment: Social Media, Whatsapp groups, other Empras, friends/family, not just students, how to get more male participants?
Do this in our Google Drive so that you can see the texts/progress of the other groups.
Homework 2 (individually): Do the dplyr tutorial
See https://www.oer.psy.lmu.de/R_Tutorial/Teil4_tidyverse.html.
dplyr is an R package for data manipulation, providing a consistent set of verbs — filter(), select(), mutate(), summarise(), and arrange() — to transform and summarize data frames. It is very convenient to clean and generally preprocess raw data.
Homework 3 (in groups): Dig into original data set / Prepare the reproducibility check
- Set up the folder structure as explained in the Good Coding Practices presentation (slides 12ff.):
- Create all folders, even if they are currently empty. Note: Git does not include empty folders to the repository. If you still want them to show up, add an empty file called
.gitkeepto the otherwise empty folder. Files with a name starting with a dot are hidden files that do not show up in the Explorer/Finder (but still are there). - Place the raw data file (see Moodle) into the
raw_datasubfolder (the data files is all you have) - Create an R-Studio project in the top level folder
- Create a file called
.gitignorein the root folder, and add a line “*.sav” to it. This tells git to ignore all files with a.savfile extension. - Put everything under
gitversion control. - Important: Really make sure that you do not share the raw data file on GitHub. If you are unsure how to proceed, do not push yet to GitHub; we’ll do it together next session.
- Import the data in R. Find out from which software this data file comes and how to import it. Try to understand the variables (which ones do we need to reproduce the main analyses of the original paper? What do their values mean?).
This is an SPSS data file. You can import it as a data frame with:
# install.packages("rio")
library(rio)
dat <- import("raw_data/RRBehavioralHumility_Deidentified.sav")In SPSS data files, meta-data about the variables (i.e., the columns) can be stored in the data file itself. This sometimes functions as an (often incomplete) codebook. When you import the .sav file, these meta-data are stored as so-called attributes of columns in the data frame. You see a preview of them if you print the structure of the data frame with str(dat):
'data.frame': 104 obs. of 28 variables:
[...]
$ Cond : num 0 0 0 0 0 0 1 1 1 1 ...
..- attr(*, "label")= chr "Condition"
..- attr(*, "format.spss")= chr "F11.0"
..- attr(*, "display_width")= int 11
..- attr(*, "labels")= Named num [1:2] 0 1
.. ..- attr(*, "names")= chr [1:2] "Control" "Awe"
[...]
$ SelectOut : num 2 2 2 2 2 2 2 2 2 2 ...
..- attr(*, "label")= chr "1= outlier (>3SD), 2=didn't follow instructions to talk about weaknesses"
..- attr(*, "format.spss")= chr "F8.2"
..- attr(*, "display_width")= int 15
So, the variable $Cond has the label Condition, and the values 0 and 1 are mapped to "Control" and "Awe".
You can directly access the attributes with this R command:
attr(dat$Cond, which="labels")- Get an overview of the data set with the
summarytoolspackage.
# install.packages("summarytools")
library(summarytools)
view(dfSummary(dat))- When you found out which variables are relevant for us, …
- compute some descriptive statistics and compare them to the paper.
- Optionally, try to reproduce the t-test that tested the main hypothesis in the paper
Make a note of any problems and inconsistencies you discover. You can use your new dplyr skills, or stay at base R.