Skip to content

Commit da5e761

Browse files
committed
add tests
1 parent 7f9cc5d commit da5e761

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

tests/test_vs_fixest.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,9 @@ def test_single_fit_feols_empty(
406406
@pytest.mark.parametrize("fml", ols_fmls)
407407
@pytest.mark.parametrize("adj", [True])
408408
@pytest.mark.parametrize("cluster_adj", [True])
409+
@pytest.mark.parametrize("offset", [False, True])
409410
def test_single_fit_fepois(
410-
data_fepois, dropna, inference, f3_type, fml, adj, cluster_adj
411+
data_fepois, dropna, inference, f3_type, fml, adj, cluster_adj, offset
411412
):
412413
global test_counter_fepois
413414
test_counter_fepois += 1
@@ -418,6 +419,11 @@ def test_single_fit_fepois(
418419
ssc_ = ssc(adj=adj, cluster_adj=cluster_adj)
419420

420421
data = data_fepois
422+
if offset:
423+
data["offset_var"] = np.ones(data.shape[0]) * 5
424+
offset_var = "offset_var"
425+
else:
426+
offset_var = None
421427

422428
if dropna:
423429
data = data.dropna()
@@ -433,14 +439,28 @@ def test_single_fit_fepois(
433439
r_fml = _c_to_as_factor(fml)
434440
r_inference = _get_r_inference(inference)
435441

436-
mod = pf.fepois(fml=fml, data=data, vcov=inference, ssc=ssc_, iwls_tol=1e-10)
437-
r_fixest = fixest.fepois(
438-
ro.Formula(r_fml),
439-
vcov=r_inference,
440-
data=data_r,
441-
ssc=fixest.ssc(adj, "none", cluster_adj, "min", "min", False),
442-
glm_tol=1e-10,
443-
)
442+
py_arg_dict = {
443+
"fml": fml,
444+
"data": data,
445+
"vcov": inference,
446+
"ssc": ssc_,
447+
"iwls_tol": iwls_tol,
448+
}
449+
450+
r_arg_dict = {
451+
"fml": ro.Formula(r_fml),
452+
"vcov": r_inference,
453+
"data": data_r,
454+
"ssc": fixest.ssc(adj, "none", cluster_adj, "min", "min", False),
455+
"glm_tol": iwls_tol,
456+
}
457+
458+
if offset:
459+
py_arg_dict["offset"] = offset_var
460+
r_arg_dict["offset"] = ro.Formula("~" + offset_var)
461+
462+
mod = pf.fepois(**py_arg_dict)
463+
r_fixest = fixest.fepois(**r_arg_dict)
444464

445465
py_coef = mod.coef().xs("X1")
446466
py_se = mod.se().xs("X1")

0 commit comments

Comments
 (0)