Repository navigation
BUG: Make the ProcessMLE.from_formula parameters explicit and use cov - #11227
Merged
bashtage merged 2 commits intoNov 26, 2026
Merged
Conversation
`ProcessMLE.from_formula(formula, data, subset=None, drop_cols=None, *args, **kwargs)` documented `scale_formula`, `smooth_formula`, `noise_formula`, `time`, `groups` and `eval_env` as parameters but took them from `**kwargs`, and passed only the matrices it built to the model. Every other keyword was silently dropped. In particular `cov`, the covariance model of `ProcessMLE`, was ignored: the model always used the default `GaussianCovariance`, so a model created with the formula API had a different likelihood, and different estimates, than the same model created from arrays. Changes - Every documented parameter is part of the signature, after `drop_cols` as keyword-only parameters: `scale_formula`, `smooth_formula`, `time` and `groups` (required), `noise_formula`, `cov` and `eval_env`. - `cov` is documented and passed to the model, and so are other keywords of the model (for example `hasconst`), as in other models' `from_formula`. - A missing required argument raises Python's TypeError, which names it, instead of a ValueError, and further positional arguments, which were ignored, raise a TypeError. Not changed - Calls that pass these arguments by keyword, as the docstring required, give the same model unless they pass `cov` or another model keyword. Tests - The parameters in the docstring are the parameters of the signature, in the same order. - With a covariance that is twice the Gaussian one, the model holds that covariance, and its log-likelihood equals that of the model constructed from arrays with the same covariance (and differs from the default). - `hasconst=False` reaches the model (`k_constant` is 0 instead of 1). - A missing `scale_formula`, and a positional argument after `drop_cols`, raise a TypeError. All fail on main.
bashtage
force-pushed
the
wip-formula-process-mle-kwargs
branch
from
November 26, 2026 14:19
1e96115 to
a84d919
Compare
Comment on lines
+393
to
+403
| ProcessMLE.from_formula( | ||
| "y ~ x", | ||
| data, | ||
| None, | ||
| None, | ||
| "0 + x", | ||
| scale_formula="0 + x", | ||
| smooth_formula="0 + x", | ||
| time="time", | ||
| groups="g", | ||
| ) |
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.
Follow-up to #11225, found while writing it: that PR passes
eval_envon fromProcessMLE.from_formula; this one makes every documented parameter part of the signature and passescovand the model's other keywords.ProcessMLE.from_formula(formula, data, subset=None, drop_cols=None, *args, **kwargs)documentedscale_formula,smooth_formula,noise_formula,time,groupsandeval_envas parameters but tookthem from
**kwargs, and passed only the matrices it built to the model.Every other keyword was silently dropped. In particular
cov, thecovariance model of
ProcessMLE, was ignored: the model always used thedefault
GaussianCovariance, so a model created with the formula API had adifferent likelihood, and different estimates, than the same model created
from arrays.
Changes
drop_colsas keyword-only parameters:
scale_formula,smooth_formula,timeandgroups(required),noise_formula,covandeval_env.covis documented and passed to the model, and so are other keywordsof the model (for example
hasconst), as in other models'from_formula.instead of a ValueError, and further positional arguments, which were
ignored, raise a TypeError.
Not changed
give the same model unless they pass
covor another model keyword.Tests
The parameters in the docstring are the parameters of the signature, in
the same order.
With a covariance that is twice the Gaussian one, the model holds that
covariance, and its log-likelihood equals that of the model constructed
from arrays with the same covariance (and differs from the default).
hasconst=Falsereaches the model (k_constantis 0 instead of 1).A missing
scale_formula, and a positional argument afterdrop_cols,raise a TypeError. All fail on main.
tests added / passed.
code/documentation is well formatted.
properly formatted commit message. See
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 Code (Claude Opus 5.5).
Used for: finding the bug in a coverage and contract audit of statsmodels.formula, writing the fix and its tests, and checking them (tests failing on main, a mutation check of the changed lines, and the tests in the oldest, middle, latest and formulaic-only environments).
I have personally read, understood, and can explain every line of this diff, and
have verified the statistical/numerical correctness of the change.
🤖 Generated with Claude Code