azcausal


Nameazcausal JSON
Version 0.2.4 PyPI version JSON
download
home_pagehttps://github.com/amazon-science/azcausal
SummaryCasual Inference
upload_time2024-06-27 15:12:05
maintainerNone
docs_urlNone
authorJulian Blank
requires_python>=3.7
licenseApache License 2.0
keywords causality inference
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            azcausal: Causal Inference in Python
====================================================================

Causal inference is an important component of the experiment evaluation. We highly recommend to have a look at the open-source
book: `Causal Inference for The Brave and True <https://matheusfacure.github.io/python-causality-handbook/landing-page.html>`_

Please find the software documentation here: https://amazon-science.github.io/azcausal/latest/

Currently, azcausal provides two well-known and widely used causal inference methods: Difference-in-Difference (DID) and
Synthetic Difference-in-Difference (SDID). Moreover, error estimates via Placebo, Boostrap, or JackKnife are available.


.. _Installation:

Installation
********************************************************************************


To install the current release, please execute:

.. code:: bash

    pip install git+https://github.com/amazon-science/azcausal.git


.. _Usage:

Usage
********************************************************************************


.. code:: python

    from azcausal.core.error import JackKnife
    from azcausal.core.panel import CausalPanel
    from azcausal.data import CaliforniaProp99
    from azcausal.estimators.panel.sdid import SDID
    from azcausal.util import to_panels


    # load an example data set with the columns Year, State, PacksPerCapita, treated.
    df = CaliforniaProp99().df()

    # create the panel data from the frame and define the causal types
    data = to_panels(df, 'Year', 'State', ['PacksPerCapita', 'treated'])
    ctypes = dict(outcome='PacksPerCapita', time='Year', unit='State', intervention='treated')

    # initialize the panel
    panel = CausalPanel(data).setup(**ctypes)

    # initialize an estimator object, here synthetic difference in difference (sdid)
    estimator = SDID()

    # run the estimator
    result = estimator.fit(panel)

    # run the error validation method
    estimator.error(result, JackKnife())

    # plot the results
    estimator.plot(result)

    # print out information about the estimate
    print(result.summary(title="CaliforniaProp99"))


.. code:: bash

    ╭──────────────────────────────────────────────────────────────────────────────╮
    |                               CaliforniaProp99                               |
    ├──────────────────────────────────────────────────────────────────────────────┤
    |                                    Panel                                     |
    |  Time Periods: 31 (19/12)                                  total (pre/post)  |
    |  Units: 39 (38/1)                                       total (contr/treat)  |
    ├──────────────────────────────────────────────────────────────────────────────┤
    |                                     ATT                                      |
    |  Effect (±SE): -15.60 (±2.9161)                                              |
    |  Confidence Interval (95%): [-21.32 , -9.8884]                          (-)  |
    |  Observed: 60.35                                                             |
    |  Counter Factual: 75.95                                                      |
    ├──────────────────────────────────────────────────────────────────────────────┤
    |                                  Percentage                                  |
    |  Effect (±SE): -20.54 (±3.8393)                                              |
    |  Confidence Interval (95%): [-28.07 , -13.02]                           (-)  |
    |  Observed: 79.46                                                             |
    |  Counter Factual: 100.00                                                     |
    ├──────────────────────────────────────────────────────────────────────────────┤
    |                                  Cumulative                                  |
    |  Effect (±SE): -187.25 (±34.99)                                              |
    |  Confidence Interval (95%): [-255.83 , -118.66]                         (-)  |
    |  Observed: 724.20                                                            |
    |  Counter Factual: 911.45                                                     |
    ╰──────────────────────────────────────────────────────────────────────────────╯

.. image:: docs/source/images/sdid.png

.. _Estimators:

Estimators
********************************************************************************


- **Difference-in-Difference (DID):** Simple implementation of the well-known Difference-in-Difference estimator.
- **Synthetic Difference-in-Difference (SDID):** Arkhangelsky, Dmitry Athey, Susan Hirshberg, David A. Imbens, Guido W. Wager, Stefan Synthetic Difference-in-Differences American Economic Review 111 12 4088-4118 2021 10.1257/aer.20190159 https://www.aeaweb.org/articles?id=10.1257/aer.20190159. Implementation based on https://synth-inference.github.io/synthdid/

.. _Contact:

Contact
********************************************************************************

Feel free to contact me if you have any questions:

