Skip to content

Commit 141d8aa

Browse files
committed
merge master into PR, including gaussian GLM fix
2 parents 9eda70f + 170391c commit 141d8aa

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

pyfixest/estimation/fegaussian_.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,6 @@ def _get_theta(self, mu: np.ndarray) -> np.ndarray:
9797
def _get_V(self, mu: np.ndarray) -> np.ndarray:
9898
return np.ones_like(mu)
9999

100-
def _vcov_iid(self):
101-
_u_hat = self._u_hat
102-
_bread = self._bread
103-
# Use df_t (degrees of freedom) for denominator, matching feols behavior
104-
sigma2 = np.sum(_u_hat.flatten() ** 2) / self._df_t
105-
_vcov = _bread * sigma2
106-
107-
return _vcov
108-
109100
def _get_score(
110101
self, y: np.ndarray, X: np.ndarray, mu: np.ndarray, eta: np.ndarray
111102
) -> np.ndarray:

tests/test_feols_feglm_internally.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,15 @@ def test_ols_vs_gaussian_glm(fml, inference, dropna):
4949
check_absolute_diff(fit_ols._u_hat[0:5], fit_gaussian._u_hat[0:5], tol=1e-10)
5050
check_absolute_diff(fit_ols._scores[0, :], fit_gaussian._scores[0, :], tol=1e-10)
5151

52-
if inference != "iid":
52+
if inference == "iid":
5353
# iid inference different: follows iid-glm; just the bread and not bread x sigma2
54+
scaling_factor = fit_ols._vcov[0, 0] / fit_gaussian._vcov[0, 0]
55+
# Check that all elements follow the same scaling
5456
check_absolute_diff(
55-
fit_ols.se().xs("X1"), fit_gaussian.se().xs("X1"), tol=1e-10
57+
fit_ols._vcov, scaling_factor * fit_gaussian._vcov, tol=1e-10
5658
)
57-
check_absolute_diff(fit_ols._vcov[0, 0], fit_gaussian._vcov[0, 0], tol=1e-10)
59+
else:
60+
check_absolute_diff(fit_ols._vcov, fit_gaussian._vcov, tol=1e-10)
5861

5962

6063
@pytest.mark.parametrize("fml", fml_list)

0 commit comments

Comments
 (0)