Skip to content

BUG: Accept pandas time and design matrices in ProcessMLE - #11230

Merged
bashtage merged 2 commits into
statsmodels:mainfrom
bashtage:wip-process-mle-pandas-inputs
Nov 27, 2026
Merged

bashtage merged 2 commits into
statsmodels:mainfrom
bashtage:wip-process-mle-pandas-inputs

Conversation

@bashtage

Copy link
Copy Markdown
Member

Found while writing #11227 (independent of it: different function; they merge cleanly in either order).

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.

  • 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.

  • No AI tools were used to develop this pull request.
  • AI tools were 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

`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.
@bashtage
bashtage marked this pull request as ready for review November 27, 2026 20:02
@bashtage
bashtage merged commit 8ee0772 into statsmodels:main Nov 27, 2026
13 of 14 checks passed
@bashtage
bashtage deleted the wip-process-mle-pandas-inputs branch November 27, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant