src/estimagic/inference/bootstrap_ci.py
def _ci_bca(data, outcome, estimates, alpha, n_cores):
    """Compute bca type confidence interval of bootstrap estimates.

    Args:
        data (pd.DataFrame): original dataset.
        outcome (callable): function of the data calculating statistic of interest.
        estimates (data.Frame): DataFrame of estimates in the bootstrap samples.
        alpha (float): significance level of choice.
        n_cores (int): number of jobs for parallelization.

    Returns:
        cis (np.array): array where k'th row contains CI for k'th parameter.

    """

    num_params = estimates.shape[1]
    boot_est = estimates.values
    cis = np.zeros((num_params, 2))

    theta = outcome(data)

    jack_est = _jackknife(data, outcome, n_cores)
    jack_mean = np.mean(jack_est, axis=0)

    for k in range(num_params):

        q = _eqf(boot_est[:, k])
        params = boot_est[:, k]

        # bias correction
        z_naught = norm.ppf(np.mean(params <= theta[k]))
        z_low = norm.ppf(alpha)
        z_high = norm.ppf(1 - alpha)

        # accelaration
        acc = np.sum((jack_mean[k] - jack_est[k]) ** 3) / (
            6 * np.sum((jack_mean[k] - jack_est[k]) ** 2) ** (3 / 2)
        )

        p1 = norm.cdf(z_naught + (z_naught + z_low) / (1 - acc * (z_naught + z_low)))
        p2 = norm.cdf(z_naught + (z_naught + z_high) / (1 - acc * (z_naught + z_high)))

        cis[k, :] = np.array([q(p1), q(p2)])

    return cis
Compute bca type confidence interval of bootstrap estimates.

    Args:
        data (pd.DataFrame): original dataset.
        outcome (callable): function of the data calculating statistic of interest.
        estimates (data.Frame): DataFrame of estimates in the bootstrap samples.
        alpha (float): significance level of choice.
        n_cores (int): number of jobs for parallelization.

    Returns:
        cis (np.array): array where k'th row contains CI for k'th parameter.

    
Compute bca type confidence interval of bootstrap estimates.
Compute bca type confidence interval of bootstrap estimates .
def _ci_bca(data, outcome, estimates, alpha, n_cores):
    num_params = estimates.shape[1]
    boot_est = estimates.values
    cis = np.zeros((num_params, 2))
    theta = outcome(data)
    jack_est = _jackknife(data, outcome, n_cores)
    jack_mean = np.mean(jack_est, axis=0)
    for k in range(num_params):
        q = _eqf(boot_est[:, k])
        params = boot_est[:, k]
        z_naught = norm.ppf(np.mean(params <= theta[k]))
        z_low = norm.ppf(alpha)
        z_high = norm.ppf(1 - alpha)
        acc = np.sum((jack_mean[k] - jack_est[k]) ** 3) / (
            6 * np.sum((jack_mean[k] - jack_est[k]) ** 2) ** (3 / 2)
        )
        p1 = norm.cdf(z_naught + (z_naught + z_low) / (1 - acc * (z_naught + z_low)))
        p2 = norm.cdf(z_naught + (z_naught + z_high) / (1 - acc * (z_naught + z_high)))
        cis[k, :] = np.array([q(p1), q(p2)])
    return cis
def _ci_bca ( data , outcome , estimates , alpha , n_cores ) : num_params = estimates . shape [ 1 ] boot_est = estimates . values cis = np . zeros ( ( num_params , 2 ) ) theta = outcome ( data ) jack_est = _jackknife ( data , outcome , n_cores ) jack_mean = np . mean ( jack_est , axis = 0 ) for k in range ( num_params ) : q = _eqf ( boot_est [ : , k ] ) params = boot_est [ : , k ] z_naught = norm . ppf ( np . mean ( params <= theta [ k ] ) ) z_low = norm . ppf ( alpha ) z_high = norm . ppf ( 1 - alpha ) acc = np . sum ( ( jack_mean [ k ] - jack_est [ k ] ) ** 3 ) / ( 6 * np . sum ( ( jack_mean [ k ] - jack_est [ k ] ) ** 2 ) ** ( 3 / 2 ) ) p1 = norm . cdf ( z_naught + ( z_naught + z_low ) / ( 1 - acc * ( z_naught + z_low ) ) ) p2 = norm . cdf ( z_naught + ( z_naught + z_high ) / ( 1 - acc * ( z_naught + z_high ) ) ) cis [ k , : ] = np . array ( [ q ( p1 ) , q ( p2 ) ] ) return cis
Compute bca type confidence interval of bootstrap estimates.
Compute bca type confidence interval of bootstrap estimates .
"""Compute bca type confidence interval of bootstrap estimates.

    Args:
        data (pd.DataFrame): original dataset.
        outcome (callable): function of the data calculating statistic of interest.
        estimates (data.Frame): DataFrame of estimates in the bootstrap samples.
        alpha (float): significance level of choice.
        n_cores (int): number of jobs for parallelization.

    Returns:
        cis (np.array): array where k'th row contains CI for k'th parameter.

    """ # bias correction # accelaration
cis (np.array): array where k'th row contains CI for k'th parameter.
cis ( np . array ) : array where k ' th row contains CI for k ' th parameter .
data
None
outcome
function of the data calculating statistic of interest.
function of the data calculating statistic of interest .
estimates
DataFrame of estimates in the bootstrap samples.
DataFrame of estimates in the bootstrap samples .
alpha
significance level of choice.
significance level of choice .
n_cores
number of jobs for parallelization.
number of jobs for parallelization .