Skip to main content

Wild Cluster Bootstrap Inference for Linear Models in Python

Project description

wildboottest

PyPI PyPI - Downloads

wildboottest implements multiple fast wild cluster bootstrap algorithms as developed in Roodman et al (2019) and MacKinnon, Nielsen & Webb (2022).

It has similar, but more limited functionality than Stata's boottest, R's fwildcusterboot or Julia's WildBootTests.jl. It supports

At the moment, wildboottest only computes wild cluster bootstrapped p-values, and no confidence intervals.

Other features that are currently not supported:

  • The (non-clustered) wild bootstrap for OLS (Wu, 1986).
  • The subcluster bootstrap (MacKinnon and Webb 2018).
  • Confidence intervals formed by inverting the test and iteratively searching for bounds.
  • Multiway clustering.

Direct support for statsmodels and linearmodels is work in progress.

If you'd like to cooperate, either send us an email or comment in the issues section!

Installation

You can install wildboottest from PyPi by running

pip install wildboottest

Example

from wildboottest.wildboottest import wildboottest
import statsmodels.api as sm
import numpy as np
import pandas as pd

# create data
np.random.seed(12312312)
N = 1000
k = 10
G = 25
X = np.random.normal(0, 1, N * k).reshape((N,k))
X = pd.DataFrame(X)
X.rename(columns = {0:"X1"}, inplace = True)
beta = np.random.normal(0,1,k)
beta[0] = 0.005
u = np.random.normal(0,1,N)
Y = 1 + X @ beta + u
cluster = np.random.choice(list(range(0,G)), N)

# estimation
model = sm.OLS(Y, X)

wildboottest(model, param = "X1", cluster = cluster, B = 9999, bootstrap_type = "11")
#   param              statistic   p-value
# 0    X1  [-1.0530803154504016]  0.308831

wildboottest(model, param = "X1", cluster = cluster, B = 9999, bootstrap_type = "31")
#   param              statistic   p-value
# 0    X1  [-1.0530803154504016]  0.307631

wildboottest(model, param = "X1", cluster = cluster, B = 9999, bootstrap_type = "33")
#   param              statistic   p-value
# 0    X1  [-1.0394791020434824]  0.294286


wildboottest(model, cluster = cluster, B = 9999)
#   param              statistic   p-value
# 0    X1  [-1.0530803154504016]  0.315132
# 1     1    [-18.5149486170657]  0.000000
# 2     2    [7.831855813581191]  0.000000
# 3     3   [-16.85188951397906]  0.000000
# 4     4  [-12.721095348008182]  0.000000
# 5     5    [1.200524160940055]  0.243624
# 6     6    [6.870946666836135]  0.000000
# 7     7   [-31.31653422266621]  0.000000
# 8     8    [10.26443257212472]  0.000000
# 9     9  [-20.650361366939535]  0.000000

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wildboottest-0.1.5.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wildboottest-0.1.5-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file wildboottest-0.1.5.tar.gz.

File metadata

  • Download URL: wildboottest-0.1.5.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.9.12 Darwin/22.1.0

File hashes

Hashes for wildboottest-0.1.5.tar.gz
Algorithm Hash digest
SHA256 31e58aeaef9128b3009d11dc5d01d9250568af3b7dc42986190b46bc4c0d6921
MD5 571003662569ec0d5273d152fe716849
BLAKE2b-256 f316ca57c1e0c863c3d0da97788f7debb4dd93efefd1f425cad76c0977a26875

See more details on using hashes here.

File details

Details for the file wildboottest-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: wildboottest-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.9.12 Darwin/22.1.0

File hashes

Hashes for wildboottest-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 17eaecd020f2cc5e8c5f9c0cb39bf18f6060e8d11ade7df0eebfaa3501d8760a
MD5 6a575673a581a3396a4a55bb5a8e9b7f
BLAKE2b-256 18adabcca0490865e610c6f0c682f91d6a4945ca7b4998d6d84c1eeccefd18aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page