Repository navigation
Bayesmixedglm predict which - #10554
Merged
Merged
Conversation
Add a which={"mean", "linear"} argument to the model and results predict
methods of the Bayes mixed GLMs, matching GLM.predict. The linear
argument is kept in its positional slot for backward compatibility, but
passing it now issues a FutureWarning, with removal planned for
statsmodels 0.17.0. Passing both linear and a non-default which raises.
Closes statsmodels#8562
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Describe the "mean" and "linear" options with the wording of the original linear docstrings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| return BayesMixedGLMResults(self, params, cov, optim_retvals=r) | ||
|
|
||
| def predict(self, params, exog=None, linear=False): | ||
| def predict(self, params, exog=None, linear=None, which="mean"): |
Contributor
Author
There was a problem hiding this comment.
If I'm not mistaken, this is a false positive, the warning is raised when a similar line is touched, like here
Member
|
Thanks |
4 of 6 tasks
bashtage
added a commit
that referenced
this pull request
Oct 25, 2026
which is now case sensitive like in GLM.predict, a list exog is converted with array_like (it raised AttributeError) and a 1-d exog raises a ValueError. The predict docstrings say that only the fixed effects are used, so that mean is the mean given zero random effects, and which estimate fit_map and fit_vb provide. The tests cover fit_map and fit_vb, Binomial and Poisson, both values of which and all call forms of the deprecated linear argument. Follow up to gh-10554. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I think this is a fairly straightforward and backward-compatible fix, apart from 1 point: what should be a good name for the case
linear=False. I used"mean"here probably a bit liberally as it's the first case (AFAIK) where "mean" doesn't mean the marginal mean E(y | x), butE(y | x, b = 0)and it's still pretty close to how "mean" is used inGLM. I can change it if there's a better name.NumPy's guide.
AI Disclosure
Contributions must comply with the statsmodels AI Policy.
Tick exactly one of the following. If AI tools were used, replace the
<...>placeholders in the second option with the tool name(s) and how the tool's output was
used.
Tool(s): Claude Opus 5.5.
Used for: drafting an implementation, writing tests, debugging, editing docstrings.
I have personally read, understood, and can explain every line of this diff, and
have verified the statistical/numerical correctness of the change.
Details
Notes:
needed for doc changes.
then show that it is fixed with the new code.
verify your changes are well formatted by running
ruffis installed. While passing this test is not required, it is good practice and it helpimprove code quality in
statsmodels.AI Policy for what disclosure
and review is expected of you before submitting.