Chapter 16 Main effects

This chapter explores the first hypothesis in the pre-registration of the experiment: Individuals that receive an unfavorable outcome express lower fairness perception than individuals that receive a favorable outcome. The estimation of the Average Marginal Component Effects is based on the function developed by Mikael P. Johannesson, and available on Github.

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)

d <- read_sav("C:\\Users/Sveinung/OneDrive/NORCE 2018-/goodloser/Conjoint/Bookdown-goodloser/Data/Goodloser-exp3.sav")

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

16.1 Prepare data

main_01 <- d %>% 
  mutate(rsp_id = as.numeric(responseid),
         rsp_beg = case_when(r13pad1 == 1 ~ "In favour of ban on begging",
                             r13pad1 == 2 ~ "Against ban on begging"),
         rsp_beg_imp = case_when(r13pad2 %in% 1:2 ~ "Important",
                                  r13pad2 %in% 3:5 ~ "Not important"),
         rsp_toll = case_when(r13pad3 == 1 ~ "In favour of road toll increase of diesel cars",
                              r13pad3 == 2 ~ "Against road toll increase of diesel cars"),
         rsp_toll_imp = case_when(r13pad4 %in% 1:2 ~ "Important",
                                  r13pad4 %in% 3:5 ~ "Not important"),
         treat_issue = case_when(r13pad5_sak == 1 ~ "Ban on begging",
                               r13pad5_sak == 2 ~ "Road toll increase of diesel cars"),
         treat_outcome = case_when(r13pad5_utfall == 1 ~ "The Yes side won the vote",
                                 r13pad5_utfall == 2 ~ "The No side won the vote"),
         treat_outfav = case_when(r13pad5_sak == 1 & r13pad1 == 1 & r13pad5_utfall == 1 ~ "Favorable outcome",
                                  r13pad5_sak == 1 & r13pad1 == 2 & r13pad5_utfall == 2 ~ "Favorable outcome",
                                  r13pad5_sak == 1 & r13pad1 == 1 & r13pad5_utfall == 2 ~ "Unfavorable outcome",
                                  r13pad5_sak == 1 & r13pad1 == 2 & r13pad5_utfall == 1 ~ "Unfavorable outcome",
                                  r13pad5_sak == 2 & r13pad3 == 1 & r13pad5_utfall == 1 ~ "Favorable outcome",
                                  r13pad5_sak == 2 & r13pad3 == 2 & r13pad5_utfall == 2 ~ "Favorable outcome",
                                  r13pad5_sak == 2 & r13pad3 == 1 & r13pad5_utfall == 2 ~ "Unfavorable outcome",
                                  r13pad5_sak == 2 & r13pad3 == 2 & r13pad5_utfall == 1 ~ "Unfavorable outcome"),
         treat_winningmargin = case_when(r13pad5_vinnermargin == 1 ~ "Not shown",
                                       r13pad5_vinnermargin == 2 ~ "Slight majority",
                                       r13pad5_vinnermargin == 3 ~ "Large majority"),
         treat_winnergloat = case_when(r13pad5_vinner == 1 ~ "Not shown",
                                     r13pad5_vinner == 2 ~ "Winning politician gloats"),
        treat_prime = case_when(r13pad5_avsender == 1 ~ "Not shown",
                               r13pad5_avsender == 2  | r13pad5_avsender == 5 ~ "No prime",
                               r13pad5_avsender == 3  | r13pad5_avsender == 6 ~ "Specific prime",
                               r13pad5_avsender == 4 | r13pad5_avsender == 7 ~ "General prime"),
         treat_messenger = case_when(r13pad5_avsender %in% 3:4 ~ "Political leader",
                                   r13pad5_avsender %in% 6:7 ~ "Local newspaper"),
         post_fair = case_when(r13pad6a == 1 | r13pad6b == 1 ~ 5,
                          r13pad6a == 2 | r13pad6b == 2 ~ 4,
                          r13pad6a == 3 | r13pad6b == 3 ~ 3,
                          r13pad6a == 4 | r13pad6b == 4 ~ 2,
                          r13pad6a == 5 | r13pad6b == 5 ~ 1),
          post_reasonable = case_when(r13pad7a == 1 | r13pad7b == 1 ~ 5,
                          r13pad7a == 2 | r13pad7b == 2 ~ 4,
                          r13pad7a == 3 | r13pad7b == 3 ~ 3,
                          r13pad7a == 4 | r13pad7b == 4 ~ 2,
                          r13pad7a == 5 | r13pad7b == 5 ~ 1),
          post_accept = case_when(r13pad8a == 1 | r13pad8b == 1 ~ 5,
                          r13pad8a == 2 | r13pad8b == 2 ~ 4,
                          r13pad8a == 3 | r13pad8b == 3 ~ 3,
                          r13pad8a == 4 | r13pad8b == 4 ~ 2,
                          r13pad8a == 5 | r13pad8b == 5 ~ 1)

  ) %>% 

  replace_with_na_all(condition = ~.x == 98 )%>%  #Recode 98 (not asked) as missing
  filter(!is.na(r13pad6_ran)) %>%  #Remove NA's
