Interactions III: Cat x Cat

Learning Objectives

At the end of this lab, you will:

  1. Understand the concept of an interaction.
  2. Be able to interpret a categorical \(\times\) categorical interaction.
  3. Visualize and probe interactions.

What You Need

  1. Be up to date with lectures
  2. Have completed previous lab exercises from Week 7 and Week 8

Required R Packages

Remember to load all packages within a code chunk at the start of your RMarkdown file using library(). If you do not have a package and need to install, do so within the console using install.packages(" "). For further guidance on installing/updating packages, see Section C here.

For this lab, you will need to load the following package(s):

  • tidyverse
  • psych
  • sjPlot
  • kableExtra
  • sandwich
  • interactions

Lab Data

You can download the data required for this lab here or read it in via this link https://uoepsy.github.io/data/cognitive_experiment_3_by_2.csv

Study Overview

Research Question

Are there differences in types of memory deficits for those experiencing different cognitive impairment(s)?

A group of researchers wants to test a hypothesised theory according to which the difference in performance between explicit and implicit memory tasks will be greatest for Huntington patients in comparison to controls. On the other hand, the difference in performance between explicit and implicit memory tasks will not significantly differ between patients with amnesia in comparison to controls.

Cognitive Exp 3x2 data codebook.

Setup

Setup
  1. Create a new RMarkdown file
  2. Load the required package(s)
  3. Read the cognitive_experiment_3_by_2 dataset into R, assigning it to an object named cog

Solution

Exercises

Question 1

Examine the dataset, and perform any necessary and appropriate data management steps.

  • Convert categorical variables to factors
  • Label appropriately factors to aid with your model interpretations
  • If needed, provide better variable names

Note that all of these steps can be done in combination - the mutate() and factor() functions will likely be useful here.

Solution


Question 2

Choose appropriate reference levels for the Diagnosis and Task variables.

Solution


Question 3

Formally state:

  • a linear model to investigate whether there are differences in types of memory deficits for those experiencing different cognitive impairment(s)
  • your chosen significance level
  • the null and alternative hypotheses

Solution


Question 4

Provide a table of descriptive statistics and visualise your data.

Remember to interpret your plot in the context of the study.

  1. For your table of descriptive statistics, both the group_by() and summarise() functions will come in handy here.
  2. Recall that when visualising categorical variables, geom_boxplot() may be most appropriate to use.

Solution


Question 5

Fit the specified model using lm(), and store the model in an object named “cog_mdl”.

Note

Fortunately, R computes the dummy variables for us! Thus. each row in the summary() output of the model will correspond to one of the estimated \(\beta\)’s in the equation above.

Solution


Question 6

Recall your table of descriptive statistics - map each coefficient from the summary() output from “cog_mdl” to the group means.

Solution


Question 7

Interpret your coefficients in the context of the study.

Solution


Question 8

Using the cat_plot() function from the interactions package, visualise the interaction effects from your model.

Try to summarise the interaction effects in a few short and concise sentences.

Solution


Question 9

Provide key model results in a formatted table.

Use tab_model() from the sjPlot package.

Remember that you can rename your DV and IV labels by specifying dv.labels and pred.labels.

Solution


Question 10

Interpret your results in the context of the research question and report your model in full.

Make reference to the interaction plot and regression table.

Solution

Footnotes

  1. Some researchers may point out that a design where each person was assessed on both tasks might have been more efficient. However, the task factor in such design would then be within-subjects, meaning that the scores corresponding to the same person would be correlated. To analyse such design we will need a different method which is discussed next year!↩︎