Repository navigation
TST: Test integer, boolean and nullable input dtypes - #10524
Merged
Merged
Conversation
Check that common models give the same results when the data are passed as integers, booleans or pandas nullable Int64, Float64 and boolean arrays as when the same values are passed as floats, and that pd.NA is dropped like nan with missing="drop".
Member
|
Fail is excessively tight test. |
Use an absolute tolerance as well, since parameters close to zero only agree up to the rounding of the linear algebra.
pandas before 2.2 converts nullable arrays to object arrays, which are not supported.
Member
|
Thanks. |
5 of 6 tasks
1 of 2 tasks
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.
As a follow-up to the comments by @bashtage on #10477, this testing-only PR adds the file statsmodels/base/tests/test_input_dtypes.py which verifies that integer, boolean, and pandas nullable input types provide the same parameter estimates as usual floats for popular models such as OLS, WLS, QuantReg, RLM, GLM, Logit, Poisson, NegativeBinomial, MixedLM, GEE, AutoReg, and ARIMA. Depending on the model, the tests check that using inputs of types int64, int32, boolean, and pandas' Int64, Float64, or boolean yields the same estimates as regular floats and using
pd.NAwith missing = "drop" yields the same estimate asnp.nan(skipped for MixedLM, see #7978).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:
drafting the tests.I have personally read, understood, and can explain every line of this diff, and
have verified the statistical/numerical correctness of the change.