From 29a862ad92b5e5a2dc45e4b529b3fb2e699e1e64 Mon Sep 17 00:00:00 2001 From: "RepoBird.ai Agent" Date: Sun, 4 May 2025 06:46:33 +0000 Subject: [PATCH 1/2] feat(fepois_.py): update demeaning function to use backend setting Add the ability to select the appropriate demeaning function based on the backend setting by introducing `_set_demeaner_backend`. Update the call to use the selected demeaning function instead of a hardcoded version. --- pyfixest/estimation/fepois_.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pyfixest/estimation/fepois_.py b/pyfixest/estimation/fepois_.py index 4a4ebbe7b..b4cbc1210 100644 --- a/pyfixest/estimation/fepois_.py +++ b/pyfixest/estimation/fepois_.py @@ -9,7 +9,8 @@ from pyfixest.errors import ( NonConvergenceError, ) -from pyfixest.estimation.demean_ import demean +# Updated import: Added _set_demeaner_backend +from pyfixest.estimation.demean_ import demean, _set_demeaner_backend from pyfixest.estimation.feols_ import Feols, PredictionErrorOptions, PredictionType from pyfixest.estimation.FormulaParser import FixestFormula from pyfixest.estimation.solvers import solve_ols @@ -228,6 +229,9 @@ def get_fit(self) -> None: _fixef_tol = self._fixef_tol _solver = self._solver + # Select the appropriate demeaning function based on the backend setting + demean_function = _set_demeaner_backend(self.demeaner_backend) + def compute_deviance(_Y: np.ndarray, mu: np.ndarray): with warnings.catch_warnings(): warnings.simplefilter("ignore") @@ -272,8 +276,8 @@ def compute_deviance(_Y: np.ndarray, mu: np.ndarray): ZX = np.concatenate([reg_Z, _X], axis=1) if _fe is not None: - # ZX_resid = algorithm.residualize(ZX, mu) - ZX_resid, success = demean( + # Updated call: Use demean_function instead of hardcoded demean + ZX_resid, success = demean_function( x=ZX, flist=_fe, weights=mu.flatten(), tol=_fixef_tol ) if success is False: @@ -474,7 +478,7 @@ def _check_for_separation( iterative rectifier ("ir"). Executes all methods by default. Returns - ------- + ------ list List of indices of observations that are removed due to separation. """ @@ -531,7 +535,7 @@ def __call__( Fixed effects. Returns - ------- + ------ set Set of indices of separated observations. """ @@ -558,7 +562,7 @@ def _check_for_separation_fe( Fixed effects. Returns - ------- + ------ set Set of indices of separated observations. """ @@ -618,7 +622,7 @@ def _check_for_separation_ir( Maximum number of iterations. Defaults to 100. Returns - ------- + ------ set Set of indices of separated observations. """ From 0eeba8e2bbd228b6bc6a878acd784d90ca393f12 Mon Sep 17 00:00:00 2001 From: "RepoBird.ai Agent" Date: Sun, 4 May 2025 07:17:16 +0000 Subject: [PATCH 2/2] fix(fepois_.py): correct reference to demeaning backend attribute --- pyfixest/estimation/fepois_.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfixest/estimation/fepois_.py b/pyfixest/estimation/fepois_.py index b4cbc1210..ad0110090 100644 --- a/pyfixest/estimation/fepois_.py +++ b/pyfixest/estimation/fepois_.py @@ -230,7 +230,7 @@ def get_fit(self) -> None: _solver = self._solver # Select the appropriate demeaning function based on the backend setting - demean_function = _set_demeaner_backend(self.demeaner_backend) + demean_function = _set_demeaner_backend(self._demeaner_backend) def compute_deviance(_Y: np.ndarray, mu: np.ndarray): with warnings.catch_warnings():