@@ -90,15 +90,12 @@ def fit_qte(y, x, d, quantiles, learner_g, learner_m, all_smpls, n_rep=1,
90
90
91
91
def boot_qte (scaled_scores , ses , quantiles , all_smpls , n_rep , bootstrap , n_rep_boot ):
92
92
n_quantiles = len (quantiles )
93
- boot_t_stat = np .zeros ((n_quantiles , n_rep_boot * n_rep ))
93
+ boot_t_stat = np .zeros ((n_rep_boot , n_quantiles , n_rep ))
94
94
for i_rep in range (n_rep ):
95
95
n_obs = scaled_scores .shape [0 ]
96
96
weights = draw_weights (bootstrap , n_rep_boot , n_obs )
97
97
for i_quant in range (n_quantiles ):
98
- i_start = i_rep * n_rep_boot
99
- i_end = (i_rep + 1 ) * n_rep_boot
100
-
101
- boot_t_stat [i_quant , i_start :i_end ] = np .matmul (weights , scaled_scores [:, i_quant , i_rep ]) / \
98
+ boot_t_stat [:, i_quant , i_rep ] = np .matmul (weights , scaled_scores [:, i_quant , i_rep ]) / \
102
99
(n_obs * ses [i_quant , i_rep ])
103
100
104
101
return boot_t_stat
@@ -108,7 +105,8 @@ def confint_qte(coef, se, quantiles, boot_t_stat=None, joint=True, level=0.95):
108
105
a = (1 - level )
109
106
ab = np .array ([a / 2 , 1. - a / 2 ])
110
107
if joint :
111
- sim = np .amax (np .abs (boot_t_stat ), 0 )
108
+ assert boot_t_stat .shape [2 ] == 1
109
+ sim = np .amax (np .abs (boot_t_stat [:, :, 0 ]), 1 )
112
110
hatc = np .quantile (sim , 1 - a )
113
111
ci = np .vstack ((coef - se * hatc , coef + se * hatc )).T
114
112
else :
0 commit comments