diff --git a/documentation/.DS_Store b/documentation/.DS_Store new file mode 100644 index 0000000..841fb83 Binary files /dev/null and b/documentation/.DS_Store differ diff --git a/documentation/Makefile b/documentation/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/documentation/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/documentation/make.bat b/documentation/make.bat new file mode 100644 index 0000000..747ffb7 --- /dev/null +++ b/documentation/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/documentation/source/conf.py b/documentation/source/conf.py new file mode 100644 index 0000000..5f72bf5 --- /dev/null +++ b/documentation/source/conf.py @@ -0,0 +1,28 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'Causaleffectpy documentation' +author = 'Haley Hummel' +release = '0.0.1' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +master_doc = 'index' +extensions = [] + +templates_path = ['_templates'] +exclude_patterns = [] + + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = "sphinx_rtd_theme" +html_static_path = ['_static'] diff --git a/documentation/source/functions.rst b/documentation/source/functions.rst new file mode 100644 index 0000000..c5a0b01 --- /dev/null +++ b/documentation/source/functions.rst @@ -0,0 +1,8 @@ +CausalEffect Functions +======================= + +.. toctree:: + :maxdepth: 1 + :titlesonly: + + simplify \ No newline at end of file diff --git a/documentation/source/index.rst b/documentation/source/index.rst new file mode 100644 index 0000000..8ba22ec --- /dev/null +++ b/documentation/source/index.rst @@ -0,0 +1,29 @@ +.. Causaleffectpy documentation documentation master file, created by + sphinx-quickstart on Tue Aug 13 12:31:43 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Causaleffect Documentation +========================== + +This documentation provides an overview of `causaleffectpy`, which is derived from Santu Tikka's `causaleffect` R package. This documentation will focus on `simplify` and related functions in order to integrate them into the open source `y0` (Why Not?) Python package. For further information, see Tikka & Karvanen (2017) "Simplifying Probabilistic Expressions in Causal Inference". + +.. toctree:: + :maxdepth: 2 + + functions + + +References +=============== + +Hoyt, C.T., Zucker, J., & Parent, M-A. (2021). Y0 “Why Not?” for Causal Inference in Python (1.0) [Python package]. 10.5281/zenodo.4950768. https://github.com/y0-causal-inference/y0. +Tikka, S., & Karvanen, J. (2017). Simplifying probabilistic expressions in causal inference. Journal of Machine Learning Research, 18(36), 1-30. + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` \ No newline at end of file diff --git a/documentation/source/simplify.rst b/documentation/source/simplify.rst new file mode 100644 index 0000000..54c5cab --- /dev/null +++ b/documentation/source/simplify.rst @@ -0,0 +1,59 @@ +Simplify +======== + +This function algebraically simplifies probabilistic expressions given by the ID algorithm from :func:`identify`. It always attempts to perform maximal simplification, meaning that as many variables of the set are removed as possible. If the simplification in terms of the entire set cannot be completed, the intermediate result with as many variables simplified as possible should be returned. + +Run :func:`identify` with the graph information first, then use the output of :func:`identify` as the `P` in :func:`parse_causaleffect`. Use the output from :func:`parse_causaleffect` as the `P` in :func:`simplify`. + +For further information, see Tikka & Karvanen (2017) "Simplifying Probabilistic Expressions in Causal Inference" Algorithm 1. + + +Parameters +---------- +P : `sympy` expression or `y0` `Probability` object + The probabilistic expression that will be simplified, typically created using symbolic expressions in `sympy` or using `y0`'s Probability class. +topo : list of nodes + The topological ordering of the vertices in graph `G`, which can be obtained using `networkx.topological_sort`. +G_unobs : networkx.DiGraph object + A separate directed acyclic graph (DAG) that includes explicit nodes for unobserved confounders, created using `networkx.DiGraph`. +G : networkx.DiGraph object + Main graph G, which includes bidirected edges, and is created with :func:`igraph.graph_formula`. +G_obs : networkx.DiGraph object + A DAG that only includes directed edges, representing observed variables, created using `networkx.DiGraph`. + +Details +------- +This function depends on several other functions and classes, including: :func:`parents`, :func:`ancestors`, :func:`parse_causaleffect`, :func:`is_d_separated`, and :class:`probability`. + +Returns +------- +list + Section in-progress + +References +---------- +Tikka, S., & Karvanen, J. (2017). Simplifying probabilistic expressions in causal inference. Journal of Machine Learning Research, 18(36), 1-30. + + +See Also +-------- +:func:`identify`, :func:`parse_causaleffect`, :func:`get.expression`, :class:`probability` + +Examples +-------- +Section in-progress + +.. code-block:: python + + +Keywords +-------- +models, manip, math, utilities +Concepts +-------- +probabilistic expressions, graph theory, causal inference + +Author +------ +Haley Hummel, +Psychology PhD student at Oregon State University