Compute absolute deviation
posthoc_error(delta, xi, ests, n)
Modified from AbsError in https://github.com/Catalist-LLC/unemployment/blob/master/unemployment_cps_mrp/helper_functions/GetYHat.R
The parameter of interest
The true target
A vector of current estimate, by cell
The sample size of the estimates, by cell
logit_ghitza calib_oneway
biased_ests <- ccesMRPrun:::invlogit(rnorm(n = 100, mean = 1, sd = 1))
sizes <- rbinom(n = 100, size = 100, prob = 0.1)
tru <- 0.5
# one delta
posthoc_error(delta = 0.1, xi = tru, ests = biased_ests, n = sizes)
#> [1] 0.2083554
# test multiple deltas
deltas <- seq(-3, 3, by = 0.1)
abserr <- purrr::map_dbl(.x = deltas,
.f = ~posthoc_error(.x, xi = tru, ests= biased_ests, n = sizes))
plot(deltas, abserr, bty = "n")