Skip to main content

A Simple Python library that implements the most commonly used Grouped Panel Data Models

Project description

groupedpaneldatamodels: A Python Library for Grouped Fixed and Interactive Effects Models

groupedpaneldatamodels is an open‑source Python library that implements a collection of Grouped Panel Data Models (GPDMs) for econometric research.

groupedpaneldatamodels is an Open Source Python library that implements multiple Grouped Panel Data Models (GPDMs) for Econometric research. These models offer a middle ground between fully homogeneous (which are often incorrectly specified) and fully heterogeneous (which are often difficult to estimate) by grouping multiple individuals and assuming the same coeficients for all members of the groupings.

Features

This package implements the models and algorithms proposed by the following four papers, which each suggest different GPDMS.

  • Grouped Fixed Effects (GFE)
  • Grouped Interactive Fixed Effects (GIFE)
  • Automatic group selection via Information Criteria (BIC, AIC, HQIC).
  • Analytical or bootstrap standard errors
  • Fast NumPy and JIT-compiled Numba core with optional parallel bootstrap for large panels
  • Familiar, statsmodels‑like API

Installation

pip install groupedpaneldatamodels
# or update
pip install --upgrade groupedpaneldatamodels

To grab the bleeding‑edge version:

git clone https://github.com/michadenheijer/groupedpaneldatamodels.git
cd groupedpaneldatamodels
pip install .

Quick start

import numpy as np
import groupedpaneldatamodels as gpdm

# Y  shape (N, T, 1); X  shape (N, T, K)
gfe = gpdm.GroupedFixedEffects(Y, X, G=3, model="bonhomme_manresa")
gfe.fit()
print(gfe.summary())

gife = gpdm.GroupedInteractiveFixedEffects(Y, X, G=3,
                                           model="ando_bai",
                                           GF=[2, 2, 2])            # 2 common factors per grouping
gife.fit()
betas = gife.params["beta"]

Selecting the number of groups

best = gpdm.grid_search_by_ic(
    gpdm.GroupedFixedEffects,
    param_ranges={"G": range(1, 7)},
    init_params={"dependent": Y, "exog": X},
    pit_params={"gife_iterations": 100},
    ic_criterion="BIC"
)
print(best.G)          # optimal group count

Documentation

An API reference with proper installation and guidelines is available at https://groupedpaneldatamodels.michadenheijer.com

Simulation Study

A simulation study has been done for the Master's thesis creating this package. This thesis has shown that this package can succesfully reproduce the properties of the underlying estimators and can reduce the RMSE compared to a fully heterogeneous model when N is large and T is small.


Citation

Please cite the thesis if you use groupedpaneldatamodels:

@mastersthesis{denheijer2025,
    author      = {Micha den Heijer},
    title       = {groupedpaneldatamodels: A Python Library for Grouped Fixed and Interactive Effects Models},
    school      = {Vrije Universiteit Amsterdam},
    year        = {2025},
    month       = {July},
    date        = {2025-07-01},
    url         = {https://groupedpaneldatamodels.michadenheijer.com/_static/thesis.pdf}
}

License

Released under the MIT License. See LICENSE for details.

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

groupedpaneldatamodels-0.1.1.tar.gz (19.8 MB view details)

Uploaded Source

Built Distribution

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

groupedpaneldatamodels-0.1.1-py3-none-any.whl (20.0 MB view details)

Uploaded Python 3

File details

Details for the file groupedpaneldatamodels-0.1.1.tar.gz.

File metadata

  • Download URL: groupedpaneldatamodels-0.1.1.tar.gz
  • Upload date:
  • Size: 19.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.4

File hashes

Hashes for groupedpaneldatamodels-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b1409e1ff85021739714bc13b5ac829d052598cfd8e06f41e30785b3012ad45c
MD5 7e1e55fce0005a626a634ca42b5660cd
BLAKE2b-256 ae74c0015f1f143cf5a638773bb25513a50798dce30a714fd1a7fa4a22d98a74

See more details on using hashes here.

File details

Details for the file groupedpaneldatamodels-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for groupedpaneldatamodels-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ad9af288f5f785a62d1dc22128f76ee1f30e211a6763d2036508183fe66a7a6b
MD5 1364cc0968654057a76838507cb7a64c
BLAKE2b-256 4cb067290d93dfa0d34b9c0a6bed8bf14fc9e5da6531c62eecdd88027abda686

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