]> code.communitydata.science - ml_measurement_error_public.git/commitdiff
update plotting code
authorNathan TeBlunthuis <nathante@uw.edu>
Wed, 1 Mar 2023 00:14:34 +0000 (16:14 -0800)
committerNathan TeBlunthuis <nathante@uw.edu>
Wed, 1 Mar 2023 00:14:34 +0000 (16:14 -0800)
simulations/plot_dv_example.R
simulations/plot_example.R
simulations/summarize_estimator.R

index 45a5d51827cf2cda733c48ddbd63876bc305feaf..88d88a8943b580c98d1014b74c6a476a0bb0bd12 100644 (file)
@@ -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)
index 09d6bf3e7394c95439133896a2404c89e080f671..4da045bfd907c316663b570966dbf392da8ebd1b 100644 (file)
@@ -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
index f416c5b30bbaf9e664499338fc002bdad42686e0..1e1341d2514096e795fcf6e937de9ab521c39abb 100644 (file)
@@ -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),

Community Data Science Collective || Want to submit a patch?