Ordinal association: an unbounded profile interval counts as separation
This commit is contained in:
@@ -447,6 +447,8 @@ def ordinal(t: pd.DataFrame, outcome: str, predictor: str, adjust, high: float)
|
||||
return {**out, "reason": "does not converge (separation)"}
|
||||
profile = lambda v: -_fit_ordinal(X, yk, K, fixed=(0, v))[1] # noqa: E731
|
||||
lo, hi = _interval(profile, beta[0], -nll, 0.1)
|
||||
if not (np.isfinite(lo) and np.isfinite(hi)):
|
||||
return {**out, "reason": "does not converge (separation)"}
|
||||
p = float(stats.chi2.sf(max(2 * (-nll - profile(0.0)), 0.0), 1))
|
||||
state = _ordinal_scoring(par, levels, high)
|
||||
return _summary("ordinal", len(d), beta[0], lo, hi, p, design, state, levels=K)
|
||||
|
||||
@@ -26,6 +26,12 @@ def test_ordinal_on_monotone_trend():
|
||||
assert a.ordinal(frame, "level", "z", (), high=2)["odds_ratio"] > 1
|
||||
|
||||
|
||||
def test_ordinal_separated_binary_predictor():
|
||||
frame = pd.DataFrame({"z": [0] * 8 + [1] * 8, "level": [0, 1] * 4 + [3, 4] * 4})
|
||||
fit = a.ordinal(frame, "level", "z", (), high=3)
|
||||
assert fit["reason"] == "does not converge (separation)"
|
||||
|
||||
|
||||
def test_pairs_by_level():
|
||||
item = a.pairs("item")
|
||||
spikes = [p for p in item if p["biomarker"] == "spikes"]
|
||||
|
||||
Reference in New Issue
Block a user