Python implementation of the Interactive Fixed Effects estimator presented in Bai (2009).
Project description
Panel Data Models with Interactive Fixed Effects
Python implementation of the Interactive Fixed Effects Estimator for panel data presented in Bai (2009).
Installation
pip install pyInteractiveFixedEffects
Usage
First, we need to import the module into our script.
import bai2009
Then we need the initiate the estimator by specifying the number of factors in the model.
# Load the Interactive Fixed Effects estimator with r=3 factors
ife = bai2009.InteractiveFixedEffects(3)
Finally, there are two ways to estimate a model with interactive fixed effects (ife).
Estimation from a Patsy formula
The easiest way to get an estimate is using a Patsy formula to specify the model. The regression is specified as normal and we add an additional term ~ife(I,T)at the end to specify the columns of the data with the $N$ and $T$ index of each observation.
# Estimate the model using a Patsy formula
betas, F, Lambda = ife.fit_from_formula('Y~0+X1+X2~ife(I,T)', df)
Estimation from explicit definition of terms
If you prefer to specify each term explicitly in your code, you can use the code below.
# Alternatively, estimate the model specifying every term explicitly
betas, F, Lambda = ife.fit(
df['Y'].values[:,np.newaxis], # Outcome
df[['X1', 'X2']].values, # Observable regressors
df['I'].values[:,np.newaxis], # First level of the factor model (I)
df['T'].values[:,np.newaxis] # Second level of the factor model (T)
)
Estimation results
The estimator returns:
- $\beta$ a $p\times 1$ vector of coefficients associated with the observables.
- $F$ a $T\times r$ matrix of the factors on the $T$ dimension.
- $\Lambda$ a $N\times r$ matrix of the loadings on the $N$ dimension.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyInteractiveFixedEffects-0.0.2.tar.gz.
File metadata
- Download URL: pyInteractiveFixedEffects-0.0.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8e52c225cfe659ab1dff1e5dc117724515e33a907e6cd51752b55cbef2a247c
|
|
| MD5 |
013522eb4075c7c44bd156a999603627
|
|
| BLAKE2b-256 |
e3ee50215f0eea0f3fac19b75a2b136c1f70959917a16398fc4008d16612d034
|
File details
Details for the file pyInteractiveFixedEffects-0.0.2-py3-none-any.whl.
File metadata
- Download URL: pyInteractiveFixedEffects-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38abf2926fd5b9cc332ed35ff11ad571ca607abe7c250ad493579ea5f0df621f
|
|
| MD5 |
27402e3ba54bce8877b3683793d6edf4
|
|
| BLAKE2b-256 |
1969083231c68883dea49a53463642c3503170e7aaf2a2bdff5850d71713c4fe
|