diff --git a/causal_curve/mediation.py b/causal_curve/mediation.py index dc153c3..3abd589 100644 --- a/causal_curve/mediation.py +++ b/causal_curve/mediation.py @@ -7,9 +7,8 @@ import numpy as np import pandas as pd -from pandas.api.types import is_float_dtype, is_numeric_dtype +from pandas.api.types import is_float_dtype from pygam import LinearGAM, s -from tqdm import tqdm from causal_curve.core import Core from causal_curve.utils import rand_seed_wrapper @@ -438,8 +437,8 @@ def calculate_mediation(self, ci=0.95): Parameters ---------- ci: float (default = 0.95) - The desired bootstrap confidence interval to produce. Default value is 0.95, corresponding - to 95% confidence intervals. bounded (0, 1.0). + The desired bootstrap confidence interval to produce. Default value is 0.95, + corresponding to 95% confidence intervals. bounded (0, 1.0). Returns ---------- @@ -532,7 +531,9 @@ def calculate_mediation(self, ci=0.95): ) print( - f"\n\nMean indirect effect proportion: {total_prop_mean} ({total_prop_lower} - {total_prop_upper})" + f"""\n\nMean indirect effect proportion: + {total_prop_mean} ({total_prop_lower} - {total_prop_upper}) + """ ) return final_results diff --git a/docs/Mediation_example.rst b/docs/Mediation_example.rst index 26933de..1c3d5a9 100644 --- a/docs/Mediation_example.rst +++ b/docs/Mediation_example.rst @@ -87,13 +87,17 @@ around 52% (+/- 1%) of the effect of the treatment on the outcome. This indicate moderate mediation is occurring here. The remaining 48% occurs through a direct effect of the treatment on the outcome. -The report also shows how this mediation effect various as a function of the continuous treatment. -In this case, it looks the effect is relatively flat (as expected). - So long as we are confident that the mediator doesn't play another role in the causal graph (it isn't a confounder of the treatment and outcome association), this supports the idea that the mediator is in fact a mediator. +The report also shows how this mediation effect various as a function of the continuous treatment. +In this case, it looks the effect is relatively flat (as expected). With a little processing +and some basic interpolation, we can plot this mediation effect: + +.. image:: ../imgs/mediation/mediation_effect.png + + References ---------- diff --git a/docs/changelog.rst b/docs/changelog.rst index 6f22605..8fb53a5 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,12 @@ Change Log ========== +Version 0.2.1 +------------- +- Fixed Mediation tool error / removed `tqdm` from requirements +- Misc documentation cleanup / revisions + + Version 0.2.0 ------------- - Added new Mediation class diff --git a/docs/conf.py b/docs/conf.py index 24507f1..02b993f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,7 +22,7 @@ author = 'Roni Kobrosly' # The full version, including alpha/beta/rc tags -release = '0.2.0' +release = '0.2.1' # -- General configuration --------------------------------------------------- diff --git a/docs/contribute.rst b/docs/contribute.rst index e2b9617..768910a 100644 --- a/docs/contribute.rst +++ b/docs/contribute.rst @@ -44,7 +44,7 @@ Feature request A good feature request usually contains: - a description of the requested feature, -- a description of the relevance of this feature to time series classification, +- a description of the relevance of this feature to causal inference, - references if applicable, with links to the papers if they are in open access. This makes reviewing the relevance of the requested feature easier. diff --git a/docs/index.rst b/docs/index.rst index 9091734..b7aed64 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -40,7 +40,7 @@ Welcome to causal-curve's documentation! :caption: Contents: -**causal-curve** is a Python package dedicated with tools to perform causal inference +**causal-curve** is a Python package with tools to perform causal inference using observational data when the treatment of interest is continuous. @@ -72,7 +72,7 @@ This library attempts to address this gap, providing tools to estimate causal cu Quick example (of the ``GPS`` tool) --------------------------------------- +----------------------------------- **causal-curve** uses a sklearn-like API that should feel familiar to python machine learning users. The following example estimates the causal dose-response curve (CDRC) by calculating @@ -105,18 +105,30 @@ generalized propensity scores. 6. Explore or plot your results! +None of the methods provided in causal-curve rely on inference via instrumental variables, they only +rely on the data from the observed treatment, confounders, and the outcome of interest (like the above GPS example). -`Getting started `_ ---------------------------------- -Information to install, test, and contribute to the package. +A caution about assumptions +--------------------------- + +There is a well-documented set of assumptions one must make to infer causal effects from +observational data. These are covered elsewhere in more detail, but briefly: + +- Causes always occur before effects: The treatment variable needs to have occurred before the outcome. +- SUTVA: The treatment status of a given individual does not affect the potential outcomes of any other individuals. +- Positivity: Any individual has a positive probability of receiving all values of the treatment variable. +- Ignorability: All major confounding variables are included in the data you provide. +Violations of these assumptions will lead to biased results and incorrect conclusions! +In addition, any covariates that are included in `causal-curve` models are assumed to only +be **confounding** variables. -Indices and tables -================== -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` + +`Getting started `_ +--------------------------------- + +Information to install, test, and contribute to the package. diff --git a/imgs/mediation/mediation_effect.png b/imgs/mediation/mediation_effect.png new file mode 100644 index 0000000..fb84b61 Binary files /dev/null and b/imgs/mediation/mediation_effect.png differ diff --git a/setup.py b/setup.py index 987bf3a..11f05f2 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="causal-curve", - version="0.2.0", + version="0.2.1", author="Roni Kobrosly", author_email="roni.kobrosly@gmail.com", description="A python library with tools to perform causal inference using \