Use data for Germany and the variable coding for model3 and model4 from the tutorial (i.e., both for the cleaning & recode, as well as the linear model formulas). Do a modelsummary table displaying both model outputs. Interpret the coefficients for the MLR without the interaction (i.e., the first displayed model), and interpret model fit metrics for both models.
setwd("/Users/kaylapatricia/Desktop/soc222/homework 5")
germany_data <- read_fst("germany_data.fst")
df <- germany_data
df$weight <- df$dweight * df$pweight
survey_design <- svydesign(ids = ~1, data = df, weights = ~weight)
# recoding
df <- df %>%
mutate(behave = ipbhprp,
secure = impsafe,
safety = ipstrgv,
tradition = imptrad,
rules = ipfrule) %>%
mutate(across(c("behave", "secure", "safety", "tradition", "rules"),
~ na_if(.x, 7) %>% na_if(8) %>% na_if(9))) %>%
#reverse coding
mutate(across(c("behave", "secure", "safety", "tradition", "rules"), ~ 7 - .x ))
df$auth <- scales::rescale(df$behave +
df$secure +
df$safety +
df$tradition +
df$rules, to=c(0,100), na.rm=TRUE)
df <- df %>% filter(!is.na(auth))
df <- df %>%
mutate(
polID = case_when(
lrscale %in% 0:3 ~ "Left",
lrscale %in% 7:10 ~ "Right",
lrscale %in% 4:6 ~ "Moderate",
lrscale %in% c(77, 88, 99) ~ NA_character_
),
religious = case_when(
rlgdgr %in% c(77, 88, 99) ~ NA_real_,
TRUE ~ rlgdgr
)
)
model3 <- lm(auth ~ polID + religious, data = df, weights = weight)
model4 <- lm(auth ~ polID + religious + polID*religious, data = df, weights = weight)
modelsummary(
list(model3, model4),
fmt = 1,
estimate = c( "{estimate} ({std.error}){stars}",
"{estimate} ({std.error}){stars}"),
statistic = NULL)
| (1) | (2) | |
|---|---|---|
| (Intercept) | 55.3 (0.3)*** | 56.4 (0.3)*** |
| polIDModerate | 4.6 (0.3)*** | 3.4 (0.4)*** |
| polIDRight | 7.7 (0.4)*** | 4.2 (0.7)*** |
| religious | 0.9 (0.0)*** | 0.6 (0.1)*** |
| polIDModerate × religious | 0.3 (0.1)*** | |
| polIDRight × religious | 0.8 (0.1)*** | |
| Num.Obs. | 23373 | 23373 |
| R2 | 0.048 | 0.050 |
| R2 Adj. | 0.048 | 0.050 |
| AIC | 200594.1 | 200558.6 |
| BIC | 200634.4 | 200615.0 |
| Log.Lik. | −100292.049 | −100272.298 |
| RMSE | 17.27 | 17.24 |
Interpret the coefficients for the MLR without the interaction (i.e., the first displayed model), and interpret model fit metrics for both models.
polIDModerate (4.6): This coefficient suggests that when comparing individuals with the same religiousness, the average outcome for individuals identifying as politically moderate are 4.6 units higher compared to the reference category (the left). The “baseline group” is interpreted as part of our intercept because it refers to the omitted category. The polIDModerate of 4.6 means politically moderate individuals have authoritarian attitudes that are an average of 4.6 units higher than those who identify as leftists.
polIDRight (7.7): This coefficient indicates that when comparing individuals with the same religiousness, individuals who are political rightists are expected to have authoritarian attitudes that are on average 7.7 units higher than the reference category (the left)
religious (0.9): A coefficient of 0.9 means that with every one-unit increase in religiousness, an average 0.9 unit increase is expected on the authoritarian values scale. If an individual increases their level of religiousness by one-unit, its expected that they would score 0.9 units higher on the authoritarian values scale compared to someone of the same political view as them who did not become more religious.
All three coefficients have ***, indicating a p < 0.001. This means there is less than a 0.1% probability that the observed result is due to chance and we incorrectly reject the null.
Num.Obs. (23373): its the same for both models because there is the same number of observations in the dataset.
R2 (0.048): this means there is about a 4.8% variance in authoritarian values that can be explained by the predictors of Model 1
R2 (0.050) this means there is about a 5% variance in authoritarian values that can be explained by the predictors of Model 2
R2 Adj. (0.048): this means after adjusting for the number of predictors, theres a 4.8% variance in authoritarian values that can be explained by the predictors of model 1.
R2 Adj. (0.050): this means after adjusting for the number of predictors, theres a 5% variance in authoritarian values that can be explained by the predictors of model 2.
Now generate the model4 interaction plot that we did in the tutorial, but again using the German data instead of the French. Interpret.
interaction_plot <- effect("polID*religious", model4, na.rm=TRUE)
plot(interaction_plot,
main="Interaction effect",
xlab="Religiousness",
ylab="Authoritarian attitudes scale")
interaction_plot
##
## polID*religious effect
## religious
## polID 0 2 5 8 10
## Left 56.40706 57.56775 59.30879 61.04983 62.21053
## Moderate 59.85063 61.66176 64.37844 67.09513 68.90626
## Right 60.60237 63.35032 67.47224 71.59416 74.34211
The graph shows that in individuals who are leftists, as religiousness increases, authoritarian attitudes slightly decrease. This is indicated by the slight downward trend, although it is not a steep slope thus, the change is not significant.
The graph also shows a more pronounced upward trend in authoritarian attitudes with an increase in religiousness for politically moderate individuals. This means that when individuals who identify as politically moderate become more religious, they become more authoritarian. The fact that the slope is more pronounced indicates a more significant effect in those who are politically moderate.
The graph finally shows the steepest slope in those who identify as politcally right. As rightist individuals become more religious, they become substantially more authoritarian as shown by the graph.
The fact that this trend is not parallel signifies that the effect of religiousness on authoritarian attitudes is strongest for rightists as compared to the other two groups.
Use data for the Netherlands and the variable coding for model5 and model6 from the tutorial (i.e., both for the cleaning & recode, as well as the linear model formulas). Do a modelsummary table displaying both model outputs. Interpret the coefficients for the MLR without the interaction (i.e., the first displayed model), and interpret model fit metrics for both models.
setwd("/Users/kaylapatricia/Desktop/soc222/homework 5")
netherlands_data <- read_fst("netherlands_data.fst")
dfn <- netherlands_data
dfn$weight <- dfn$dweight * dfn$pweight
survey_design <- svydesign(ids = ~1, data = dfn, weights = ~weight)
dfn <- dfn %>%
mutate(behave = ipbhprp,
secure = impsafe,
safety = ipstrgv,
tradition = imptrad,
rules = ipfrule) %>%
mutate(across(c("behave", "secure", "safety", "tradition", "rules"),
~ na_if(.x, 7) %>% na_if(8) %>% na_if(9))) %>%
# Apply the reverse coding
mutate(across(c("behave", "secure", "safety", "tradition", "rules"), ~ 7 - .x ))
# Now you can calculate 'schwartzauth' after the NA recoding
dfn$auth <- scales::rescale(dfn$behave +
dfn$secure +
dfn$safety +
dfn$tradition +
dfn$rules, to=c(0,100), na.rm=TRUE)
dfn <- dfn %>% filter(!is.na(auth))
dfn <- dfn %>%
mutate(
cohort = ifelse(yrbrn < 1930 | yrbrn > 2000, NA, yrbrn),
gen = case_when(
yrbrn %in% 1900:1945 ~ "1",
yrbrn %in% 1946:1964 ~ "2",
yrbrn %in% 1965:1979 ~ "3",
yrbrn %in% 1980:1996 ~ "4",
TRUE ~ as.character(yrbrn)
),
gen = factor(gen,
levels = c("1", "2", "3", "4"),
labels = c("Interwar", "Baby Boomers", "Gen X", "Millennials"))
)
table(dfn$gen)
##
## Interwar Baby Boomers Gen X Millennials
## 3771 6147 4548 2730
dfn <- dfn %>%
mutate(religion = case_when(
rlgblg == 2 ~ "No",
rlgblg == 1 ~ "Yes",
rlgblg %in% c(7, 8, 9) ~ NA_character_,
TRUE ~ as.character(rlgblg)
))
table(dfn$religion)
##
## No Yes
## 10913 6750
dfn <- dfn %>%
mutate(ID = case_when(
lrscale >= 0 & lrscale <= 4 ~ "Left",
lrscale >= 6 & lrscale <= 10 ~ "Right",
lrscale > 10 ~ NA_character_,
TRUE ~ NA_character_
))
table(dfn$ID)
##
## Left Right
## 5449 7010
model5 <- lm(auth ~ religion + ID + gen, data = dfn, weights = weight)
model6 <- lm(auth ~ religion + ID + gen + religion*gen, data = dfn, weights = weight)
modelsummary(
list(model5, model6),
fmt = 1,
estimate = c( "{estimate} ({std.error}){stars}",
"{estimate} ({std.error}){stars}"),
statistic = NULL,
coef_omit = "Intercept")
| (1) | (2) | |
|---|---|---|
| religionYes | 7.2 (0.3)*** | 5.7 (0.7)*** |
| IDRight | 4.2 (0.3)*** | 4.3 (0.3)*** |
| genBaby Boomers | −5.2 (0.4)*** | −5.9 (0.6)*** |
| genGen X | −7.7 (0.4)*** | −8.8 (0.6)*** |
| genMillennials | −8.4 (0.5)*** | −9.7 (0.6)*** |
| religionYes × genBaby Boomers | 1.1 (0.8) | |
| religionYes × genGen X | 2.3 (0.9)** | |
| religionYes × genMillennials | 2.9 (1.0)** | |
| Num.Obs. | 12116 | 12116 |
| R2 | 0.124 | 0.125 |
| R2 Adj. | 0.124 | 0.125 |
| AIC | 101219.3 | 101213.5 |
| BIC | 101271.2 | 101287.5 |
| Log.Lik. | −50602.672 | −50596.757 |
| RMSE | 15.27 | 15.26 |
Interpret the coefficients for the MLR without the interaction (i.e., the first displayed model), and interpret model fit metrics for both models.
religionYes (7.2): this coefficient indicates that religious individuals have authoritarian attitudes that are on average 7.2 units higher on the authoritarian scale than individuals who do not identify with a religion.
IDRight (4.2): this coefficient indicates that when other variables are constant, individuals who are rightists are expected to have authoritarian attitudes that are an average of 4.2 units higher compared to leftists.
genBaby Boomers (-5.2): this coefficient indicates that baby boomers have authoritarian attitudes that are about 5.2 units lower on the authoritarian scale compared to those of the reference generation.
genGen x (-7.7): This coefficient indicates that those from generation X are expected to have authoritarian attitudes that are about 7.7 units lower on the authoritarian scale compared to those of the reference generation.
genMillennials (-8.4): This coefficient indicates that those of the millenial generation are expected to be less authoritarian by about 7.7 units on the authoritarian scale compared to those of the reference generation.
Num.Obs. (12116): indicates the same total number of observations in both analyses.
R2 (0.124; 0.125): indicates there is about a 12.4-12.5% variance in authoritarian values that can be explained by the independent variables measured
Produce the model7 interaction plot from the tutorial, but again using the Netherlands data. Interpret.
dfn <- dfn %>%
mutate(
cohort = ifelse(yrbrn < 1930 | yrbrn > 2000, NA, yrbrn))
dfn <- dfn %>%
mutate(
polID = case_when(
lrscale %in% 0:3 ~ "Left",
lrscale %in% 7:10 ~ "Right",
lrscale %in% 4:6 ~ "Moderate",
lrscale %in% c(77, 88, 99) ~ NA_character_
))
model7 <- lm(auth ~ + cohort + polID + cohort*polID, data = dfn, weights = weight)
interact_plot(model7, pred = cohort, modx = polID, jnplot = TRUE)
This graph shows that regardless of political position, authoritarian
attitudes decrease as birth cohorts evolve. This graph signifies a
general trend towards new generations becoming less and less
authoritarian. The degree of decline seems to be most significant for
rightists, least significant for leftists, and moderately significant
for moderates, indicated by steepness of the lines. The intersection
between the rightists and moderates indicate an interaction effect
between birth cohort and political ideologies pertaining to
authoritarian attitudes. This indicates that as individuals change their
political position from moderate to right, the impact of birth cohort on
their authoritarian attitudes are moderated by their political position.
So, while new generations of people are becoming less and less
authoritarian, the degree of decline varies based on their political
position, and the relationship between birth cohort and authoritarian
values is not consistent across political positions, rather it depends
on them.
Produce the model8 interaction plot from the tutorial, but again using the Netherlands data. Interpret.
dfn <- dfn %>%
mutate(religion = case_when(
rlgblg == 2 ~ "No",
rlgblg == 1 ~ "Yes",
rlgblg %in% c(7, 8, 9) ~ NA_character_,
TRUE ~ as.character(rlgblg)
))
dfn <- dfn %>%
mutate(ID = case_when(
lrscale >= 0 & lrscale <= 4 ~ "Left",
lrscale >= 6 & lrscale <= 10 ~ "Right",
lrscale > 10 ~ NA_character_,
TRUE ~ NA_character_
))
model8 <- lm(auth ~ religion + ID + religion*ID, data = dfn, weights = weight)
cat_plot(model8, pred = religion, modx = ID, jnplot = TRUE)
This plot displays the relationship between religiousness and
authoritarian values across different political positions. This graph
shows that leftists who are not religious are the least authoritarian,
while people who are rightists and non-religious are more authoritarian
than them. However, those who are non-religious are less authoritarian
in general regardless of political ideology than leftists and rightists
who are religious. Religious rightists have the most authoritarian
attitudes, while religious leftists are less authoritarian than them.
This indicates that religion and political position both predict
authoritarian attitudes.