X-Git-Url: https://code.communitydata.science/ml_measurement_error_public.git/blobdiff_plain/47e9367ed5c61b721bdc17cddd76bced4f8ed621..69948cae1e691191fc86e6abdaa485bc98f38f1f:/simulations/03_depvar_differential.R diff --git a/simulations/03_depvar_differential.R b/simulations/03_depvar_differential.R index 7b920ba..02944a5 100644 --- a/simulations/03_depvar_differential.R +++ b/simulations/03_depvar_differential.R @@ -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")