Skip to content

[ENH] Add Wild Cluster Bootstrapping to OLS - #8578

Open
amichuda wants to merge 8 commits into
statsmodels:mainfrom
amichuda:main
Open

amichuda wants to merge 8 commits into
statsmodels:mainfrom
amichuda:main

Conversation

@amichuda

Copy link
Copy Markdown

This PR adds wild cluster bootstrapping as a cov_type into OLS based on the package wildboottest.

This PR includes all functionality built into OLS with cov_type and cov_params.

I added a test in statsmodels/regression/tests/test_robustcov.py and updated the docstring in linear_model.py.

A few caveats:

  1. Estimating standard errors and confidence intervals is not trivial in certain instances, so summary only includes t-stats and p-values for now.
  2. The tests inherit from CheckOLSRobustCluster and CheckOLSRobustNewMixin and so tests fail for those reasons as well.
  3. Not sure where to include this in the docs, as from what I can see, the robust covariance docs are usually generated from docstrings?

@josef-pkt

Copy link
Copy Markdown
Member

sorry, I missed this
I will try to catch up with this after release preparation

from statsmodels.tools.typing import Float64Array
from statsmodels.tools.validation import bool_like, float_like, string_like

from wildboottest.wildboottest import wildboottest

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is wildboottest?
is this a package or module?
can we include it in statsmodels.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wildboottest is a package that implements the wild cluster bootstrap.

https://github.com/s3alfisc/wildboottest

I'll let @s3alfisc comment as well, but I think we'd like to keep the package separate, as there are more features to add, and we want to ultimately make a PR for linearmodels as well.

@amichuda

amichuda commented Jan 5, 2023

Copy link
Copy Markdown
Author

sorry, I missed this
I will try to catch up with this after release preparation

No worries, I hope you had a good new year!

@josef-pkt

Copy link
Copy Markdown
Member

I guess test runs failed with unavailable import. azure test run is not available (anymore)

@josef-pkt

Copy link
Copy Markdown
Member

question in terms of design

If wildboottest function is mainly for hypothesis test on parameters, then we might want to split cov from bootstrap from a hypothesis test method.
Does wildboottest function work for linear/affine hypothesis of parameters?

@josef-pkt

Copy link
Copy Markdown
Member

linearmodels has statsmodels as dependency, so including it here would make it available also for linearmodels.
It might require some compatibility code if model design differs.

@s3alfisc

s3alfisc commented Jan 6, 2023

Copy link
Copy Markdown
Contributor

Hi @josef-pkt , a few quick comments (I am traveling and will reply more exhaustively once back):

  • @amichuda and I have started an 'internal' discussion on whether to 'fully' integrate wildboottest into statsmodels, which is a charming idea. Beyond linearmodels integration, the key arguments against are that the package is not yet 'feature compete' (e.g. the non-clustered wild bootstrap is still in development) and that we'd like to provide an API to WildBootTests.jl, which is 'best in class' in terms of speed and feature completeness (e.g. it offers highly optimized wild cluster bootstrap inference for IVs). But all of this could definitely be solved 😄
  • I agree that having a hypothesis testing method instead of a cov method is likely a better place for wildboottest.
  • In principle, it would also be possible to compute a full 'bootstrapped' variance-covariance matrix, as e.g. R's sandwich::vcovBS does, though this is not in line with other wild cluster bootstrap implementations (e.g. boottest, WildBootTests.jl, fwildclusterboot).
  • In general, all sorts of linear&affine hypotheses can be supported but currently are not (tests of multiple parameters, Wald Tests). This is on the schedule for the next release.

Best, Alex

@s3alfisc

s3alfisc commented Jan 8, 2023

Copy link
Copy Markdown
Contributor

Hi @josef-pkt, @amichuda and I had a brief catch up about integrating wildboottest as a module into statsmodels, and if you'd be interested, we would love to do so!

In this case, I would suggest to add the WildboottestCL and WildboottestHC methods to statsmodels and to add a hypothesis test method for OLS/WLS instead of linking to the module via covariance methods (as covariances are only computed on the fly).

wildboottest currently allows to compute percentile-t p-values via wild bootstraps (both clustered and non-clustered), mostly following algorithms in MacKinnon, Nielsen and Webb (2022). Allowing to compute confidence intervals by test inversion and affine hypotheses & Wald tests are the next thing on the to do list. In the long-term, I would further like to add support for bootstrap based multiple testing corrections, as the ones by Romano and Wolf and Westfall and Young.

I'd suggest the following steps for this PR:

  1. we refactor the PR to include wildboottest's core methods as a module to statsmodels. Additionally, we create a hypothesis test method for OLS / WLS
  2. we add functionality for confidence intervals & affine hypotheses
  3. we add functionality for Wald tests
  4. we add functionality for bootstrap based multiple testing corrections

Based on your preferences, we could split steps into multiple separate PRs, @josef-pkt .

@josef-pkt josef-pkt mentioned this pull request Jun 17, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants