Download 23/replication_package/Code/replicate_fig_6.R from chuxuan/REPRO-Bench: direct link, hf CLI and curl.
- Browser
- Download file 4.85 kB
-
https://huggingface.co/datasets/chuxuan/REPRO-Bench/resolve/main/23/replication_package/Code/replicate_fig_6.R
- Command line
-
hf download hf://datasets/chuxuan/REPRO-Bench/23/replication_package/Code/replicate_fig_6.R
-
curl -L -o replicate_fig_6.R https://huggingface.co/datasets/chuxuan/REPRO-Bench/resolve/main/23/replication_package/Code/replicate_fig_6.R
4.85 kB
| ##--##--##--## | |
| ## Figure 6 | |
| ##--##--##--## | |
| goal_white_usa_pdv = lm_robust(degree_violence_std ~ group_goal, data=us_survey_wave2[us_survey_wave2$identity_protesters_fac=="White",]) | |
| goal_black_usa_pdv = lm_robust(degree_violence_std ~ group_goal, data=us_survey_wave2[us_survey_wave2$identity_protesters_fac=="Black",]) | |
| goal_white_usa_rv = lm_robust(recall_violence_std ~ group_goal, data=us_survey_wave2[us_survey_wave2$identity_protesters_fac=="White",]) | |
| goal_black_usa_rv = lm_robust(recall_violence_std ~ group_goal, data=us_survey_wave2[us_survey_wave2$identity_protesters_fac=="Black",]) | |
| goal_white_usa_paq = lm_robust(police_action_required_std ~ group_goal, data=us_survey_wave2[us_survey_wave2$identity_protesters_fac=="White",]) | |
| goal_black_usa_paq = lm_robust(police_action_required_std ~ group_goal, data=us_survey_wave2[us_survey_wave2$identity_protesters_fac=="Black",]) | |
| ## Plot interaction of goal and identity | |
| term_degree_violence = c(goal_white_usa_pdv$coefficients[2], goal_black_usa_pdv$coefficients[2]) | |
| se_degree_violence = c(goal_white_usa_pdv$std.error[2], goal_black_usa_pdv$std.error[2]) | |
| statistic_degree_violence = c(goal_white_usa_pdv$statistic[2], goal_black_usa_pdv$statistic[2]) | |
| pval_degree_violence = c(goal_white_usa_pdv$p.value[2], goal_black_usa_pdv$p.value[2]) | |
| term = c("Majority group protesters", "Minority group protesters") | |
| degree_violence = as.data.frame(cbind(term_degree_violence, se_degree_violence, statistic_degree_violence, pval_degree_violence)) | |
| degree_violence = cbind(degree_violence, term) | |
| colnames(degree_violence) = c("estimate", "std.error", "statistic", "p.value", "term") | |
| rownames(degree_violence) = term | |
| degree_violence$model = "Perceived degree \nof violence" | |
| term_recall_violence = c(goal_white_usa_rv$coefficients[2], goal_black_usa_rv$coefficients[2]) | |
| se_recall_violence = c(goal_white_usa_rv$std.error[2], goal_black_usa_rv$std.error[2]) | |
| statistic_recall_violence = c(goal_white_usa_rv$statistic[2], goal_black_usa_rv$statistic[2]) | |
| pval_recall_violence = c(goal_white_usa_rv$p.value[2], goal_black_usa_rv$p.value[2]) | |
| term = c("Majority group protesters", "Minority group protesters") | |
| recall_violence = as.data.frame(cbind(term_recall_violence, se_recall_violence, statistic_recall_violence, pval_recall_violence)) | |
| recall_violence = cbind(recall_violence, term) | |
| colnames(recall_violence) = c("estimate", "std.error", "statistic", "p.value", "term") | |
| rownames(recall_violence) = term | |
| recall_violence$model = "Recall \nviolence" | |
| term_police_action_required = c(goal_white_usa_paq$coefficients[2], goal_black_usa_paq$coefficients[2]) | |
| se_police_action_required = c(goal_white_usa_paq$std.error[2], goal_black_usa_paq$std.error[2]) | |
| statistic_police_action_required = c(goal_white_usa_paq$statistic[2], goal_black_usa_paq$statistic[2]) | |
| pval_police_action_required = c(goal_white_usa_paq$p.value[2], goal_black_usa_paq$p.value[2]) | |
| term = c("Majority group protesters", "Minority group protesters") | |
| police_action_required = as.data.frame(cbind(term_police_action_required, se_police_action_required, statistic_police_action_required, pval_police_action_required)) | |
| police_action_required = cbind(police_action_required, term) | |
| colnames(police_action_required) = c("estimate", "std.error", "statistic", "p.value", "term") | |
| rownames(police_action_required) = term | |
| police_action_required$model = "Police action \nrequired" | |
| differences_us = rbind(degree_violence, recall_violence, police_action_required) | |
| ## Result tables for plot | |
| differences_us2 = differences_us | |
| differences_us2$submodel = differences_us2$term | |
| differences_us2$term = "Protesting against police brutality" | |
| diffs_sm = differences_us2 | |
| results_df = data.frame(term = diffs_sm$term, | |
| estimate = diffs_sm$estimate, | |
| std.error = diffs_sm$std.error, | |
| model = diffs_sm$model, | |
| submodel = as.character(diffs_sm$submodel), | |
| stringsAsFactors = FALSE) | |
| results_df$term = factor(results_df$model, levels=c("Perceived degree \nof violence", | |
| "Recall \nviolence", | |
| "Police action \nrequired", | |
| "Does not support \nprotest")) | |
| results_df$model[results_df$submodel=="Majority group protesters"] = "White protesters" | |
| results_df$model[results_df$submodel=="Minority group protesters"] = "Black protesters" | |
| dwplot(results_df, vline = geom_vline(xintercept = 0, colour = "grey60", linetype = 2), dot_args = list(size = 2.5)) + | |
| theme_bw() + xlab("Coefficient Estimate (Std. Dev. Units)") + theme(legend.position = "bottom", axis.text=element_text(size=9), legend.title = element_blank()) + | |
| scale_colour_grey(start = .1, end = .7) | |
| ggsave(filename="Figures/fig_6.pdf", width=5, height=4) | |