Instructions

Suggested resources

Required R packages

Load the required packages and set a seed for the random number generator.

library(tidyverse)

library(rstan)
# set cores to use to the total number of cores (minimally 4)
options(mc.cores = max(parallel::detectCores(), 4))
# save a compiled version of the Stan model file
rstan_options(auto_write = TRUE)

library(brms)

# install faintr with devtools::install_github('michael-franke/bayes_mixed_regression_tutorial/faintr', build_vignettes = TRUE))
library(faintr)


set.seed(123)

Step 1. Read the data and take a glimpse of it.

Use read_csv() and glimpse()

# your code here

Step 2. Select only the columns of interest.

Do this with the select() command.

# your code here

Step 3. Change columns to the correct data type.

Use mutate(): * expected should be a factor (also rename this to condition) * correctness should be a factor * angle should be a factor * trial_type should be a factor

# your code here

Step 4. Show the data frame.

Check that everything is there and of the correct type.

# your code here

Step 5. Filter only the ‘main’ trials with correct responses.

Use filter().

# your code here

Step 6. Make a boxplot of the data.

Show condition (same/different) on the x-axis and RT on the y-axis. Show the different angles in different colors (fill). (use ggplot() and geom_boxplot)

# your code here

Step 7. Remove outliers

Use filter() to filter only response times that are in a reasonable range.

# your code here

Step 8. Show means for each design cell.

Use group_by() %>% summarise().

# your code here

Step 9. Run a bayesian fixed-effects model

Use brm to model the response times from angle, condition and angle*condition.

# your code here

Step 10. See how probable the following hypotheses are:

Use faintr::compare_groups()

"Responses to ‘same’ trials are faster than responses to ‘different’ trials.

# your code here

"Responses to ‘50 degree’ trials are faster than responses to ‘150 degree’ trials.

# your code here

“Angle matters more than same/different for response times”. (In other words, when the angle is lower but the objects are ‘different’, people are still faster than when the angle is higher but the objects are the ‘same’.)

# your code here

Step 11. Run the model again, but this time include random effects

Include random by-item intercepts (+ (1|item)).

# your code here

Step 12. Check the same hypotheses for the mixed effects model

# your code here

Step 13. Conclude

Write a conclusion about the results.


End of sheet.