Learning from Biased Agents

Table of Contents


1 Data Analysis

1.1 Prep the Data

require(sqldf)
options(sqldf.driver = "SQLite")
require('RMySQL')

query <- function(con, query){
    db <- dbGetQuery(con, query)[-1]
    data.frame(lapply(db, function(x){
        if(is.character(x)){
            tryCatch({
                as.POSIXlt(x)
            }, error = function(err)
                {
                    if (nchar(x[1])<15){factor(x)}
                    else{x}
                })
        }
        else{x}
    }))
}

##ssh -L 3307:localhost:3306 djthorne@104.131.138.238
con = dbConnect(MySQL(), host="127.0.0.1", user="djthorne",
      password="************", db="*******", port=3307)

dj_trials <- query(con, "select * from lfba_trials")
dj_subj <- query(con, "select * from lfba_subj")
dj_check <- query(con, "select * from lfba_check")
dj_system <- query(con, "select * from lfba_system")
dj_condition <- query(con, "select * from lfba_condition")

## add condition to trials
trials <- sqldf("select dj_trials.*, dj_condition.*
                    from dj_trials
                    inner join dj_condition
                    on dj_trials.uwid=dj_condition.uwid
                    ")

## add condition and trials and check
trials_all <- sqldf("select dj_trials.*, dj_condition.*, dj_check.*
                          from dj_trials
                          inner join dj_condition
                          on dj_trials.uwid=dj_condition.uwid
                          inner join dj_check
                          on dj_trials.uwid=dj_check.uwid
                          ")

1.2 Analyses

 #load("data/lfba.Rdata")
# load("data/lfba.Rdata")

 e3_trials <- trials[trials$expt=="e3",]
 e3_trials_p <- trials[trials$expt=="e3" & ! trials$sid %in% c(39, 47, 48, 59, 57), ]
 e2_trials <- trials[trials$expt=="e2",]

1.2.1 Pilot Experiment

Condition N

load("data/lfba.Rdata")
length(unique(trials$uwid))
length(unique(e3_trials_p$uwid))
table(trials[trials$version=="test" & trials$pid ==1, 'expt'])
[1] 64
[1] 53

e1 e2 e3
12 15 37
1.2.1.1 Baseline
baseline <- s(e3_trials, version == "baseline")
ggplot(baseline, aes(prop, prop_estimate)) +
    stat_summary(fun.y=mean, geom="point", size = 3) +
        stat_summary(fun.data = "mean_cl_boot", geom="errorbar") +
            scale_x_continuous("Distance from Winning Bin") +
                scale_y_continuous("Horse X's Chances") +
                    ggtitle("Ss' estimate of Zach's belief about Horse X's chances")

a.png

baseline <- s(e3_trials, version == "baseline")

 ggplot(baseline, aes(prop, prop_estimate)) +
     geom_point() +
             scale_x_continuous("Distance from Winning Bin") +
                 scale_y_continuous("Horse X's Chances") +
                     facet_wrap(~sid) +
                     ggtitle("Ss' estimate of Zach's belief about Horse X's chances")

b.png

1.2.1.2 Main Effect
test <- e3_trials[e3_trials$version == 'test',]
test$wbC <- factor(test$wb, levels = c(0,1), labels=c("against bias","with bias"))
test$testimonyC <- factor(test$testimony, levels = c(0,1), labels=c("Team X","Team Y"))

 t.err <- summarySE(test, measurevar='prop_estimate', groupvars=c('prop', 'testimonyC','wbC'), na.rm=TRUE)

 ggplot(t.err, aes(testimonyC, prop_estimate, fill=factor(wbC))) +
     geom_bar(stat="identity",position="dodge") +
         geom_errorbar(aes(ymin=prop_estimate-se, ymax=prop_estimate+se), width=.25, position=position_dodge(1)) +
             scale_x_discrete("") +
                 scale_y_continuous("P(Team X Wins)") +
                     facet_wrap(~prop) +
                     scale_fill_manual("Testimony supporting", values=c("#d95f02", "#818181", "#7570b3")) +
 ggtitle("Ss' estimate of Zach's belief of P(Win)")

c.png

compared with mean response

test <- e3_trials[e3_trials$version == 'test',]
test$wbC <- factor(test$wb, levels = c(0,1), labels=c("against bias","with bias"))
test$testimonyC <- factor(test$testimony, levels = c(0,1), labels=c("Team X","Team Y"))
out <- ddply(test, .(prop), transform, dmd = prop_estimate - mean(prop_estimate))


t.err <- summarySE(out, measurevar='dmd', groupvars=c('prop', 'testimonyC','wbC'), na.rm=TRUE)

ggplot(t.err, aes(testimonyC, dmd, fill=factor(wbC))) +
    geom_bar(stat="identity",position="dodge") +
        geom_errorbar(aes(ymin=dmd-se, ymax=dmd+se), width=.25, position=position_dodge(1)) +
            scale_x_discrete("") +
                scale_y_continuous("Change in P(Team X Wins) from Mean P(Team X Wins)") +
                    facet_wrap(~prop) +
                        scale_fill_manual("Testimony supporting", values=c("#d95f02", "#818181", "#7570b3")) +
ggtitle("Ss' estimate of Zach's belief of P(Win)")

d.png

compared to baseline

test <- e3_trials[e3_trials$version == 'test',]
baseline <- e3_trials[e3_trials$version == 'baseline',]

test$wbC <- factor(test$wb, levels = c(0,1), labels=c("against bias","with bias"))
test$testimonyC <- factor(test$testimony, levels = c(0,1), labels=c("Team X","Team Y"))
out <- ddply(test, .(prop), transform, dmd = prop_estimate - mean(baseline[baseline$prop == prop,'prop_estimate']))


t.err <- summarySE(out, measurevar='dmd', groupvars=c('prop', 'testimonyC','wbC'), na.rm=TRUE)

ggplot(t.err, aes(testimonyC, dmd, fill=factor(wbC))) +
    geom_bar(stat="identity",position="dodge") +
        geom_errorbar(aes(ymin=dmd-se, ymax=dmd+se), width=.25, position=position_dodge(1)) +
            scale_x_discrete("") +
                scale_y_continuous("Change in P(Team X Wins) from Mean P(Team X Wins)") +
                    facet_wrap(~prop) +
                        scale_fill_manual("Testimony supporting", values=c("#d95f02", "#818181", "#7570b3")) +
ggtitle("Ss' estimate of Zach's belief of P(Win)")

62.png

1.2.1.3 By Subject
test <- e3_trials[e3_trials$version == 'test',]
test$wbC <- factor(test$wb, levels = c(0,1), labels=c("against bias","with bias"))
test$testimonyC <- factor(test$testimony, levels = c(0,1), labels=c("Team X","Team Y"))

out <- ddply(test, .(prop, sid), transform, dmd = prop_estimate - mean(prop_estimate))

 ggplot(out, aes(testimonyC, dmd, fill=factor(wbC))) +
     geom_bar(stat="identity",position="dodge") +
             scale_x_discrete("") +
                 scale_y_continuous("P(Team X Wins)") +
                     facet_wrap(sid~prop) +
                     scale_fill_manual("Testimony supporting", values=c("#d95f02", "#818181", "#7570b3")) +
ggtitle("Ss' estimate of Zach's belief of P(Win)")

e.png

1.2.1.4 Final
load("data/lfba_final.Rdata")
load('model/results/mod.Rdata')

dj_Pub <- function(base_size = 35) {
  theme_bw()+ theme(
      text=element_text(size=base_size),
      plot.margin= unit(c(1, 1, 3, 3), "lines") ,
      legend.key.size = unit(2, "lines"),
      strip.text.x = element_text(size=30),
      panel.grid.minor = element_blank(),
      axis.title.y = element_text(vjust=4),
      plot.title = element_text(vjust=3, hjust=1),
      axis.title.x = element_text(vjust=-5) ,
      strip.background = element_rect(fill = "white")
      )}

conditions <- c("fan of X\nthinks\nX will win","fan of Y\nthinks\nX will win","fan of Y\nthinks\nY will win","fan of X\nthinks\nY will win")
                                        #conditions <- c("Fan of X","fan of Y","fan of Y","fan of X")

mod$cond <- factor(mapply(function(fan, testimony){
  if(testimony == 'X'){
    if(fan == 'X'){conditions[1]}
    else{conditions[2]}
  } else{
    if(fan == 'Y'){conditions[3]}
    else{conditions[4]}
  }
}, mod$fan, mod$testimony))

RToM <- s(mod, kind=='RToM')
EToM <- s(mod, kind=='OToM')

mod$cond <- factor(mod$cond, levels= conditions, labels=conditions)
mod$testimony <- factor(as.character(mod$testimony))
levels(mod$testimony) <- c(0,1)

### Data
test <- e3_trials_p[e3_trials_p$version == 'test',]
baseline <- e3_trials_p[e3_trials_p$version == 'baseline',]

model_data <- s(out, prop == .6, select=c(prop_estimate, bias, testimony))
model_data$testimony <- 1- as.numeric(model_data$testimony)
model_data$bias <- 1- as.numeric(model_data$bias)
model_data[model_data$bias == 0, 'bias'] <- -1
write.table(model_data, "model/data/lfba_fin.csv", col.names=FALSE, row.names=FALSE, sep=',')

ggplot(model_data, aes(testimony, prop_estimate, color=factor(bias))) +
  stat_summary(fun.y=mean, geom="point")




test$wbC <- factor(test$wb, levels = c(0,1), labels=c("inconsistent", "consistent"))
test$testimonyC <- factor(test$testimony, levels = c(0,1), labels=c("Team X","Team Y"))
out <- ddply(test, .(prop), transform, dfb = prop_estimate - mean(baseline[baseline$prop == prop,'prop_estimate']))


out$cond <- factor(mapply(function(wb, testimony){
  if(testimony == 0){
    if(wb == 1){conditions[1]}
    else{conditions[2]}
  } else{
    if(wb == 1){conditions[3]}
    else{conditions[4]}
  }
}, out$wb,out$testimony))

t.err <- summarySE(s(out, prop == .6), measurevar='dfb', groupvars=c('cond','testimony'), na.rm=TRUE)
t.err$cond <- factor(t.err$cond, levels= conditions, labels=conditions)
t.err$kind <- "data"

mod$testimony <- as.numeric(mod$testimony)-1
comb <- rbind.fill(t.err, mod)

comb$kind <- factor(comb$kind,levels=c("data","EToM", "RToM"), labels=c("(a) data", "(b) oToM", "(c) rToM"))

ggplot(comb, aes(cond, dfb, fill=factor(testimony))) +
  geom_bar(stat="identity",position="dodge") +
  geom_hline() +
  facet_grid(~kind ) +
  geom_errorbar(aes(ymin=dfb-se, ymax=dfb+se), width=.25, position=position_dodge(1)) +
  scale_x_discrete("Social Cue", labels="") +
  scale_y_continuous(expression(atop("Social Cue's Effect", paste("on ", italic("p(wins"), ''[x], ")")))) +
  scale_fill_manual(values=c("#d95f02", "#7570b3"), guide=F) +
dj_Pub(30)

f.png

load("data/lfba_final.Rdata")
load('model/results/mod.Rdata')

dj_Pub <- function(base_size = 35) {
    theme_bw()+ theme(
        text=element_text(size=base_size),
        plot.margin= unit(c(1, 1, 3, 3), "lines") ,
        legend.key.size = unit(2, "lines"),
        strip.text.x = element_text(size=30),
        panel.grid.minor = element_blank(),
        axis.title.y = element_text(vjust=4),
        plot.title = element_text(vjust=3, hjust=1),
        axis.title.x = element_text(vjust=-5) ,
        strip.background = element_rect(fill = "white")
        )}

conditions <- c("fan of X\nthinks\nX will win","fan of Y\nthinks\nX will win","fan of Y\nthinks\nY will win","fan of X\nthinks\nY will win")
                                        #conditions <- c("Fan of X","fan of Y","fan of Y","fan of X")
mod$cond <- factor(mapply(function(fan, testimony){
    if(testimony == 'X'){
        if(fan == 'X'){conditions[1]}
        else{conditions[2]}
    } else{
        if(fan == 'Y'){conditions[3]}
        else{conditions[4]}
    }
}, mod$fan, mod$testimony))

RToM <- s(mod, kind=='RToM')
EToM <- s(mod, kind=='OToM')

mod$cond <- factor(mod$cond, levels= conditions, labels=conditions)
mod$testimony <- factor(as.character(mod$testimony))
levels(mod$testimony) <- c(0,1)

test <- e3_trials_p[e3_trials_p$version == 'test',]
baseline <- e3_trials_p[e3_trials_p$version == 'baseline',]

test$wbC <- factor(test$wb, levels = c(0,1), labels=c("inconsistent", "consistent"))
test$testimonyC <- factor(test$testimony, levels = c(0,1), labels=c("Team X","Team Y"))
out <- ddply(test, .(prop), transform, dfb = prop_estimate - mean(baseline[baseline$prop == prop,'prop_estimate']))



out$cond <- factor(mapply(function(wb, testimony){
    if(testimony == 0){
        if(wb == 1){conditions[1]}
        else{conditions[2]}
    } else{
        if(wb == 1){conditions[3]}
        else{conditions[4]}
    }
}, out$wb,out$testimony))

t.err <- summarySE(s(out, prop == .6), measurevar='dfb', groupvars=c('cond','testimony'), na.rm=TRUE)
t.err$cond <- factor(t.err$cond, levels= conditions, labels=conditions)
t.err$kind <- "data"

mod$testimony <- as.numeric(mod$testimony)-1
comb <- rbind.fill(t.err, mod)

comb$kind <- factor(comb$kind,levels=c("data","EToM", "RToM"), labels=c("(a) data", "(b) oToM", "(c) rToM"))

ggplot(comb, aes(cond, dfb, fill=factor(testimony))) +
    geom_bar(stat="identity",position="dodge") +
        geom_hline() +
            facet_grid(~kind ) +
                geom_errorbar(aes(ymin=dfb-se, ymax=dfb+se), width=.25, position=position_dodge(1)) +
                    scale_x_discrete("Social Cue", labels="") +
                        scale_y_continuous(expression(paste("Social Cue's Affect on p(",wins[x],")"))) +
                            dj_Pub(30) +
                                scale_fill_manual(values=c("#d95f02", "#7570b3"), guide=F)

g.png

1.2.2 Leaner Experiment

1.2.2.1 “All” condition
load("data/lfba_lean.Rdata")
dl <- trials[trials$expt=="wunbiased",]

Condition N

length(unique(dl$uwid))
[1] 30
1.2.2.1.1 Baseline
baseline <- s(dl, version == "baseline")
ggplot(baseline, aes(prop, prop_estimate)) +
    stat_summary(fun.y=mean, geom="point", size = 3) +
        stat_summary(fun.data = "mean_cl_boot", geom="errorbar") +
            scale_x_continuous("Distance from Winning Bin") +
                scale_y_continuous("Horse X's Chances") +
                    ggtitle("Ss' estimate of Zach's belief about Horse X's chances")

i.png

baseline <- s(dl, version == "baseline")

 ggplot(baseline, aes(prop, prop_estimate)) +
     geom_point() +
             scale_x_continuous("Distance from Winning Bin") +
                 scale_y_continuous("Horse X's Chances") +
                     facet_wrap(~sid) +
                     ggtitle("Ss' estimate of Zach's belief about Horse X's chances")

j.png

1.2.2.1.2 Main Effect
test <- dl[dl$version == 'test',]
test$wbC <- factor(test$wb, levels = c(0,-1,1), labels=c("against bias","impartial","with bias"))
test$testimonyC <- factor(test$testimony, levels = c(0,1), labels=c("Team X","Team Y"))

t.err <- summarySE(test, measurevar='prop_estimate', groupvars=c('prop', 'testimonyC','wbC'), na.rm=TRUE)

 ggplot(t.err, aes(testimonyC, prop_estimate, color=factor(wbC))) +
     geom_point(size=2,position=position_dodge(1)) +
         geom_errorbar(aes(ymin=prop_estimate-se, ymax=prop_estimate+se), width=.25, position=position_dodge(1)) +
             scale_x_discrete("") +
                 scale_y_continuous("P(Team X Wins)") +
                     scale_color_manual("Testimony supporting", values=c("#d95f02", "#818181", "#7570b3")) +
 ggtitle("Ss' estimate of Zach's belief of P(Win)")

k.png

Condition N

length(unique(dl$uwid))
[1] 30
1.2.2.1.3 Main Effect
test$wbC <- factor(test$wb, levels = c(0,-1,1), labels=c("against bias","impartial","with bias"))
test$testimonyC <- factor(test$testimony, levels = c(0,1), labels=c("Team X","Team Y"))

t.err <- summarySE(test, measurevar='prop_estimate', groupvars=c('testimonyC','wbC'), na.rm=TRUE)

 ggplot(t.err, aes(wbC, prop_estimate, color=wbC)) +
   geom_point(size=2,position=position_dodge(1)) +
   geom_errorbar(aes(ymin=prop_estimate-se, ymax=prop_estimate+se), width=.25, position=position_dodge(1)) +
             scale_x_discrete("Bias of ") +
                 scale_y_continuous("P(Team Wins)") +
                     scale_color_manual(values=c("#d95f02", "#818181", "#7570b3"), guide=F) +
ggtitle("Ss' estimate of Zach's belief of P(Win)")  +
    dj_Pub(18)

l.png

Within subjects difference from impartial

diff <- ddply(dl, .(uwid),  function(x){
  data.frame(wb = x[x$wb==1, "prop_estimate"] - x[x$wb==-1, "prop_estimate"], ab = x[x$wb==0, "prop_estimate"] - x[x$wb==-1, "prop_estimate"] )
})

mdiff <- melt(diff, measured=c("wb","ab"))

t.err <- summarySE(mdiff, measurevar='value', groupvars=c('variable'), na.rm=TRUE)


ggplot(t.err, aes(variable, value, color=variable)) +
  geom_point(size=2,position=position_dodge(1)) +
  geom_errorbar(aes(ymin=value-se, ymax=value+se), width=.25, position=position_dodge(1)) +
  scale_x_discrete("Bias of ") +
  scale_y_continuous("P(Team Wins)") +
  scale_color_manual(values=c("#d95f02", "#818181", "#7570b3"), guide=F) +
ggtitle("Ss' estimate of Zach's belief of P(Win)")  +
  dj_Pub(18)

m.png

test$wbC <- factor(test$wb, levels = c(0,-1,1), labels=c("against bias","impartial","with bias"))
test$testimonyC <- factor(test$testimony, levels = c(0,1), labels=c("Team X","Team Y"))

ggplot(test, aes(wbC, prop_estimate, color=wbC)) +
  geom_point(size=2) +
  scale_x_discrete("Bias of Bettor") +
  facet_wrap(~sid ) +
  scale_y_continuous("P(Team X Wins)") +
  scale_color_manual(values=c("#d95f02", "#818181", "#7570b3"),guide=F)

n.png

1.2.2.2 “No but” condition
load("data/lfba_l2.Rdata")
dl <- trials[trials$expt=="textnobut",]
test <- dl[!dl$sid %in% c(220, 205, 210, 209, 228),]

Condition N

length(unique(test$uwid))
[1] 70
1.2.2.2.1 By Subj
test$wbC <- factor(test$wb, levels = c(0,-1,1), labels=c("against bias","impartial","with bias"))
test$testimonyC <- factor(test$testimony, levels = c(0,1), labels=c("Team X","Team Y"))


ggplot(test, aes(wbC, prop_estimate, color=wbC)) +
  geom_point(size=2,position=position_dodge(1)) +
  scale_x_discrete("Source's Bias", labels=c("incon", "impartial", "con")) +
  scale_y_continuous("P(Team Wins)") +
  facet_wrap(~sid) +
  scale_color_manual(values=c("#d95f02", "#818181", "#7570b3"), guide=F) +
dj_Pub(18)

o.png

1.2.2.2.2 Main Effect
test$wbC <- factor(test$wb, levels = c(0,-1,1), labels=c("against bias","impartial","with bias"))
test$testimonyC <- factor(test$testimony, levels = c(0,1), labels=c("Team X","Team Y"))

t.err <- summarySE(test, measurevar='prop_estimate', groupvars=c('testimonyC','wbC'), na.rm=TRUE)

 ggplot(t.err, aes(wbC, prop_estimate, color=wbC)) +
   geom_point(size=2,position=position_dodge(1)) +
   geom_errorbar(aes(ymin=prop_estimate-se, ymax=prop_estimate+se), width=.25, position=position_dodge(1)) +
             scale_x_discrete("Source's Bias", labels=c("against bet", "impartial", "with bet")) +
                 scale_y_continuous("P(Team Wins)") +
                     scale_color_manual(values=c("#d95f02", "#818181", "#7570b3"), guide=F) +
    dj_Pub(18)

p.png

Within subjects difference from impartial

diff <- ddply(dl, .(uwid),  function(x){
  data.frame(wb = x[x$wb==1, "prop_estimate"] - x[x$wb==-1, "prop_estimate"], ab = x[x$wb==0, "prop_estimate"] - x[x$wb==-1, "prop_estimate"] )
})

mdiff <- melt(diff, measured=c("wb","ab"))

t.err <- summarySE(mdiff, measurevar='value', groupvars=c('variable'), na.rm=TRUE)
t.err$variable <- factor(t.err$variable, levels=c("ab","wb"))

ggplot(t.err, aes(variable, value, color=variable)) +
  geom_point(size=2,position=position_dodge(1)) +
  geom_errorbar(aes(ymin=value-se, ymax=value+se), width=.25, position=position_dodge(1)) +
  scale_x_discrete("Source's Bias", labels=c("Against Bet - Impartial","With Bet - Impartial")) +
  scale_y_continuous("P(Team Wins)") +
  scale_color_manual(values=c("#d95f02", "#7570b3"), guide=F) +
  dj_Pub(18)

q.png

test$wbC <- factor(test$wb, levels = c(0,-1,1), labels=c("against bias","impartial","with bias"))
test$testimonyC <- factor(test$testimony, levels = c(0,1), labels=c("Team X","Team Y"))

ggplot(test, aes(wbC, prop_estimate, color=wbC)) +
  geom_point(size=2) +
  scale_x_discrete("Bias of Bettor") +
  facet_wrap(~sid ) +
  scale_y_continuous("P(Team X Wins)") +
  scale_color_manual(values=c("#d95f02", "#818181", "#7570b3"),guide=F)

r.png

1.2.2.2.3 1st trial
test1 <- s(dl, pid==1)
cats <- c("yes","indifferent","no")
test1$wbC <- factor(test1$wb, levels = c(0,-1,1), labels=cats)
test1$testimonyC <- factor(test1$testimony, levels = c(0,1), labels=c("Team X","Team Y"))
t.err <- summarySE(test1, measurevar='prop_estimate', groupvars=c('testimonyC','wbC'), na.rm=TRUE)
t.err$kind <- "data"
t.err$utility <- t.err$wbC

df <- data.frame(list(utility=cats), list(prop_estimate = c(.65,.65,.65)))
full <- df
full$kind <- "rToM"

df <- data.frame(list(utility=cats), list(prop_estimate = c(.73,.65,.53)))
df$kind <- "oToM"
full <- rbind(full,df)
full$kind <- factor(full$kind, levels=c("rToM","oToM"))
full$utility <- factor(full$utility, levels=cats)
full <- rbind.fill(full, t.err)

dj_Pub <- function(base_size = 35) {
  theme_bw()+ theme(
      text=element_text(size=base_size),
      plot.margin= unit(c(1, 1, 3, 3), "lines"),
      legend.key.size = unit(2, "lines"),
      panel.grid.minor = element_blank(),
      axis.text.x = element_text(size=20),
      strip.text.x = element_text(size=30),
      axis.title.x = element_text(vjust=-3) ,
      axis.title.y = element_text(vjust=4, hjust = .63),
      plot.title = element_text(vjust=3, hjust=1),
      strip.background = element_rect(fill = "white")
      )}

ggplot(full, aes(utility, prop_estimate, color=utility)) +
  geom_point(size = 6) +
  geom_errorbar(aes(ymin=prop_estimate-se, ymax=prop_estimate+se)) +
  scale_x_discrete("Does source want the team to win?") +
  scale_y_continuous("p(Team Wins)") +
  facet_wrap(~kind) +
  scale_colour_manual("Utility", values=c("#d95f02", "#818181", "#7570b3"), guide=F) +
#theme(axis.text.x = element_text(angle = 45, hjust = .5, vjust=.5))
dj_Pub(30)

q.png

1.2.3 Final

df <- data.frame(list(utility=c("Sox","Impartial", "Cubs")), list(Cubs = c(.7,.7,.7)))
full <- df
full$kind <- "rToM"

df <- data.frame(list(utility=c("Sox","Impartial", "Cubs")), list(Cubs = c(.9,.7,.55)))
df$kind <- "oToM"
full <- rbind(full,df)
full$kind <- factor(full$kind, levels=c("rToM","oToM"))
full$utility <- factor(full$utility, levels=c("Sox","Impartial", "Cubs"))


  ggplot(full, aes(utility, Cubs, color=utility)) +
    geom_point(size = 4) +
    scale_x_discrete("Source's Bias") +
    scale_y_continuous("p(Cubs Win)") +
    facet_wrap(~kind) +
    scale_colour_manual("Utility", values=c("#d95f02", "#818181", "#7570b3"), guide=F) +
  dj_Pub(30)

r.png

Between Subjects

cats <- c("yes","indifferent","no")
test$wbC <- factor(test$wb, levels = c(0,-1,1), labels=cats)
test$testimonyC <- factor(test$testimony, levels = c(0,1), labels=c("Team X","Team Y"))
t.err <- summarySE(test, measurevar='prop_estimate', groupvars=c('testimonyC','wbC'), na.rm=TRUE)
t.err$kind <- "data"
t.err$utility <- t.err$wbC

df <- data.frame(list(utility=cats), list(prop_estimate = c(.65,.65,.65)))
full <- df
full$kind <- "rToM"

df <- data.frame(list(utility=cats), list(prop_estimate = c(.73,.65,.53)))
df$kind <- "oToM"
full <- rbind(full,df)
full$kind <- factor(full$kind, levels=c("rToM","oToM"))
full$utility <- factor(full$utility, levels=cats)
full <- rbind.fill(full, t.err)

dj_Pub <- function(base_size = 35) {
  theme_bw()+ theme(
      text=element_text(size=base_size),
      plot.margin= unit(c(1, 1, 3, 3), "lines"),
      legend.key.size = unit(2, "lines"),
      panel.grid.minor = element_blank(),
      axis.text.x = element_text(size=20),
      strip.text.x = element_text(size=30),
      axis.title.x = element_text(vjust=-3) ,
      axis.title.y = element_text(vjust=4, hjust = .63),
      plot.title = element_text(vjust=3, hjust=1),
      strip.background = element_rect(fill = "white")
      )}

ggplot(full, aes(utility, prop_estimate, color=utility)) +
  geom_point(size = 6) +
  geom_errorbar(aes(ymin=prop_estimate-se, ymax=prop_estimate+se)) +
  scale_x_discrete("Does source want the team to win?") +
  scale_y_continuous("p(Team Wins)") +
  facet_wrap(~kind) +
  scale_colour_manual("Utility", values=c("#d95f02", "#818181", "#7570b3"), guide=F) +
#theme(axis.text.x = element_text(angle = 45, hjust = .5, vjust=.5))
dj_Pub(30)

t.png