zo | zc | ze | za | zn | scs | dass |
---|---|---|---|---|---|---|
0.76 | 1.58 | -0.79 | -0.09 | 1.32 | 30 | 56 |
0.30 | -0.27 | -0.09 | 0.09 | -0.40 | 30 | 48 |
-0.13 | 0.66 | -0.80 | -0.95 | 0.93 | 35 | 48 |
1.06 | -1.02 | -0.16 | -0.50 | -0.02 | 29 | 48 |
1.74 | -0.78 | -1.55 | -2.86 | -1.14 | 41 | 43 |
0.22 | -0.41 | 0.78 | 0.90 | -0.25 | 37 | 60 |
Interactions II: Num x Num
Learning Objectives
At the end of this lab, you will:
- Understand the concept of an interaction.
- Be able to interpret the meaning of a numeric \(\times\) numeric interaction.
- Understand the principle of marginality and why this impacts modelling choices with interactions.
- Visualize and probe interactions.
What You Need
- Be up to date with lectures
- Have completed previous lab exercises from Week 7
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/scs_study.csv.
Study Overview
Research Question
Does the effect of social comparison on symptoms of depression, anxiety and stress vary depending on level of Neuroticism?
Previous research has identified an association between an individual’s perception of their social rank and symptoms of depression, anxiety and stress. We are interested in the individual differences in this association.
To investigate whether the effect of social comparison on symptoms of depression, anxiety and stress varies depending on level of Neuroticism, we will need to fit a multiple regression model with an interaction term. Before we think about fitting our model, it is important that we understand the data available - how many participants? What type (or class) of data will we be working with? What was the measurement scale? How were scales scored? Look at the social comparison study data codebook below.
Setup
- Create a new RMarkdown file
- Load the required package(s)
- Read the scs_study dataset into R, assigning it to an object named
scs_study
Exercises
Formally state:
- a linear model to investigate whether the effect of social comparison on symptoms of depression, anxiety and stress varies depending on level of Neuroticism
- your chosen significance level
- the null and alternative hypotheses
Provide a table of descriptive statistics and visualise your data.
Remember to interpret these plots in the context of the study.
Run the two code chunks below. It takes the dataset, and uses the cut()
function to add a new variable called “zn_group”, which is the “zn” variable split into 4 groups.
We can see how it has split the “zn” variable by plotting the two against one another (note that the levels of the new variable are named according to the cut-points):
ggplot(data = scs_study, aes(x = zn_group, y = zn)) +
geom_point()
Plot the association between scores on the SCS and scores on the DASS-21, for each group of the variable we just created.
How does the pattern differ across groups? Does it suggest an interaction?
Visualising Interaction Terms
Cutting one of the explanatory variables up into groups essentially turns a numeric variable into a categorical one. We did this just to make it easier to visualise how an association differs across the values of another variable, because we can imagine a separate line for the association between SCS and DASS-21 scores for each of the groups of Neuroticism. However, in grouping a numeric variable like this we lose information. Neuroticism is measured on a continuous scale, and we want to capture how the association between SCS and DASS-21 differs across that continuum (rather than cutting it into chunks).
We could imagine cutting it into more and more chunks (see Figure 1), until what we end up with is an infinite number of lines - i.e., a three-dimensional plane/surface (recall that in for a multiple regression model with 2 explanatory variables, we can think of the model as having three-dimensions). The inclusion of the interaction term simply results in this surface no longer being necessarily flat. You can see this in Figure 2).
Consider that Neuroticism has already been \(z\)-scored, but scs has not. To ensure that we can compare the effects of our estimates (and so they are both on meaningful scales), standardize the scs variable.
Fit your model (including the standardized variables) using lm()
, and assign it as an object with the name “dass_mdl”.
Interpret your coefficients in the context of the study.
Using the probe_interaction()
function from the interactions package, visualise the interaction effects from your model.
Try to summarise the interaction effects in a short and concise sentence.
Conduct a simple slopes analysis.
Provide key model results in a formatted table.
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.