## We want the value labels in particular order for the tables and figures.
        mutate(treat_winningmargin = lvls_reorder(treat_winningmargin, c(2, 3, 1)), 
               treat_prime = lvls_reorder(treat_prime, c(3, 2, 4, 1)) 
        )

16.2 Reasonable decision

source("Functions/amce.R")

res_main <-  main_01 %>%
  amce(post_reasonable, treat_outfav, treat_winningmargin, treat_winnergloat, treat_prime, treat_messenger) 

res_main <- res_main %>% 
  mutate(
  treatment =  case_when(treatment == "treat_outfav" ~ "Outcome\nfavor-\nability",
            treatment == "treat_winningmargin" ~ "Winning\nmargin",
            treatment == "treat_winnergloat" ~ "Winner\ngloats",
            treatment == "treat_prime" ~ "Democratic\nprime",
            treatment == "treat_messenger" ~ "Primer")
)

#Figure
fig_amce <-
  res_main %>%
  ggplot(aes(x = estimate, y = value)) +
  facet_grid(
    treatment ~ .,
    scales = "free_y",
    space = "free_y") +
  geom_errorbarh(
    aes(xmin = estimate - (2 * std_error),
        xmax = estimate + (2 * std_error)),
    height = 0) +
  geom_point() +
  geom_vline(aes(xintercept = 0), linetype = "dotted") +
  scale_x_continuous(
    limits = c(-1, 1),
    breaks = round(seq(-1, 1, .1), 2),
    expand = c(0, 0)) +
   labs(
    x = "Marginal effect, reasonable decision",
    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_amce

ggsave(
  here("output", "nocon", "figs", "pngs", "fig_main_reasonable.png"),
  plot = fig_amce,
  width = 5.5, height = 2.75
)

ggsave(
  here("output", "nocon", "figs", "pdfs", "fig_main_reasonable.pdf"),
  plot = fig_amce,
  width = 5.5, height = 2.75
)

#Table
res_main <- res_main %>% 
  select(value, estimate, std_error, statistic, p_value)

kable(res_main, booktabs = TRUE, caption = "Average Marginal Component Effects", col.names = linebreak(c("Treatment value", "Estimate", "Std. Error", "t-statistic", "p value"))) %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "responsive")) %>% 
 group_rows(index = c("Outcome favorability" = 2, "Winning margin" = 3, "Winner gloating" = 2, "Good loser prime" = 4, "Primer" = 2))
(#tab:304_post_reasonable)Average Marginal Component Effects
Treatment value Estimate Std. Error t-statistic p value
Outcome favorability
Favorable outcome 0.0000000 0.0000000 NA NA
Unfavorable outcome -0.8723486 0.0411633 -21.1923847 0.0000000
Winning margin
Not shown 0.0000000 0.0000000 NA NA
Slight majority -0.0148208 0.0541505 -0.2736968 0.7843385
Large majority 0.0403618 0.0537010 0.7516017 0.4523557
Winner gloating
Not shown 0.0000000 0.0000000 NA NA
Winning politician gloats 0.0253638 0.0442066 0.5737556 0.5661807
Good loser prime
Not shown 0.0000000 0.0000000 NA NA
No prime 0.1008070 0.0739444 1.3632801 0.1729073
Specific prime 0.1594546 0.0743333 2.1451313 0.0320308
General prime 0.2318837 0.0739864 3.1341382 0.0017420
Primer
Local newspaper 0.0000000 0.0000000 NA NA
Political leader 0.0177423 0.0570918 0.3107683 0.7560180

16.3 Willingnes to accept

source("Functions/amce.R")

res_main <-  main_01 %>%
  amce(post_accept, treat_outfav, treat_winningmargin, treat_winnergloat, treat_prime, treat_messenger) 
 
res_main <- res_main %>% 
  mutate(
  treatment =  case_when(treatment == "treat_outfav" ~ "Outcome\nfavor-\nability",
            treatment == "treat_winningmargin" ~ "Winning\nmargin",
            treatment == "treat_winnergloat" ~ "Winner\ngloats",
            treatment == "treat_prime" ~ "Democratic\nprime",
            treatment == "treat_messenger" ~ "Primer")
)

#Figure
fig_amce <-
  res_main %>%
  ggplot(aes(x = estimate, y = value)) +
  facet_grid(
    treatment ~ .,
    scales = "free_y",
    space = "free_y") +
  geom_errorbarh(
    aes(xmin = estimate - (2 * std_error),
        xmax = estimate + (2 * std_error)),
    height = 0) +
  geom_point() +
  geom_vline(aes(xintercept = 0), linetype = "dotted") +
  scale_x_continuous(
    limits = c(-1, 1),
    breaks = round(seq(-1, 1, .1), 2),
    expand = c(0, 0)) +
   labs(
    x = "Marginal effect, willingnes to accept decision",
    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)))
fig_amce

