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
BUG: GEE fit_history #5789
BUG: GEE fit_history #5789
Changes from all commits
d5d3acb
7a4418f
77c89d4
600e6de
fca7ad2
e7ab942
e816bde
47e6a21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -635,14 +635,19 @@ def test_compare_score_test(self, cov_struct): | |
|
||
mod_sub = gee.GEE(endog, exog_sub, group, cov_struct=cov_struct()) | ||
res_sub = mod_sub.fit() | ||
mod = gee.GEE(endog, exog, group, cov_struct=cov_struct()) | ||
score_results = mod.compare_score_test(res_sub) | ||
assert_almost_equal(score_results["statistic"], | ||
mod_lr.score_test_results["statistic"]) | ||
assert_almost_equal(score_results["p-value"], | ||
mod_lr.score_test_results["p-value"]) | ||
assert_almost_equal(score_results["df"], | ||
mod_lr.score_test_results["df"]) | ||
|
||
for call_fit in [False, True]: | ||
mod = gee.GEE(endog, exog, group, cov_struct=cov_struct()) | ||
if call_fit: | ||
# Should work with or without fitting the parent model | ||
mod.fit() | ||
score_results = mod.compare_score_test(res_sub) | ||
assert_almost_equal(score_results["statistic"], | ||
mod_lr.score_test_results["statistic"]) | ||
assert_almost_equal(score_results["p-value"], | ||
mod_lr.score_test_results["p-value"]) | ||
assert_almost_equal(score_results["df"], | ||
mod_lr.score_test_results["df"]) | ||
|
||
def test_compare_score_test_warnings(self): | ||
|
||
|
@@ -682,6 +687,14 @@ def test_compare_score_test_warnings(self): | |
mod = gee.GEE(endog, exog, group) | ||
_ = mod.compare_score_test(res_sub) | ||
|
||
# Parent and submodel are the same dimension | ||
with pytest.warns(UserWarning): | ||
w = np.random.uniform(size=n) | ||
mod_sub = gee.GEE(endog, exog, group) | ||
res_sub = mod_sub.fit() | ||
mod = gee.GEE(endog, exog, group) | ||
_ = mod.compare_score_test(res_sub) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could part of this block be outside of the pytest.warns context? |
||
|
||
def test_constraint_covtype(self): | ||
# Test constraints with different cov types | ||
np.random.seed(6432) | ||
|
@@ -1883,8 +1896,10 @@ def test_ql_known(family): | |
assert_allclose(ql1, qle1[0], rtol=1e-4) | ||
assert_allclose(ql2, qle2[0], rtol=1e-4) | ||
|
||
qler1 = result1.qic() | ||
qler2 = result2.qic() | ||
with warnings.catch_warnings(): | ||
warnings.simplefilter("ignore") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this warn consistently and/or intentionally? i.e. could be pytest.warns? |
||
qler1 = result1.qic() | ||
qler2 = result2.qic() | ||
assert_equal(qler1, qle1[1:]) | ||
assert_equal(qler2, qle2[1:]) | ||
|
||
|
@@ -1922,3 +1937,11 @@ def test_ql_diff(family): | |
qle2, _, _ = model2.qic(result2.params, result2.scale, result2.cov_params()) | ||
|
||
assert_allclose(qle1 - qle2, qldiff, rtol=1e-5, atol=1e-5) | ||
|
||
def test_qic_warnings(): | ||
with pytest.warns(UserWarning): | ||
fam = families.Gaussian() | ||
y, x1, _, g = simple_qic_data(fam) | ||
model = gee.GEE(y, x1, family=fam, groups=g) | ||
result = model.fit() | ||
result.qic() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1989,7 +1989,7 @@ def test_tweedie_EQL_upper_limit(): | |
# Un-regularized fit using gradients not IRLS | ||
fam = sm.families.Tweedie(var_power=2, eql=True) | ||
model1 = sm.GLM(y, x, family=fam) | ||
result1 = model1.fit(method="newton") | ||
result1 = model1.fit(method="newton", scale=scale) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this related to the rest of the Pr? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. before this fades into distant memory, any thoughts here? |
||
assert_allclose(result1.params, np.r_[4, 1, 1], atol=1e-3, rtol=1e-1) | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
future reference, the lint-compatible version of this is one of: