In the following exercises, you will work on your own ‘research question’ using the GESIS Panel data. If you have not already done so, you can load the data first using the following code:
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")
If you’re really struggling to find something you like, what about the following variables:
# We will use option 2 from the list in the clues in the following.
education_cat
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(performance)
library(see)
gp_covid <-
gp_covid %>%
mutate(curfew_yes_no = case_when(
hzcy026a == 2 ~ 0,
hzcy026a == 1 ~ 1
)
)
linear_model <-
lm(
curfew_yes_no ~ age_cat + education_cat,
data = gp_covid
)
check_normality(linear_model) %>%
plot()
## Warning: Non-normality of residuals detected (p < .001).
performance
package.
check_model(linear_model)