Chapter 6 Effects on losers

if(!require("broom")){install.packages("broom");  library(broom)}
if(!require("haven")){install.packages("haven");  library(haven)}
if(!require("here")){install.packages("here");  library(here)}
if(!require("knitr")){install.packages("knitr");  library(knitr)}
if(!require("kableExtra")){install.packages("kableExtra");  library(kableExtra)}
if(!require("naniar")){install.packages("naniar");  library(naniar)}
if(!require("tidyverse")){install.packages("tidyverse");  library(tidyverse)}
# The analysis uses custom functions included in the compendium. Install the included pkg with `devtools::install()` or just install from github with:
if (!require(wiggle)) {  devtools::install_github("mikajoh/wiggle")}

set.seed(2016)
## Utils. 
source("goodloser-utils.R")

d <- read_sav("Data/Goodloser-exp1.sav")

knitr::opts_chunk$set(echo = TRUE, knitr.kable.NA = "", cache = FALSE, warning = FALSE)

6.1 Prepare data

Select only respondents who receive an unfavorable outcome

d <- d %>% 
  filter(favorability == "Unfavorable") %>% 
  mutate(treatment = lvls_reorder(treatment, c(3, 2, 1)))

6.2 Fairness

res_main <-  lm(fairness ~ treatment, data = d) 
res_main <- broom::tidy(res_main)

labels <- data.frame(
  term = c(
    "treatmentLamenting politician",
    "treatmentGeneral prime"
    
  ),
  label = c( "Lamenting politician",
             "General prime")
)
#Figure
fig <-   res_main %>%
  filter(term != "(Intercept)") %>% 
  left_join(labels, by = "term") %>% 
  
  ggplot(aes(x = estimate, y = label,
             xmin = estimate - (2 * std.error),
             xmax = estimate + (2 * std.error))) +
   geom_errorbarh(height = 0) +
  geom_point() +
  geom_vline(aes(xintercept = 0), linetype = "dotted") +
  scale_x_continuous(limits = c(-1.3, 1.3),
                     breaks = round(seq(-1, 1, .25), 2),
                     expand = c(0, 0)) +
  labs(x = "Change in fairness perception",
       y = "Decision process attributes") +
  theme_bw() +
  theme(plot.margin = unit(c(2, 2, 2, 2), "mm"), axis.text.x=element_text(size=rel(0.6))) +
  theme(panel.spacing = unit(0.5, "lines"))
fig

ggsave(
  here("output", "swevig", "figs", "pngs", "exp1-fairness-losers.png"),
  plot = fig,
  width = 5.5, height = 2.75
)

ggsave(
  here("output", "swevig", "figs", "pdfs", "exp1-fairness-losers.pdf"),
  plot = fig,
  width = 5.5, height = 2.75
)


#Table
table <- res_main %>% 
  select(term, estimate, std.error, statistic, p.value) %>% 
  mutate(term = case_when( term == "(Intercept)" ~ "Not shown",
                    term == "treatmentLamenting politician" ~ "Lamenting politician",
                   term == "treatmentGeneral prime" ~ "General prime")
         )

