2 summarize.estimator <- function(df, suffix='naive', coefname='x'){
7 paste0('B',coefname,'y.est.',suffix),
8 paste0('B',coefname,'y.ci.lower.',suffix),
9 paste0('B',coefname,'y.ci.upper.',suffix),
10 'y_explained_variance',
13 'accuracy_imbalance_difference'
17 true.in.ci <- as.integer((part$Bxy >= part[[paste0('B',coefname,'y.ci.lower.',suffix)]]) & (part$Bxy <= part[[paste0('B',coefname,'y.ci.upper.',suffix)]]))
18 zero.in.ci <- as.integer(0 >= part[[paste0('B',coefname,'y.ci.lower.',suffix)]]) & (0 <= part[[paste0('B',coefname,'y.ci.upper.',suffix)]])
19 bias <- part$Bxy - part[[paste0('B',coefname,'y.est.',suffix)]]
20 sign.correct <- as.integer(sign(part$Bxy) == sign(part[[paste0('B',coefname,'y.est.',suffix)]]))
22 part <- part[,':='(true.in.ci = true.in.ci,
23 zero.in.ci = zero.in.ci,
25 sign.correct =sign.correct)]
27 part.plot <- part[, .(p.true.in.ci = mean(true.in.ci),
28 mean.bias = mean(bias),
29 mean.est = mean(.SD[[paste0('B',coefname,'y.est.',suffix)]]),
30 var.est = var(.SD[[paste0('B',coefname,'y.est.',suffix)]]),
31 est.upper.95 = quantile(.SD[[paste0('B',coefname,'y.est.',suffix)]],0.95,na.rm=T),
32 est.lower.95 = quantile(.SD[[paste0('B',coefname,'y.est.',suffix)]],0.05,na.rm=T),
34 p.sign.correct = mean(as.integer(sign.correct & (! zero.in.ci))),
38 by=c("N","m",'y_explained_variance','Bzx', 'Bzy', 'accuracy_imbalance_difference')