Skip to content

Commit 808b197

Browse files
committed
remove var_scaling_factors from aggregation
1 parent 0269253 commit 808b197

File tree

6 files changed

+9
-12
lines changed

6 files changed

+9
-12
lines changed

doubleml/double_ml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ def fit(self, n_jobs_cv=None, store_predictions=True, external_predictions=None,
537537
self._fit_sensitivity_elements(nuisance_predictions)
538538

539539
# aggregated parameter estimates and standard errors from repeated cross-fitting
540-
self.coef, self.se = _aggregate_coefs_and_ses(self._all_coef, self._all_se, self._var_scaling_factors)
540+
self.coef, self.se = _aggregate_coefs_and_ses(self._all_coef, self._all_se)
541541

542542
# validate sensitivity elements (e.g., re-estimate nu2 if negative)
543543
self._validate_sensitivity_elements()
@@ -1392,7 +1392,7 @@ def _est_causal_pars_and_se(self):
13921392
self._all_se[self._i_treat, self._i_rep], self._var_scaling_factors[self._i_treat] = self._se_causal_pars()
13931393

13941394
# aggregated parameter estimates and standard errors from repeated cross-fitting
1395-
self.coef, self.se = _aggregate_coefs_and_ses(self._all_coef, self._all_se, self._var_scaling_factors)
1395+
self.coef, self.se = _aggregate_coefs_and_ses(self._all_coef, self._all_se)
13961396

13971397
# Score estimation and elements
13981398
@abstractmethod

doubleml/double_ml_framework.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def __add__(self, other):
310310
# compute standard errors (Uses factor 1/n for scaling!)
311311
sigma2_hat = np.divide(np.mean(np.square(scaled_psi), axis=0), var_scaling_factors.reshape(-1, 1))
312312
all_ses = np.sqrt(sigma2_hat)
313-
thetas, ses = _aggregate_coefs_and_ses(all_thetas, all_ses, var_scaling_factors)
313+
thetas, ses = _aggregate_coefs_and_ses(all_thetas, all_ses)
314314

315315
doubleml_dict = {
316316
"thetas": thetas,
@@ -358,7 +358,7 @@ def __sub__(self, other):
358358
# compute standard errors
359359
sigma2_hat = np.divide(np.mean(np.square(scaled_psi), axis=0), var_scaling_factors.reshape(-1, 1))
360360
all_ses = np.sqrt(sigma2_hat)
361-
thetas, ses = _aggregate_coefs_and_ses(all_thetas, all_ses, var_scaling_factors)
361+
thetas, ses = _aggregate_coefs_and_ses(all_thetas, all_ses)
362362

363363
doubleml_dict = {
364364
"thetas": thetas,
@@ -507,8 +507,8 @@ def _calc_sensitivity_analysis(self, cf_y, cf_d, rho, level):
507507
all_sigma_upper[i_theta, i_rep] = np.sqrt(sigma2_upper_hat)
508508

509509
# aggregate coefs and ses over n_rep
510-
theta_lower, sigma_lower = _aggregate_coefs_and_ses(all_theta_lower, all_sigma_lower, self._var_scaling_factors)
511-
theta_upper, sigma_upper = _aggregate_coefs_and_ses(all_theta_upper, all_sigma_upper, self._var_scaling_factors)
510+
theta_lower, sigma_lower = _aggregate_coefs_and_ses(all_theta_lower, all_sigma_lower)
511+
theta_upper, sigma_upper = _aggregate_coefs_and_ses(all_theta_upper, all_sigma_upper)
512512

513513
# per repetition confidence intervals
514514
quant = norm.ppf(level)

doubleml/tests/_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def generate_dml_dict(psi_a, psi_b):
101101
thetas, ses = _aggregate_coefs_and_ses(
102102
all_coefs=all_thetas,
103103
all_ses=all_ses,
104-
var_scaling_factors=var_scaling_factors,
105104
)
106105
scaled_psi = psi_b / np.mean(psi_a, axis=0)
107106

doubleml/tests/_utils_doubleml_sensitivity_manual.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def doubleml_sensitivity_manual(sensitivity_elements, all_coefs, psi, psi_deriv,
3131
all_sigma_lower = np.transpose(np.sqrt(np.divide(np.mean(np.square(psi_lower), axis=0), var_scaling_factor)))
3232
all_sigma_upper = np.transpose(np.sqrt(np.divide(np.mean(np.square(psi_upper), axis=0), var_scaling_factor)))
3333

34-
theta_lower, sigma_lower = _aggregate_coefs_and_ses(all_theta_lower, all_sigma_lower, var_scaling_factor)
35-
theta_upper, sigma_upper = _aggregate_coefs_and_ses(all_theta_upper, all_sigma_upper, var_scaling_factor)
34+
theta_lower, sigma_lower = _aggregate_coefs_and_ses(all_theta_lower, all_sigma_lower)
35+
theta_upper, sigma_upper = _aggregate_coefs_and_ses(all_theta_upper, all_sigma_upper)
3636

3737
quant = norm.ppf(level)
3838

doubleml/utils/_estimation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def abs_ipw_score(theta):
239239
return ipw_est
240240

241241

242-
def _aggregate_coefs_and_ses(all_coefs, all_ses, var_scaling_factors):
242+
def _aggregate_coefs_and_ses(all_coefs, all_ses):
243243
# already expects equally scaled variances over all repetitions
244244
# aggregation is done over dimension 1, such that the coefs and ses have to be of shape (n_coefs, n_rep)
245245
coefs = np.median(all_coefs, 1)

doubleml/utils/tests/test_var_est_and_aggregation.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@ def test_var_est_and_aggr_fixture(n_rep, n_coefs, level):
5454
theta, se = _aggregate_coefs_and_ses(
5555
all_coefs=all_thetas,
5656
all_ses=all_ses,
57-
var_scaling_factors=all_var_scaling_factors[:, 0],
5857
)
5958

6059
# with n_rep
6160
theta_2, se_2 = _aggregate_coefs_and_ses(
6261
all_coefs=all_thetas,
6362
all_ses=all_ses,
64-
var_scaling_factors=all_var_scaling_factors,
6563
)
6664

6765
result_dict = {

0 commit comments

Comments
 (0)