dmsul / econtools

Econometrics and data manipulation functions.
http://www.danielmsullivan.com/econtools
BSD 3-Clause "New" or "Revised" License
111 stars 24 forks source link
econometrics python regression scipy stata statistics

econtools

econtools is a Python package of econometric functions and convenient shortcuts for data work with pandas and numpy. Full documentation here.

Installation

You can install directly from PYPI:

$ pip install econtools

Or you can clone from Github and install directly.

$ git clone http://github.com/dmsul/econtools
$ cd econtools
$ python setup.py install

Econometrics

import econtools
import econtools.metrics as mt

# Read Stata DTA file
df = econtools.read('my_data.dta')

# Estimate OLS regression with fixed-effects and clustered s.e.'s
result = mt.reg(df,                     # DataFrame to use
                'y',                    # Outcome
                ['x1', 'x2'],           # Indep. Variables
                fe_name='person_id',    # Fixed-effects using variable 'person_id'
                cluster='state'         # Cluster by state
)

# Results
print(result.summary)                                # Print regression results
beta_x1 = result.beta['x1']                          # Get coefficient by variable name
r_squared = result.r2a                               # Get adjusted R-squared
joint_F = result.Ftest(['x1', 'x2'])                 # Test for joint significance
equality_F = result.Ftest(['x1', 'x2'], equal=True)  # Test for coeff. equality

Regression and Summary Stat Tables

Misc. Data Manipulation Tools

Data I/O

Requirements