france_data <- france_data %>%
mutate('Trust in People' = pplfair)
france_data <- france_data %>%
mutate('Satisfaction with Democracy' = stfdem)
france_data <- france_data %>%
mutate('BA [1] or No BA [2]' = ba_indicator)
datasummary_skim(france_data %>%
select('Trust in People', 'Satisfaction with Democracy', 'BA [1] or No BA [2]'),
title = "Figure 1: Descriptive Statistics of Variables")
Figure 1: Descriptive Statistics of Variables
Unique (#)
Missing (%)
Mean
SD
Min
Median
Max
Trust in People
11
0
5.8
2.1
0.0
6.0
10.0
Satisfaction with Democracy
11
0
4.6
2.4
0.0
5.0
10.0
BA [1] or No BA [2]
2
0
1.2
0.4
1.0
1.0
2.0
unique(france_data$'Education Level')
## NULL
Hypothesis Testing
t_test_result <- t.test(stfdem ~ educ_level, data = france_data)
# I chose this test statistic as my response variable is a numeric variable and my explanatory variable is categorical.
print(t_test_result)
##
## Welch Two Sample t-test
##
## data: stfdem by educ_level
## t = -18.169, df = 7029.2, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group BA and group No BA is not equal to 0
## 95 percent confidence interval:
## -0.8305445 -0.6687805
## sample estimates:
## mean in group BA mean in group No BA
## 4.443495 5.193158
# This score of -18.169 indicates a significant level of difference between satisfaction with democracy between those who do and do not have a BA. This is evidence against the null hypothesis.
t_test_num <- -18.169
null_distribution <- france_data %>%
specify(explanatory = educ_level,
response = stfdem) %>%
hypothesize(null = "independence") %>%
generate(reps = 1000, type = "permute") %>%
calculate(stat = "t")
## Warning: The statistic is based on a difference or ratio; by default, for
## difference-based statistics, the explanatory variable is subtracted in the
## order "BA" - "No BA", or divided in the order "BA" / "No BA" for ratio-based
## statistics. To specify this order yourself, supply `order = c("BA", "No BA")`
## to the calculate() function.
p_val <- null_distribution %>%
get_pvalue(obs_stat = t_test_num, direction = "two-sided")
## Warning: Please be cautious in reporting a p-value of 0. This result is an
## approximation based on the number of `reps` chosen in the `generate()` step.
## See `?get_p_value()` for more information.
null_distribution %>%
visualize() +
shade_p_value(obs_stat = t_test_num, direction = "two-sided")
# After all of the testing, we have enough evidence to reject the null hypothesis given the visualization and the scores received. This means there must be a correlation between education and satisfaction with democracy.
## (Intercept) educ_levelNo BA
## 4.4434950 0.7496625
# If a person has a BA, their predicted satisfaction with democracy is to be 4.44 or slightly dissatisfied. Having no BA is associated with a 0.75 drop in the predicted value compared to having a BA, coming to 3.69.
models <- list(
"Model 1" = lm(stfdem ~ educ_level, data = france_data, weights = weight),
"Model 2" = lm(stfdem ~ educ_level + pplfair, data = france_data, weights = weight))
modelplot(models, coef_omit = 'Interc')
modelsummary(
models,
fmt = 1,
estimate = c("{estimate} ({std.error}){stars}",
"{estimate} ({std.error}){stars}"),
statistic = NULL,
title = 'Table 2. Regression models predicting satisfaction with democracy (0 to 100)'
)
Table 2. Regression models predicting satisfaction with democracy (0 to
100)
Model 1
Model 2
(Intercept)
4.0 (0.1)***
2.1 (0.2)***
educ_levelNo BA
1.1 (0.1)***
0.8 (0.1)***
pplfair
0.3 (0.0)***
Num.Obs.
1891
1891
R2
0.027
0.103
R2 Adj.
0.026
0.102
AIC
9204.2
9051.2
BIC
9220.8
9073.4
Log.Lik.
−4599.100
−4521.622
RMSE
2.44
2.38
Interaction Effect
model3 <- lm(stfdem ~ educ_level * pplfair, data = france_data, weights = weight)
interaction_plot <- effect("educ_level:pplfair", model3)
plot(interaction_plot,
main="Interaction Effect",
xlab="Satisfaction With Democracy",
ylab="Trust in People")
# The interaction Effect model provides visual evidence that there is an interaction between the variables. The unparalleled lines provide this evidence, particularly so with those who do not have a BA.