library(knitr)
library(ggplot2)
library(data.table)
knitr::opts_chunk$set(fig.show='hold')
f <- function (x) {formatC(x, format="d", big.mark=',')}
format.percent <- function(x) {x<-as.numeric(x);paste(f(x*100),"\\%",sep='')}

theme_set(theme_bw())
r <- readRDS('remembr.RDS')
attach(r)
r2 <- readRDS('remember_irr.RDS')
attach(r2)
r3 <- readRDS('remember_grid_sweep.RDS')
attach(r3)


## simulation.summary.df <- data.table(sample.4
## simulation.summary.df <- kable(simulation.summary.df,format='latex',row.names=T, column.names=c("Factors", "Input Parameters")


sim1a.cor.xz <- as.numeric(unlist(example.1['med.cor.xz']))
sim1a.acc <- unlist(example.1['med.accuracy'])
sim1b.acc <- unlist(example.2['med.accuracy'])
sim1b.acc.y1 <- unlist(example.2['med.accuracy.y1'])
sim1b.acc.y0 <- example.2['med.accuracy.y0']
(sim1b.fnr <- example.2['med.fnr'])
(sim1b.fnr.y0 <- example.2['med.fnr.y0'])
(sim1b.fnr.y1 <- example.2['med.fnr.y1'])
sim1b.fpr <- example.2['med.fpr']
sim1b.fpr.y0 <- example.2['med.fpr.y0']
sim1b.fpr.y1 <- example.2['med.fpr.y1']
sim1b.cor.resid.w_pred <- as.numeric(unlist(example.2['cor.resid.w_pred']))
(sim1b.cor.xz <- example.2['med.cor.xz'])

sim2a.AC.acc <- example.3['med.accuracy']
sim2a.lik.ratio <- example.3['med.lik.ratio']
sim2a.cor.xz <- as.numeric(example.3['med.cor.xz'])


sim2b.AC.acc <- example.4['med.accuracy']
sim2b.lik.ratio <- example.4['med.lik.ratio']
(sim2b.error.cor.x <- as.numeric(unlist(example.4['med.error.cor.x'])))
(sim2b.error.cor.z <- as.numeric(unlist(example.4['med.error.cor.z'])))

n.simulations <- max(unlist(example_1_jobs$seed))
sim1a.cor.xz <- as.numeric(unlist(example.3['med.cor.xz']))
sim1.R2 <- unlist(example_1_jobs$y_explained_variance)
N.sizes <- unlist(example_1_jobs$N)
N.sizes <- N.sizes[N.sizes!=800]
m.sizes <- unlist(example_1_jobs$m)
sim2.Bx <- as.numeric(example_4_jobs$Bxy)
sim2.Bz <- as.numeric(example_4_jobs$Bzy)
sim1.z.sd <- 0.5
irr.coder.accuracy <- unlist(example_5_jobs$coder_accuracy)
med.loco.accuracy <-  unlist(example.5$med.loco.acc)
