X-Git-Url: https://code.communitydata.science/ml_measurement_error_public.git/blobdiff_plain/d0c5766bdf867a81a2477d2cac1d40812110af90..refs/heads/main:/simulations/plot_example.R diff --git a/simulations/plot_example.R b/simulations/plot_example.R index 8e6c477..4da045b 100644 --- a/simulations/plot_example.R +++ b/simulations/plot_example.R @@ -9,7 +9,7 @@ source("summarize_estimator.R") parser <- arg_parser("Simulate data and fit corrected models.") -parser <- add_argument(parser, "--infile", default="", help="name of the file to read.") +parser <- add_argument(parser, "--infile", default="robustness_2.feather", help="name of the file to read.") parser <- add_argument(parser, "--remember-file", default="remembr.RDS", help="name of the remember file.") parser <- add_argument(parser, "--name", default="", help="The name to safe the data to in the remember file.") args <- parse_args(parser) @@ -47,7 +47,7 @@ args <- parse_args(parser) ## var.est = var(.SD[[paste0('B',coefname,'y.est.',suffix)]]), ## est.upper.95 = quantile(.SD[[paste0('B',coefname,'y.est.',suffix)]],0.95,na.rm=T), ## est.lower.95 = quantile(.SD[[paste0('B',coefname,'y.est.',suffix)]],0.05,na.rm=T), -## N.sims = .N, +## N.sims = . ## p.sign.correct = mean(as.integer(sign.correct & (! zero.in.ci))), ## variable=coefname, ## method=suffix @@ -76,13 +76,13 @@ build_plot_dataset <- function(df){ z.amelia.full <- summarize.estimator(df, 'amelia.full', 'z') - x.mecor <- summarize.estimator(df, 'mecor', 'x') + ## x.mecor <- summarize.estimator(df, 'mecor', 'x') - z.mecor <- summarize.estimator(df, 'mecor', 'z') + ## z.mecor <- summarize.estimator(df, 'mecor', 'z') - x.mecor <- summarize.estimator(df, 'mecor', 'x') + ## x.mecor <- summarize.estimator(df, 'mecor', 'x') - z.mecor <- summarize.estimator(df, 'mecor', 'z') + ## z.mecor <- summarize.estimator(df, 'mecor', 'z') x.mle <- summarize.estimator(df, 'mle', 'x') @@ -97,7 +97,7 @@ build_plot_dataset <- function(df){ z.gmm <- summarize.estimator(df, 'gmm', 'z') accuracy <- df[,mean(accuracy)] - plot.df <- rbindlist(list(x.true,z.true,x.naive,z.naive,x.amelia.full,z.amelia.full,x.mecor, z.mecor, x.gmm, z.gmm, x.feasible, z.feasible,z.mle, x.mle, x.zhang, z.zhang, x.gmm, z.gmm),use.names=T) + plot.df <- rbindlist(list(x.true,z.true,x.naive,z.naive,x.amelia.full,z.amelia.full,x.gmm, z.gmm, x.feasible, z.feasible,z.mle, x.mle, x.zhang, z.zhang, x.gmm, z.gmm),use.names=T) plot.df[,accuracy := accuracy] plot.df <- plot.df[,":="(sd.est=sqrt(var.est)/N.sims)] return(plot.df) @@ -105,6 +105,7 @@ build_plot_dataset <- function(df){ sims.df <- read_feather(args$infile) +unique(sims.df[,.N,by=.(N,m)]) print(unique(sims.df$N)) # df <- df[apply(df,1,function(x) !any(is.na(x)))]