Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRV3 inference for poisson #157 #185

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified pyfixest/__pycache__/feols.cpython-310.pyc
Binary file not shown.
Binary file modified pyfixest/__pycache__/fepois.cpython-310.pyc
Binary file not shown.
17 changes: 3 additions & 14 deletions pyfixest/feols.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,6 @@ def vcov(self, vcov: Union[str, Dict[str, str]]):
) = _deparse_vcov_input(vcov, _has_fixef, _is_iv)


if _is_iv:
if self._vcov_type in ["CRV3"]:
raise VcovTypeNotSupportedError(
"CRV3 inference is not supported for IV regressions."
)

if _is_iv:
bread = np.linalg.inv(_tXZ @ _tZZinv @ _tZX)
else:
Expand Down Expand Up @@ -372,19 +366,14 @@ def vcov(self, vcov: Union[str, Dict[str, str]]):
# if not, either error or turn fixefs into dummies
# for now: don't allow for use with fixed effects

if _is_iv:
raise VcovTypeNotSupportedError(
"CRV3 inference is not supported with IV estimation."
)

if not _support_crv3_inference:
raise NotImplementedError(
f"'CRV3' inference is not supported for {_method} regressions."
raise VcovTypeNotSupportedError(
"CRV3 inference is not supported with IV regression."
)

beta_jack = np.zeros((len(clustid), _k))

if (self._has_fixef == False) and (self._method == "feols"):
if (self._has_fixef == False) and (self._method == "feols") and (_is_iv == False):
# inverse hessian precomputed?
tXX = np.transpose(self._X) @ self._X
tXy = np.transpose(self._X) @ self._Y
Expand Down
2 changes: 1 addition & 1 deletion pyfixest/fepois.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(
self._N_separation_na = None
self._check_for_separation()

self._support_crv3_inference = False
self._support_crv3_inference = True
self._support_iid_inference = True

# attributes that are updated outside of the class (not optimal)
Expand Down
Binary file modified tests/__pycache__/test_demean.cpython-310-pytest-7.3.1.pyc
Binary file not shown.
19 changes: 19 additions & 0 deletions tests/test_ses.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,22 @@ def test_CRV3_fixef(N, seed, beta_type, error_type):
raise ValueError("HC3 and CRV3 ses are not the same.")
if not np.allclose(res_crv3a["t value"], res_crv3b["t value"]):
raise ValueError("HC3 and CRV3 t values are not the same.")



def run_crv3_poisson():

data = get_data(N=1000, seed=1234, beta_type="1", error_type="1", model="Fepois")
fit = fepois(
fml="Y~X1 + C(f2)",
data=data,
vcov={"CRV3": "f1"},
ssc=ssc(adj=False, cluster_adj=False),
)

fit = fepois(
fml="Y~X1 |f1 + f2",
data=data,
vcov={"CRV3": "f1"},
ssc=ssc(adj=False, cluster_adj=False),
)
2 changes: 1 addition & 1 deletion tests/test_vs_fixest.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def test_single_fit(N, seed, beta_type, error_type, dropna, model, inference, fm

# relax tolerance for Poisson regression - effective rtol and atol of
# 5e-05
inference_inflation_factor = 50
inference_inflation_factor = 100

try:
pyfixest = fepois(fml=fml, data=data, vcov=inference)
Expand Down