Skip to content

TST: Test integer, boolean and nullable input dtypes - #10524

Merged
bashtage merged 3 commits into
statsmodels:mainfrom
shan3520:tst-input-dtypes
Oct 21, 2026
Merged

bashtage merged 3 commits into
statsmodels:mainfrom
shan3520:tst-input-dtypes

Conversation

@shan3520

Copy link
Copy Markdown
Contributor

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.NA with missing = "drop" yields the same estimate as np.nan (skipped for MixedLM, see #7978).

  • closes #xxxx
  • 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: 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.

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".
@bashtage

Copy link
Copy Markdown
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.
@bashtage

Copy link
Copy Markdown
Member

Thanks.

@bashtage
bashtage merged commit 30df665 into statsmodels:main Oct 21, 2026
13 checks passed
@shan3520 shan3520 mentioned this pull request Oct 22, 2026
5 of 6 tasks
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.

2 participants