Code owners
Assign users and groups as approvers for specific file changes. Learn more.
interaction_plots_presi.R 4.24 KiB
# Create Interaction Term Plot for Presentation
####
create_interaction_term_plot <- function(ols_summary, treatment_labels, ord, unit, down, up) {
alpha <- 0.1
z_value <- qnorm(1 - alpha / 2)
plot_data <- summary(ols_summary)
plot_data <- as.data.frame(plot_data$coefficients)
plot_data$ME <- z_value * plot_data$`Std. Error`
plot_data <- rownames_to_column(plot_data, "Coefficient")
plot_data <- plot_data %>% filter(str_detect(Coefficient, "Treatment"))
plot_data$Coefficient <- treatment_labels
plot <- ggplot(data = plot_data) +
geom_point(aes(y = factor(Coefficient, levels=c(ord)), x = Estimate ,fill = Coefficient, color= Coefficient), stat = "identity", size =3) +
geom_errorbar(aes(y = Coefficient, xmin = Estimate - ME, xmax = Estimate + ME), width = 0.3, position = position_dodge(0.8)) +
scale_y_discrete(guide = guide_axis(angle = 0)) +
guides(fill = "none") +
geom_vline(xintercept = 0, lty = 2) +
coord_cartesian(xlim=c(down, up)) +
ylab("") +
xlab(paste0(unit))+
guides(fill = "none", color = "none", shape = "none")
return(plot)
}
case_A_labels <- c("Treated", "Optional Treatment")
case_C_labels <- c("No Info 2", "Text 1", "Text 2", "Video 1", "Video 2")
case_C_labels_re <- c("Text 1", "Text 2", "Video 1", "Video 2", "No Info 2")
case_D_labels <- c("No Info", "Treated", "Vol. Treated")
case_D_labels_re <- c("No Info", "Vol. Treated", "Treated")
plot_interview_A <- create_interaction_term_plot(ols_time_spent_control_A, case_A_labels, case_A_labels,
"Difference in Interview Time in Seconds", -150, 150)
plot_interview_A
plot_interview_C <- create_interaction_term_plot(ols_time_spent_control_C, case_C_labels, case_C_labels_re,
"Interview Time in Seconds", -150, 150)
plot_interview_D <- create_interaction_term_plot(ols_time_spent_control_D, case_D_labels, case_D_labels_re,
"Difference in Interview Time in Seconds", -150, 150)
plot_cc_A <- create_interaction_term_plot(ols_time_cc_control_A, case_A_labels, case_A_labels,
"Difference in Mean Choice Card Time in Seconds", -3, 3)
plot_cc_C <- create_interaction_term_plot(ols_time_cc_control_C, case_C_labels, case_C_labels_re,
"Difference in Mean Choice Card Time in Seconds", -3, 3)
plot_cc_D <- create_interaction_term_plot(ols_time_cc_control_D, case_D_labels, case_D_labels_re,
"Difference in Mean Choice Card Time in Seconds", -3, 3)
ggpubr::ggarrange(plot_interview_A, plot_cc_A, nrow=2 )
ggpubr::ggarrange(plot_interview_D, plot_cc_D, nrow=2 )
plot_mani_A <- create_interaction_term_plot(ols_percentage_correct_control_A, case_A_labels, case_A_labels,
"Difference in Percentage Points of Correct Quiz Statements", -5, 10)
plot_mani_C <- create_interaction_term_plot(ols_percentage_correct_control_C, case_C_labels, case_C_labels_re,
"Percentage of Correct Quiz Statements", -15, 15)
plot_mani_D <- create_interaction_term_plot(ols_percentage_correct_control_D, case_D_labels, case_D_labels_re,
"Difference in Percentage Points of Correct Quiz Statements", -5, 10)
plot_cons_A <- create_interaction_term_plot(conseq_model_control_A, case_A_labels, case_A_labels,
"Consequentiality Score", -0.8, 0.8)
plot_cons_C <- create_interaction_term_plot(conseq_model_control_C, case_C_labels, case_C_labels_re,
"Consequentiality Score", -0.8, 0.8)
plot_cons_D <- create_interaction_term_plot(conseq_model_control_D, case_D_labels, case_D_labels_re,
"Consequentiality Score", -0.8, 0.8)
plot_opt_A <- create_interaction_term_plot(ols_opt_out_control_A, case_A_labels, case_A_labels,
"Number of Status Quo Choices", -1.5, 1.5)
plot_opt_C <- create_interaction_term_plot(ols_opt_out_control_C, case_C_labels, case_C_labels_re,
"Number of Status Quo Choices", -1.5, 1.5)