From eefbed12bdf9a028a5371dbb41d74a1601e30842 Mon Sep 17 00:00:00 2001 From: Oliver Schacht Date: Thu, 26 Jun 2025 17:13:53 +0200 Subject: [PATCH 1/3] explicitly set c and fuzzy to avoid overwrite by kwargs --- doubleml/rdd/rdd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doubleml/rdd/rdd.py b/doubleml/rdd/rdd.py index 858ae5ed..80ea2ebe 100644 --- a/doubleml/rdd/rdd.py +++ b/doubleml/rdd/rdd.py @@ -453,10 +453,10 @@ def _update_weights(self): def _fit_rdd(self, h=None, b=None): if self.fuzzy: rdd_res = rdrobust.rdrobust( - y=self._M_Y[:, self._i_rep], x=self._score, fuzzy=self._M_D[:, self._i_rep], h=h, b=b, **self.kwargs + y=self._M_Y[:, self._i_rep], x=self._score, fuzzy=self._M_D[:, self._i_rep], h=h, b=b, c=0, **self.kwargs ) else: - rdd_res = rdrobust.rdrobust(y=self._M_Y[:, self._i_rep], x=self._score, h=h, b=b, **self.kwargs) + rdd_res = rdrobust.rdrobust(y=self._M_Y[:, self._i_rep], x=self._score, fuzzy=None, h=h, b=b, **self.kwargs) return rdd_res def _set_coefs(self, rdd_res, h): From 1566af439535babdf1dc56fa5f7c66627c51decc Mon Sep 17 00:00:00 2001 From: Oliver Schacht Date: Thu, 26 Jun 2025 17:23:16 +0200 Subject: [PATCH 2/3] allow custom bandwidth for rdd --- doubleml/rdd/rdd.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doubleml/rdd/rdd.py b/doubleml/rdd/rdd.py index 80ea2ebe..ba062fcd 100644 --- a/doubleml/rdd/rdd.py +++ b/doubleml/rdd/rdd.py @@ -453,10 +453,12 @@ def _update_weights(self): def _fit_rdd(self, h=None, b=None): if self.fuzzy: rdd_res = rdrobust.rdrobust( - y=self._M_Y[:, self._i_rep], x=self._score, fuzzy=self._M_D[:, self._i_rep], h=h, b=b, c=0, **self.kwargs + y=self._M_Y[:, self._i_rep], x=self._score, fuzzy=self._M_D[:, self._i_rep], + c=0, **{{"h": h, "b": b} | self.kwargs} ) else: - rdd_res = rdrobust.rdrobust(y=self._M_Y[:, self._i_rep], x=self._score, fuzzy=None, h=h, b=b, **self.kwargs) + rdd_res = rdrobust.rdrobust(y=self._M_Y[:, self._i_rep], x=self._score, fuzzy=None, + c=0, **{{"h": h, "b": b} | self.kwargs}) return rdd_res def _set_coefs(self, rdd_res, h): From efaa63b09549f03ba312d87c59c15b13e06bd5c4 Mon Sep 17 00:00:00 2001 From: Oliver Schacht Date: Thu, 26 Jun 2025 18:05:20 +0200 Subject: [PATCH 3/3] add warning for setting kwargs --- doubleml/rdd/rdd.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doubleml/rdd/rdd.py b/doubleml/rdd/rdd.py index ba062fcd..8db9171f 100644 --- a/doubleml/rdd/rdd.py +++ b/doubleml/rdd/rdd.py @@ -143,7 +143,10 @@ def __init__( self._check_effect_sign() - # TODO: Add further input checks + if ("h", "b") & kwargs.keys(): + warnings.warn(f"Key-worded arguments contain: {('h', 'b') & kwargs.keys()}. \n \ + Iterative bandwidth selection will be overwritten by provided values.") + self.kwargs = kwargs self._smpls = DoubleMLResampling( @@ -454,11 +457,11 @@ def _fit_rdd(self, h=None, b=None): if self.fuzzy: rdd_res = rdrobust.rdrobust( y=self._M_Y[:, self._i_rep], x=self._score, fuzzy=self._M_D[:, self._i_rep], - c=0, **{{"h": h, "b": b} | self.kwargs} + c=0, **({"h": h, "b": b} | self.kwargs) ) else: rdd_res = rdrobust.rdrobust(y=self._M_Y[:, self._i_rep], x=self._score, fuzzy=None, - c=0, **{{"h": h, "b": b} | self.kwargs}) + c=0, **({"h": h, "b": b} | self.kwargs)) return rdd_res def _set_coefs(self, rdd_res, h):