Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Linear Panel, Instrumental Variable, Asset Pricing, and System Regression models for Python
Metric | |
---|---|
Latest Release | |
Continuous Integration | |
Coverage | |
Code Quality | |
Citation |
Linear (regression) models for Python. Extends statsmodels with Panel regression, instrumental variable estimators, system estimators and models for estimating asset prices:
Panel models:
High-dimensional Regresssion:
Instrumental Variable estimators
Factor Asset Pricing Models:
System Regression:
Designed to work equally well with NumPy, Pandas or xarray data.
Like statsmodels to include, supports formulas for specifying models. For example, the classic Grunfeld regression can be specified
import numpy as np
from statsmodels.datasets import grunfeld
data = grunfeld.load_pandas().data
data.year = data.year.astype(np.int64)
# MultiIndex, entity - time
data = data.set_index(['firm','year'])
from linearmodels import PanelOLS
mod = PanelOLS(data.invest, data[['value','capital']], entity_effects=True)
res = mod.fit(cov_type='clustered', cluster_entity=True)
Models can also be specified using the formula interface.
from linearmodels import PanelOLS
mod = PanelOLS.from_formula('invest ~ value + capital + EntityEffects', data)
res = mod.fit(cov_type='clustered', cluster_entity=True)
The formula interface for PanelOLS
supports the special values
EntityEffects
and TimeEffects
which add entity (fixed) and time
effects, respectively.
Formula support comes from the formulaic package which is a replacement for patsy.
IV regression models can be similarly specified.
import numpy as np
from linearmodels.iv import IV2SLS
from linearmodels.datasets import mroz
data = mroz.load()
mod = IV2SLS.from_formula('np.log(wage) ~ 1 + exper + exper ** 2 + [educ ~ motheduc + fatheduc]', data)
The expressions in the [ ]
indicate endogenous regressors (before ~
)
and the instruments.
The latest release can be installed using pip
pip install linearmodels
The main branch can be installed by cloning the repo and running setup
git clone https://github.com/bashtage/linearmodels
cd linearmodels
pip install .
Stable Documentation is built on every tagged version using doctr. Development Documentation is automatically built on every successful build of main.
Should eventually add some useful linear model estimators such as panel regression. Currently only the single variable IV estimators are polished.
FAQs
Linear Panel, Instrumental Variable, Asset Pricing, and System Regression models for Python
We found that linearmodels demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.