Download 23/replication_package/Code/replicate_fig_7.R from chuxuan/REPRO-Bench: direct link, hf CLI and curl.
- Browser
- Download file 4.71 kB
-
https://huggingface.co/datasets/chuxuan/REPRO-Bench/resolve/main/23/replication_package/Code/replicate_fig_7.R
- Command line
-
hf download hf://datasets/chuxuan/REPRO-Bench/23/replication_package/Code/replicate_fig_7.R
-
curl -L -o replicate_fig_7.R https://huggingface.co/datasets/chuxuan/REPRO-Bench/resolve/main/23/replication_package/Code/replicate_fig_7.R
4.71 kB
| ##--##--##--## | |
| ## Figure 7 | |
| ##--##--##--## | |
| commitment_white_usa_pdv = lm_robust(degree_violence_std ~ commitment, data=us_survey_wave2[us_survey_wave2$identity_protesters_fac=="White",]) | |
| commitment_black_usa_pdv = lm_robust(degree_violence_std ~ commitment, data=us_survey_wave2[us_survey_wave2$identity_protesters_fac=="Black",]) | |
| commitment_white_israel_pdv = lm_robust(degree_violence_std ~ commitment, data=isr_survey_wave2[isr_survey_wave2$identity_protesters==0,]) | |
| commitment_ethiopian_israel_pdv = lm_robust(degree_violence_std ~ commitment, data=isr_survey_wave2[isr_survey_wave2$identity_protesters==1,]) | |
| commitment_arab_israel_pdv = lm_robust(degree_violence_std ~ commitment, data=isr_survey_wave2[isr_survey_wave2$identity_protesters==2,]) | |
| term_degree_violence = c(commitment_white_usa_pdv$coefficients[2], commitment_black_usa_pdv$coefficients[2]) | |
| se_degree_violence = c(commitment_white_usa_pdv$std.error[2], commitment_black_usa_pdv$std.error[2]) | |
| statistic_degree_violence = c(commitment_white_usa_pdv$statistic[2], commitment_black_usa_pdv$statistic[2]) | |
| pval_degree_violence = c(commitment_white_usa_pdv$p.value[2], commitment_black_usa_pdv$p.value[2]) | |
| term = c("Majority group", "Minority group") | |
| 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 of violence" | |
| differences_us = rbind(degree_violence) | |
| term_degree_violence = c(commitment_white_israel_pdv$coefficients[2], commitment_arab_israel_pdv$coefficients[2]) | |
| se_degree_violence = c(commitment_white_israel_pdv$std.error[2], commitment_arab_israel_pdv$std.error[2]) | |
| statistic_degree_violence = c(commitment_white_israel_pdv$statistic[2], commitment_arab_israel_pdv$statistic[2]) | |
| pval_degree_violence = c(commitment_white_israel_pdv$p.value[2], commitment_arab_israel_pdv$p.value[2]) | |
| term = c("Majority group", "Minority group") | |
| 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 of violence" | |
| differences_isr_arab = degree_violence | |
| term_degree_violence = c(commitment_white_israel_pdv$coefficients[2], commitment_ethiopian_israel_pdv$coefficients[2]) | |
| se_degree_violence = c(commitment_white_israel_pdv$std.error[2], commitment_ethiopian_israel_pdv$std.error[2]) | |
| statistic_degree_violence = c(commitment_white_israel_pdv$statistic[2], commitment_ethiopian_israel_pdv$statistic[2]) | |
| pval_degree_violence = c(commitment_white_israel_pdv$p.value[2], commitment_ethiopian_israel_pdv$p.value[2]) | |
| term = c("Majority group", "Minority group") | |
| 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 of violence" | |
| differences_isr_ethiopian = degree_violence | |
| ## Result tables for plot | |
| differences_us2 = differences_us | |
| differences_us2$submodel = differences_us2$term | |
| differences_us2$term = "Perception of Blacks \n(United States)" | |
| differences_isr_black2 = differences_isr_ethiopian | |
| differences_isr_black2$submodel = differences_isr_black2$term | |
| differences_isr_black2$term = "Perception of Ethiopians \n(Israel)" | |
| differences_isr_arab2 = differences_isr_arab | |
| differences_isr_arab2$submodel = differences_isr_arab2$term | |
| differences_isr_arab2$term = "Perception of Arabs \n(Israel)" | |
| diffs_sm = rbind(differences_us2, differences_isr_black2, differences_isr_arab2) | |
| rownames(diffs_sm) = 1:nrow(diffs_sm) | |
| results_df <- data.frame(term = diffs_sm$term, | |
| estimate = diffs_sm$estimate, | |
| std.error = diffs_sm$std.error, | |
| model = as.character(diffs_sm$submodel), | |
| stringsAsFactors = FALSE) | |
| 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) +xlim(-0.35,0.1) | |
| ggsave(filename="Figures/fig_7.pdf", width=5.5, height=4) | |