library(foreign) library(tidyverse) library(dotwhisker) library(emmeans) library(broom) library(stevemisc) library(ggpubr) library(lemon) library(expss) library(insight) library(gt) # Set working directory setwd("C:/Users/Alan/Dropbox/Nottingham Research Fellow/Negativity Experiment/EJPR/PDF Figures") # Import data yougov3 <- read.spss("C:/Users/Alan/OneDrive - The University of Nottingham/Documents/YouGov3.sav", to.data.frame = TRUE) # Create functions to help with descriptives table_count <- function(x, table_object1, table_object2) { if(missing(table_object2)) { table_out <- addmargins(table(table_object1),c(x),sum) } else { table_out <- addmargins(table(table_object1, table_object2),c(x),sum) } return(table_out) } table_percent <- function(x="", y, table_object1, table_object2) { if(missing(table_object2)) { table_out <- addmargins(prop.table(table(table_object1))*100, c(y),sum) } else { table_out <- addmargins(prop.table(table(table_object1, table_object2), margin=x)*100, c(y),sum) } return(table_out) } # Create variable to indicate which party is engaging in the negative messaging yougov3$attacker <- case_when( yougov3$qgroup_exp == "1" ~ "labour", yougov3$qgroup_exp == "3" ~ "labour", yougov3$qgroup_exp == "4" ~ "labour", yougov3$qgroup_exp == "5" ~ "labour", yougov3$qgroup_exp == "2" ~ "tory", yougov3$qgroup_exp == "6" ~ "tory", yougov3$qgroup_exp == "7" ~ "tory", yougov3$qgroup_exp == "8" ~ "tory") yougov3$target <- case_when( yougov3$qgroup_exp == "1" ~ "tory", yougov3$qgroup_exp == "3" ~ "tory", yougov3$qgroup_exp == "4" ~ "tory", yougov3$qgroup_exp == "5" ~ "tory", yougov3$qgroup_exp == "2" ~ "labour", yougov3$qgroup_exp == "6" ~ "labour", yougov3$qgroup_exp == "7" ~ "labour", yougov3$qgroup_exp == "8" ~ "labour") # Create variables for labour, tory, and pooled treatment groups yougov3$labour_groups <- case_when( yougov3$qgroup_exp == "1" ~ "Control", yougov3$qgroup_exp == "3" ~ "Treat1", yougov3$qgroup_exp == "4" ~ "Treat2", yougov3$qgroup_exp == "5" ~ "Treat3") yougov3$labour_groups <- as.factor(yougov3$labour_groups) yougov3$tory_groups <- case_when( yougov3$qgroup_exp == "2" ~ "Control", yougov3$qgroup_exp == "6" ~ "Treat1", yougov3$qgroup_exp == "7" ~ "Treat2", yougov3$qgroup_exp == "8" ~ "Treat3") yougov3$tory_groups <- as.factor(yougov3$tory_groups) yougov3$pooled_groups <- case_when( yougov3$qgroup_exp == "1" ~ "Control", yougov3$qgroup_exp == "3" ~ "Treat1", yougov3$qgroup_exp == "4" ~ "Treat2", yougov3$qgroup_exp == "5" ~ "Treat3", yougov3$qgroup_exp == "2" ~ "Control", yougov3$qgroup_exp == "6" ~ "Treat1", yougov3$qgroup_exp == "7" ~ "Treat2", yougov3$qgroup_exp == "8" ~ "Treat3") yougov3$pooled_groups <- as.factor(yougov3$pooled_groups) # Create partisanship variable table_count(1,yougov3$partyid_2017) yougov3$partisan <- case_when( yougov3$partyid_2017 == "Labour" & yougov3$attacker == "labour" ~ "Attacker Copartisan", yougov3$partyid_2017 == "Conservative" & yougov3$attacker == "tory" ~ "Attacker Copartisan", yougov3$partyid_2017 == "Labour" & yougov3$target == "labour" ~ "Target Copartisan", yougov3$partyid_2017 == "Conservative" & yougov3$target == "tory" ~ "Target Copartisan", yougov3$partyid_2017 == "No – None" ~ "Non-partisan", yougov3$partyid_2017 == "Don't know" ~ "Non-partisan", is.na(yougov3$partyid_2017) ~ NA_character_, TRUE ~ "Out-party") yougov3$partisan <- as.factor(yougov3$partisan) table_count(1,yougov3$partisan) table(yougov3$partyid_2017, yougov3$partisan) # Attacking candidates # Recode negativity variables yougov3$NU1_Q4_Lab <- dplyr::recode(yougov3$NU1_Q4_Lab, "10 - Very positive" = "10", "5 - Neither negative nor positive" = "5", "0 - Very negative" = "0") yougov3$NU1_Q4_Lab <- as.numeric(yougov3$NU1_Q4_Lab) yougov3$NU1_Q4_Lab <- revcode(yougov3$NU1_Q4_Lab) yougov3$NU2_Q4_Con <- dplyr::recode(yougov3$NU2_Q4_Con, "10 - Very positive" = "10", "5 - Neither negative nor positive" = "5", "0 - Very negative" = "0") yougov3$NU2_Q4_Con <- as.numeric(yougov3$NU2_Q4_Con) yougov3$NU2_Q4_Con <- revcode(yougov3$NU2_Q4_Con) # Create aggregate negativity variable yougov3$Q4_neg1 <- with(yougov3, ifelse(attacker == "labour", NU1_Q4_Lab, NU2_Q4_Con)) # Perceived negativity of attacking candidate # Pooled candidates reg1 <- lm(Q4_neg1 ~ pooled_groups, data=yougov3) summary(reg1) # Pairwise comparison analysis for pooled candidates pairwise1_def <- pairs(emmeans(reg1, ~ pooled_groups), adjust = "none") pairwise1_rev <- pairs(emmeans(reg1, ~ pooled_groups), reverse = TRUE, adjust = "none") pairwise1_def <- tidy(pairwise1_def, conf.int = TRUE) pairwise1_rev <- tidy(pairwise1_rev, conf.int = TRUE) pairwise1_def <- pairwise1_def[c(4,5),] pairwise1_rev <- pairwise1_rev[c(1,2,4,6),] pairwise1 <- rbind(pairwise1_rev, pairwise1_def) pairwise1$order <- c(1,2,3,5,4,6) # Partisanship analysis for pooled candidates reg2 <- lm(Q4_neg1 ~ pooled_groups*partisan, data=yougov3) summary(reg2) pairwise2_def <- pairs(emmeans(reg2, ~ pooled_groups*partisan), adjust = "none") pairwise2_rev <- pairs(emmeans(reg2, ~ pooled_groups*partisan), reverse = TRUE, adjust = "none") pairwise2_def <- tidy(pairwise2_def, conf.int = TRUE) pairwise2_rev <- tidy(pairwise2_rev, conf.int = TRUE) pairwise2_def_ac <- pairwise2_def[c(16,17),] pairwise2_rev_ac <- pairwise2_rev[c(1,2,4,6),] pairwise2_ac <- rbind(pairwise2_rev_ac, pairwise2_def_ac) pairwise2_ac$model <- 1 pairwise2_ac$N <- 418 pairwise2_ac$order <- c(1,2,3,5,4,6) pairwise2_ac$contrast <- str_replace_all(pairwise2_ac$contrast, "Attacker Copartisan", "") pairwise2_ac$contrast <- str_replace_all(pairwise2_ac$contrast, " ", "") pairwise2_def_tc <- pairwise2_def[c(118,119),] pairwise2_rev_tc <- pairwise2_rev[c(91,104,118,120),] pairwise2_tc <- rbind(pairwise2_rev_tc, pairwise2_def_tc) pairwise2_tc$model <- 2 pairwise2_tc$N <- 383 pairwise2_tc$order <- c(1,2,3,5,4,6) pairwise2_tc$contrast <- str_replace_all(pairwise2_tc$contrast, "Target Copartisan", "") pairwise2_tc$contrast <- str_replace_all(pairwise2_tc$contrast, " ", "") pairwise2_def_np <- pairwise2_def[c(66,67),] pairwise2_rev_np <- pairwise2_rev[c(15,20,26,28),] pairwise2_np <- rbind(pairwise2_rev_np, pairwise2_def_np) pairwise2_np$model <- 3 pairwise2_np$N <- 351 pairwise2_np$order <- c(1,2,3,5,4,6) pairwise2_np$contrast <- str_replace_all(pairwise2_np$contrast, "Non-partisan", "") pairwise2_np$contrast <- gsub("[][(]", "", pairwise2_np$contrast) pairwise2_np$contrast <- gsub("[][)]", "", pairwise2_np$contrast) pairwise2_np$contrast <- str_replace_all(pairwise2_np$contrast, " ", "") pairwise2_def_op <- pairwise2_def[c(100,101),] pairwise2_rev_op <- pairwise2_rev[c(45,54,64,66),] pairwise2_op <- rbind(pairwise2_rev_op, pairwise2_def_op) pairwise2_op$model <- 4 pairwise2_op$N <- 262 pairwise2_op$order <- c(1,2,3,5,4,6) pairwise2_op$contrast <- str_replace_all(pairwise2_op$contrast, "Out-party", "") pairwise2_op$contrast <- gsub("[][(]", "", pairwise2_op$contrast) pairwise2_op$contrast <- gsub("[][)]", "", pairwise2_op$contrast) pairwise2_op$contrast <- str_replace_all(pairwise2_op$contrast, " ", "") pairwise2 <- rbind(pairwise2_ac, pairwise2_tc, pairwise2_np, pairwise2_op) pairwise2 <- subset(pairwise2, select = -c(1)) pairwise2 <- rename(pairwise2, term="contrast") val_lab(pairwise2$model) = num_lab(" 1 Attacker Copartisan 2 Target Copartisan 3 Non-Partisan 4 Out-Party ") pdf("Figure_S6.pdf", width = 7, height = 6) ggplot(pairwise2, aes(x = term, y = estimate) ) + geom_point(aes(color = p.value < 0.05)) + geom_pointrange(aes(ymin = conf.low, ymax = conf.high, color = p.value < 0.05), size = 0.15) + coord_flip() + scale_x_discrete(limits=rev) + geom_hline(yintercept=0, linetype="dashed", color="grey50") + theme_classic() + facet_wrap(~model, scales = "fixed", nrow=2, ncol=2, strip.position = "top") + theme(strip.placement = "outside") + labs(x = NULL, y = "Degree of negativity (Attacker)") + scale_x_discrete(limits=c("Treat1-Treat3","Treat3-Treat2","Treat1-Treat2", "Treat3-Control", "Treat2-Control", "Treat1-Control"), breaks=c("Treat1-Treat3","Treat3-Treat2","Treat1-Treat2", "Treat3-Control", "Treat2-Control", "Treat1-Control"), labels=c("**Personal Vs**
Both", "**Both Vs**
Policy", "**Personal Vs**
Policy", "**Both Vs**
Control", "**Policy Vs**
Control", "**Personal Vs**
Control")) + theme(axis.text.y=element_markdown(size=11.5, color="black"), axis.title=element_text(size=12), strip.text = element_text(size = 12, face = "bold")) + scale_color_manual(values = c("TRUE" = "black", "FALSE" = "darkgrey"), guide="none" ) dev.off() # Favourability analysis # Attacking candidate # Recode favourability variables yougov3$NU1_Q1_Lab <- dplyr::recode(yougov3$NU1_Q1_Lab, "10 - Very favourable" = "10", "5 - Neither unfavourable nor favourable" = "5", "0 - Very unfavourable" = "0") yougov3$NU1_Q1_Lab <- as.numeric(yougov3$NU1_Q1_Lab) yougov3$NU2_Q1_Con <- dplyr::recode(yougov3$NU2_Q1_Con, "10 - Very favourable" = "10", "5 - Neither unfavourable nor favourable" = "5", "0 - Very unfavourable" = "0") yougov3$NU2_Q1_Con <- as.numeric(yougov3$NU2_Q1_Con) # Create aggregate favourability variables yougov3$Q4_fav1 <- with(yougov3, ifelse(attacker == "labour", NU1_Q1_Lab, NU2_Q1_Con)) # Pooled candidates reg3 <- lm(Q4_fav1 ~ pooled_groups, data=yougov3) summary(reg3) # Pairwise comparison analysis for pooled candidates pairwise3_def <- pairs(emmeans(reg3, ~ pooled_groups), adjust = "none") pairwise3_rev <- pairs(emmeans(reg3, ~ pooled_groups), reverse = TRUE, adjust = "none") pairwise3_def <- tidy(pairwise3_def, conf.int = TRUE) pairwise3_rev <- tidy(pairwise3_rev, conf.int = TRUE) pairwise3_def <- pairwise3_def[c(4,5),] pairwise3_rev <- pairwise3_rev[c(1,2,4,6),] pairwise3 <- rbind(pairwise3_rev, pairwise3_def) pairwise3$order <- c(1,2,3,5,4,6) # Partisanship analysis for pooled candidates reg4 <- lm(Q4_fav1 ~ pooled_groups*partisan, data=yougov3) summary(reg4) pairwise4_def <- pairs(emmeans(reg4, ~ pooled_groups*partisan), adjust = "none") pairwise4_rev <- pairs(emmeans(reg4, ~ pooled_groups*partisan), reverse = TRUE, adjust = "none") pairwise4_def <- tidy(pairwise4_def, conf.int = TRUE) pairwise4_rev <- tidy(pairwise4_rev, conf.int = TRUE) pairwise4_def_ac <- pairwise4_def[c(16,17),] pairwise4_rev_ac <- pairwise4_rev[c(1,2,4,6),] pairwise4_ac <- rbind(pairwise4_rev_ac, pairwise4_def_ac) pairwise4_ac$model <- 1 pairwise4_ac$N <- 418 pairwise4_ac$order <- c(1,2,3,5,4,6) pairwise4_ac$contrast <- str_replace_all(pairwise4_ac$contrast, "Attacker Copartisan", "") pairwise4_ac$contrast <- str_replace_all(pairwise4_ac$contrast, " ", "") pairwise4_def_tc <- pairwise4_def[c(118,119),] pairwise4_rev_tc <- pairwise4_rev[c(91,104,118,120),] pairwise4_tc <- rbind(pairwise4_rev_tc, pairwise4_def_tc) pairwise4_tc$model <- 2 pairwise4_tc$N <- 383 pairwise4_tc$order <- c(1,2,3,5,4,6) pairwise4_tc$contrast <- str_replace_all(pairwise4_tc$contrast, "Target Copartisan", "") pairwise4_tc$contrast <- str_replace_all(pairwise4_tc$contrast, " ", "") pairwise4_def_np <- pairwise4_def[c(66,67),] pairwise4_rev_np <- pairwise4_rev[c(15,20,26,28),] pairwise4_np <- rbind(pairwise4_rev_np, pairwise4_def_np) pairwise4_np$model <- 3 pairwise4_np$N <- 351 pairwise4_np$order <- c(1,2,3,5,4,6) pairwise4_np$contrast <- str_replace_all(pairwise4_np$contrast, "Non-partisan", "") pairwise4_np$contrast <- gsub("[][(]", "", pairwise4_np$contrast) pairwise4_np$contrast <- gsub("[][)]", "", pairwise4_np$contrast) pairwise4_np$contrast <- str_replace_all(pairwise4_np$contrast, " ", "") pairwise4_def_op <- pairwise4_def[c(100,101),] pairwise4_rev_op <- pairwise4_rev[c(45,54,64,66),] pairwise4_op <- rbind(pairwise4_rev_op, pairwise4_def_op) pairwise4_op$model <- 4 pairwise4_op$N <- 262 pairwise4_op$order <- c(1,2,3,5,4,6) pairwise4_op$contrast <- str_replace_all(pairwise4_op$contrast, "Out-party", "") pairwise4_op$contrast <- gsub("[][(]", "", pairwise4_op$contrast) pairwise4_op$contrast <- gsub("[][)]", "", pairwise4_op$contrast) pairwise4_op$contrast <- str_replace_all(pairwise4_op$contrast, " ", "") pairwise4 <- rbind(pairwise4_ac, pairwise4_tc, pairwise4_np, pairwise4_op) pairwise4 <- subset(pairwise4, select = -c(1)) pairwise4 <- rename(pairwise4, term="contrast") val_lab(pairwise4$model) = num_lab(" 1 Attacker Copartisan 2 Target Copartisan 3 Non-Partisan 4 Out-Party ") pdf("Figure_S7.pdf", width = 7, height = 6) ggplot(pairwise4, aes(x = term, y = estimate) ) + geom_point(aes(color = p.value < 0.05)) + geom_pointrange(aes(ymin = conf.low, ymax = conf.high, color = p.value < 0.05), size = 0.15) + coord_flip() + scale_x_discrete(limits=rev) + geom_hline(yintercept=0, linetype="dashed", color="grey50") + theme_classic() + facet_wrap(~model, scales = "fixed", nrow=2, ncol=2, strip.position = "top") + theme(strip.placement = "outside") + labs(x = NULL, y = "Favourability (Attacker)") + scale_x_discrete(limits=c("Treat1-Treat3","Treat3-Treat2","Treat1-Treat2", "Treat3-Control", "Treat2-Control", "Treat1-Control"), breaks=c("Treat1-Treat3","Treat3-Treat2","Treat1-Treat2", "Treat3-Control", "Treat2-Control", "Treat1-Control"), labels=c("**Personal Vs**
Both", "**Both Vs**
Policy", "**Personal Vs**
Policy", "**Both Vs**
Control", "**Policy Vs**
Control", "**Personal Vs**
Control")) + theme(axis.text.y=element_markdown(size=11.5, color="black"), axis.title=element_text(size=12), strip.text = element_text(size = 12, face = "bold")) + scale_color_manual(values = c("TRUE" = "black", "FALSE" = "darkgrey"), guide="none" ) dev.off() # Favourability (Targeted candidate) # Targeted candidate yougov3$NU1_Q1_Con <- dplyr::recode(yougov3$NU1_Q1_Con, "10 - Very favourable" = "10", "5 - Neither unfavourable nor favourable" = "5", "0 - Very unfavourable" = "0") yougov3$NU1_Q1_Con <- as.numeric(yougov3$NU1_Q1_Con) yougov3$NU2_Q1_Lab <- dplyr::recode(yougov3$NU2_Q1_Lab, "10 - Very favourable" = "10", "5 - Neither unfavourable nor favourable" = "5", "0 - Very unfavourable" = "0") yougov3$NU2_Q1_Lab <- as.numeric(yougov3$NU2_Q1_Lab) # Create aggregate favourability variables # Targeted candidates yougov3$Q4_fav2 <- with(yougov3, ifelse(target == "tory", NU1_Q1_Con, NU2_Q1_Lab)) # Pooled candidates reg5 <- lm(Q4_fav2 ~ pooled_groups, data=yougov3) summary(reg5) pairwise5_def <- pairs(emmeans(reg5, ~ pooled_groups), adjust = "none") pairwise5_rev <- pairs(emmeans(reg5, ~ pooled_groups), reverse = TRUE, adjust = "none") pairwise5_def <- tidy(pairwise5_def, conf.int = TRUE) pairwise5_rev <- tidy(pairwise5_rev, conf.int = TRUE) pairwise5_def <- pairwise5_def[c(4,5),] pairwise5_rev <- pairwise5_rev[c(1,2,4,6),] pairwise5 <- rbind(pairwise5_rev, pairwise5_def) pairwise5$order <- c(1,2,3,5,4,6) # Partisanship analysis for pooled candidates reg6 <- lm(Q4_fav2 ~ pooled_groups*partisan, data=yougov3) summary(reg6) pairwise6_def <- pairs(emmeans(reg6, ~ pooled_groups*partisan), adjust = "none") pairwise6_rev <- pairs(emmeans(reg6, ~ pooled_groups*partisan), reverse = TRUE, adjust = "none") pairwise6_def <- tidy(pairwise6_def, conf.int = TRUE) pairwise6_rev <- tidy(pairwise6_rev, conf.int = TRUE) pairwise6_def_ac <- pairwise6_def[c(16,17),] pairwise6_rev_ac <- pairwise6_rev[c(1,2,4,6),] pairwise6_ac <- rbind(pairwise6_rev_ac, pairwise6_def_ac) pairwise6_ac$model <- 1 pairwise6_ac$N <- 418 pairwise6_ac$order <- c(1,2,3,5,4,6) pairwise6_ac$contrast <- str_replace_all(pairwise6_ac$contrast, "Attacker Copartisan", "") pairwise6_ac$contrast <- str_replace_all(pairwise6_ac$contrast, " ", "") pairwise6_def_tc <- pairwise6_def[c(118,119),] pairwise6_rev_tc <- pairwise6_rev[c(91,104,118,120),] pairwise6_tc <- rbind(pairwise6_rev_tc, pairwise6_def_tc) pairwise6_tc$model <- 2 pairwise6_tc$N <- 383 pairwise6_tc$order <- c(1,2,3,5,4,6) pairwise6_tc$contrast <- str_replace_all(pairwise6_tc$contrast, "Target Copartisan", "") pairwise6_tc$contrast <- str_replace_all(pairwise6_tc$contrast, " ", "") pairwise6_def_np <- pairwise6_def[c(66,67),] pairwise6_rev_np <- pairwise6_rev[c(15,20,26,28),] pairwise6_np <- rbind(pairwise6_rev_np, pairwise6_def_np) pairwise6_np$model <- 3 pairwise6_np$N <- 351 pairwise6_np$order <- c(1,2,3,5,4,6) pairwise6_np$contrast <- str_replace_all(pairwise6_np$contrast, "Non-partisan", "") pairwise6_np$contrast <- gsub("[][(]", "", pairwise6_np$contrast) pairwise6_np$contrast <- gsub("[][)]", "", pairwise6_np$contrast) pairwise6_np$contrast <- str_replace_all(pairwise6_np$contrast, " ", "") pairwise6_def_op <- pairwise6_def[c(100,101),] pairwise6_rev_op <- pairwise6_rev[c(45,54,64,66),] pairwise6_op <- rbind(pairwise6_rev_op, pairwise6_def_op) pairwise6_op$model <- 4 pairwise6_op$N <- 262 pairwise6_op$order <- c(1,2,3,5,4,6) pairwise6_op$contrast <- str_replace_all(pairwise6_op$contrast, "Out-party", "") pairwise6_op$contrast <- gsub("[][(]", "", pairwise6_op$contrast) pairwise6_op$contrast <- gsub("[][)]", "", pairwise6_op$contrast) pairwise6_op$contrast <- str_replace_all(pairwise6_op$contrast, " ", "") pairwise6 <- rbind(pairwise6_ac, pairwise6_tc, pairwise6_np, pairwise6_op) pairwise6 <- subset(pairwise6, select = -c(1)) pairwise6 <- rename(pairwise6, term="contrast") val_lab(pairwise6$model) = num_lab(" 1 Attacker Copartisan 2 Target Copartisan 3 Non-Partisan 4 Out-Party ") pdf("Figure_S8.pdf", width = 7, height = 6) ggplot(pairwise6, aes(x = term, y = estimate) ) + geom_point(aes(color = p.value < 0.05)) + geom_pointrange(aes(ymin = conf.low, ymax = conf.high, color = p.value < 0.05), size = 0.15) + coord_flip() + scale_x_discrete(limits=rev) + geom_hline(yintercept=0, linetype="dashed", color="grey50") + theme_classic() + facet_wrap(~model, scales = "fixed", nrow=2, ncol=2, strip.position = "top") + theme(strip.placement = "outside") + labs(x = NULL, y = "Favourability (Target)") + scale_x_discrete(limits=c("Treat1-Treat3","Treat3-Treat2","Treat1-Treat2", "Treat3-Control", "Treat2-Control", "Treat1-Control"), breaks=c("Treat1-Treat3","Treat3-Treat2","Treat1-Treat2", "Treat3-Control", "Treat2-Control", "Treat1-Control"), labels=c("**Personal Vs**
Both", "**Both Vs**
Policy", "**Personal Vs**
Policy", "**Both Vs**
Control", "**Policy Vs**
Control", "**Personal Vs**
Control")) + theme(axis.text.y=element_markdown(size=11.5, color="black"), axis.title=element_text(size=12), strip.text = element_text(size = 12, face = "bold")) + scale_color_manual(values = c("TRUE" = "black", "FALSE" = "darkgrey"), guide="none" ) dev.off() # Export Figure S5 pairwise1$model <- 1 pairwise3$model <- 2 pairwise5$model <- 3 figureS5 <- rbind(pairwise1, pairwise3, pairwise5) val_lab(figureS5$model) = num_lab(" 1 Degree of Negativity (Attacker) 2 Favourability (Attacker) 3 Favourability (Target) ") pdf("Figure_S5.pdf", width = 7, height = 4.2) ggplot(figureS5, aes(contrast, estimate)) + geom_point(aes(color = p.value < 0.05)) + geom_pointrange(aes(ymin = conf.low, ymax = conf.high, color = p.value < 0.05), size = 0.15) + coord_flip() + scale_x_discrete(limits=rev) + geom_hline(yintercept=0, linetype="dashed", color="grey50") + theme_classic() + facet_wrap(~model, labeller = label_wrap_gen(width=22)) + labs(x = NULL, y = "") + scale_x_discrete(limits=c("Treat1 - Treat3","Treat3 - Treat2","Treat1 - Treat2", "Treat3 - Control", "Treat2 - Control", "Treat1 - Control"), breaks=c("Treat1 - Treat3","Treat3 - Treat2","Treat1 - Treat2", "Treat3 - Control", "Treat2 - Control", "Treat1 - Control"), labels=c("**Personal Vs**
Both", "**Both Vs**
Policy", "**Personal Vs**
Policy", "**Both Vs**
Control", "**Policy Vs**
Control", "**Personal Vs**
Control")) + ylim(-1.25, 2.25) + theme(axis.text.y=element_markdown(size=12, color="black"), axis.title=element_text(size=12), strip.text = element_text(size = 12, face = "bold")) + scale_color_manual(values = c("TRUE" = "black", "FALSE" = "darkgrey"), guide="none" ) dev.off() rm(list = ls()) # Set working directory setwd("C:/Users/Alan/Dropbox/Nottingham Research Fellow/Negativity Experiment/EJPR/PDF Figures") # Import data yougov3 <- read.spss("C:/Users/Alan/OneDrive - The University of Nottingham/Documents/YouGov3.sav", to.data.frame = TRUE) # Create functions to help with descriptives table_count <- function(x, table_object1, table_object2) { if(missing(table_object2)) { table_out <- addmargins(table(table_object1),c(x),sum) } else { table_out <- addmargins(table(table_object1, table_object2),c(x),sum) } return(table_out) } table_percent <- function(x="", y, table_object1, table_object2) { if(missing(table_object2)) { table_out <- addmargins(prop.table(table(table_object1))*100, c(y),sum) } else { table_out <- addmargins(prop.table(table(table_object1, table_object2), margin=x)*100, c(y),sum) } return(table_out) } # Quality check based on response time yougov3$duration_seconds <- yougov3$endtime - yougov3$starttime yougov3$duration_minutes <- yougov3$duration_seconds / 60 yougov3$duration_hours <- yougov3$duration_minutes / 60 summary(yougov3$duration_minutes) summary(yougov3$duration_hours) sd(yougov3$duration_minutes) yougov3 <- subset(yougov3, yougov3$duration_hours < 1) # 54 # Create variable to indicate which party is engaging in the negative messaging yougov3$attacker <- case_when( yougov3$qgroup_exp == "1" ~ "labour", yougov3$qgroup_exp == "3" ~ "labour", yougov3$qgroup_exp == "4" ~ "labour", yougov3$qgroup_exp == "5" ~ "labour", yougov3$qgroup_exp == "2" ~ "tory", yougov3$qgroup_exp == "6" ~ "tory", yougov3$qgroup_exp == "7" ~ "tory", yougov3$qgroup_exp == "8" ~ "tory") yougov3$target <- case_when( yougov3$qgroup_exp == "1" ~ "tory", yougov3$qgroup_exp == "3" ~ "tory", yougov3$qgroup_exp == "4" ~ "tory", yougov3$qgroup_exp == "5" ~ "tory", yougov3$qgroup_exp == "2" ~ "labour", yougov3$qgroup_exp == "6" ~ "labour", yougov3$qgroup_exp == "7" ~ "labour", yougov3$qgroup_exp == "8" ~ "labour") # Create variables for labour, tory, and pooled treatment groups yougov3$labour_groups <- case_when( yougov3$qgroup_exp == "1" ~ "Control", yougov3$qgroup_exp == "3" ~ "Treat1", yougov3$qgroup_exp == "4" ~ "Treat2", yougov3$qgroup_exp == "5" ~ "Treat3") yougov3$labour_groups <- as.factor(yougov3$labour_groups) yougov3$tory_groups <- case_when( yougov3$qgroup_exp == "2" ~ "Control", yougov3$qgroup_exp == "6" ~ "Treat1", yougov3$qgroup_exp == "7" ~ "Treat2", yougov3$qgroup_exp == "8" ~ "Treat3") yougov3$tory_groups <- as.factor(yougov3$tory_groups) yougov3$pooled_groups <- case_when( yougov3$qgroup_exp == "1" ~ "Control", yougov3$qgroup_exp == "3" ~ "Treat1", yougov3$qgroup_exp == "4" ~ "Treat2", yougov3$qgroup_exp == "5" ~ "Treat3", yougov3$qgroup_exp == "2" ~ "Control", yougov3$qgroup_exp == "6" ~ "Treat1", yougov3$qgroup_exp == "7" ~ "Treat2", yougov3$qgroup_exp == "8" ~ "Treat3") yougov3$pooled_groups <- as.factor(yougov3$pooled_groups) # Create partisanship variable table_count(1,yougov3$partyid_2017) yougov3$partisan <- case_when( yougov3$partyid_2017 == "Labour" & yougov3$attacker == "labour" ~ "Attacker Copartisan", yougov3$partyid_2017 == "Conservative" & yougov3$attacker == "tory" ~ "Attacker Copartisan", yougov3$partyid_2017 == "Labour" & yougov3$target == "labour" ~ "Target Copartisan", yougov3$partyid_2017 == "Conservative" & yougov3$target == "tory" ~ "Target Copartisan", yougov3$partyid_2017 == "No – None" ~ "Non-partisan", yougov3$partyid_2017 == "Don't know" ~ "Non-partisan", is.na(yougov3$partyid_2017) ~ NA_character_, TRUE ~ "Out-party") yougov3$partisan <- as.factor(yougov3$partisan) table_count(1,yougov3$partisan) table(yougov3$partyid_2017, yougov3$partisan) # Attacking candidates # Recode negativity variables yougov3$NU1_Q4_Lab <- dplyr::recode(yougov3$NU1_Q4_Lab, "10 - Very positive" = "10", "5 - Neither negative nor positive" = "5", "0 - Very negative" = "0") yougov3$NU1_Q4_Lab <- as.numeric(yougov3$NU1_Q4_Lab) yougov3$NU1_Q4_Lab <- revcode(yougov3$NU1_Q4_Lab) yougov3$NU2_Q4_Con <- dplyr::recode(yougov3$NU2_Q4_Con, "10 - Very positive" = "10", "5 - Neither negative nor positive" = "5", "0 - Very negative" = "0") yougov3$NU2_Q4_Con <- as.numeric(yougov3$NU2_Q4_Con) yougov3$NU2_Q4_Con <- revcode(yougov3$NU2_Q4_Con) # Create aggregate negativity variable yougov3$Q4_neg1 <- with(yougov3, ifelse(attacker == "labour", NU1_Q4_Lab, NU2_Q4_Con)) # Perceived negativity of attacking candidate # Pooled candidates reg1 <- lm(Q4_neg1 ~ pooled_groups, data=yougov3, weights = yougov3$weight) summary(reg1) # Pairwise comparison analysis for pooled candidates pairwise1_def <- pairs(emmeans(reg1, ~ pooled_groups), adjust = "none") pairwise1_rev <- pairs(emmeans(reg1, ~ pooled_groups), reverse = TRUE, adjust = "none") pairwise1_def <- tidy(pairwise1_def, conf.int = TRUE) pairwise1_rev <- tidy(pairwise1_rev, conf.int = TRUE) pairwise1_def <- pairwise1_def[c(4,5),] pairwise1_rev <- pairwise1_rev[c(1,2,4,6),] pairwise1 <- rbind(pairwise1_rev, pairwise1_def) pairwise1$order <- c(1,2,3,5,4,6) # Partisanship analysis for pooled candidates reg2 <- lm(Q4_neg1 ~ pooled_groups*partisan, data=yougov3, weights = yougov3$weight) summary(reg2) pairwise2_def <- pairs(emmeans(reg2, ~ pooled_groups*partisan), adjust = "none") pairwise2_rev <- pairs(emmeans(reg2, ~ pooled_groups*partisan), reverse = TRUE, adjust = "none") pairwise2_def <- tidy(pairwise2_def, conf.int = TRUE) pairwise2_rev <- tidy(pairwise2_rev, conf.int = TRUE) pairwise2_def_ac <- pairwise2_def[c(16,17),] pairwise2_rev_ac <- pairwise2_rev[c(1,2,4,6),] pairwise2_ac <- rbind(pairwise2_rev_ac, pairwise2_def_ac) pairwise2_ac$model <- 1 pairwise2_ac$N <- 418 pairwise2_ac$order <- c(1,2,3,5,4,6) pairwise2_ac$contrast <- str_replace_all(pairwise2_ac$contrast, "Attacker Copartisan", "") pairwise2_ac$contrast <- str_replace_all(pairwise2_ac$contrast, " ", "") pairwise2_def_tc <- pairwise2_def[c(118,119),] pairwise2_rev_tc <- pairwise2_rev[c(91,104,118,120),] pairwise2_tc <- rbind(pairwise2_rev_tc, pairwise2_def_tc) pairwise2_tc$model <- 2 pairwise2_tc$N <- 383 pairwise2_tc$order <- c(1,2,3,5,4,6) pairwise2_tc$contrast <- str_replace_all(pairwise2_tc$contrast, "Target Copartisan", "") pairwise2_tc$contrast <- str_replace_all(pairwise2_tc$contrast, " ", "") pairwise2_def_np <- pairwise2_def[c(66,67),] pairwise2_rev_np <- pairwise2_rev[c(15,20,26,28),] pairwise2_np <- rbind(pairwise2_rev_np, pairwise2_def_np) pairwise2_np$model <- 3 pairwise2_np$N <- 351 pairwise2_np$order <- c(1,2,3,5,4,6) pairwise2_np$contrast <- str_replace_all(pairwise2_np$contrast, "Non-partisan", "") pairwise2_np$contrast <- gsub("[][(]", "", pairwise2_np$contrast) pairwise2_np$contrast <- gsub("[][)]", "", pairwise2_np$contrast) pairwise2_np$contrast <- str_replace_all(pairwise2_np$contrast, " ", "") pairwise2_def_op <- pairwise2_def[c(100,101),] pairwise2_rev_op <- pairwise2_rev[c(45,54,64,66),] pairwise2_op <- rbind(pairwise2_rev_op, pairwise2_def_op) pairwise2_op$model <- 4 pairwise2_op$N <- 262 pairwise2_op$order <- c(1,2,3,5,4,6) pairwise2_op$contrast <- str_replace_all(pairwise2_op$contrast, "Out-party", "") pairwise2_op$contrast <- gsub("[][(]", "", pairwise2_op$contrast) pairwise2_op$contrast <- gsub("[][)]", "", pairwise2_op$contrast) pairwise2_op$contrast <- str_replace_all(pairwise2_op$contrast, " ", "") pairwise2 <- rbind(pairwise2_ac, pairwise2_tc, pairwise2_np, pairwise2_op) pairwise2 <- subset(pairwise2, select = -c(1)) pairwise2 <- rename(pairwise2, term="contrast") val_lab(pairwise2$model) = num_lab(" 1 Attacker Copartisan 2 Target Copartisan 3 Non-Partisan 4 Out-Party ") pdf("Figure_S2.pdf", width = 7, height = 6) ggplot(pairwise2, aes(x = term, y = estimate) ) + geom_point(aes(color = p.value < 0.05)) + geom_pointrange(aes(ymin = conf.low, ymax = conf.high, color = p.value < 0.05), size = 0.15) + coord_flip() + scale_x_discrete(limits=rev) + geom_hline(yintercept=0, linetype="dashed", color="grey50") + theme_classic() + facet_wrap(~model, scales = "fixed", nrow=2, ncol=2, strip.position = "top") + theme(strip.placement = "outside") + labs(x = NULL, y = "Degree of negativity (Attacker)") + scale_x_discrete(limits=c("Treat1-Treat3","Treat3-Treat2","Treat1-Treat2", "Treat3-Control", "Treat2-Control", "Treat1-Control"), breaks=c("Treat1-Treat3","Treat3-Treat2","Treat1-Treat2", "Treat3-Control", "Treat2-Control", "Treat1-Control"), labels=c("**Personal Vs**
Both", "**Both Vs**
Policy", "**Personal Vs**
Policy", "**Both Vs**
Control", "**Policy Vs**
Control", "**Personal Vs**
Control")) + theme(axis.text.y=element_markdown(size=11.5, color="black"), axis.title=element_text(size=12), strip.text = element_text(size = 12, face = "bold")) + scale_color_manual(values = c("TRUE" = "black", "FALSE" = "darkgrey"), guide="none" ) dev.off() # Favourability analysis # Attacking candidate # Recode favourability variables yougov3$NU1_Q1_Lab <- dplyr::recode(yougov3$NU1_Q1_Lab, "10 - Very favourable" = "10", "5 - Neither unfavourable nor favourable" = "5", "0 - Very unfavourable" = "0") yougov3$NU1_Q1_Lab <- as.numeric(yougov3$NU1_Q1_Lab) yougov3$NU2_Q1_Con <- dplyr::recode(yougov3$NU2_Q1_Con, "10 - Very favourable" = "10", "5 - Neither unfavourable nor favourable" = "5", "0 - Very unfavourable" = "0") yougov3$NU2_Q1_Con <- as.numeric(yougov3$NU2_Q1_Con) # Create aggregate favourability variables yougov3$Q4_fav1 <- with(yougov3, ifelse(attacker == "labour", NU1_Q1_Lab, NU2_Q1_Con)) # Pooled candidates reg3 <- lm(Q4_fav1 ~ pooled_groups, data=yougov3, weights = yougov3$weight) summary(reg3) # Pairwise comparison analysis for pooled candidates pairwise3_def <- pairs(emmeans(reg3, ~ pooled_groups), adjust = "none") pairwise3_rev <- pairs(emmeans(reg3, ~ pooled_groups), reverse = TRUE, adjust = "none") pairwise3_def <- tidy(pairwise3_def, conf.int = TRUE) pairwise3_rev <- tidy(pairwise3_rev, conf.int = TRUE) pairwise3_def <- pairwise3_def[c(4,5),] pairwise3_rev <- pairwise3_rev[c(1,2,4,6),] pairwise3 <- rbind(pairwise3_rev, pairwise3_def) pairwise3$order <- c(1,2,3,5,4,6) # Partisanship analysis for pooled candidates reg4 <- lm(Q4_fav1 ~ pooled_groups*partisan, data=yougov3, weights = yougov3$weight) summary(reg4) pairwise4_def <- pairs(emmeans(reg4, ~ pooled_groups*partisan), adjust = "none") pairwise4_rev <- pairs(emmeans(reg4, ~ pooled_groups*partisan), reverse = TRUE, adjust = "none") pairwise4_def <- tidy(pairwise4_def, conf.int = TRUE) pairwise4_rev <- tidy(pairwise4_rev, conf.int = TRUE) pairwise4_def_ac <- pairwise4_def[c(16,17),] pairwise4_rev_ac <- pairwise4_rev[c(1,2,4,6),] pairwise4_ac <- rbind(pairwise4_rev_ac, pairwise4_def_ac) pairwise4_ac$model <- 1 pairwise4_ac$N <- 418 pairwise4_ac$order <- c(1,2,3,5,4,6) pairwise4_ac$contrast <- str_replace_all(pairwise4_ac$contrast, "Attacker Copartisan", "") pairwise4_ac$contrast <- str_replace_all(pairwise4_ac$contrast, " ", "") pairwise4_def_tc <- pairwise4_def[c(118,119),] pairwise4_rev_tc <- pairwise4_rev[c(91,104,118,120),] pairwise4_tc <- rbind(pairwise4_rev_tc, pairwise4_def_tc) pairwise4_tc$model <- 2 pairwise4_tc$N <- 383 pairwise4_tc$order <- c(1,2,3,5,4,6) pairwise4_tc$contrast <- str_replace_all(pairwise4_tc$contrast, "Target Copartisan", "") pairwise4_tc$contrast <- str_replace_all(pairwise4_tc$contrast, " ", "") pairwise4_def_np <- pairwise4_def[c(66,67),] pairwise4_rev_np <- pairwise4_rev[c(15,20,26,28),] pairwise4_np <- rbind(pairwise4_rev_np, pairwise4_def_np) pairwise4_np$model <- 3 pairwise4_np$N <- 351 pairwise4_np$order <- c(1,2,3,5,4,6) pairwise4_np$contrast <- str_replace_all(pairwise4_np$contrast, "Non-partisan", "") pairwise4_np$contrast <- gsub("[][(]", "", pairwise4_np$contrast) pairwise4_np$contrast <- gsub("[][)]", "", pairwise4_np$contrast) pairwise4_np$contrast <- str_replace_all(pairwise4_np$contrast, " ", "") pairwise4_def_op <- pairwise4_def[c(100,101),] pairwise4_rev_op <- pairwise4_rev[c(45,54,64,66),] pairwise4_op <- rbind(pairwise4_rev_op, pairwise4_def_op) pairwise4_op$model <- 4 pairwise4_op$N <- 262 pairwise4_op$order <- c(1,2,3,5,4,6) pairwise4_op$contrast <- str_replace_all(pairwise4_op$contrast, "Out-party", "") pairwise4_op$contrast <- gsub("[][(]", "", pairwise4_op$contrast) pairwise4_op$contrast <- gsub("[][)]", "", pairwise4_op$contrast) pairwise4_op$contrast <- str_replace_all(pairwise4_op$contrast, " ", "") pairwise4 <- rbind(pairwise4_ac, pairwise4_tc, pairwise4_np, pairwise4_op) pairwise4 <- subset(pairwise4, select = -c(1)) pairwise4 <- rename(pairwise4, term="contrast") val_lab(pairwise4$model) = num_lab(" 1 Attacker Copartisan 2 Target Copartisan 3 Non-Partisan 4 Out-Party ") pdf("Figure_S3.pdf", width = 7, height = 6) ggplot(pairwise4, aes(x = term, y = estimate) ) + geom_point(aes(color = p.value < 0.05)) + geom_pointrange(aes(ymin = conf.low, ymax = conf.high, color = p.value < 0.05), size = 0.15) + coord_flip() + scale_x_discrete(limits=rev) + geom_hline(yintercept=0, linetype="dashed", color="grey50") + theme_classic() + facet_wrap(~model, scales = "fixed", nrow=2, ncol=2, strip.position = "top") + theme(strip.placement = "outside") + labs(x = NULL, y = "Favourability (Attacker)") + scale_x_discrete(limits=c("Treat1-Treat3","Treat3-Treat2","Treat1-Treat2", "Treat3-Control", "Treat2-Control", "Treat1-Control"), breaks=c("Treat1-Treat3","Treat3-Treat2","Treat1-Treat2", "Treat3-Control", "Treat2-Control", "Treat1-Control"), labels=c("**Personal Vs**
Both", "**Both Vs**
Policy", "**Personal Vs**
Policy", "**Both Vs**
Control", "**Policy Vs**
Control", "**Personal Vs**
Control")) + theme(axis.text.y=element_markdown(size=11.5, color="black"), axis.title=element_text(size=12), strip.text = element_text(size = 12, face = "bold")) + scale_color_manual(values = c("TRUE" = "black", "FALSE" = "darkgrey"), guide="none" ) dev.off() # Favourability (Targeted candidate) # Targeted candidate yougov3$NU1_Q1_Con <- dplyr::recode(yougov3$NU1_Q1_Con, "10 - Very favourable" = "10", "5 - Neither unfavourable nor favourable" = "5", "0 - Very unfavourable" = "0") yougov3$NU1_Q1_Con <- as.numeric(yougov3$NU1_Q1_Con) yougov3$NU2_Q1_Lab <- dplyr::recode(yougov3$NU2_Q1_Lab, "10 - Very favourable" = "10", "5 - Neither unfavourable nor favourable" = "5", "0 - Very unfavourable" = "0") yougov3$NU2_Q1_Lab <- as.numeric(yougov3$NU2_Q1_Lab) # Create aggregate favourability variables # Targeted candidates yougov3$Q4_fav2 <- with(yougov3, ifelse(target == "tory", NU1_Q1_Con, NU2_Q1_Lab)) # Pooled candidates reg5 <- lm(Q4_fav2 ~ pooled_groups, data=yougov3, weights = yougov3$weight) summary(reg5) pairwise5_def <- pairs(emmeans(reg5, ~ pooled_groups), adjust = "none") pairwise5_rev <- pairs(emmeans(reg5, ~ pooled_groups), reverse = TRUE, adjust = "none") pairwise5_def <- tidy(pairwise5_def, conf.int = TRUE) pairwise5_rev <- tidy(pairwise5_rev, conf.int = TRUE) pairwise5_def <- pairwise5_def[c(4,5),] pairwise5_rev <- pairwise5_rev[c(1,2,4,6),] pairwise5 <- rbind(pairwise5_rev, pairwise5_def) pairwise5$order <- c(1,2,3,5,4,6) # Partisanship analysis for pooled candidates reg6 <- lm(Q4_fav2 ~ pooled_groups*partisan, data=yougov3, weights = yougov3$weight) summary(reg6) pairwise6_def <- pairs(emmeans(reg6, ~ pooled_groups*partisan), adjust = "none") pairwise6_rev <- pairs(emmeans(reg6, ~ pooled_groups*partisan), reverse = TRUE, adjust = "none") pairwise6_def <- tidy(pairwise6_def, conf.int = TRUE) pairwise6_rev <- tidy(pairwise6_rev, conf.int = TRUE) pairwise6_def_ac <- pairwise6_def[c(16,17),] pairwise6_rev_ac <- pairwise6_rev[c(1,2,4,6),] pairwise6_ac <- rbind(pairwise6_rev_ac, pairwise6_def_ac) pairwise6_ac$model <- 1 pairwise6_ac$N <- 418 pairwise6_ac$order <- c(1,2,3,5,4,6) pairwise6_ac$contrast <- str_replace_all(pairwise6_ac$contrast, "Attacker Copartisan", "") pairwise6_ac$contrast <- str_replace_all(pairwise6_ac$contrast, " ", "") pairwise6_def_tc <- pairwise6_def[c(118,119),] pairwise6_rev_tc <- pairwise6_rev[c(91,104,118,120),] pairwise6_tc <- rbind(pairwise6_rev_tc, pairwise6_def_tc) pairwise6_tc$model <- 2 pairwise6_tc$N <- 383 pairwise6_tc$order <- c(1,2,3,5,4,6) pairwise6_tc$contrast <- str_replace_all(pairwise6_tc$contrast, "Target Copartisan", "") pairwise6_tc$contrast <- str_replace_all(pairwise6_tc$contrast, " ", "") pairwise6_def_np <- pairwise6_def[c(66,67),] pairwise6_rev_np <- pairwise6_rev[c(15,20,26,28),] pairwise6_np <- rbind(pairwise6_rev_np, pairwise6_def_np) pairwise6_np$model <- 3 pairwise6_np$N <- 351 pairwise6_np$order <- c(1,2,3,5,4,6) pairwise6_np$contrast <- str_replace_all(pairwise6_np$contrast, "Non-partisan", "") pairwise6_np$contrast <- gsub("[][(]", "", pairwise6_np$contrast) pairwise6_np$contrast <- gsub("[][)]", "", pairwise6_np$contrast) pairwise6_np$contrast <- str_replace_all(pairwise6_np$contrast, " ", "") pairwise6_def_op <- pairwise6_def[c(100,101),] pairwise6_rev_op <- pairwise6_rev[c(45,54,64,66),] pairwise6_op <- rbind(pairwise6_rev_op, pairwise6_def_op) pairwise6_op$model <- 4 pairwise6_op$N <- 262 pairwise6_op$order <- c(1,2,3,5,4,6) pairwise6_op$contrast <- str_replace_all(pairwise6_op$contrast, "Out-party", "") pairwise6_op$contrast <- gsub("[][(]", "", pairwise6_op$contrast) pairwise6_op$contrast <- gsub("[][)]", "", pairwise6_op$contrast) pairwise6_op$contrast <- str_replace_all(pairwise6_op$contrast, " ", "") pairwise6 <- rbind(pairwise6_ac, pairwise6_tc, pairwise6_np, pairwise6_op) pairwise6 <- subset(pairwise6, select = -c(1)) pairwise6 <- rename(pairwise6, term="contrast") val_lab(pairwise6$model) = num_lab(" 1 Attacker Copartisan 2 Target Copartisan 3 Non-Partisan 4 Out-Party ") pdf("Figure_S4.pdf", width = 7, height = 6) ggplot(pairwise6, aes(x = term, y = estimate) ) + geom_point(aes(color = p.value < 0.05)) + geom_pointrange(aes(ymin = conf.low, ymax = conf.high, color = p.value < 0.05), size = 0.15) + coord_flip() + scale_x_discrete(limits=rev) + geom_hline(yintercept=0, linetype="dashed", color="grey50") + theme_classic() + facet_wrap(~model, scales = "fixed", nrow=2, ncol=2, strip.position = "top") + theme(strip.placement = "outside") + labs(x = NULL, y = "Favourability (Target)") + scale_x_discrete(limits=c("Treat1-Treat3","Treat3-Treat2","Treat1-Treat2", "Treat3-Control", "Treat2-Control", "Treat1-Control"), breaks=c("Treat1-Treat3","Treat3-Treat2","Treat1-Treat2", "Treat3-Control", "Treat2-Control", "Treat1-Control"), labels=c("**Personal Vs**
Both", "**Both Vs**
Policy", "**Personal Vs**
Policy", "**Both Vs**
Control", "**Policy Vs**
Control", "**Personal Vs**
Control")) + theme(axis.text.y=element_markdown(size=11.5, color="black"), axis.title=element_text(size=12), strip.text = element_text(size = 12, face = "bold")) + scale_color_manual(values = c("TRUE" = "black", "FALSE" = "darkgrey"), guide="none" ) dev.off() # Export Figure S1 pairwise1$model <- 1 pairwise3$model <- 2 pairwise5$model <- 3 figureS1 <- rbind(pairwise1, pairwise3, pairwise5) val_lab(figureS1$model) = num_lab(" 1 Degree of Negativity (Attacker) 2 Favourability (Attacker) 3 Favourability (Target) ") pdf("Figure_S1.pdf", width = 7, height = 4.2) ggplot(figureS1, aes(contrast, estimate)) + geom_point(aes(color = p.value < 0.05)) + geom_pointrange(aes(ymin = conf.low, ymax = conf.high, color = p.value < 0.05), size = 0.15) + coord_flip() + scale_x_discrete(limits=rev) + geom_hline(yintercept=0, linetype="dashed", color="grey50") + theme_classic() + facet_wrap(~model, labeller = label_wrap_gen(width=22)) + labs(x = NULL, y = "") + scale_x_discrete(limits=c("Treat1 - Treat3","Treat3 - Treat2","Treat1 - Treat2", "Treat3 - Control", "Treat2 - Control", "Treat1 - Control"), breaks=c("Treat1 - Treat3","Treat3 - Treat2","Treat1 - Treat2", "Treat3 - Control", "Treat2 - Control", "Treat1 - Control"), labels=c("**Personal Vs**
Both", "**Both Vs**
Policy", "**Personal Vs**
Policy", "**Both Vs**
Control", "**Policy Vs**
Control", "**Personal Vs**
Control")) + ylim(-1.3, 2.25) + theme(axis.text.y=element_markdown(size=12, color="black"), axis.title=element_text(size=12), strip.text = element_text(size = 12, face = "bold")) + scale_color_manual(values = c("TRUE" = "black", "FALSE" = "darkgrey"), guide="none" ) dev.off() rm(list = ls()) # Set working directory setwd("C:/Users/Alan/Dropbox/Nottingham Research Fellow/Negativity Experiment/EJPR/PDF Figures") # Import data yougov3 <- read.spss("C:/Users/Alan/OneDrive - The University of Nottingham/Documents/YouGov3.sav", to.data.frame = TRUE) # Create functions to help with descriptives table_count <- function(x, table_object1, table_object2) { if(missing(table_object2)) { table_out <- addmargins(table(table_object1),c(x),sum) } else { table_out <- addmargins(table(table_object1, table_object2),c(x),sum) } return(table_out) } table_percent <- function(x="", y, table_object1, table_object2) { if(missing(table_object2)) { table_out <- addmargins(prop.table(table(table_object1))*100, c(y),sum) } else { table_out <- addmargins(prop.table(table(table_object1, table_object2), margin=x)*100, c(y),sum) } return(table_out) } # Create variable to indicate which party is engaging in the negative messaging yougov3$attacker <- case_when( yougov3$qgroup_exp == "1" ~ "labour", yougov3$qgroup_exp == "3" ~ "labour", yougov3$qgroup_exp == "4" ~ "labour", yougov3$qgroup_exp == "5" ~ "labour", yougov3$qgroup_exp == "2" ~ "tory", yougov3$qgroup_exp == "6" ~ "tory", yougov3$qgroup_exp == "7" ~ "tory", yougov3$qgroup_exp == "8" ~ "tory") yougov3$target <- case_when( yougov3$qgroup_exp == "1" ~ "tory", yougov3$qgroup_exp == "3" ~ "tory", yougov3$qgroup_exp == "4" ~ "tory", yougov3$qgroup_exp == "5" ~ "tory", yougov3$qgroup_exp == "2" ~ "labour", yougov3$qgroup_exp == "6" ~ "labour", yougov3$qgroup_exp == "7" ~ "labour", yougov3$qgroup_exp == "8" ~ "labour") # Create variables for labour, tory, and pooled treatment groups yougov3$labour_groups <- case_when( yougov3$qgroup_exp == "1" ~ "Control", yougov3$qgroup_exp == "3" ~ "Treat1", yougov3$qgroup_exp == "4" ~ "Treat2", yougov3$qgroup_exp == "5" ~ "Treat3") yougov3$labour_groups <- as.factor(yougov3$labour_groups) yougov3$tory_groups <- case_when( yougov3$qgroup_exp == "2" ~ "Control", yougov3$qgroup_exp == "6" ~ "Treat1", yougov3$qgroup_exp == "7" ~ "Treat2", yougov3$qgroup_exp == "8" ~ "Treat3") yougov3$tory_groups <- as.factor(yougov3$tory_groups) yougov3$pooled_groups <- case_when( yougov3$qgroup_exp == "1" ~ "Control", yougov3$qgroup_exp == "3" ~ "Treat1", yougov3$qgroup_exp == "4" ~ "Treat2", yougov3$qgroup_exp == "5" ~ "Treat3", yougov3$qgroup_exp == "2" ~ "Control", yougov3$qgroup_exp == "6" ~ "Treat1", yougov3$qgroup_exp == "7" ~ "Treat2", yougov3$qgroup_exp == "8" ~ "Treat3") yougov3$pooled_groups <- as.factor(yougov3$pooled_groups) # Create partisanship variable table_count(1,yougov3$partyid_2017) yougov3$partisan <- case_when( yougov3$partyid_2017 == "Labour" & yougov3$attacker == "labour" ~ "Attacker Copartisan", yougov3$partyid_2017 == "Conservative" & yougov3$attacker == "tory" ~ "Attacker Copartisan", yougov3$partyid_2017 == "Labour" & yougov3$target == "labour" ~ "Target Copartisan", yougov3$partyid_2017 == "Conservative" & yougov3$target == "tory" ~ "Target Copartisan", yougov3$partyid_2017 == "No – None" ~ "Non-partisan", yougov3$partyid_2017 == "Don't know" ~ "Non-partisan", is.na(yougov3$partyid_2017) ~ NA_character_, TRUE ~ "Out-party") yougov3$partisan <- as.factor(yougov3$partisan) table_count(1,yougov3$partisan) table(yougov3$partyid_2017, yougov3$partisan) # Attacking candidates # Recode negativity variables yougov3$NU1_Q4_Lab <- dplyr::recode(yougov3$NU1_Q4_Lab, "10 - Very positive" = "10", "5 - Neither negative nor positive" = "5", "0 - Very negative" = "0") yougov3$NU1_Q4_Lab <- as.numeric(yougov3$NU1_Q4_Lab) yougov3$NU1_Q4_Lab <- revcode(yougov3$NU1_Q4_Lab) yougov3$NU2_Q4_Con <- dplyr::recode(yougov3$NU2_Q4_Con, "10 - Very positive" = "10", "5 - Neither negative nor positive" = "5", "0 - Very negative" = "0") yougov3$NU2_Q4_Con <- as.numeric(yougov3$NU2_Q4_Con) yougov3$NU2_Q4_Con <- revcode(yougov3$NU2_Q4_Con) # Create aggregate negativity variable yougov3$Q4_neg1 <- with(yougov3, ifelse(attacker == "labour", NU1_Q4_Lab, NU2_Q4_Con)) # Perceived negativity of attacking candidate # Pooled candidates reg1 <- lm(Q4_neg1 ~ pooled_groups, data=yougov3, weights = yougov3$weight) summary(reg1) # Pairwise comparison analysis for pooled candidates pairwise1_def <- pairs(emmeans(reg1, ~ pooled_groups), adjust = "BH") pairwise1_rev <- pairs(emmeans(reg1, ~ pooled_groups), reverse = TRUE, adjust = "BH") pairwise1_def <- tidy(pairwise1_def) pairwise1_rev <- tidy(pairwise1_rev) pairwise1_def <- pairwise1_def[c(4,5),] pairwise1_rev <- pairwise1_rev[c(1,2,4,6),] pairwise1 <- rbind(pairwise1_rev, pairwise1_def) pairwise1$order <- c(1,2,3,5,4,6) # Partisanship analysis for pooled candidates reg2 <- lm(Q4_neg1 ~ pooled_groups*partisan, data=yougov3, weights = yougov3$weight) summary(reg2) pairwise2_def <- pairs(emmeans(reg2, ~ pooled_groups*partisan), adjust = "BH") pairwise2_rev <- pairs(emmeans(reg2, ~ pooled_groups*partisan), reverse = TRUE, adjust = "BH") pairwise2_def <- tidy(pairwise2_def) pairwise2_rev <- tidy(pairwise2_rev) pairwise2_def_ac <- pairwise2_def[c(16,17),] pairwise2_rev_ac <- pairwise2_rev[c(1,2,4,6),] pairwise2_ac <- rbind(pairwise2_rev_ac, pairwise2_def_ac) pairwise2_ac$model <- 1 pairwise2_ac$N <- 418 pairwise2_ac$order <- c(1,2,3,5,4,6) pairwise2_ac$contrast <- str_replace_all(pairwise2_ac$contrast, "Attacker Copartisan", "") pairwise2_ac$contrast <- str_replace_all(pairwise2_ac$contrast, " ", "") pairwise2_def_tc <- pairwise2_def[c(118,119),] pairwise2_rev_tc <- pairwise2_rev[c(91,104,118,120),] pairwise2_tc <- rbind(pairwise2_rev_tc, pairwise2_def_tc) pairwise2_tc$model <- 2 pairwise2_tc$N <- 383 pairwise2_tc$order <- c(1,2,3,5,4,6) pairwise2_tc$contrast <- str_replace_all(pairwise2_tc$contrast, "Target Copartisan", "") pairwise2_tc$contrast <- str_replace_all(pairwise2_tc$contrast, " ", "") pairwise2_def_np <- pairwise2_def[c(66,67),] pairwise2_rev_np <- pairwise2_rev[c(15,20,26,28),] pairwise2_np <- rbind(pairwise2_rev_np, pairwise2_def_np) pairwise2_np$model <- 3 pairwise2_np$N <- 351 pairwise2_np$order <- c(1,2,3,5,4,6) pairwise2_np$contrast <- str_replace_all(pairwise2_np$contrast, "Non-partisan", "") pairwise2_np$contrast <- gsub("[][(]", "", pairwise2_np$contrast) pairwise2_np$contrast <- gsub("[][)]", "", pairwise2_np$contrast) pairwise2_np$contrast <- str_replace_all(pairwise2_np$contrast, " ", "") pairwise2_def_op <- pairwise2_def[c(100,101),] pairwise2_rev_op <- pairwise2_rev[c(45,54,64,66),] pairwise2_op <- rbind(pairwise2_rev_op, pairwise2_def_op) pairwise2_op$model <- 4 pairwise2_op$N <- 262 pairwise2_op$order <- c(1,2,3,5,4,6) pairwise2_op$contrast <- str_replace_all(pairwise2_op$contrast, "Out-party", "") pairwise2_op$contrast <- gsub("[][(]", "", pairwise2_op$contrast) pairwise2_op$contrast <- gsub("[][)]", "", pairwise2_op$contrast) pairwise2_op$contrast <- str_replace_all(pairwise2_op$contrast, " ", "") pairwise2 <- rbind(pairwise2_ac, pairwise2_tc, pairwise2_np, pairwise2_op) pairwise2 <- subset(pairwise2, select = -c(1)) pairwise2 <- rename(pairwise2, term="contrast") val_lab(pairwise2$model) = num_lab(" 1 Attacker Copartisan 2 Target Copartisan 3 Non-Partisan 4 Out-Party ") # Export results as table with main stats treatment_order <- c("Treat1-Control", "Treat2-Control", "Treat3-Control", "Treat1-Treat2", "Treat3-Treat2", "Treat1-Treat3") pairwise2$term <- factor(pairwise2$term, levels = treatment_order) pairwise2 <- pairwise2[,c(1, 3:4, 6:9)] pairwise2 <- pairwise2 %>% arrange(model, term) pairwise2 <- pairwise2 %>% mutate(adj.p.value = round(adj.p.value, 5)) colnames(pairwise2) <- c("Treatment", "Estimate", "Std Error", "t stat", "p-value", "Model", "N") pairwise2 <- pairwise2 %>% mutate(Treatment = case_when( Treatment == "Treat1-Control" ~ "Personal-Control", Treatment == "Treat2-Control" ~ "Policy-Control", Treatment == "Treat3-Control" ~ "Both-Control", Treatment == "Treat1-Treat2" ~ "Personal-Policy", Treatment == "Treat3-Treat2" ~ "Both-Policy", TRUE ~ "Personal-Both" )) html_table <- pairwise2 %>% gt() %>% fmt_number( columns = "p-value", decimals = 5 ) %>% fmt_number( columns = c("Estimate", "Std Error", "t stat"), decimals = 2 ) %>% tab_style( style = cell_text(weight = "bold"), locations = cells_body( columns = everything(), rows = `p-value` < 0.05 ) ) html_table |> gtsave("table_S2.docx", type = "docx") # Favourability analysis # Attacking candidate # Recode favourability variables yougov3$NU1_Q1_Lab <- dplyr::recode(yougov3$NU1_Q1_Lab, "10 - Very favourable" = "10", "5 - Neither unfavourable nor favourable" = "5", "0 - Very unfavourable" = "0") yougov3$NU1_Q1_Lab <- as.numeric(yougov3$NU1_Q1_Lab) yougov3$NU2_Q1_Con <- dplyr::recode(yougov3$NU2_Q1_Con, "10 - Very favourable" = "10", "5 - Neither unfavourable nor favourable" = "5", "0 - Very unfavourable" = "0") yougov3$NU2_Q1_Con <- as.numeric(yougov3$NU2_Q1_Con) # Create aggregate favourability variables yougov3$Q4_fav1 <- with(yougov3, ifelse(attacker == "labour", NU1_Q1_Lab, NU2_Q1_Con)) # Pooled candidates reg3 <- lm(Q4_fav1 ~ pooled_groups, data=yougov3, weights = yougov3$weight) summary(reg3) # Pairwise comparison analysis for pooled candidates pairwise3_def <- pairs(emmeans(reg3, ~ pooled_groups), adjust = "BH") pairwise3_rev <- pairs(emmeans(reg3, ~ pooled_groups), reverse = TRUE, adjust = "BH") pairwise3_def <- tidy(pairwise3_def) pairwise3_rev <- tidy(pairwise3_rev) pairwise3_def <- pairwise3_def[c(4,5),] pairwise3_rev <- pairwise3_rev[c(1,2,4,6),] pairwise3 <- rbind(pairwise3_rev, pairwise3_def) pairwise3$order <- c(1,2,3,5,4,6) # Partisanship analysis for pooled candidates reg4 <- lm(Q4_fav1 ~ pooled_groups*partisan, data=yougov3, weights = yougov3$weight) summary(reg4) pairwise4_def <- pairs(emmeans(reg4, ~ pooled_groups*partisan), adjust = "BH") pairwise4_rev <- pairs(emmeans(reg4, ~ pooled_groups*partisan), reverse = TRUE, adjust = "BH") pairwise4_def <- tidy(pairwise4_def) pairwise4_rev <- tidy(pairwise4_rev) pairwise4_def_ac <- pairwise4_def[c(16,17),] pairwise4_rev_ac <- pairwise4_rev[c(1,2,4,6),] pairwise4_ac <- rbind(pairwise4_rev_ac, pairwise4_def_ac) pairwise4_ac$model <- 1 pairwise4_ac$N <- 418 pairwise4_ac$order <- c(1,2,3,5,4,6) pairwise4_ac$contrast <- str_replace_all(pairwise4_ac$contrast, "Attacker Copartisan", "") pairwise4_ac$contrast <- str_replace_all(pairwise4_ac$contrast, " ", "") pairwise4_def_tc <- pairwise4_def[c(118,119),] pairwise4_rev_tc <- pairwise4_rev[c(91,104,118,120),] pairwise4_tc <- rbind(pairwise4_rev_tc, pairwise4_def_tc) pairwise4_tc$model <- 2 pairwise4_tc$N <- 383 pairwise4_tc$order <- c(1,2,3,5,4,6) pairwise4_tc$contrast <- str_replace_all(pairwise4_tc$contrast, "Target Copartisan", "") pairwise4_tc$contrast <- str_replace_all(pairwise4_tc$contrast, " ", "") pairwise4_def_np <- pairwise4_def[c(66,67),] pairwise4_rev_np <- pairwise4_rev[c(15,20,26,28),] pairwise4_np <- rbind(pairwise4_rev_np, pairwise4_def_np) pairwise4_np$model <- 3 pairwise4_np$N <- 351 pairwise4_np$order <- c(1,2,3,5,4,6) pairwise4_np$contrast <- str_replace_all(pairwise4_np$contrast, "Non-partisan", "") pairwise4_np$contrast <- gsub("[][(]", "", pairwise4_np$contrast) pairwise4_np$contrast <- gsub("[][)]", "", pairwise4_np$contrast) pairwise4_np$contrast <- str_replace_all(pairwise4_np$contrast, " ", "") pairwise4_def_op <- pairwise4_def[c(100,101),] pairwise4_rev_op <- pairwise4_rev[c(45,54,64,66),] pairwise4_op <- rbind(pairwise4_rev_op, pairwise4_def_op) pairwise4_op$model <- 4 pairwise4_op$N <- 262 pairwise4_op$order <- c(1,2,3,5,4,6) pairwise4_op$contrast <- str_replace_all(pairwise4_op$contrast, "Out-party", "") pairwise4_op$contrast <- gsub("[][(]", "", pairwise4_op$contrast) pairwise4_op$contrast <- gsub("[][)]", "", pairwise4_op$contrast) pairwise4_op$contrast <- str_replace_all(pairwise4_op$contrast, " ", "") pairwise4 <- rbind(pairwise4_ac, pairwise4_tc, pairwise4_np, pairwise4_op) pairwise4 <- subset(pairwise4, select = -c(1)) pairwise4 <- rename(pairwise4, term="contrast") val_lab(pairwise4$model) = num_lab(" 1 Attacker Copartisan 2 Target Copartisan 3 Non-Partisan 4 Out-Party ") # Export results as table with main stats treatment_order <- c("Treat1-Control", "Treat2-Control", "Treat3-Control", "Treat1-Treat2", "Treat3-Treat2", "Treat1-Treat3") pairwise4$term <- factor(pairwise4$term, levels = treatment_order) pairwise4 <- pairwise4[,c(1, 3:4, 6:9)] pairwise4 <- pairwise4 %>% arrange(model, term) pairwise4 <- pairwise4 %>% mutate(adj.p.value = round(adj.p.value, 5)) colnames(pairwise4) <- c("Treatment", "Estimate", "Std Error", "t stat", "p-value", "Model", "N") pairwise4 <- pairwise4 %>% mutate(Treatment = case_when( Treatment == "Treat1-Control" ~ "Personal-Control", Treatment == "Treat2-Control" ~ "Policy-Control", Treatment == "Treat3-Control" ~ "Both-Control", Treatment == "Treat1-Treat2" ~ "Personal-Policy", Treatment == "Treat3-Treat2" ~ "Both-Policy", TRUE ~ "Personal-Both" )) html_table <- pairwise4 %>% gt() %>% fmt_number( columns = "p-value", decimals = 5 ) %>% fmt_number( columns = c("Estimate", "Std Error", "t stat"), decimals = 2 ) %>% tab_style( style = cell_text(weight = "bold"), locations = cells_body( columns = everything(), rows = `p-value` < 0.05 ) ) html_table |> gtsave("table_S3.docx", type = "docx") # Favourability (Targeted candidate) # Targeted candidate yougov3$NU1_Q1_Con <- dplyr::recode(yougov3$NU1_Q1_Con, "10 - Very favourable" = "10", "5 - Neither unfavourable nor favourable" = "5", "0 - Very unfavourable" = "0") yougov3$NU1_Q1_Con <- as.numeric(yougov3$NU1_Q1_Con) yougov3$NU2_Q1_Lab <- dplyr::recode(yougov3$NU2_Q1_Lab, "10 - Very favourable" = "10", "5 - Neither unfavourable nor favourable" = "5", "0 - Very unfavourable" = "0") yougov3$NU2_Q1_Lab <- as.numeric(yougov3$NU2_Q1_Lab) # Create aggregate favourability variables # Targeted candidates yougov3$Q4_fav2 <- with(yougov3, ifelse(target == "tory", NU1_Q1_Con, NU2_Q1_Lab)) # Pooled candidates reg5 <- lm(Q4_fav2 ~ pooled_groups, data=yougov3, weights = yougov3$weight) summary(reg5) pairwise5_def <- pairs(emmeans(reg5, ~ pooled_groups), adjust = "BH") pairwise5_rev <- pairs(emmeans(reg5, ~ pooled_groups), reverse = TRUE, adjust = "BH") pairwise5_def <- tidy(pairwise5_def) pairwise5_rev <- tidy(pairwise5_rev) pairwise5_def <- pairwise5_def[c(4,5),] pairwise5_rev <- pairwise5_rev[c(1,2,4,6),] pairwise5 <- rbind(pairwise5_rev, pairwise5_def) pairwise5$order <- c(1,2,3,5,4,6) # Partisanship analysis for pooled candidates reg6 <- lm(Q4_fav2 ~ pooled_groups*partisan, data=yougov3, weights = yougov3$weight) summary(reg6) pairwise6_def <- pairs(emmeans(reg6, ~ pooled_groups*partisan), adjust = "BH") pairwise6_rev <- pairs(emmeans(reg6, ~ pooled_groups*partisan), reverse = TRUE, adjust = "BH") pairwise6_def <- tidy(pairwise6_def) pairwise6_rev <- tidy(pairwise6_rev) pairwise6_def_ac <- pairwise6_def[c(16,17),] pairwise6_rev_ac <- pairwise6_rev[c(1,2,4,6),] pairwise6_ac <- rbind(pairwise6_rev_ac, pairwise6_def_ac) pairwise6_ac$model <- 1 pairwise6_ac$N <- 418 pairwise6_ac$order <- c(1,2,3,5,4,6) pairwise6_ac$contrast <- str_replace_all(pairwise6_ac$contrast, "Attacker Copartisan", "") pairwise6_ac$contrast <- str_replace_all(pairwise6_ac$contrast, " ", "") pairwise6_def_tc <- pairwise6_def[c(118,119),] pairwise6_rev_tc <- pairwise6_rev[c(91,104,118,120),] pairwise6_tc <- rbind(pairwise6_rev_tc, pairwise6_def_tc) pairwise6_tc$model <- 2 pairwise6_tc$N <- 383 pairwise6_tc$order <- c(1,2,3,5,4,6) pairwise6_tc$contrast <- str_replace_all(pairwise6_tc$contrast, "Target Copartisan", "") pairwise6_tc$contrast <- str_replace_all(pairwise6_tc$contrast, " ", "") pairwise6_def_np <- pairwise6_def[c(66,67),] pairwise6_rev_np <- pairwise6_rev[c(15,20,26,28),] pairwise6_np <- rbind(pairwise6_rev_np, pairwise6_def_np) pairwise6_np$model <- 3 pairwise6_np$N <- 351 pairwise6_np$order <- c(1,2,3,5,4,6) pairwise6_np$contrast <- str_replace_all(pairwise6_np$contrast, "Non-partisan", "") pairwise6_np$contrast <- gsub("[][(]", "", pairwise6_np$contrast) pairwise6_np$contrast <- gsub("[][)]", "", pairwise6_np$contrast) pairwise6_np$contrast <- str_replace_all(pairwise6_np$contrast, " ", "") pairwise6_def_op <- pairwise6_def[c(100,101),] pairwise6_rev_op <- pairwise6_rev[c(45,54,64,66),] pairwise6_op <- rbind(pairwise6_rev_op, pairwise6_def_op) pairwise6_op$model <- 4 pairwise6_op$N <- 262 pairwise6_op$order <- c(1,2,3,5,4,6) pairwise6_op$contrast <- str_replace_all(pairwise6_op$contrast, "Out-party", "") pairwise6_op$contrast <- gsub("[][(]", "", pairwise6_op$contrast) pairwise6_op$contrast <- gsub("[][)]", "", pairwise6_op$contrast) pairwise6_op$contrast <- str_replace_all(pairwise6_op$contrast, " ", "") pairwise6 <- rbind(pairwise6_ac, pairwise6_tc, pairwise6_np, pairwise6_op) pairwise6 <- subset(pairwise6, select = -c(1)) pairwise6 <- rename(pairwise6, term="contrast") val_lab(pairwise6$model) = num_lab(" 1 Attacker Copartisan 2 Target Copartisan 3 Non-Partisan 4 Out-Party ") # Export results as table with main stats treatment_order <- c("Treat1-Control", "Treat2-Control", "Treat3-Control", "Treat1-Treat2", "Treat3-Treat2", "Treat1-Treat3") pairwise6$term <- factor(pairwise6$term, levels = treatment_order) pairwise6 <- pairwise6[,c(1, 3:4, 6:9)] pairwise6 <- pairwise6 %>% arrange(model, term) pairwise6 <- pairwise6 %>% mutate(adj.p.value = round(adj.p.value, 5)) colnames(pairwise6) <- c("Treatment", "Estimate", "Std Error", "t stat", "p-value", "Model", "N") pairwise6 <- pairwise6 %>% mutate(Treatment = case_when( Treatment == "Treat1-Control" ~ "Personal-Control", Treatment == "Treat2-Control" ~ "Policy-Control", Treatment == "Treat3-Control" ~ "Both-Control", Treatment == "Treat1-Treat2" ~ "Personal-Policy", Treatment == "Treat3-Treat2" ~ "Both-Policy", TRUE ~ "Personal-Both" )) html_table <- pairwise6 %>% gt() %>% fmt_number( columns = "p-value", decimals = 5 ) %>% fmt_number( columns = c("Estimate", "Std Error", "t stat"), decimals = 2 ) %>% tab_style( style = cell_text(weight = "bold"), locations = cells_body( columns = everything(), rows = `p-value` < 0.05 ) ) html_table |> gtsave("table_S4.docx", type = "docx") # Export Table S1 pairwise1$model <- 1 pairwise3$model <- 2 pairwise5$model <- 3 tableS1 <- rbind(pairwise1, pairwise3, pairwise5) tableS1 <- subset(tableS1, select = -c(1)) tableS1 <- rename(tableS1, term="contrast") tableS1$term <- str_replace_all(tableS1$term, " ", "") val_lab(tableS1$model) = num_lab(" 1 Degree of Negativity (Attacker) 2 Favourability (Attacker) 3 Favourability (Target) ") # Export results as table with main stats treatment_order <- c("Treat1-Control", "Treat2-Control", "Treat3-Control", "Treat1-Treat2", "Treat3-Treat2", "Treat1-Treat3") tableS1$term <- factor(tableS1$term, levels = treatment_order) tableS1 <- tableS1[,c(1, 3:4, 6, 7, 9)] tableS1$N <- 1664 tableS1 <- tableS1 %>% arrange(model, term) tableS1 <- tableS1 %>% mutate(adj.p.value = round(adj.p.value, 5)) colnames(tableS1) <- c("Treatment", "Estimate", "Std Error", "t stat", "p-value", "Model", "N") tableS1 <- tableS1 %>% mutate(Treatment = case_when( Treatment == "Treat1-Control" ~ "Personal-Control", Treatment == "Treat2-Control" ~ "Policy-Control", Treatment == "Treat3-Control" ~ "Both-Control", Treatment == "Treat1-Treat2" ~ "Personal-Policy", Treatment == "Treat3-Treat2" ~ "Both-Policy", TRUE ~ "Personal-Both" )) html_table <- tableS1 %>% gt() %>% fmt_number( columns = "p-value", decimals = 5 ) %>% fmt_number( columns = c("Estimate", "Std Error", "t stat"), decimals = 2 ) %>% tab_style( style = cell_text(weight = "bold"), locations = cells_body( columns = everything(), rows = `p-value` < 0.05 ) ) html_table |> gtsave("table_S1.docx", type = "docx") # Descriptive stats for respondents (Appendix A) # Import data yougov3 <- read.spss("C:/Users/Alan/OneDrive - The University of Nottingham/Documents/YouGov3.sav", to.data.frame = TRUE) # Create functions to help with descriptives table_count <- function(x, table_object1, table_object2) { if(missing(table_object2)) { table_out <- addmargins(table(table_object1),c(x),sum) } else { table_out <- addmargins(table(table_object1, table_object2),c(x),sum) } return(table_out) } table_percent <- function(x="", y, table_object1, table_object2) { if(missing(table_object2)) { table_out <- addmargins(prop.table(table(table_object1))*100, c(y),sum) } else { table_out <- addmargins(prop.table(table(table_object1, table_object2), margin=x)*100, c(y),sum) } return(table_out) } # Create variable to indicate which party is engaging in the negative messaging yougov3$attacker <- case_when( yougov3$qgroup_exp == "1" ~ "labour", yougov3$qgroup_exp == "3" ~ "labour", yougov3$qgroup_exp == "4" ~ "labour", yougov3$qgroup_exp == "5" ~ "labour", yougov3$qgroup_exp == "2" ~ "tory", yougov3$qgroup_exp == "6" ~ "tory", yougov3$qgroup_exp == "7" ~ "tory", yougov3$qgroup_exp == "8" ~ "tory") yougov3$target <- case_when( yougov3$qgroup_exp == "1" ~ "tory", yougov3$qgroup_exp == "3" ~ "tory", yougov3$qgroup_exp == "4" ~ "tory", yougov3$qgroup_exp == "5" ~ "tory", yougov3$qgroup_exp == "2" ~ "labour", yougov3$qgroup_exp == "6" ~ "labour", yougov3$qgroup_exp == "7" ~ "labour", yougov3$qgroup_exp == "8" ~ "labour") # Create variables for labour, tory, and pooled treatment groups yougov3$labour_groups <- case_when( yougov3$qgroup_exp == "1" ~ "Control", yougov3$qgroup_exp == "3" ~ "Treat1", yougov3$qgroup_exp == "4" ~ "Treat2", yougov3$qgroup_exp == "5" ~ "Treat3") yougov3$labour_groups <- as.factor(yougov3$labour_groups) yougov3$tory_groups <- case_when( yougov3$qgroup_exp == "2" ~ "Control", yougov3$qgroup_exp == "6" ~ "Treat1", yougov3$qgroup_exp == "7" ~ "Treat2", yougov3$qgroup_exp == "8" ~ "Treat3") yougov3$tory_groups <- as.factor(yougov3$tory_groups) yougov3$pooled_groups <- case_when( yougov3$qgroup_exp == "1" ~ "Control", yougov3$qgroup_exp == "3" ~ "Treat1", yougov3$qgroup_exp == "4" ~ "Treat2", yougov3$qgroup_exp == "5" ~ "Treat3", yougov3$qgroup_exp == "2" ~ "Control", yougov3$qgroup_exp == "6" ~ "Treat1", yougov3$qgroup_exp == "7" ~ "Treat2", yougov3$qgroup_exp == "8" ~ "Treat3") yougov3$pooled_groups <- as.factor(yougov3$pooled_groups) # Create partisanship variable table_count(1,yougov3$partyid_2017) yougov3$partisan <- case_when( yougov3$partyid_2017 == "Labour" & yougov3$attacker == "labour" ~ "Attacker Copartisan", yougov3$partyid_2017 == "Conservative" & yougov3$attacker == "tory" ~ "Attacker Copartisan", yougov3$partyid_2017 == "Labour" & yougov3$target == "labour" ~ "Target Copartisan", yougov3$partyid_2017 == "Conservative" & yougov3$target == "tory" ~ "Target Copartisan", yougov3$partyid_2017 == "No – None" ~ "Non-partisan", yougov3$partyid_2017 == "Don't know" ~ "Non-partisan", is.na(yougov3$partyid_2017) ~ NA_character_, TRUE ~ "Out-party") yougov3$partisan <- as.factor(yougov3$partisan) table_count(1,yougov3$partisan) table(yougov3$partyid_2017, yougov3$partisan) # Recode age variable yougov3$age <- as.numeric(as.character(yougov3$age)) yougov3 <- yougov3 %>% mutate( age_group = case_when( age < 25 ~ "18-24", age >= 25 & age < 35 ~ "25-34", age >= 35 & age < 45 ~ "35-44", age >= 45 & age < 55 ~ "45-54", age >= 55 & age < 65 ~ "55-64", age >= 65 ~ "65+", TRUE ~ "Unknown" ) ) table_count(1, yougov3$age_group) table_percent(1, 1, yougov3$age_group) table_count(1, yougov3$profile_gender) table_percent(1, 1, yougov3$profile_gender) table_count(1, yougov3$profile_socialgrade_cie) table_percent(1, 1, yougov3$profile_socialgrade_cie) table_count(1, yougov3$highest_education_gce) table_percent(1, 1, yougov3$highest_education_gce)