## print(mean(df[z==1]$x == df[z==1]$w_pred))
## print(mean(df$w_pred == df$x))
- odds.x1 <- qlogis(prediction_accuracy) + y_bias*qlogis(pnorm(scale(df[x==1]$y)))
- odds.x0 <- qlogis(prediction_accuracy,lower.tail=F) + y_bias*qlogis(pnorm(scale(df[x==0]$y)))
+ resids <- resid(lm(y~x + z))
+ odds.x1 <- qlogis(prediction_accuracy) + y_bias*qlogis(pnorm(resids[x==1]))
+ odds.x0 <- qlogis(prediction_accuracy,lower.tail=F) + y_bias*qlogis(pnorm(resids[x==0]))
## acc.x0 <- p.correct[df[,x==0]]
## acc.x1 <- p.correct[df[,x==1]]
df[,w_pred := as.integer(w > 0.5)]
- print(mean(df[z==0]$x == df[z==0]$w_pred))
- print(mean(df[z==1]$x == df[z==1]$w_pred))
+
print(mean(df$w_pred == df$x))
print(mean(df[y>=0]$w_pred == df[y>=0]$x))
print(mean(df[y<=0]$w_pred == df[y<=0]$x))
}
parser <- arg_parser("Simulate data and fit corrected models")
-parser <- add_argument(parser, "--N", default=1000, help="number of observations of w")
+parser <- add_argument(parser, "--N", default=5000, help="number of observations of w")
parser <- add_argument(parser, "--m", default=500, help="m the number of ground truth observations")
parser <- add_argument(parser, "--seed", default=51, help='seed for the rng')
parser <- add_argument(parser, "--outfile", help='output file', default='example_2.feather')
parser <- add_argument(parser, "--Bxy", help='Effect of z on y', default=0.3)
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*z*x")
-parser <- add_argument(parser, "--y_bias", help='coefficient of y on the probability a classification is correct', default=-0.75)
+parser <- add_argument(parser, "--y_bias", help='coefficient of y on the probability a classification is correct', default=-1)
parser <- add_argument(parser, "--truth_formula", help='formula for the true variable', default="x~z")
args <- parse_args(parser)