Atheist Agnostic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gg <- cces20 %>% | |
mutate(grp = frcode(religpew == 9 ~ "Atheist", | |
religpew == 10 ~ "Agnostic")) %>% | |
mutate(imp = frcode(pew_religimp == 4 ~ "Not At All", | |
pew_religimp == 3 ~ "Not Too", | |
pew_religimp == 2 ~ "Somewhat", | |
pew_religimp == 1 ~ "Very")) %>% | |
group_by(grp) %>% | |
ct(imp, wt = commonweight, show_na = FALSE) %>% | |
na.omit() | |
one <- gg %>% | |
ggplot(., aes(x = 1, y = pct, fill = fct_rev(imp))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ grp, ncol =1, strip.position = "left") + | |
scale_fill_paletteer_d("suffrager::london") + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle=0)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(pct*100, '%'), '')), position = position_stack(vjust = 0.5), size = 4, family = "font", color = "black") + | |
geom_text(aes(label = ifelse(imp == "Not At All" & pct >.05, paste0(pct*100, '%'), '')), position = position_stack(vjust = 0.5), size = 4, family = "font", color = "white") + | |
labs(x = "", y = "", title = "Comparing the Religiosity of Atheists and Agnostics", subtitle = "How Important is Religion to You?", caption = "") + | |
ggsave("E://religimp_ath_agn.png", width = 9, height = 4) | |
gg <- cces20 %>% | |
mutate(grp = frcode(religpew == 9 ~ "Atheist", | |
religpew == 10 ~ "Agnostic")) %>% | |
cces_attend(pew_churatd) %>% | |
group_by(grp) %>% | |
ct(att, wt = commonweight, show_na = FALSE) %>% | |
na.omit() | |
two <- gg %>% | |
ggplot(., aes(x = 1, y = pct, fill = fct_rev(att))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ grp, ncol =1, strip.position = "left") + | |
scale_fill_paletteer_d("calecopal::kelp1") + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle=0)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(pct*100, '%'), '')), position = position_stack(vjust = 0.5), size = 4, family = "font", color = "black") + | |
# geom_text(aes(label = ifelse(pct >.05, paste0(pct*100, '%'), '')), position = position_stack(vjust = 0.5), size = 4, family = "font", color = "white") + | |
labs(x = "", y = "", title = "", subtitle = "How Often Do You Attend Religious Services?", caption = "") + | |
ggsave("E://religatt_ath_agn.png", width = 9, height = 4) | |
gg <- cces20 %>% | |
mutate(grp = frcode(religpew == 9 ~ "Atheist", | |
religpew == 10 ~ "Agnostic")) %>% | |
mutate(pray = pew_prayer) %>% | |
mutate(pray = frcode(pray == 7 ~ "Never", | |
pray == 6 ~ "Seldom", | |
pray == 5 ~ "Monthly", | |
pray == 4 ~ "Once a Week", | |
pray == 3 ~ "Few Times a Week", | |
pray == 2 ~ "Daily", | |
pray == 1 ~ "Several Times a Day")) %>% | |
group_by(grp) %>% | |
ct(pray, wt = commonweight, show_na = FALSE) %>% | |
na.omit() | |
three <- gg %>% | |
ggplot(., aes(x = 1, y = pct, fill = fct_rev(pray))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ grp, ncol =1, strip.position = "left") + | |
scale_fill_paletteer_d("ggsci::legacy_tron") + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle=0)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
theme(legend.text = element_text(size = 10)) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(pct*100, '%'), '')), position = position_stack(vjust = 0.5), size = 4, family = "font", color = "black") + | |
# geom_text(aes(label = ifelse(pct >.05, paste0(pct*100, '%'), '')), position = position_stack(vjust = 0.5), size = 4, family = "font", color = "white") + | |
labs(x = "", y = "", title = "", subtitle = "How Often Do You Pray?", caption = "@ryanburge\nData: CES 2020") + | |
ggsave("E://religpray_ath_agn.png", width = 9, height = 4) | |
library(patchwork) | |
all <- one / two / three | |
ggsave("E://patched_ath_agn.png", type = 'cairo-png', width = 8, height = 8, all) | |
ggg1 <- cces08 %>% | |
mutate(grp = frcode(V219 == 9 ~ "Atheist", | |
V219 == 10 ~ "Agnostic", | |
V219 == 11 ~ "Nothing in Particular")) %>% | |
group_by(grp) %>% | |
mutate(vote = CC410) %>% | |
mutate(vote = frcode(vote == 1 ~ "Republican", | |
vote == 2 ~ "Democrat", | |
vote == 3 | vote == 4 | vote == 5 | vote == 6 ~ "Third Party")) %>% | |
ct(vote, wt = V201, show_na = FALSE) %>% | |
mutate(year = 2008) | |
ggg2 <- cces12 %>% | |
mutate(grp = frcode(religpew == 9 ~ "Atheist", | |
religpew == 10 ~ "Agnostic", | |
religpew == 11 ~ "Nothing in Particular")) %>% | |
group_by(grp) %>% | |
mutate(vote = CC410a) %>% | |
mutate(vote = frcode(vote == 1 ~ "Democrat", | |
vote == 2 ~ "Republican", | |
vote == 4 ~ "Third Party")) %>% | |
ct(vote, wt = weight_vv_post, show_na = FALSE) %>% | |
mutate(year = 2012) | |
ggg3 <- cces16 %>% | |
mutate(grp = frcode(religpew == 9 ~ "Atheist", | |
religpew == 10 ~ "Agnostic", | |
religpew == 11 ~ "Nothing in Particular")) %>% | |
group_by(grp) %>% | |
mutate(vote = CC16_410a) %>% | |
mutate(vote = frcode(vote == 1 ~ "Republican", | |
vote == 2 ~ "Democrat", | |
vote == 3 | vote == 4 | vote == 5 | vote == 8 ~ "Third Party")) %>% | |
ct(vote, wt = commonweight_vv_post, show_na = FALSE) %>% | |
mutate(year = 2016) | |
ggg4 <- cces20 %>% | |
mutate(grp = frcode(religpew == 9 ~ "Atheist", | |
religpew == 10 ~ "Agnostic", | |
religpew == 11 ~ "Nothing in Particular")) %>% | |
group_by(grp) %>% | |
mutate(vote = CC20_410) %>% | |
mutate(vote = frcode(vote == 1 ~ "Democrat", | |
vote == 2 ~ "Republican", | |
vote == 4 ~ "Third Party")) %>% | |
ct(vote, wt = commonpostweight, show_na = FALSE) %>% | |
mutate(year = 2020) | |
pres <- bind_rows(ggg1, ggg2, ggg3, ggg4) | |
pres %>% | |
filter(grp == "Atheist" | grp == "Agnostic") %>% | |
ggplot(., aes(x = 1, y = pct, fill = fct_rev(vote))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_grid(year ~ grp, switch = "y") + | |
scale_fill_manual(values = c("darkorchid", "dodgerblue3", "firebrick3")) + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle = 0)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(pct*100, '%'), '')), position = position_stack(vjust = 0.5), size = 4, family = "font", color = "black") + | |
labs(x = "", y = "", title = "Vote Choice for President", subtitle = "", caption = "@ryanburge\nData: CCES 2008-2020") + | |
ggsave("E://vote_choice_ath_agn.png", width = 9, height = 3.5) | |
pid <- cces %>% | |
mutate(grp = frcode(religion == 9 ~ "Atheist", | |
religion == 10 ~ "Agnostic")) %>% | |
filter(grp != "NA") %>% | |
filter(pid7 <= 7) %>% | |
group_by(grp, year) %>% | |
mean_ci(pid7, wt = weight, ci = .84) %>% | |
select(grp, year, pid = mean) | |
id <- cces %>% | |
mutate(grp = frcode(religion == 9 ~ "Atheist", | |
religion == 10 ~ "Agnostic")) %>% | |
filter(grp != "NA") %>% | |
filter(ideo5 <= 5) %>% | |
group_by(grp, year) %>% | |
mean_ci(ideo5, wt = weight, ci = .84) %>% | |
select(grp, year, id =mean) | |
graph <- left_join(pid, id) %>% | |
mutate(year = as.factor(year)) | |
graph %>% | |
ggplot(., aes(x = pid, y = id, color = grp)) + | |
geom_point(shape = 21, stroke = 2) + | |
scale_x_continuous(limits = c(1,4.5), breaks = c(1,2,3,4,5,6,7), labels = c("Strong\nDem.", "Not Very\nStrong Dem.", "Lean\nDem.", "Independent", "Lean\nRep.", "Not Very\nStrong Rep.", "Strong\nRep.")) + | |
scale_y_continuous(limits = c(1,3.5), breaks = c(1,2,3,4,5), labels = c("Very\nLiberal", "Liberal", "Moderate", "Conservative", "Very\nConservative")) + | |
theme_rb() + | |
scale_color_manual(values = c("#008BDE", "#FF9C00")) + | |
theme(panel.grid.major = element_line(colour = "white")) + | |
geom_text_repel(data = graph, aes(x = pid, y = id, label = year), family = "font") + | |
labs(x = "Partisanship", y = "Ideology", title = "Political Positions of Atheists and Agnostics", caption = "") + | |
add_text(x = 3, y = 3, word = "Agnostics", sz = 6) + | |
add_text(x = 2.5, y = 1.65, word = "Atheists", sz = 6) + | |
ggsave("E://ath_agn_pid_id.png", dpi = 300, width = 8.34, height = 5.15) | |
cc20 <- cces20 %>% | |
filter(faminc_new <= 16) %>% | |
mutate(ath = case_when(religpew == 9 ~ 1, | |
TRUE ~ 0)) %>% | |
mutate(agn = case_when(religpew == 10 ~ 1, | |
TRUE ~ 0)) %>% | |
mutate(white = case_when(race == 1 ~ 1, TRUE ~ 0)) %>% | |
mutate(inc = faminc_new) %>% | |
mutate(age = 2020 - birthyr) %>% | |
mutate(male = case_when(gender == 1 ~ 1, gender == 2 ~ 0)) %>% | |
mutate(south = case_when(inputstate == 1 | inputstate == 12 | inputstate == 13 | inputstate == 22 | inputstate == 28 | inputstate == 37 | inputstate == 45 | inputstate == 47 ~ 1, TRUE ~ 0)) %>% | |
mutate(att = car::recode(pew_churatd, "6=1; 5=2; 4=3; 3=4; 2=5; 1=6; else = NA")) %>% | |
mutate(lib = case_when(ideo5 == 1 | ideo5 == 2 ~ 1, | |
ideo5 == 3 | ideo5 == 4 | ideo5 == 5 ~ 0)) %>% | |
select(lib, inc, age, male, educ, att, south, ath, agn) | |
coef_names <- c("Education" = "educ", | |
"Age" = "age", | |
"Male" = "male", | |
"Income" = "inc", | |
"White" = "white", | |
"Attendance" = "att", | |
"South" = "south", | |
"Immigrant/First Gen." = "imm", | |
"Political Liberal" = "lib") | |
reg1 <- glm(ath ~ educ + age + male + inc + south + att + lib, family = "binomial", data = cc20) | |
reg2 <- glm(agn ~ educ + age + male + inc + south + att + lib, family = "binomial", data = cc20) | |
model <- plot_summs(reg1, reg2, model.names = c("Atheist", "Agnostic"), scale = TRUE, robust = "HC3", coefs = coef_names) | |
model + | |
theme_rb(legend = FALSE) + | |
theme(legend.position = c(.25, y = .75)) + | |
# scale_color_manual(values = c("#008BDE", "#FF9C00")) + | |
labs(x = "Coefficient Estimate", y = "", subtitle = "", title = "Predicting an Atheist or Agnostic Identity", caption = "@ryanburge\nData: CES 2020") + | |
ggsave("E://ath_agn.png", type = 'cairo-png', width = 8, height = 4) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment