{"id":19184354,"url":"https://bashtage.github.io/linearmodels/","last_synced_at":"2025-04-20T05:30:46.040Z","repository":{"id":37318479,"uuid":"82291672","full_name":"bashtage/linearmodels","owner":"bashtage","description":"Additional linear models including instrumental variable and panel data models that are missing from statsmodels.","archived":false,"fork":false,"pushed_at":"2025-03-22T18:46:05.000Z","size":148376,"stargazers_count":982,"open_issues_count":43,"forks_count":183,"subscribers_count":25,"default_branch":"main","last_synced_at":"2025-04-19T14:11:08.183Z","etag":null,"topics":["asset-pricing","between-estimator","clustered-standard-errors","fama-macbeth","first-difference","fixed-effects","gmm","instrumental-variable","iv","linear-models","ols","panel","panel-data","panel-models","panel-regression","pooled-ols","random-effects","regression","seemingly-unrelated-regression","statistical-model"],"latest_commit_sha":null,"homepage":"https://bashtage.github.io/linearmodels/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"ncsa","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bashtage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-17T11:39:15.000Z","updated_at":"2025-04-18T15:23:45.000Z","dependencies_parsed_at":"2024-01-14T03:48:19.322Z","dependency_job_id":"7d11df5d-5559-46ac-a6dd-83ff3665079b","html_url":"https://github.com/bashtage/linearmodels","commit_stats":{"total_commits":724,"total_committers":17,"mean_commits":"42.588235294117645","dds":0.07320441988950277,"last_synced_commit":"53f86bb48288689cbca782a56d3014fe83ade82e"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashtage%2Flinearmodels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashtage%2Flinearmodels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashtage%2Flinearmodels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashtage%2Flinearmodels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bashtage","download_url":"https://codeload.github.com/bashtage/linearmodels/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249854548,"owners_count":21335129,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asset-pricing","between-estimator","clustered-standard-errors","fama-macbeth","first-difference","fixed-effects","gmm","instrumental-variable","iv","linear-models","ols","panel","panel-data","panel-models","panel-regression","pooled-ols","random-effects","regression","seemingly-unrelated-regression","statistical-model"],"created_at":"2024-11-09T11:06:52.256Z","updated_at":"2025-04-20T05:30:45.560Z","avatar_url":"https://github.com/bashtage.png","language":"Python","readme":"# Linear Models\n\n| Metric                     |                                                                                                                                                                                                                                                          |\n| :------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| **Latest Release**         | [![PyPI version](https://badge.fury.io/py/linearmodels.svg)](https://badge.fury.io/py/linearmodels)                                                                                                                                                      |\n| **Continuous Integration** | [![Build Status](https://dev.azure.com/kevinksheppard/kevinksheppard/_apis/build/status/bashtage.linearmodels?branchName=main)](https://dev.azure.com/kevinksheppard/kevinksheppard/_build/latest?definitionId=2\u0026branchName=main)                        |\n| **Coverage**               | [![codecov](https://codecov.io/gh/bashtage/linearmodels/branch/main/graph/badge.svg)](https://codecov.io/gh/bashtage/linearmodels)                                                                                                                       |\n| **Code Quality**           | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/745a24a69cb2466b95df6a53c83892de)](https://www.codacy.com/manual/bashtage/linearmodels?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=bashtage/linearmodels\u0026utm_campaign=Badge_Grade) |\n|                            | [![codebeat badge](https://codebeat.co/badges/aaae2fb4-72b5-4a66-97cd-77b93488f243)](https://codebeat.co/projects/github-com-bashtage-linearmodels-main)                                                                                                 |\n| **Citation**               | [![DOI](https://zenodo.org/badge/82291672.svg)](https://zenodo.org/badge/latestdoi/82291672)                                                                                                                                                             |\n\nLinear (regression) models for Python. Extends\n[statsmodels](http://www.statsmodels.org) with Panel regression,\ninstrumental variable estimators, system estimators and models for\nestimating asset prices:\n\n-   **Panel models**:\n    -   Fixed effects (maximum two-way)\n    -   First difference regression\n    -   Between estimator for panel data\n    -   Pooled regression for panel data\n    -   Fama-MacBeth estimation of panel models\n\n-   **High-dimensional Regresssion**:\n    -   Absorbing Least Squares\n\n-   **Instrumental Variable estimators**\n    -   Two-stage Least Squares\n    -   Limited Information Maximum Likelihood\n    -   k-class Estimators\n    -   Generalized Method of Moments, also with continuously updating\n\n-   **Factor Asset Pricing Models**:\n    -   2- and 3-step estimation\n    -   Time-series estimation\n    -   GMM estimation\n\n-   **System Regression**:\n    -   Seemingly Unrelated Regression (SUR/SURE)\n    -   Three-Stage Least Squares (3SLS)\n    -   Generalized Method of Moments (GMM) System Estimation\n\nDesigned to work equally well with NumPy, Pandas or xarray data.\n\n## Panel models\n\nLike [statsmodels](http://www.statsmodels.org) to include, supports\nformulas for specifying models. For example, the classic Grunfeld regression can be\nspecified\n\n```python\nimport numpy as np\nfrom statsmodels.datasets import grunfeld\ndata = grunfeld.load_pandas().data\ndata.year = data.year.astype(np.int64)\n# MultiIndex, entity - time\ndata = data.set_index(['firm','year'])\nfrom linearmodels import PanelOLS\nmod = PanelOLS(data.invest, data[['value','capital']], entity_effects=True)\nres = mod.fit(cov_type='clustered', cluster_entity=True)\n```\n\nModels can also be specified using the formula interface.\n\n```python\nfrom linearmodels import PanelOLS\nmod = PanelOLS.from_formula('invest ~ value + capital + EntityEffects', data)\nres = mod.fit(cov_type='clustered', cluster_entity=True)\n```\n\nThe formula interface for `PanelOLS` supports the special values\n`EntityEffects` and `TimeEffects` which add entity (fixed) and time\neffects, respectively.\n\nFormula support comes from the [formulaic](https://github.com/matthewwardrop/formulaic/)\npackage which is a replacement for [patsy](https://patsy.readthedocs.io/en/latest/).\n\n## Instrumental Variable Models\n\nIV regression models can be similarly specified.\n\n```python\nimport numpy as np\nfrom linearmodels.iv import IV2SLS\nfrom linearmodels.datasets import mroz\ndata = mroz.load()\nmod = IV2SLS.from_formula('np.log(wage) ~ 1 + exper + exper ** 2 + [educ ~ motheduc + fatheduc]', data)\n```\n\nThe expressions in the `[ ]` indicate endogenous regressors (before `~`)\nand the instruments.\n\n## Installing\n\nThe latest release can be installed using pip\n\n```bash\npip install linearmodels\n```\n\nThe main branch can be installed by cloning the repo and running setup\n\n```bash\ngit clone https://github.com/bashtage/linearmodels\ncd linearmodels\npip install .\n```\n\n## Documentation\n\n[Stable Documentation](https://bashtage.github.io/linearmodels/) is\nbuilt on every tagged version using\n[doctr](https://github.com/drdoctr/doctr).\n[Development Documentation](https://bashtage.github.io/linearmodels/devel)\nis automatically built on every successful build of main.\n\n## Plan and status\n\nShould eventually add some useful linear model estimators such as panel\nregression. Currently only the single variable IV estimators are polished.\n\n-   Linear Instrumental variable estimation - **complete**\n-   Linear Panel model estimation - **complete**\n-   Fama-MacBeth regression - **complete**\n-   Linear Factor Asset Pricing - **complete**\n-   System regression - **complete**\n-   Linear IV Panel model estimation - _not started_\n-   Dynamic Panel model estimation - _not started_\n\n## Requirements\n\n### Running\n\n-   Python 3.9+\n-   NumPy (1.22+)\n-   SciPy (1.8+)\n-   pandas (1.4+)\n-   statsmodels (0.12+)\n-   formulaic (1.0.0+)\n-   xarray (0.16+, optional)\n-   Cython (3.0.10+, optional)\n\n\n### Testing\n\n-   py.test\n\n### Documentation\n\n-   sphinx\n-   sphinx-immaterial\n-   nbsphinx\n-   nbconvert\n-   nbformat\n-   ipython\n-   jupyter\n","funding_links":[],"categories":["Statistical Analysis"],"sub_categories":["Specialized Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/bashtage.github.io%2Flinearmodels%2F","html_url":"https://awesome.ecosyste.ms/projects/bashtage.github.io%2Flinearmodels%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/bashtage.github.io%2Flinearmodels%2F/lists"}