1 source("RemembR/R/RemembeR.R")
8 parser <- arg_parser("Simulate data and fit corrected models.")
9 parser <- add_argument(parser, "--infile", default="", help="name of the file to read.")
10 parser <- add_argument(parser, "--name", default="", help="The name to safe the data to in the remember file.")
11 args <- parse_args(parser)
12 source("summarize_estimator.R")
14 build_plot_dataset <- function(df){
16 x.true <- summarize.estimator(df, 'true','x')
18 z.true <- summarize.estimator(df, 'true','z')
20 x.naive <- summarize.estimator(df, 'naive','x')
22 z.naive <- summarize.estimator(df, 'naive','z')
24 x.loa0.feasible <- summarize.estimator(df, 'loa0.feasible','x')
26 z.loa0.feasible <- summarize.estimator(df,'loa0.feasible','z')
28 x.loa0.mle <- summarize.estimator(df, 'loa0.mle', 'x')
30 z.loa0.mle <- summarize.estimator(df, 'loa0.mle', 'z')
32 x.loco.feasible <- summarize.estimator(df, 'loco.feasible', 'x')
34 z.loco.feasible <- summarize.estimator(df, 'loco.feasible', 'z')
36 x.loco.mle <- summarize.estimator(df, 'loco.mle', 'x')
38 z.loco.mle <- summarize.estimator(df, 'loco.mle', 'z')
41 z.loco.amelia <- summarize.estimator(df, 'amelia.full', 'z')
42 x.loco.amelia <- summarize.estimator(df, 'amelia.full', 'x')
44 z.loco.zhang <- summarize.estimator(df, 'zhang', 'z')
45 x.loco.zhang <- summarize.estimator(df, 'zhang', 'x')
47 accuracy <- df[,mean(accuracy)]
48 plot.df <- rbindlist(list(x.true,z.true,x.loa0.feasible,z.loa0.feasible,x.naive,z.naive,x.loa0.mle,z.loa0.mle,x.loco.feasible, z.loco.feasible, z.loco.mle, x.loco.mle, x.loco.amelia, z.loco.amelia, z.loco.zhang, x.loco.zhang),use.names=T)
49 plot.df[,accuracy := accuracy]
50 plot.df <- plot.df[,":="(sd.est=sqrt(var.est)/N.sims)]
55 plot.df <- read_feather(args$infile)
56 print(unique(plot.df$N))
58 # df <- df[apply(df,1,function(x) !any(is.na(x)))]
60 if(!('Bzx' %in% names(plot.df)))
63 if(!('accuracy_imbalance_difference' %in% names(plot.df)))
64 plot.df[,accuracy_imbalance_difference:=NA]
66 unique(plot.df[,'accuracy_imbalance_difference'])
68 #plot.df <- build_plot_dataset(df[accuracy_imbalance_difference==0.1][N==700])
69 plot.df <- build_plot_dataset(plot.df)
71 change.remember.file("remember_irr.RDS",clear=TRUE)
73 remember(plot.df,args$name)