Repository navigation
BUG: Accept pandas time and design matrices in ProcessMLE - #11230
Merged
bashtage merged 2 commits intoNov 27, 2026
Merged
Conversation
`ProcessMLE` documents `time`, `exog_scale`, `exog_smooth` and `exog_noise` as array_like, but `loglike`, `score` and so `fit` index them by position, which only works for NumPy arrays: the model kept pandas objects as given. A Series `time` raised `NotImplementedError` (from pandas, in the covariance) with a default index and `KeyError` with any other index, and a DataFrame `exog_scale`, `exog_smooth` or `exog_noise` made `score` raise `InvalidIndexError`. `from_formula` converts them to arrays, so only models constructed directly were affected. Changes - The model converts these four to NumPy arrays after the base class stores them. The parameter names still come from the DataFrame columns. Not changed - Models built from arrays, or with `from_formula`, are the same as before. Tests - With and without noise: a model built from a Series `endog`, `time` and `groups` and DataFrame designs, all with the index 100, ..., 149, has the log-likelihood and score of the model built from the same arrays, and takes its parameter names from the columns. Fails on main.
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.
Found while writing #11227 (independent of it: different function; they merge cleanly in either order).
ProcessMLEdocumentstime,exog_scale,exog_smoothandexog_noiseas array_like, butloglike,scoreand sofitindex themby position, which only works for NumPy arrays: the model kept pandas
objects as given. A Series
timeraisedNotImplementedError(frompandas, in the covariance) with a default index and
KeyErrorwith anyother index, and a DataFrame
exog_scale,exog_smoothorexog_noisemade
scoreraiseInvalidIndexError.from_formulaconverts them toarrays, so only models constructed directly were affected.
Changes
stores them. The parameter names still come from the DataFrame columns.
Not changed
from_formula, are the same asbefore.
Tests
With and without noise: a model built from a Series
endog,timeandgroupsand DataFrame designs, all with the index 100, ..., 149, has thelog-likelihood and score of the model built from the same arrays, and
takes its parameter names from the columns. Fails 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