utils.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:pyprocessmacro 作者: QuentinAndre 项目源码 文件源码
def bias_corrected_ci(true_coeff, samples, conf=95):
    """
    Return the bias-corrected bootstrap confidence interval, using the method from the book.
    :param true_coeff: The estimates in the original sample
    :param samples: The bootstrapped estimates
    :param conf: The level of the desired confidence interval
    :return: The bias-corrected LLCI and ULCI for the bootstrapped estimates.
    """
    ptilde = (samples < true_coeff).mean()
    Z = norm.ppf(ptilde)
    Zci = z_score(conf)
    Zlow, Zhigh = -Zci + 2 * Z, Zci + 2 * Z
    plow, phigh = norm._cdf(Zlow), norm._cdf(Zhigh)
    llci = np.percentile(samples, plow * 100, interpolation='lower')
    ulci = np.percentile(samples, phigh * 100, interpolation='higher')
    return llci, ulci
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号