kable(table, booktabs = TRUE, caption = "Treatment effects on fairness perceptions of decision, Study 1 -- Swedish vignette", col.names = linebreak(c("Treatment value", "Estimate", "Std. Error", "t-statistic", "p value"))) %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "responsive")) 
(#tab:105_post_fairness)Treatment effects on fairness perceptions of decision, Study 1 – Swedish vignette
Treatment value Estimate Std. Error t-statistic p value
Not shown 3.9041096 0.1572271 24.8310160 0.0000000
Lamenting politician 0.1510628 0.2227358 0.6782153 0.4979901
General prime 0.7842021 0.2194461 3.5735530 0.0003909

6.3 Justice

res_main <-  lm(justice ~ treatment, data = d) 
res_main <- broom::tidy(res_main)

labels <- data.frame(
  term = c(
    "treatmentLamenting politician",
    "treatmentGeneral prime"
    
  ),
  label = c( "Lamenting politician",
             "General prime")
)
#Figure
fig <-   res_main %>%
  filter(term != "(Intercept)") %>% 
  left_join(labels, by = "term") %>% 
  
  ggplot(aes(x = estimate, y = label,
             xmin = estimate - (2 * std.error),
             xmax = estimate + (2 * std.error))) +
   geom_errorbarh(height = 0) +
  geom_point() +
  geom_vline(aes(xintercept = 0), linetype = "dotted") +
  scale_x_continuous(limits = c(-1, 1),
                     breaks = round(seq(-1, 1, .25), 2),
                     expand = c(0, 0)) +
  labs(x = "Change in justice perception",
       y = "Decision process attributes") +
  theme_bw() +
  theme(plot.margin = unit(c(2, 2, 2, 2), "mm"), axis.text.x=element_text(size=rel(0.6))) +
  theme(panel.spacing = unit(0.5, "lines"))
fig

ggsave(
  here("output", "swevig", "figs", "pngs", "exp1-justice-losers.png"),
  plot = fig,
  width = 5.5, height = 2.75
)

ggsave(
  here("output", "swevig", "figs", "pdfs", "exp1-justice-losers.pdf"),
  plot = fig,
  width = 5.5, height = 2.75
)


#Table
table <- res_main %>% 
  select(term, estimate, std.error, statistic, p.value) %>% 
  mutate(term = case_when( term == "(Intercept)" ~ "Not shown",
                    term == "treatmentLamenting politician" ~ "Lamenting politician",
                   term == "treatmentGeneral prime" ~ "General prime")
         )

kable(table, booktabs = TRUE, caption = "Treatment effects on justice perceptions of decision, Study 1 -- Swedish vignette", col.names = linebreak(c("Treatment value", "Estimate", "Std. Error", "t-statistic", "p value"))) %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "responsive")) 
(#tab:105_post_justice)Treatment effects on justice perceptions of decision, Study 1 – Swedish vignette
Treatment value Estimate Std. Error t-statistic p value
Not shown 3.8698630 0.1447119 26.7418457 0.0000000
Lamenting politician -0.0422768 0.2050061 -0.2062222 0.8367123
General prime 0.5846824 0.2019782 2.8947801 0.0039822

6.4 Decision evaluation

res_main <-  lm(eval ~ treatment, data = d) 
res_main <- broom::tidy(res_main)

labels <- data.frame(
  term = c(
    "treatmentLamenting politician",
    "treatmentGeneral prime"
    
  ),
  label = c( "Lamenting politician",
             "General prime")
)
#Figure
fig <-   res_main %>%
  filter(term != "(Intercept)") %>% 
  left_join(labels, by = "term") %>% 
  
  ggplot(aes(x = estimate, y = label,
             xmin = estimate - (2 * std.error),
             xmax = estimate + (2 * std.error))) +
   geom_errorbarh(height = 0) +
  geom_point() +
  geom_vline(aes(xintercept = 0), linetype = "dotted") +
  scale_x_continuous(limits = c(-1, 1),
                     breaks = round(seq(-1, 1, .25), 2),
                     expand = c(0, 0)) +
  labs(x = "Change in decision evaluation",
       y = "Decision process attributes") +
  theme_bw() +
  theme(plot.margin = unit(c(2, 2, 2, 2), "mm"), axis.text.x=element_text(size=rel(0.7))) +
  theme(panel.spacing = unit(0.5, "lines"))
fig

ggsave(
  here("output", "swevig", "figs", "pngs", "exp1-eval-losers.png"),
  plot = fig,
  width = 5.5, height = 2.75
)

ggsave(
  here("output", "swevig", "figs", "pdfs", "exp1-eval-losers.pdf"),
  plot = fig,
  width = 5.5, height = 2.75
)


#Table
table <- res_main %>% 
  select(term, estimate, std.error, statistic, p.value) %>% 
  mutate(term = case_when( term == "(Intercept)" ~ "Not shown",
                    term == "treatmentLamenting politician" ~ "Lamenting politician",
                   term == "treatmentGeneral prime" ~ "General prime")
         )

kable(table, booktabs = TRUE, caption = "Treatment effects on decision evaluation, Study 1 -- Swedish vignette", col.names = linebreak(c("Treatment value", "Estimate", "Std. Error", "t-statistic", "p value"))) %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "responsive")) 
(#tab:105_post_eval)Treatment effects on decision evaluation, Study 1 – Swedish vignette
Treatment value Estimate Std. Error t-statistic p value
Not shown 4.0547945 0.1769636 22.9131510 0.0000000
Lamenting politician -0.0616911 0.2506955 -0.2460797 0.8057348
General prime -0.1586906 0.2469928 -0.6424909 0.5208876

6.5 Willingness to accept

res_main <-  lm(accept ~ treatment, data = d) 
res_main <- broom::tidy(res_main)

labels <- data.frame(
  term = c(
    "treatmentLamenting politician",
    "treatmentGeneral prime"
    
  ),
  label = c( "Lamenting politician",
             "General prime")
)
#Figure
fig <-   res_main %>%
  filter(term != "(Intercept)") %>% 
  left_join(labels, by = "term") %>% 
  
  ggplot(aes(x = estimate, y = label,
             xmin = estimate - (2 * std.error),
             xmax = estimate + (2 * std.error))) +
   geom_errorbarh(height = 0) +
  geom_point() +
  geom_vline(aes(xintercept = 0), linetype = "dotted") +
  scale_x_continuous(limits = c(-1, 1),
                     breaks = round(seq(-1, 1, .25), 2),
                     expand = c(0, 0)) +
  labs(x = "Change in willingness to accept outcome",
       y = "Decision process attributes") +
  theme_bw() +
  theme(plot.margin = unit(c(2, 2, 2, 2), "mm"), axis.text.x=element_text(size=rel(0.6))) +
  theme(panel.spacing = unit(0.5, "lines"))
fig

ggsave(
  here("output", "swevig", "figs", "pngs", "exp1-accept-losers.png"),
  plot = fig,
  width = 5.5, height = 2.75
)

ggsave(
  here("output", "swevig", "figs", "pdfs", "exp1-accept-losers.pdf"),
  plot = fig,
  width = 5.5, height = 2.75
)


#Table
table <- res_main %>% 
  select(term, estimate, std.error, statistic, p.value) %>% 
  mutate(term = case_when( term == "(Intercept)" ~ "Not shown",
                    term == "treatmentLamenting politician" ~ "Lamenting politician",
                   term == "treatmentGeneral prime" ~ "General prime")
         )

kable(table, booktabs = TRUE, caption = "Treatment effects on willingness to accept decision, Study 1 -- Swedish vignette", col.names = linebreak(c("Treatment value", "Estimate", "Std. Error", "t-statistic", "p value"))) %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "responsive")) 
(#tab:105_post_accept)Treatment effects on willingness to accept decision, Study 1 – Swedish vignette
Treatment value Estimate Std. Error t-statistic p value
Not shown 4.8356164 0.1724504 28.0406164 0.0000000
Lamenting politician 0.0540387 0.2443019 0.2211966 0.8250415
General prime 0.1968511 0.2406936 0.8178493 0.4138839

6.6 Compliance

res_main <-  lm(comply ~ treatment, data = d) 
res_main <- broom::tidy(res_main)

labels <- data.frame(
  term = c(
    "treatmentLamenting politician",
    "treatmentGeneral prime"
    
  ),
  label = c( "Lamenting politician",
             "General prime")
)
#Figure
fig <-   res_main %>%
  filter(term != "(Intercept)") %>% 
  left_join(labels, by = "term") %>% 
  
  ggplot(aes(x = estimate, y = label,
             xmin = estimate - (2 * std.error),
             xmax = estimate + (2 * std.error))) +
   geom_errorbarh(height = 0) +
  geom_point() +
  geom_vline(aes(xintercept = 0), linetype = "dotted") +
  scale_x_continuous(limits = c(-1, 1),
                     breaks = round(seq(-1, 1, .25), 2),
                     expand = c(0, 0)) +
  labs(x = "Change in decision compliance",
       y = "Decision process attributes") +
  theme_bw() +
  theme(plot.margin = unit(c(2, 2, 2, 2), "mm"), axis.text.x=element_text(size=rel(0.6))) +
  theme(panel.spacing = unit(0.5, "lines"))
fig

ggsave(
  here("output", "swevig", "figs", "pngs", "exp1-comply-losers.png"),
  plot = fig,
  width = 5.5, height = 2.75
)

ggsave(
  here("output", "swevig", "figs", "pdfs", "exp1-comply-losers.pdf"),
  plot = fig,
  width = 5.5, height = 2.75
)


#Table
table <- res_main %>% 
  select(term, estimate, std.error, statistic, p.value) %>% 
  mutate(term = case_when( term == "(Intercept)" ~ "Not shown",
                    term == "treatmentLamenting politician" ~ "Lamenting politician",
                   term == "treatmentGeneral prime" ~ "General prime")
         )

kable(table, booktabs = TRUE, caption = "Treatment effects on decision compliance, Study 1 -- Swedish vignette", col.names = linebreak(c("Treatment value", "Estimate", "Std. Error", "t-statistic", "p value"))) %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "responsive")) 
(#tab:105_post_comply)Treatment effects on decision compliance, Study 1 – Swedish vignette
Treatment value Estimate Std. Error t-statistic p value
Not shown 4.8082192 0.1618013 29.7168094 0.0000000
Lamenting politician 0.0469532 0.2292158 0.2048429 0.8377891
General prime 0.2242484 0.2258304 0.9929947 0.3212558