]> code.communitydata.science - ml_measurement_error_public.git/blobdiff - simulations/03_depvar_differential.R
Added, but didn't test the remaining robustness checks.
[ml_measurement_error_public.git] / simulations / 03_depvar_differential.R
index 7b920ba6af6c7b6bfe7ed1cf962910767ab8e384..02944a51c0306d67c85a7cc79da2f903dc09a188 100644 (file)
@@ -31,14 +31,14 @@ source("simulation_base.R")
 
 ## one way to do it is by adding correlation to x.obs and y that isn't in w.
 ## in other words, the model is missing an important feature of x.obs that's related to y.
-simulate_data <- function(N, m, B0, Bxy, Bzy, seed, prediction_accuracy=0.73, x_bias=-0.75){
+simulate_data <- function(N, m, B0, Bxy, Bzy, Py, seed, prediction_accuracy=0.73, x_bias=-0.75){
     set.seed(seed)
 
     # make w and y dependent
     z <- rbinom(N, 1, 0.5)
     x <- rbinom(N, 1, 0.5)
 
-    ystar <- Bzy * z + Bxy * x + B0
+    ystar <- Bzy * z + Bxy * x + B0 + qlogix(Py)
     y <- rbinom(N,1,plogis(ystar))
 
     # glm(y ~ x + z, family="binomial")
@@ -77,6 +77,7 @@ parser <- add_argument(parser, "--prediction_accuracy", help='how accurate is th
 parser <- add_argument(parser, "--x_bias", help='how is the classifier biased?', default=0.75)
 parser <- add_argument(parser, "--Bxy", help='coefficient of x on y', default=0.3)
 parser <- add_argument(parser, "--Bzy", help='coeffficient of z on y', default=-0.3)
+parser <- add_argument(parser, "--Py", help='Base rate of y', default=0.5)
 parser <- add_argument(parser, "--outcome_formula", help='formula for the outcome variable', default="y~x+z")
 parser <- add_argument(parser, "--proxy_formula", help='formula for the proxy variable', default="w_pred~y*x")
 

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