Skip to content

BUG: Drop missing values in all ProcessMLE arrays - #11255

Open
JakkulaVeerababu wants to merge 2 commits into
statsmodels:mainfrom
JakkulaVeerababu:fix-processmle-missing
Open

JakkulaVeerababu wants to merge 2 commits into
statsmodels:mainfrom
JakkulaVeerababu:fix-processmle-missing

Conversation

@JakkulaVeerababu

@JakkulaVeerababu JakkulaVeerababu commented Nov 27, 2026 •

Copy link
Copy Markdown

ProcessMLE now drops the rows with a missing value from endog, exog, exog_scale, exog_smooth, exog_noise, time and groups together, in from_formula and with missing="drop". All five paths in the issue's table now work.

  • Missing values in the arrays. ProcessMLE.__init__ drops the rows itself and passes missing="none" to the base class. ModelData.handle_missing assumes 2-D extra arrays are square, so it cannot reduce exog_scale with more than one column. missing="raise" raises MissingDataError. missing="none" is unchanged, and an invalid missing value still raises a ValueError, as in the base class.
  • Checks and groups. _check_args and the group index now use the attributes after the rows are dropped.
  • Formulas. from_formula evaluates the scale, smoothness and noise formulas with the same missing-value action as the mean formula. Rows those formulas drop are put back as NaN, so every array loses the same rows.

Tests: each path is compared with a model built from data with those rows dropped first. The arrays, groups and log-likelihood match. Both formula engines give the same result. For the arrays, a missing value is tested in each of the seven arguments, with NumPy and with pandas inputs. test_processreg.py passes (57 tests), and so do regression/tests, formula/tests and base/tests/test_data.py (2539 passed). 37 of the 40 new tests fail on main; the other 3 check that endog and exog of different lengths are still reported by the base class. ruff check passes.

The branch is rebased on main after #11230. The release-note fragment is in the second commit.

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: drafting the implementation, writing the tests and debugging.
    I have personally read, understood, and can explain every line of this diff, and
    have verified the statistical/numerical correctness of the change.

ProcessMLE failed whenever a value was missing, both in from_formula
(which drops missing rows by default) and with missing="drop". The base
class treats 2-d extra arrays as square and drops their columns too,
__init__ checked and grouped the arguments before the rows were dropped,
and the scale, smoothness and noise formulas each dropped their own rows.

ProcessMLE now finds the rows with a missing value in endog, exog,
exog_scale, exog_smooth, exog_noise, time or groups, and drops them from
all of them. from_formula keeps the rows that the extra formulas drop as
NaN, so that they are dropped together with the mean formula's rows.
An invalid missing value still raises a ValueError, and with
missing="none" the arrays are passed on unchanged.

Closes statsmodels#11231

AI disclosure: written with Claude Code (Claude Opus 5.5), reviewed and
tested by me.
AI disclosure: written with Claude Code (Claude Opus 5.5), reviewed by me.
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.

BUG: ProcessMLE fails when the data have missing values

1 participant