| `Julian Blank <http://julianblank.com>`_  (blankjul [at] amazon.com)
| Amazon.com
| Applied Scientist, Amazon
| 410 Terry Ave N, Seattle 98109, WA.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/amazon-science/azcausal",
    "name": "azcausal",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "causality, inference",
    "author": "Julian Blank",
    "author_email": "blankjul@amazon.com",
    "download_url": "https://files.pythonhosted.org/packages/bf/aa/5a15b3c910dd8eda0b4f7c0bd675ed3106c4f3bc19da53ed3522418d1747/azcausal-0.2.4.tar.gz",
    "platform": "any",
    "description": "azcausal: Causal Inference in Python\n====================================================================\n\nCausal inference is an important component of the experiment evaluation. We highly recommend to have a look at the open-source\nbook: `Causal Inference for The Brave and True <https://matheusfacure.github.io/python-causality-handbook/landing-page.html>`_\n\nPlease find the software documentation here: https://amazon-science.github.io/azcausal/latest/\n\nCurrently, azcausal provides two well-known and widely used causal inference methods: Difference-in-Difference (DID) and\nSynthetic Difference-in-Difference (SDID). Moreover, error estimates via Placebo, Boostrap, or JackKnife are available.\n\n\n.. _Installation:\n\nInstallation\n********************************************************************************\n\n\nTo install the current release, please execute:\n\n.. code:: bash\n\n    pip install git+https://github.com/amazon-science/azcausal.git\n\n\n.. _Usage:\n\nUsage\n********************************************************************************\n\n\n.. code:: python\n\n    from azcausal.core.error import JackKnife\n    from azcausal.core.panel import CausalPanel\n    from azcausal.data import CaliforniaProp99\n    from azcausal.estimators.panel.sdid import SDID\n    from azcausal.util import to_panels\n\n\n    # load an example data set with the columns Year, State, PacksPerCapita, treated.\n    df = CaliforniaProp99().df()\n\n    # create the panel data from the frame and define the causal types\n    data = to_panels(df, 'Year', 'State', ['PacksPerCapita', 'treated'])\n    ctypes = dict(outcome='PacksPerCapita', time='Year', unit='State', intervention='treated')\n\n    # initialize the panel\n    panel = CausalPanel(data).setup(**ctypes)\n\n    # initialize an estimator object, here synthetic difference in difference (sdid)\n    estimator = SDID()\n\n    # run the estimator\n    result = estimator.fit(panel)\n\n    # run the error validation method\n    estimator.error(result, JackKnife())\n\n    # plot the results\n    estimator.plot(result)\n\n    # print out information about the estimate\n    print(result.summary(title=\"CaliforniaProp99\"))\n\n\n.. code:: bash\n\n    \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n    |                               CaliforniaProp99                               |\n    \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n    |                                    Panel                                     |\n    |  Time Periods: 31 (19/12)                                  total (pre/post)  |\n    |  Units: 39 (38/1)                                       total (contr/treat)  |\n    \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n    |                                     ATT                                      |\n    |  Effect (\u00b1SE): -15.60 (\u00b12.9161)                                              |\n    |  Confidence Interval (95%): [-21.32 , -9.8884]                          (-)  |\n    |  Observed: 60.35                                                             |\n    |  Counter Factual: 75.95                                                      |\n    \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n    |                                  Percentage                                  |\n    |  Effect (\u00b1SE): -20.54 (\u00b13.8393)                                              |\n    |  Confidence Interval (95%): [-28.07 , -13.02]                           (-)  |\n    |  Observed: 79.46                                                             |\n    |  Counter Factual: 100.00                                                     |\n    \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n    |                                  Cumulative                                  |\n    |  Effect (\u00b1SE): -187.25 (\u00b134.99)                                              |\n    |  Confidence Interval (95%): [-255.83 , -118.66]                         (-)  |\n    |  Observed: 724.20                                                            |\n    |  Counter Factual: 911.45                                                     |\n    \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\n.. image:: docs/source/images/sdid.png\n\n.. _Estimators:\n\nEstimators\n********************************************************************************\n\n\n- **Difference-in-Difference (DID):** Simple implementation of the well-known Difference-in-Difference estimator.\n- **Synthetic Difference-in-Difference (SDID):** Arkhangelsky, Dmitry Athey, Susan Hirshberg, David A. Imbens, Guido W. Wager, Stefan Synthetic Difference-in-Differences American Economic Review 111 12 4088-4118 2021 10.1257/aer.20190159 https://www.aeaweb.org/articles?id=10.1257/aer.20190159. Implementation based on https://synth-inference.github.io/synthdid/\n\n.. _Contact:\n\nContact\n********************************************************************************\n\nFeel free to contact me if you have any questions:\n\n| `Julian Blank <http://julianblank.com>`_  (blankjul [at] amazon.com)\n| Amazon.com\n| Applied Scientist, Amazon\n| 410 Terry Ave N, Seattle 98109, WA.\n\n\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Casual Inference",
    "version": "0.2.4",
    "project_urls": {
        "Homepage": "https://github.com/amazon-science/azcausal"
    },
    "split_keywords": [
        "causality",
        " inference"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bfaa5a15b3c910dd8eda0b4f7c0bd675ed3106c4f3bc19da53ed3522418d1747",
                "md5": "46a4608c1be52c492d98b4dd5ecd5b61",
                "sha256": "85205313f7a9be3fa91dff32240c21cec999cf797bcaa767d0901c05cbfc6207"
            },
            "downloads": -1,
            "filename": "azcausal-0.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "46a4608c1be52c492d98b4dd5ecd5b61",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 255016,
            "upload_time": "2024-06-27T15:12:05",
            "upload_time_iso_8601": "2024-06-27T15:12:05.715096Z",
            "url": "https://files.pythonhosted.org/packages/bf/aa/5a15b3c910dd8eda0b4f7c0bd675ed3106c4f3bc19da53ed3522418d1747/azcausal-0.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-27 15:12:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "amazon-science",
    "github_project": "azcausal",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "azcausal"
}
        
Elapsed time: 0.31138s