Skip to content

Commit 170391c

Browse files
authored
Fix gaussian glm se (#1078)
* make env work * fix docs * bring back benchmarks * use github resource * only bread for iid inference * delete run.py * refine testing strategy * refine
1 parent 6777e3d commit 170391c

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
@@ -94,15 +94,6 @@ def _get_theta(self, mu: np.ndarray) -> np.ndarray:
9494
def _get_V(self, mu: np.ndarray) -> np.ndarray:
9595
return np.ones_like(mu)
9696

97-
def _vcov_iid(self):
98-
_N = self._N
99-
_u_hat = self._u_hat
100-
_bread = self._bread
101-
sigma2 = np.sum(_u_hat.flatten() ** 2) / (_N)
102-
_vcov = _bread * sigma2
103-
104-
return _vcov
105-
10697
def _get_score(
10798
self, y: np.ndarray, X: np.ndarray, mu: np.ndarray, eta: np.ndarray
10899
) -> 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.skip("Fixed effects are not yet supported.")

0 commit comments

Comments
 (0)