In the following exercises, you will work on your own ‘research question’ using the ALLBUS 2021. If you have not already done so, you can load the data first using the following code:

library(haven)

allbus_2021_dvII_1 <- 
  read_spss("./data/allbus_2021/ZA5280_v1-0-0.sav") 
## Converting atomic to factors. Please wait...

1

Take a few minutes to choose a dependent variable (DV) and an independent variable (IV) from the codebook that lives in the ./data folder or the full Allbus 2021 codebook. Don’t overthink your choices!

If you’re really struggling to find something you like, what about the following variables:

  1. mi05 (accepting refugees from war-torn countries) as DV and st01 (general trust in people) as IV
  2. pa01 (left-right self-placement) as DV and age as IV
  3. fr12 (man taking care of the household and children) as DV and sex IV
Be aware that you may have to do some recoding, and that your sample is likely reduced due to filter questions.
# We will use option 2 from the list in the following.

2

Run a linear regression model with your variables and eastwest as covariate. If it is part of your predictor variables (IV), choose another one. Then check visually if the residuals are normally distributed.
You need the performance and see packages for this task (and dplyr for the preparatory wrangling part).
library(dplyr)
library(performance)
library(see)

allbus_2021_dvII_1 <-
  allbus_2021_dvII_1 %>% 
  mutate(political_orientation = as.numeric(pa01))

linear_model <-
  lm(
    political_orientation ~ age + eastwest,
    data = allbus_2021_dvII_1
  )

check_normality(linear_model) %>%
  plot()

3

Now, do the full range of model checks using a function from the performance package.
check_model(linear_model)