def boot_pliv(theta, Y, D, Z, g_hat, m_hat, r_hat, smpls, score, se, bootstrap, n_rep, dml_procedure):
    n_obs = len(Y)
    weights = draw_weights(bootstrap, n_rep, n_obs)
    if np.isscalar(theta):
        n_d = 1
    else:
        n_d = len(theta)
    assert n_d == 1
    boot_theta, boot_t_stat = boot_pliv_single_treat(theta, Y, D, Z, g_hat, m_hat, r_hat,
                                                     smpls, score, se, weights, n_rep, dml_procedure)
    return boot_theta, boot_t_stat
Ejemplo n.º 2
0
def boot_plr(theta,
             Y,
             D,
             g_hat,
             m_hat,
             smpls,
             score,
             se,
             bootstrap,
             n_rep,
             dml_procedure,
             apply_cross_fitting=True):
    if apply_cross_fitting:
        n_obs = len(Y)
    else:
        test_index = smpls[0][1]
        n_obs = len(test_index)
    weights = draw_weights(bootstrap, n_rep, n_obs)

    if np.isscalar(theta):
        n_d = 1
    else:
        n_d = len(theta)
    if n_d > 1:
        boot_theta = np.full((n_d, n_rep), np.nan)
        boot_t_stat = np.full((n_d, n_rep), np.nan)
        for i_d in range(n_d):
            boot_theta[i_d, :], boot_t_stat[i_d, :] = boot_plr_single_treat(
                theta[i_d], Y, D[:, i_d], g_hat[i_d], m_hat[i_d], smpls, score,
                se[i_d], weights, n_rep, dml_procedure, apply_cross_fitting)
    else:
        boot_theta, boot_t_stat = boot_plr_single_treat(
            theta, Y, D, g_hat, m_hat, smpls, score, se, weights, n_rep,
            dml_procedure, apply_cross_fitting)

    return boot_theta, boot_t_stat