knitr::opts_chunk$set(
  fig.width = 7,
  fig.height = 4.5,
  collapse = TRUE,
  comment = "#>"
)
library(mmbruteluck)
library(tidyverse)

Reading data and creating summaries

Summary stats of background variables for the mTurk workers. For the Forced Choice treatments, I add the share that chose the safe alternative. This is all for Table A.1, Panel B, in the online appendix.

mturk_workers <- mturk_workers %>% mutate(treatment=factor(treatment_str))
rdf_summary <- mturk_workers %>% 
  group_by(treatment) %>%
  summarize(mean_age = mean(age), se_age = sd(age)/sqrt(n()),
            mean_female = mean(female), se_female= sd(female)/sqrt(n()),
            mean_education = mean(education), se_education = sd(education)/sqrt(n()),
            mean_political = mean(political), se_political = sd(political)/sqrt(n()),
            mean_risky = mean(risky), se_risky = sd(risky)/sqrt(n()),
            mean_green = mean(green), se_green = sd(green)/sqrt(n()),
            n = n())

rdf_totals <- mturk_workers %>% 
    summarize(mean_age = mean(age), se_age = sd(age)/sqrt(n()),
            mean_female = mean(female), se_female= sd(female)/sqrt(n()),
            mean_education = mean(education), se_education = sd(education)/sqrt(n()),
            mean_political = mean(political), se_political = sd(political)/sqrt(n()),
            mean_risky = mean(risky, na.rm=TRUE), se_risky = sd(risky, na.rm=TRUE)/sqrt(n()),
            mean_green = mean(green, na.rm=TRUE), se_green = sd(green, na.rm=TRUE)/sqrt(n()),
            n = n())

Output of balance table

rdf_summary %>% knitr::kable(digits=c(3,1,2,2,2,2,2,2,2,2,2,2,2,0))

Margins of the balance table

rdf_totals %>% knitr::kable(digits=c(1,2,2,2,2,2,2,2,2,2,2,2,2,0))

Requested balance tests

mturk_workers %>% lm(age ~ treatment, data=.) %>% summary()
mturk_workers %>% lm(female ~ treatment, data=.) %>% summary()
mturk_workers %>% lm(education ~ treatment, data=.) %>% summary()
mturk_workers %>% lm(political ~ treatment, data=.) %>% summary()

sessionInfo()

sessionInfo()


FAIR-NHH/mmbruteluck documentation built on Oct. 29, 2020, 9 p.m.