Compute absolute deviation

posthoc_error(delta, xi, ests, n)

Source

Modified from AbsError in https://github.com/Catalist-LLC/unemployment/blob/master/unemployment_cps_mrp/helper_functions/GetYHat.R

Arguments

delta

The parameter of interest

xi

The true target

ests

A vector of current estimate, by cell

n

The sample size of the estimates, by cell

See also

logit_ghitza calib_oneway

Author

Yair Ghitza and Shiro Kuriwaki

Examples

 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")