You can continue to work with the analyses you did in the previous set of exercises. For the examples we are going to use, we need to first load and wrangle the data. NB You do not need to run this code, if you want to continue with/from the analyses you did in the previous exercises (which is what we would recommend).

library(haven)
library(dplyr)
library(sjlabelled)

gp_covid <- 
  read_sav(
    "./data/ZA5667_v1-1-0.sav"
  ) %>% 
  set_na(na = c(-1:-99, 97, 98)) %>% 
  rowwise() %>%
  mutate(
    mean_trust = 
      mean(
        c_across(hzcy044a:hzcy052a),
        na.rm = TRUE
      )
  ) %>% 
  ungroup() %>% 
  remove_all_labels() %>% 
  mutate(
    pol_leaning_cat = 
      case_when(
        between(political_orientation, 0, 3) ~ "left",
        between(political_orientation, 4, 7) ~ "center",
        political_orientation > 7 ~ "right"
      ) %>% 
      as.factor()
  ) %>% 
  filter(pol_leaning_cat != "NA")

gp_covid <-
  gp_covid %>% 
  mutate(
    curfew_yes_no = 
      case_when(
        hzcy026a == 2 ~ 0,
        hzcy026a == 1 ~ 1,
      )
  )

1

Re-use your analysis from the previous set of exercises and run an interaction model between your IV and the other covariate. Plot the interaction as a coefficient plot.
For the coefficient plot, you can use the easystats packages we have used in the lecture.
library(parameters)
## 
## Attache Paket: 'parameters'
## Die folgenden Objekte sind maskiert von 'package:datawizard':
## 
##     center, check_multimodal, convert_data_to_numeric, data_partition, data_to_numeric, degroup, demean,
##     describe_distribution, detrend, kurtosis, rescale_weights, skewness, smoothness
library(performance)
library(see)

linear_model_interaction <-
  lm(
    curfew_yes_no ~ age_cat * education_cat,
    data = gp_covid
  )

model_parameters(linear_model_interaction) %>% 
  plot()

2

Imagine that you want to use the plot in a publication. Color figures usually cost extra. So, to save some money, try to make let the plot “turn grey”.
Remember that the easytats plots are based on ggplot2. You could choose from one of ggplot2’s built-in themes from this list: https://ggplot2.tidyverse.org/reference/ggtheme.html. In another step, you could adjust the color of the scale, e.g., with scale_colour_grey(). Be creative.
model_parameters(linear_model_interaction) %>% 
  plot() +
  scale_colour_grey(start = 0,
                    end = .5,
                    guide = "none") +
  theme_minimal()
## Scale for 'colour' is already present. Adding another scale for 'colour', which will replace the existing scale.

3

Plot the interaction effect as a prediction.
For this purpose, you need the plot_model() function from sjPlot.
library(sjPlot)
## Registered S3 methods overwritten by 'lme4':
##   method                          from
##   cooks.distance.influence.merMod car 
##   influence.merMod                car 
##   dfbeta.influence.merMod         car 
##   dfbetas.influence.merMod        car
plot_model(
  linear_model_interaction,
  type = "int"
)