ggsave(
  here("output", "nocon", "figs", "pngs", "fig_main_accept.png"),
  plot = fig_amce,
  width = 5.5, height = 2.75
)
ggsave(
  here("output", "nocon", "figs", "pdfs", "fig_main_accept.pdf"),
  plot = fig_amce,
  width = 5.5, height = 2.75
)

#table
res_main <- res_main %>% 
  select(value, estimate, std_error, statistic, p_value)

kable(res_main, booktabs = TRUE, caption = "Average Marginal Component Effects", col.names = linebreak(c("Treatment value", "Estimate", "Std. Error", "t-statistic", "p value"))) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "responsive")) %>% 
 group_rows(index = c("Outcome favorability" = 2, "Winning margin" = 3, "Winner gloating" = 2, "Good loser prime" = 4, "Primer" = 2))
(#tab:304_post_accept)Average Marginal Component Effects
Treatment value Estimate Std. Error t-statistic p value
Outcome favorability
Favorable outcome 0.0000000 0.0000000 NA NA
Unfavorable outcome -0.6690568 0.0391582 -17.0859858 0.0000000
Winning margin
Not shown 0.0000000 0.0000000 NA NA
Slight majority -0.0577342 0.0500296 -1.1539990 0.2486017
Large majority 0.0075074 0.0496861 0.1510965 0.8799108
Winner gloating
Not shown 0.0000000 0.0000000 NA NA
Winning politician gloats 0.0466331 0.0408820 1.1406742 0.2541056
Good loser prime
Not shown 0.0000000 0.0000000 NA NA
No prime 0.0628270 0.0683913 0.9186405 0.3583649
Specific prime 0.1622815 0.0687363 2.3609288 0.0182992
General prime 0.1581877 0.0684430 2.3112325 0.0208942
Primer
Local newspaper 0.0000000 0.0000000 NA NA
Political leader 0.0229761 0.0521782 0.4403399 0.6597513

16.4 Fairness perceptions

source("Functions/amce.R")

res_main <-  main_01 %>%
  amce(post_fair, treat_outfav, treat_winningmargin, treat_winnergloat, treat_prime, treat_messenger)
  
res_main <- res_main %>% 
  mutate(
  treatment =  case_when(treatment == "treat_outfav" ~ "Outcome\nfavor-\nability",
            treatment == "treat_winningmargin" ~ "Winning\nmargin",
            treatment == "treat_winnergloat" ~ "Winner\ngloats",
            treatment == "treat_prime" ~ "Democratic\nprime",
            treatment == "treat_messenger" ~ "Primer")
)

#Figure
fig_amce <-
  res_main %>%
  ggplot(aes(x = estimate, y = value)) +
  facet_grid(
    treatment ~ .,
    scales = "free_y",
    space = "free_y") +
  geom_errorbarh(
    aes(xmin = estimate - (2 * std_error),
        xmax = estimate + (2 * std_error)),
    height = 0) +
  geom_point() +
  geom_vline(aes(xintercept = 0), linetype = "dotted") +
  scale_x_continuous(
    limits = c(-1, 1),
    breaks = round(seq(-1, 1, .1), 2),
    expand = c(0, 0)) +
   labs(
    x = "Marginal effect, perceived fairness of decision",
    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)))
fig_amce

ggsave(
  here("output", "nocon", "figs", "pngs", "fig_main_fair.png"),
  plot = fig_amce,
  width = 5.5, height = 4.75
)

ggsave(
  here("output", "nocon", "figs", "pdfs", "fig_main_fair.pdf"),
  plot = fig_amce,
  width = 5.5, height = 4.75
)

#table
res_main <- res_main %>% 
  select(value, estimate, std_error, statistic, p_value)

kable(res_main, booktabs = TRUE, caption = "Average Marginal Component Effects", col.names = linebreak(c("Treatment value", "Estimate", "Std. Error", "t-statistic", "p value"))) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "responsive")) %>% 
 group_rows(index = c("Outcome favorability" = 2, "Winning margin" = 3, "Winner gloating" = 2, "Good loser prime" = 4, "Primer" = 2))
(#tab:304_post_fair)Average Marginal Component Effects
Treatment value Estimate Std. Error t-statistic p value
Outcome favorability
Favorable outcome 0.0000000 0.0000000 NA NA
Unfavorable outcome -0.3086343 0.0375947 -8.2095070 0.0000000
Winning margin
Not shown 0.0000000 0.0000000 NA NA
Slight majority -0.0272538 0.0463493 -0.5880087 0.5565751
Large majority 0.0261409 0.0459917 0.5683835 0.5698213
Winner gloating
Not shown 0.0000000 0.0000000 NA NA
Winning politician gloats 0.0108084 0.0378599 0.2854851 0.7752942
Good loser prime
Not shown 0.0000000 0.0000000 NA NA
No prime 0.2367388 0.0632112 3.7452035 0.0001840
Specific prime 0.2757440 0.0635288 4.3404587 0.0000147
General prime 0.2926006 0.0632708 4.6245764 0.0000039
Primer
Local newspaper 0.0000000 0.0000000 NA NA
Political leader 0.0244199 0.0483394 0.5051773 0.6135049