Skip to content

BUG: Raise for ignored flags in out-of-sample panel predictions - #849

Merged
bashtage merged 1 commit into
bashtage:mainfrom
inchang-ing:fix/panel-predict-oos-flags
Oct 18, 2026
Merged

bashtage merged 1 commit into
bashtage:mainfrom
inchang-ing:fix/panel-predict-oos-flags

Conversation

@inchang-ing

Copy link
Copy Markdown
Contributor

Fixes #768.

PanelResults.predict silently ignored fitted, effects and idiosyncratic whenever exog or data was passed, returning a single predictions column regardless of the flags:

res.predict(exog, effects=True).columns           # ['predictions']
res.predict(exog, idiosyncratic=True).columns     # ['predictions']
res.predict(exog, fitted=False).columns           # ['predictions']

This contradicts the documented contract: effects and idiosyncratic errors are not available for out-of-sample predictions, and at least one output must be selected.

Changes

  • Raise ValueError when effects or idiosyncratic is requested together with exog/data.
  • Raise ValueError("At least one output must be selected") when fitted=False and no other output is selected, matching the existing in-sample behaviour.
  • Update the Raises section of the docstring.
  • Add test_predict_out_of_sample_flags covering the three previously ignored flags.

Verification

  • linearmodels/tests/panel/: 7061 passed, 73 skipped, 47 xfailed.
  • ruff check, ruff format --check and numpydoc lint pass on the changed files.

Happy to add a changelog entry or adjust the error type/message if you prefer a different convention.

@codecov

codecov Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.68%. Comparing base (89c3487) to head (c2063b5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #849   +/-   ##
=======================================
  Coverage   99.68%   99.68%           
=======================================
  Files         199      199           
  Lines       37851    37870   +19     
  Branches     2433     2436    +3     
=======================================
+ Hits        37730    37751   +21     
+ Misses         53       51    -2     
  Partials       68       68           
Flag Coverage Δ
adder 99.67% <100.00%> (+<0.01%) ⬆️
subtractor 99.67% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@inchang-ing

Copy link
Copy Markdown
Contributor Author

Gentle ping on this one — CI is green (15/15) and it is a small, self-contained bug fix. Would appreciate a review when you get a chance. Thanks!

@bashtage

Copy link
Copy Markdown
Owner

Thanks. LGTM.

@bashtage
bashtage merged commit f959921 into bashtage:main Oct 18, 2026
15 checks passed
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.

PanelResults.predict ignores effects, idiosyncratic and fitted out of sample

2 participants