Chapter 5 Main effects

if(!require("broom")){install.packages("broom");  library(broom)}
## Loading required package: broom
if(!require("haven")){install.packages("haven");  library(haven)}
if(!require("here")){install.packages("here");  library(here)}
## Loading required package: here
## here() starts at C:/Users/Sveinung/OneDrive/NORCE 2018-/goodloser/Conjoint/Bookdown-goodloser
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")}
## Loading required package: 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)

5.1 Prepare data

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

5.2 Fairness

5.2.1 Outcome favorability

Winner-loser effect on fairness perceptions

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

labels <- data.frame(
  term = c(
    "favorabilityUnfavorable"
  ),
  label = c( "Loser")
)
#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 fairness perceptions between decision winner and losers",
       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-favorability.png"),
  plot = fig,
  width = 5.5, height = 2.75
)

ggsave(
  here("output", "swevig", "figs", "pdfs", "exp1-fairness-favorability.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 == "favorabilityUnfavorable" ~ "Unfavorable outcome")
         )

kable(table, booktabs = TRUE, caption = "Difference fairness perceptions of decision between winners and losers, 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:104_post_fairness_favorability)Difference fairness perceptions of decision between winners and losers, Study 1 – Swedish vignette
Treatment value Estimate Std. Error t-statistic p value
Not shown 4.4564460 0.0769648 57.902377 0.0000000
Unfavorable outcome -0.2317269 0.1164660 -1.989652 0.0468968

5.2.2 Priming effects

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, 1),
                     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-mainfig.png"),
  plot = fig,
  width = 5.5, height = 2.75
)

ggsave(
  here("output", "swevig", "figs", "pdfs", "exp1-fairness-mainfig.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:104_post_fairness)Treatment effects on fairness perceptions of decision, Study 1 – Swedish vignette
Treatment value Estimate Std. Error t-statistic p value
Not shown 4.1138462 0.1016588 40.467206 0.0000000
Lamenting politician 0.1426380 0.1414701 1.008255 0.3135720
General prime 0.5662691 0.1414701 4.002747 0.0000672

5.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-mainfig.png"),
  plot = fig,
  width = 5.5, height = 2.75
)

ggsave(
  here("output", "swevig", "figs", "pdfs", "exp1-justice-mainfig.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:104_post_justice)Treatment effects on justice perceptions of decision, Study 1 – Swedish vignette
Treatment value Estimate Std. Error t-statistic p value
Not shown 4.0615385 0.0943412 43.0515828 0.0000000
Lamenting politician 0.0883174 0.1312869 0.6727058 0.5012875
General prime 0.3476834 0.1312869 2.6482724 0.0082158

5.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-mainfig.png"),
  plot = fig,
  width = 5.5, height = 2.75
)

ggsave(
  here("output", "swevig", "figs", "pdfs", "exp1-eval-mainfig.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:104_post_eval)Treatment effects on decision evaluation, Study 1 – Swedish vignette
Treatment value Estimate Std. Error t-statistic p value
Not shown 4.3076923 0.1154874 37.300098 0.0000000
Lamenting politician -0.2125914 0.1607143 -1.322791 0.1862026
General prime -0.2298825 0.1607143 -1.430380 0.1529155

5.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-mainfig.png"),
  plot = fig,
  width = 5.5, height = 2.75
)

ggsave(
  here("output", "swevig", "figs", "pdfs", "exp1-accept-mainfig.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:104_post_accept)Treatment effects on willingness to accept decision, Study 1 – Swedish vignette
Treatment value Estimate Std. Error t-statistic p value
Not shown 5.1784615 0.1101387 47.0176540 0.0000000
Lamenting politician -0.1640523 0.1532709 -1.0703422 0.2847195
General prime 0.0002128 0.1532709 0.0013885 0.9988924

5.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-mainfig.png"),
  plot = fig,
  width = 5.5, height = 2.75
)

ggsave(
  here("output", "swevig", "figs", "pdfs", "exp1-comply-mainfig.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:104_post_comply)Treatment effects on decision compliance, Study 1 – Swedish vignette
Treatment value Estimate Std. Error t-statistic p value
Not shown 5.1446154 0.1031449 49.8775325 0.0000000
Lamenting politician -0.0783330 0.1435383 -0.5457286 0.5853723
General prime 0.0542319 0.1435383 0.3778216 0.7056420