Framing effects for various issues
framing_anova <- function(frame_factor, issue_support, issue_name) {
# Create quosures
enquo_frame <- enquo(frame_factor)
enquo_support <- enquo(issue_support)
# Create string versions of arguments
char_frame <- deparse(substitute(frame_factor))
char_support <- deparse(substitute(issue_support))
# Summarize data based on issue and support
frame_summary <- survey_clean %>%
filter(!is.na(!!enquo_frame)) %>%
group_by(!!enquo_frame) %>%
summarize(N = n(),
Mean = Hmisc::wtd.mean(!!enquo_support, weight, na.rm = TRUE),
SD = sqrt(Hmisc::wtd.var(!!enquo_support, weight, na.rm = TRUE))) %>%
rename(Frame = !!enquo_frame) %>%
arrange(Frame)
# ANOVA
anova_formula <- as.formula(paste(char_support, "~", char_frame))
frame_anova <- aov(anova_formula, weights = weight, data = survey_clean)
# Round to nearest ten-thousandth
frame_sig <- ceiling(tidy(frame_anova)[1,]$p.value * 10000) / 10000
frame_summary_sig <- frame_summary %>%
mutate(`Sig.` = c(NA, frame_sig),
Issue = c(issue_name, NA)) %>%
select(Issue, everything()) %>%
mutate(Frame = as.character(Frame))
frame_summary_sig
}
# KKK experiment
kkk_summary <- framing_anova(KKKFrame_CivLibs.factor,
KKK_Support, model_kkk_name)
# Guns experiment
guns_summary <- framing_anova(GunFrame_CivLibs.factor,
Gun_Support, model_guns_name)
# Stem cells experiment
stemcells_summary <- framing_anova(StemCellsFrame_Positive.factor,
StemCellsSupport, model_stemcells_name)
# Affirmative action experiment
aa_summary <- framing_anova(AAFrame_positive.factor,
AASupport, model_af_ac_name)
# Everything in one table
framing_summary <- bind_rows(kkk_summary, guns_summary,
stemcells_summary, aa_summary)
caption <- "Framing effects for various issues"
tbl_framing <- pandoc.table.return(framing_summary, caption = caption,
justify = "llcccc", digits = 3)
cat(tbl_framing)
Framing effects for various issues
KKK rally |
Public safety (−) |
273 |
2.67 |
1.88 |
|
|
Civil liberties (+) |
267 |
3.25 |
2.17 |
0.001 |
Concealed handgun law |
Public safety (−) |
273 |
3.39 |
2.27 |
|
|
Civil liberties (+) |
269 |
4.22 |
2.26 |
0 |
Stem cell research |
Traditional values (−) |
273 |
4.43 |
2.19 |
|
|
Scientific progress (+) |
267 |
4.72 |
2 |
0.111 |
Affirmative action for women |
Unfair advantage (−) |
267 |
3.73 |
1.99 |
|
|
Remedy historical wrongs (+) |
269 |
3.71 |
1.79 |
0.851 |
Notes: “Mean” table entries are average responses, where minimum response is 1, and maximum response is 7, where 7 is maximum support.
Questions measuring support:
- KKK rally: In general, do you oppose or support allowing members of the Ku Klux Klan to hold public rallies?
- Concealed handgun law: How strongly do you support or oppose a proposed state law allowing citizens to carry concealed handguns?
- Stem cell research: How strongly do you oppose or support embryonic stem cell research?
- Affirmative action for women: Do you oppose or support preferential hiring and promotion of women?
Visualize average support across frames
clean_issue_means <- function(frame_factor, issue_support) {
enquo_frame <- enquo(frame_factor)
enquo_support <- enquo(issue_support)
survey_clean %>%
select(frame = !!enquo_frame,
support = !!enquo_support) %>%
filter(!is.na(frame),
!is.na(support))
}
issue_means <- tribble(
~issue_name, ~plot,
model_kkk_name, clean_issue_means(KKKFrame_CivLibs.factor, KKK_Support),
model_guns_name, clean_issue_means(GunFrame_CivLibs.factor, Gun_Support),
model_stemcells_name, clean_issue_means(StemCellsFrame_Positive.factor,
StemCellsSupport),
model_af_ac_name_plot, clean_issue_means(AAFrame_positive.factor, AASupport)
) %>%
unnest(plot) %>%
mutate(issue_name = fct_inorder(issue_name, ordered = TRUE)) %>%
left_join(frame_labs_all, by = "frame")
set.seed(1234)
plot_issue_means <- ggplot(issue_means, aes(x = frame_plot, y = support)) +
geom_point(position = position_jitter(height = 0.1, width = 0.1),
alpha = 0.1, size = 0.3) +
stat_summary(fun.data = "mean_cl_boot", colour = "black",
size = 1.5, fatten = 2) +
scale_y_continuous(breaks = 1:7,
labels = c("Strongly oppose (1)",
"Moderately oppose (2)",
"Slightly oppose (3)",
"Neither oppose nor support (4)",
"Slightly support (5)",
"Moderately support (6)",
"Strongly support (7)")) +
coord_cartesian(ylim = c(1, 7)) +
labs(x = "Frame", y = NULL) +
theme_framing() +
theme(panel.grid.major.x = element_blank(),
panel.grid.minor.y = element_blank(),
strip.text = element_text(size = rel(0.8))) +
facet_wrap(~ issue_name, scales = "free_x", nrow = 1)
LS0tCnRpdGxlOiAiRGlmZmVyZW5jZXMgaW4gbWVhbnMiCmF1dGhvcjogIk1lcmVkaXRoIENvbnJveSBhbmQgQW5kcmV3IEhlaXNzIgpkYXRlOiAiYHIgZm9ybWF0KFN5cy50aW1lKCksICclQiAlZSwgJVknKWAiCmVkaXRvcl9vcHRpb25zOiAKICBjaHVua19vdXRwdXRfdHlwZTogY29uc29sZQotLS0KCmBgYHtyIHNldHVwLCBtZXNzYWdlPUZBTFNFfQprbml0cjo6b3B0c19jaHVuayRzZXQoY2FjaGUgPSBGQUxTRSwgZmlnLnJldGluYSA9IDIsCiAgICAgICAgICAgICAgICAgICAgICB0aWR5Lm9wdHMgPSBsaXN0KHdpZHRoLmN1dG9mZiA9IDEyMCksICAjIEZvciBjb2RlCiAgICAgICAgICAgICAgICAgICAgICB3aWR0aCA9IDEyMCkgICMgRm9yIG91dHB1dApgYGAKCmBgYHtyIGxvYWQtbGlicmFyaWVzLWRhdGEsIG1lc3NhZ2U9RkFMU0UsIHdhcm5pbmc9RkFMU0V9CmxpYnJhcnkodGlkeXZlcnNlKQpsaWJyYXJ5KHBhbmRlcikKbGlicmFyeShicm9vbSkKbGlicmFyeShoZXJlKQoKc291cmNlKGZpbGUucGF0aChoZXJlKCksICJsaWIiLCAicGFuZGVyX29wdGlvbnMuUiIpKQpzb3VyY2UoZmlsZS5wYXRoKGhlcmUoKSwgImxpYiIsICJncmFwaGljcy5SIikpCnNvdXJjZShmaWxlLnBhdGgoaGVyZSgpLCAibGliIiwgImxhYmVscy5SIikpCgpzdXJ2ZXlfY2xlYW4gPC0gcmVhZFJEUyhmaWxlLnBhdGgoaGVyZSgpLCAiRGF0YSIsICJzdXJ2ZXlfY2xlYW4ucmRzIikpCmBgYAoKCiMjIEZyYW1pbmcg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IGFscGhhID0gMC4xLCBzaXplID0gMC4zKSArCiAgc3RhdF9zdW1tYXJ5KGZ1bi5kYXRhID0gIm1lYW5fY2xfYm9vdCIsIGNvbG91ciA9ICJibGFjayIsCiAgICAgICAgICAgICAgICAgc2l6ZSA9IDEuNSwgZmF0dGVuID0gMikgKwogIHNjYWxlX3lfY29udGludW91cyhicmVha3MgPSAxOjcsCiAgICAgICAgICAgICAgICAgICAgIGxhYmVscyA9IGMoIlN0cm9uZ2x5IG9wcG9zZSAoMSkiLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiTW9kZXJhdGVseSBvcHBvc2UgKDIpIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiU2xpZ2h0bHkgb3Bwb3NlICgzKSIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIk5laXRoZXIgb3Bwb3NlIG5vciBzdXBwb3J0ICg0KSIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIlNsaWdodGx5IHN1cHBvcnQgKDUpIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiTW9kZXJhdGVseSBzdXBwb3J0ICg2KSIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIlN0cm9uZ2x5IHN1cHBvcnQgKDcpIikpICsKICBjb29yZF9jYXJ0ZXNpYW4oeWxpbSA9IGMoMSwgNykpICsKICBsYWJzKHggPSAiRnJhbWUiLCB5ID0gTlVMTCkgKwogIHRoZW1lX2ZyYW1pbmcoKSArCiAgdGhlbWUocGFuZWwuZ3JpZC5tYWpvci54ID0gZWxlbWVudF9ibGFuaygpLAogICAgICAgIHBhbmVsLmdyaWQubWlub3IueSA9IGVsZW1lbnRfYmxhbmsoKSwKICAgICAgICBzdHJpcC50ZXh0ID0gZWxlbWVudF90ZXh0KHNpemUgPSByZWwoMC44KSkpICsKICBmYWNldF93cmFwKH4gaXNzdWVfbmFtZSwgc2NhbGVzID0gImZyZWVfeCIsIG5yb3cgPS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