-
Notifications
You must be signed in to change notification settings - Fork 5
/
Fig2_noteb.Rmd
37 lines (25 loc) · 903 Bytes
/
Fig2_noteb.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---
title: "Figure 2 replication"
output: html_notebook
---
```{r}
rm(list=ls())
library(ggplot2)
library(reshape2)
#wd <- getwd()
wd <- "/Users/andrew/Dropbox/machine_parliament/PA_replication/"
data.dir <- paste0(wd, "/data/")
df <- read.csv(paste0(data.dir, "preds_sims.csv"))
df$noisefrac <- seq(0,.999, .001) # cut off 1 in python...
df4 <- df[c(101, 301, 501, 701, 901),] # presenting too many makes viz unclear
m <- melt(df4, id.vars='noisefrac')
m$party <- sapply(m$variable, substring, 1,1)
m$party[m$party=='r'] <- 'Right'
m$party[m$party=='l'] <- 'Left'
left <- m[m$party=='Left',]
right <- m[m$party=='Right',]
p <- ggplot(m, aes(value, linetype=as.factor(noisefrac)))
p + geom_density() + theme_bw() + xlim(0,1)+labs(linetype = "Fraction Noise") + xlab("Predicted Probability Conservative") + ylab("density")
#ggsave("density_by_noise.pdf", width=10, height=6)
#dev.off()
```