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...
./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:
mi05
(accepting refugees from war-torn countries) as DV
and st01
(general trust in people) as IVpa01
(left-right self-placement) as DV and
age
as IVfr12
(man taking care of the household and children) as
DV and sex
IV# We will use option 2 from the list in the following.
eastwest
as covariate. If it is part of your predictor
variables (IV), choose another one. Then check visually if the residuals
are normally distributed.
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()
performance
package.
check_model(linear_model)