From: Nathan TeBlunthuis Date: Wed, 1 Mar 2023 00:14:34 +0000 (-0800) Subject: update plotting code X-Git-Url: https://code.communitydata.science/ml_measurement_error_public.git/commitdiff_plain/69948cae1e691191fc86e6abdaa485bc98f38f1f?ds=sidebyside update plotting code --- diff --git a/simulations/plot_dv_example.R b/simulations/plot_dv_example.R index 45a5d51..88d88a8 100644 --- a/simulations/plot_dv_example.R +++ b/simulations/plot_dv_example.R @@ -6,7 +6,7 @@ library(filelock) library(argparser) parser <- arg_parser("Simulate data and fit corrected models.") -parser <- add_argument(parser, "--infile", default="example_4.feather", help="name of the file to read.") +parser <- add_argument(parser, "--infile", default="robustness_3_dv.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) @@ -86,9 +86,6 @@ build_plot_dataset <- function(df){ change.remember.file(args$remember_file, clear=TRUE) sims.df <- read_feather(args$infile) -sims.df[,Bzx:=NA] -sims.df[,y_explained_variance:=NA] -sims.df[,accuracy_imbalance_difference:=NA] plot.df <- build_plot_dataset(sims.df) remember(plot.df,args$name) diff --git a/simulations/plot_example.R b/simulations/plot_example.R index 09d6bf3..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="example_2.feather", 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 diff --git a/simulations/summarize_estimator.R b/simulations/summarize_estimator.R index f416c5b..1e1341d 100644 --- a/simulations/summarize_estimator.R +++ b/simulations/summarize_estimator.R @@ -9,7 +9,7 @@ summarize.estimator <- function(df, suffix='naive', coefname='x'){ ) - grouping_vars <- c('N','m','B0', 'Bxy', 'Bzy', 'Bzx', 'Px', 'y_explained_variance', 'prediction_accuracy','outcome_formula','proxy_formula','truth_formula','z_bias','y_bias') + grouping_vars <- c('N','m','B0', 'Bxy', 'Bzy', 'Bzx', 'Px', 'Py','y_explained_variance', 'prediction_accuracy','outcome_formula','proxy_formula','truth_formula','z_bias','y_bias') grouping_vars <- grouping_vars[grouping_vars %in% names(df)] @@ -37,6 +37,8 @@ summarize.estimator <- function(df, suffix='naive', coefname='x'){ est.lower.95 = quantile(.SD[[paste0('B',coefname,'y.est.',suffix)]],0.025,na.rm=T), mean.ci.upper = mean(.SD[[paste0('B',coefname,'y.ci.upper.',suffix)]],na.rm=T), mean.ci.lower = mean(.SD[[paste0('B',coefname,'y.ci.lower.',suffix)]],na.rm=T), + median.ci.upper = median(.SD[[paste0('B',coefname,'y.ci.upper.',suffix)]],na.rm=T), + median.ci.lower = median(.SD[[paste0('B',coefname,'y.ci.lower.',suffix)]],na.rm=T), ci.upper.975 = quantile(.SD[[paste0('B',coefname,'y.ci.upper.',suffix)]],0.975,na.rm=T), ci.upper.025 = quantile(.SD[[paste0('B',coefname,'y.ci.upper.',suffix)]],0.025,na.rm=T), ci.lower.975 = quantile(.SD[[paste0('B',coefname,'y.ci.lower.',suffix)]],0.975,na.rm=T),