Repository: jakobrunge/tigramite (language: python)

Issue:
Tom branch 1
Es gab einen Bug bei pairwise_mult_ci. Der sollte nun gefixt sein. Außerdem habe ich weitere Unit-Tests hinzugefügt.


Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index d494facf..f6399347 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 # Tigramite – Causal inference for time series datasets
+![logo](docs/_images/tigramite_logo_header.png)
 Version 5.2
-
 (Python Package)
 
 [Github](https://github.com/jakobrunge/tigramite.git)
diff --git a/docs/_build/.doctrees/environment.pickle b/docs/_build/.doctrees/environment.pickle
index ff7c537d..94a0faa2 100644
Binary files a/docs/_build/.doctrees/environment.pickle and b/docs/_build/.doctrees/environment.pickle differ
diff --git a/docs/_build/.doctrees/index.doctree b/docs/_build/.doctrees/index.doctree
index 3a2391a7..bcdb9131 100644
Binary files a/docs/_build/.doctrees/index.doctree and b/docs/_build/.doctrees/index.doctree differ
diff --git a/docs/_build/_modules/index.html b/docs/_build/_modules/index.html
index 5f197719..725cda80 100644
--- a/docs/_build/_modules/index.html
+++ b/docs/_build/_modules/index.html
@@ -34,6 +34,7 @@
   <h1>All modules for which code is available</h1>
 <ul><li><a href="abc.html">abc</a></li>
 <li><a href="tigramite/causal_effects.html">tigramite.causal_effects</a></li>
+<li><a href="tigramite/causal_mediation.html">tigramite.causal_mediation</a></li>
 <li><a href="tigramite/data_processing.html">tigramite.data_processing</a></li>
 <li><a href="tigramite/independence_tests/cmiknn.html">tigramite.independence_tests.cmiknn</a></li>
 <li><a href="tigramite/independence_tests/cmisymb.html">tigramite.independence_tests.cmisymb</a></li>
diff --git a/docs/_build/_modules/tigramite/causal_mediation.html b/docs/_build/_modules/tigramite/causal_mediation.html
new file mode 100644
index 00000000..9c3da029
--- /dev/null
+++ b/docs/_build/_modules/tigramite/causal_mediation.html
@@ -0,0 +1,1672 @@
+
+<!DOCTYPE html>
+
+<html lang="en">
+  <head>
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>tigramite.causal_mediation &#8212; Tigramite 5.2 documentation</title>
+    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../../_static/alabaster.css" />
+    <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
+    <script src="../../_static/jquery.js"></script>
+    <script src="../../_static/underscore.js"></script>
+    <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
+    <script src="../../_static/doctools.js"></script>
+    <link rel="index" title="Index" href="../../genindex.html" />
+    <link rel="search" title="Search" href="../../search.html" />
+   
+  <link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
+  
+  
+  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
+
+  </head><body>
+  
+
+    <div class="document">
+      <div class="documentwrapper">
+        <div class="bodywrapper">
+          
+
+          <div class="body" role="main">
+            
+  <h1>Source code for tigramite.causal_mediation</h1><div class="highlight"><pre>
+<span></span><span class="sd">&quot;&quot;&quot;Tigramite causal discovery for time series.&quot;&quot;&quot;</span>
+
+<span class="c1"># Authors: Martin Rabel, Jakob Runge &lt;jakob@jakob-runge.com&gt;</span>
+<span class="c1">#</span>
+<span class="c1"># License: GNU General Public License v3.0</span>
+
+<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
+<span class="kn">from</span> <span class="nn">sklearn.neighbors</span> <span class="kn">import</span> <span class="n">KNeighborsRegressor</span><span class="p">,</span> <span class="n">KernelDensity</span>
+<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">partial</span>
+<span class="kn">import</span> <span class="nn">tigramite.toymodels.non_additive</span> <span class="k">as</span> <span class="nn">toy_setup</span>
+<span class="kn">from</span> <span class="nn">tigramite.causal_effects</span> <span class="kn">import</span> <span class="n">CausalEffects</span>
+<span class="kn">from</span> <span class="nn">tigramite.toymodels.non_additive</span> <span class="kn">import</span> <span class="n">_Fct_on_grid</span><span class="p">,</span> <span class="n">_Fct_smoothed</span>
+
+
+
+<span class="sd">&quot;&quot;&quot;-------------------------------------------------------------------------------------------</span>
+<span class="sd">-----------------------------   Helpers for Mixed Data Fitting   -----------------------------</span>
+<span class="sd">-------------------------------------------------------------------------------------------&quot;&quot;&quot;</span>
+
+
+<span class="k">class</span> <span class="nc">MixedData</span><span class="p">:</span>
+<span class="w">    </span><span class="sd">&quot;&quot;&quot;Namescope for mixed-data helpers.</span>
+
+<span class="sd">    Mostly for internal use.</span>
+<span class="sd">    &quot;&quot;&quot;</span>
+
+    <span class="nd">@staticmethod</span>
+    <span class="k">def</span> <span class="nf">IsPurelyCategorical</span><span class="p">(</span><span class="n">vars_and_data</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Check if all variables are categorical</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        vars_and_data : dictionary&lt; toy_setup.VariableDescription, np.array(N) &gt;</span>
+<span class="sd">            Samples with meta-data.</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        purely categorical : bool</span>
+<span class="sd">            If all variables in vars_and_data are categorical, return true, otherwise false.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">for</span> <span class="n">var</span> <span class="ow">in</span> <span class="n">vars_and_data</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
+            <span class="k">if</span> <span class="ow">not</span> <span class="n">var</span><span class="o">.</span><span class="n">Id</span><span class="p">()</span><span class="o">.</span><span class="n">is_categorical</span><span class="p">:</span>
+                <span class="k">return</span> <span class="kc">False</span>
+        <span class="k">return</span> <span class="kc">True</span>
+
+    <span class="nd">@staticmethod</span>
+    <span class="k">def</span> <span class="nf">_FixZeroDim</span><span class="p">(</span><span class="n">continuous_data</span><span class="p">,</span> <span class="n">categorical_data</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;[INTERNAL] Ensure consistent shape (0,N) for batches containing zero categorical or continuous variables&quot;&quot;&quot;</span>
+        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">continuous_data</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
+            <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">categorical_data</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">0</span>
+            <span class="n">continuous_data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="n">categorical_data</span><span class="p">)[</span><span class="mi">1</span><span class="p">]],</span> <span class="n">dtype</span><span class="o">=</span><span class="s2">&quot;float64&quot;</span><span class="p">)</span>
+            <span class="n">categorical_data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">categorical_data</span><span class="p">)</span>
+        <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">categorical_data</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
+            <span class="n">categorical_data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="n">continuous_data</span><span class="p">)[</span><span class="mi">1</span><span class="p">]],</span> <span class="n">dtype</span><span class="o">=</span><span class="s2">&quot;int32&quot;</span><span class="p">)</span>
+            <span class="n">continuous_data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">continuous_data</span><span class="p">)</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="n">continuous_data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">continuous_data</span><span class="p">)</span>
+            <span class="n">categorical_data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">categorical_data</span><span class="p">)</span>
+        <span class="k">return</span> <span class="n">continuous_data</span><span class="p">,</span> <span class="n">categorical_data</span>
+
+    <span class="nd">@staticmethod</span>
+    <span class="k">def</span> <span class="nf">Get_data_via_var_ids</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">var_ids</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;For a subset of variables, get separate batches for continuous and categorical data, and category-shape</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        x : dictionary&lt; toy_setup.VariableDescription, np.array(N) &gt;</span>
+<span class="sd">            Samples and meta-data.</span>
+<span class="sd">        var_ids : *iterable* &lt;toy_setup.VariableDescription&gt;</span>
+<span class="sd">            Subset of variables to extract data for.</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        continuous_data : np.array( # continuous variables in var_ids, # samples )</span>
+<span class="sd">            Continuous entries of the data.</span>
+<span class="sd">        categorical_data : np.array( # categorical variables in var_ids, # samples )</span>
+<span class="sd">            Categorical entries of the data.</span>
+<span class="sd">        category_shape : list &lt;uint&gt;</span>
+<span class="sd">            List of the number of categories for each categorical variable in var_ids in the same ordering.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="n">category_shape</span> <span class="o">=</span> <span class="p">[]</span>
+        <span class="n">categorical_data</span> <span class="o">=</span> <span class="p">[]</span>
+        <span class="n">continuous_data</span> <span class="o">=</span> <span class="p">[]</span>
+        <span class="k">for</span> <span class="n">desc</span> <span class="ow">in</span> <span class="n">var_ids</span><span class="p">:</span>
+            <span class="k">if</span> <span class="n">desc</span><span class="o">.</span><span class="n">is_categorical</span><span class="p">:</span>
+                <span class="n">category_shape</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">desc</span><span class="o">.</span><span class="n">categories</span><span class="p">)</span>
+                <span class="n">categorical_data</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="n">desc</span><span class="p">])</span>
+            <span class="k">else</span><span class="p">:</span>
+                <span class="n">continuous_data</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="n">desc</span><span class="p">])</span>
+        <span class="k">return</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">_FixZeroDim</span><span class="p">(</span><span class="n">continuous_data</span><span class="p">,</span> <span class="n">categorical_data</span><span class="p">)</span> <span class="o">+</span> <span class="p">(</span><span class="n">category_shape</span><span class="p">,)</span>
+
+    <span class="nd">@classmethod</span>
+    <span class="k">def</span> <span class="nf">Split_data_into_categorical_and_continuous</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get separate batches for continuous and categorical data, and category-shape</span>
+
+<span class="sd">        (see Get_data_via_var_ids)</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">Get_data_via_var_ids</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
+
+    <span class="nd">@staticmethod</span>
+    <span class="k">def</span> <span class="nf">CategoryCount</span><span class="p">(</span><span class="n">category_shape</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get total number of categories in shape.</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        category_shape : list&lt;uint&gt;</span>
+<span class="sd">            Number of categories per variable.</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        total : uint</span>
+<span class="sd">            Total number of categories in the product.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="n">result</span> <span class="o">=</span> <span class="mi">1</span>
+        <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">category_shape</span><span class="p">:</span>
+            <span class="n">result</span> <span class="o">*=</span> <span class="n">c</span>
+        <span class="k">return</span> <span class="n">result</span>
+
+    <span class="nd">@staticmethod</span>
+    <span class="k">def</span> <span class="nf">Get_Len</span><span class="p">(</span><span class="n">continuous</span><span class="p">,</span> <span class="n">categorical</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Extract number of samples from data&quot;&quot;&quot;</span>
+        <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="n">continuous</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
+            <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="n">continuous</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="k">assert</span> <span class="n">np</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="n">categorical</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">0</span>
+            <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="n">categorical</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span>
+
+    <span class="nd">@staticmethod</span>
+    <span class="k">def</span> <span class="nf">SimplifyIfTrivialVector</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Make shapes consistent.&quot;&quot;&quot;</span>
+        <span class="n">result</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">squeeze</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
+        <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="n">result</span><span class="p">)</span> <span class="o">==</span> <span class="p">():</span>
+            <span class="k">return</span> <span class="n">result</span><span class="p">[()]</span>  <span class="c1"># turn a scalar from array(x) of shape () to an actual scalar</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="k">return</span> <span class="n">result</span>
+
+    <span class="nd">@classmethod</span>
+    <span class="k">def</span> <span class="nf">Call_map</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Execute call consistently.&quot;&quot;&quot;</span>
+        <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="s1">&#39;__iter__&#39;</span><span class="p">):</span>
+            <span class="n">result</span> <span class="o">=</span> <span class="p">[]</span>
+            <span class="k">for</span> <span class="n">coord</span> <span class="ow">in</span> <span class="n">f</span><span class="p">:</span>
+                <span class="n">result</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="n">Call_map</span><span class="p">(</span><span class="n">coord</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
+            <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
+        <span class="k">if</span> <span class="nb">callable</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
+            <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">SimplifyIfTrivialVector</span><span class="p">(</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">SimplifyIfTrivialVector</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="n">predict</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
+
+
+<span class="k">class</span> <span class="nc">FitProvider_Continuous_Default</span><span class="p">:</span>
+<span class="w">    </span><span class="sa">r</span><span class="sd">&quot;&quot;&quot;Helper for fitting continuous maps.</span>
+
+<span class="sd">    See &quot;Technical Appendix B&quot; of the Causal Mediation Tutorial.</span>
+
+<span class="sd">    Parameters</span>
+<span class="sd">    ----------</span>
+<span class="sd">    fit_map : *callable* (np.array(N, dim x), np.array(N))</span>
+<span class="sd">        A callable, that given data (x,y) fits a regressor f s.t. y = f(x)</span>
+<span class="sd">    fit_map_1d : *None* or *callable* (np.array(N, 1), np.array(N))</span>
+<span class="sd">        overwrite fit_map in the case of a 1-dimensional domain.</span>
+<span class="sd">    &quot;&quot;&quot;</span>
+
+    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fit_map</span><span class="p">,</span> <span class="n">fit_map_1d</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">fit_map</span> <span class="o">=</span> <span class="n">fit_map</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">fit_map_1d</span> <span class="o">=</span> <span class="n">fit_map_1d</span>
+
+    <span class="nd">@classmethod</span>
+    <span class="k">def</span> <span class="nf">UseSklearn</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">neighbors</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">weights</span><span class="o">=</span><span class="s1">&#39;uniform&#39;</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Use an sci-kit learn KNeighborsRegressor</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        neighbors : uint</span>
+<span class="sd">            The number of neighbors to consider</span>
+<span class="sd">        weights : string</span>
+<span class="sd">            Either &#39;uniform&#39; or &#39;radius&#39;, see sci-kit learn.</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        K-Neighbors Fit-Provider : FitProvider_Continuous_Default</span>
+<span class="sd">            Fit-Provider for use with FitSetup.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">KNeighborsRegressor</span><span class="p">(</span><span class="n">n_neighbors</span><span class="o">=</span><span class="n">neighbors</span><span class="p">,</span> <span class="n">weights</span><span class="o">=</span><span class="n">weights</span><span class="p">)</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">))</span>
+
+    <span class="nd">@classmethod</span>
+    <span class="k">def</span> <span class="nf">UseSklearn_GC</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Use an sci-kit learn GaussianProcessRegressor</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        ... : any-type</span>
+<span class="sd">            forwarded to sci-kit</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        GC Fit-Provider : FitProvider_Continuous_Default</span>
+<span class="sd">            Fit-Provider for use with FitSetup.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="kn">from</span> <span class="nn">sklearn.gaussian_process</span> <span class="kn">import</span> <span class="n">GaussianProcessRegressor</span>
+        <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">GaussianProcessRegressor</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">))</span>
+
+    <span class="k">def</span> <span class="nf">Get_Fit_Continuous</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Produce a fit</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        x : np.array(N, dim x)</span>
+<span class="sd">            Predictor values</span>
+<span class="sd">        y : np.array(N)</span>
+<span class="sd">            Training values</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        Continuous Fit : *callable* (x)</span>
+<span class="sd">            The fitted predictor.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="n">dim_of_domain</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="n">x</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span>
+        <span class="k">if</span> <span class="n">dim_of_domain</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
+            <span class="k">return</span> <span class="k">lambda</span> <span class="n">x_dim_zero</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
+        <span class="k">elif</span> <span class="n">dim_of_domain</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_map_1d</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
+            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_map_1d</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>  <span class="c1"># use splines?</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_map</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
+
+
+<span class="k">class</span> <span class="nc">FitProvider_Density_Default</span><span class="p">:</span>
+<span class="w">    </span><span class="sa">r</span><span class="sd">&quot;&quot;&quot;Helper for fitting continuous densities.</span>
+
+<span class="sd">   See &quot;Technical Appendix B&quot; of the Causal Mediation Tutorial.</span>
+
+<span class="sd">   Parameters</span>
+<span class="sd">   ----------</span>
+<span class="sd">   fit_density : *callable* (np.array(N, dim x))</span>
+<span class="sd">       A callable, that given data (x) fits a density estimator p s.t. x ~ p</span>
+<span class="sd">   &quot;&quot;&quot;</span>
+
+    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fit_density</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">fit_density</span> <span class="o">=</span> <span class="n">fit_density</span>
+
+    <span class="nd">@classmethod</span>
+    <span class="k">def</span> <span class="nf">UseSklearn</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">kernel</span><span class="o">=</span><span class="s1">&#39;gaussian&#39;</span><span class="p">,</span> <span class="n">bandwidth</span><span class="o">=</span><span class="mf">0.2</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Use an sci-kit learn KernelDensity</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        kernel : string</span>
+<span class="sd">            E.g. &#39;gaussian&#39;, see sci-kit learn documentation.</span>
+<span class="sd">        bandwidth : float</span>
+<span class="sd">            See sci-kit learn documentation.</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        Density Estimator : FitProvider_Density_Default</span>
+<span class="sd">            Fit-Provider for use with FitSetup.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">KernelDensity</span><span class="p">(</span><span class="n">kernel</span><span class="o">=</span><span class="n">kernel</span><span class="p">,</span> <span class="n">bandwidth</span><span class="o">=</span><span class="n">bandwidth</span><span class="p">)</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
+
+    <span class="k">def</span> <span class="nf">Get_Fit_Density</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x_train</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Produce a fit</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        x_train : np.array(N, dim x)</span>
+<span class="sd">            Training samples.</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        Density Estimate : *callable* (x)</span>
+<span class="sd">            The fitted predictor.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="n">dim_of_domain</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="n">x_train</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span>
+        <span class="k">if</span> <span class="n">dim_of_domain</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
+            <span class="k">return</span> <span class="k">lambda</span> <span class="n">x_dim_zero</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="n">x_dim_zero</span><span class="p">)[</span><span class="mi">0</span><span class="p">])</span>
+        <span class="k">elif</span> <span class="n">np</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="n">x_train</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
+            <span class="n">model</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_density</span><span class="p">(</span><span class="n">x_train</span><span class="p">)</span>
+            <span class="k">return</span> <span class="k">lambda</span> <span class="n">x_predict</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">score_samples</span><span class="p">(</span><span class="n">x_predict</span><span class="p">))</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="k">return</span> <span class="k">lambda</span> <span class="n">x_predict</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="n">x_predict</span><span class="p">)[</span><span class="mi">0</span><span class="p">])</span>
+
+
+<span class="k">class</span> <span class="nc">MixedMap</span><span class="p">:</span>
+<span class="w">    </span><span class="sd">&quot;&quot;&quot;Helper to evaluate fitted maps on mixed data.</span>
+
+<span class="sd">    Used internally, should not normally be required in user-code.</span>
+<span class="sd">    &quot;&quot;&quot;</span>
+    <span class="n">error_value</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="s1">&#39;nan&#39;</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">maps</span><span class="p">,</span> <span class="n">var_ids</span><span class="p">,</span> <span class="n">dtype</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">maps</span> <span class="o">=</span> <span class="n">maps</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">var_ids</span> <span class="o">=</span> <span class="n">var_ids</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">dtype</span> <span class="o">=</span> <span class="n">dtype</span>
+
+    <span class="k">def</span> <span class="nf">predict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Given x, predict y.&quot;&quot;&quot;</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="fm">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Given x, predict y.&quot;&quot;&quot;</span>
+        <span class="n">continuous_data</span><span class="p">,</span> <span class="n">categorical_data</span><span class="p">,</span> <span class="n">category_shape</span> <span class="o">=</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">Get_data_via_var_ids</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">var_ids</span><span class="p">)</span>
+        <span class="n">category_count</span> <span class="o">=</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">CategoryCount</span><span class="p">(</span><span class="n">category_shape</span><span class="p">)</span>
+        <span class="k">if</span> <span class="n">category_count</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>  <span class="c1"># avoid errors in ravel_multi_index and improve performance by treating separately</span>
+            <span class="k">return</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">Call_map</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">maps</span><span class="p">,</span> <span class="n">continuous_data</span><span class="o">.</span><span class="n">T</span><span class="p">)</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="n">categories</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ravel_multi_index</span><span class="p">(</span><span class="n">categorical_data</span><span class="p">,</span> <span class="n">category_shape</span><span class="p">)</span>
+            <span class="n">result</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="n">MixedData</span><span class="o">.</span><span class="n">Get_Len</span><span class="p">(</span><span class="n">continuous_data</span><span class="p">,</span> <span class="n">categorical_data</span><span class="p">),</span> <span class="n">dtype</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">dtype</span><span class="p">)</span>
+            <span class="k">for</span> <span class="n">cX</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">category_count</span><span class="p">):</span>
+                <span class="n">filter_x</span> <span class="o">=</span> <span class="p">(</span><span class="n">categories</span> <span class="o">==</span> <span class="n">cX</span><span class="p">)</span>
+                <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">count_nonzero</span><span class="p">(</span><span class="n">filter_x</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
+                    <span class="c1"># Avoid errors if asking for prediction on data with cX not occurring</span>
+                    <span class="c1"># (Queries must be validated elsewhere)</span>
+                    <span class="n">filtered_x</span> <span class="o">=</span> <span class="n">continuous_data</span><span class="p">[:,</span> <span class="n">filter_x</span><span class="p">]</span>
+                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">maps</span><span class="p">[</span><span class="n">cX</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
+                        <span class="n">result</span><span class="p">[</span><span class="n">filter_x</span><span class="p">]</span> <span class="o">=</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">Call_map</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">maps</span><span class="p">[</span><span class="n">cX</span><span class="p">],</span> <span class="n">filtered_x</span><span class="o">.</span><span class="n">T</span><span class="p">)</span>
+                    <span class="k">else</span><span class="p">:</span>
+                        <span class="n">result</span><span class="p">[</span><span class="n">filter_x</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_value</span>
+            <span class="k">return</span> <span class="n">result</span>
+
+
+<span class="k">class</span> <span class="nc">MixedMarkovKernel</span><span class="p">:</span>
+<span class="w">    </span><span class="sd">&quot;&quot;&quot;Helper to evaluate fitted densities on mixed data.</span>
+
+<span class="sd">    Used internally, should not normally be required in user-code.</span>
+<span class="sd">    &quot;&quot;&quot;</span>
+    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">transfers</span><span class="p">,</span> <span class="n">var_ids</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">output_category_count</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">transfers</span> <span class="o">=</span> <span class="n">transfers</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">var_ids</span> <span class="o">=</span> <span class="n">var_ids</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">dtype</span> <span class="o">=</span> <span class="n">dtype</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">output_category_count</span> <span class="o">=</span> <span class="n">output_category_count</span>
+
+    <span class="k">def</span> <span class="nf">predict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Given np.array x, predict probability of each sample.&quot;&quot;&quot;</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="fm">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Given np.array x, predict probability of each sample.&quot;&quot;&quot;</span>
+        <span class="n">continuous_data</span><span class="p">,</span> <span class="n">categorical_data</span><span class="p">,</span> <span class="n">category_shape</span> <span class="o">=</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">Get_data_via_var_ids</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">var_ids</span><span class="p">)</span>
+        <span class="n">category_count</span> <span class="o">=</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">CategoryCount</span><span class="p">(</span><span class="n">category_shape</span><span class="p">)</span>
+        <span class="n">categories</span> <span class="o">=</span> <span class="kc">None</span>
+        <span class="k">if</span> <span class="n">category_count</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>  <span class="c1"># avoid errors in ravel_multi_index and improve performance by treating separately</span>
+            <span class="n">categories</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="n">continuous_data</span><span class="p">)[</span><span class="mi">1</span><span class="p">])</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="n">categories</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ravel_multi_index</span><span class="p">(</span><span class="n">categorical_data</span><span class="p">,</span> <span class="n">category_shape</span><span class="p">)</span>
+
+        <span class="n">values</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">output_category_count</span><span class="p">,</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">Get_Len</span><span class="p">(</span><span class="n">continuous_data</span><span class="p">,</span> <span class="n">categorical_data</span><span class="p">)])</span>
+        <span class="k">for</span> <span class="n">cX</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">category_count</span><span class="p">):</span>
+            <span class="n">filter_x</span> <span class="o">=</span> <span class="p">(</span><span class="n">categories</span> <span class="o">==</span> <span class="n">cX</span><span class="p">)</span>
+            <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">count_nonzero</span><span class="p">(</span><span class="n">filter_x</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
+                <span class="c1"># Avoid errors if asking for prediction on data with cX not occurring</span>
+                <span class="c1"># (Queries must be validated elsewhere)</span>
+                <span class="n">filtered_x</span> <span class="o">=</span> <span class="n">continuous_data</span><span class="p">[:,</span> <span class="n">filter_x</span><span class="p">]</span>
+                <span class="k">for</span> <span class="n">cY</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">output_category_count</span><span class="p">):</span>
+                    <span class="n">transfer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">transfers</span><span class="p">[</span><span class="n">cX</span><span class="p">][</span><span class="n">cY</span><span class="p">]</span>
+                    <span class="n">values</span><span class="p">[</span><span class="n">cY</span><span class="p">][</span><span class="n">filter_x</span><span class="p">]</span> <span class="o">=</span> <span class="n">transfer</span><span class="p">(</span><span class="n">filtered_x</span><span class="o">.</span><span class="n">T</span><span class="p">)</span>
+        <span class="n">normalize</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">values</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
+        <span class="k">return</span> <span class="p">(</span><span class="n">values</span> <span class="o">/</span> <span class="n">normalize</span><span class="p">)</span><span class="o">.</span><span class="n">T</span>
+
+
+<span class="k">class</span> <span class="nc">FitSetup</span><span class="p">:</span>
+<span class="w">    </span><span class="sd">&quot;&quot;&quot;Helper to fit mixed data.</span>
+
+<span class="sd">   See &quot;Technical Appendix B&quot; of the Causal Mediation Tutorial.</span>
+<span class="sd">    &quot;&quot;&quot;</span>
+    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fit_map</span><span class="o">=</span><span class="n">FitProvider_Continuous_Default</span><span class="o">.</span><span class="n">UseSklearn</span><span class="p">(),</span>
+                 <span class="n">fit_density</span><span class="o">=</span><span class="n">FitProvider_Density_Default</span><span class="o">.</span><span class="n">UseSklearn</span><span class="p">()):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">fit_map</span> <span class="o">=</span> <span class="n">fit_map</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">fit_density</span> <span class="o">=</span> <span class="n">fit_density</span>
+
+    <span class="k">def</span> <span class="nf">Fit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">domain</span><span class="p">,</span> <span class="n">target</span><span class="p">,</span> <span class="n">dont_wrap_1d_y_in_vector</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Fit a mixed data mapping.</span>
+
+<span class="sd">        See &quot;Technical Appendix B&quot; of the Causal Mediation Tutorial.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="n">dont_wrap</span> <span class="o">=</span> <span class="n">dont_wrap_1d_y_in_vector</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">target</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span>
+        <span class="n">result</span> <span class="o">=</span> <span class="p">{}</span>
+        <span class="k">for</span> <span class="n">y</span><span class="p">,</span> <span class="n">train</span> <span class="ow">in</span> <span class="n">target</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
+            <span class="n">_next</span> <span class="o">=</span> <span class="kc">None</span>
+            <span class="k">if</span> <span class="n">y</span><span class="o">.</span><span class="n">is_categorical</span><span class="p">:</span>
+                <span class="n">_next</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Fit_CategoricalTarget_MarkovKernel</span><span class="p">(</span><span class="n">domain</span><span class="p">,</span> <span class="n">train</span><span class="p">,</span> <span class="n">y</span><span class="o">.</span><span class="n">categories</span><span class="p">)</span>
+            <span class="k">else</span><span class="p">:</span>
+                <span class="n">_next</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Fit_ContinuousTarget</span><span class="p">(</span><span class="n">domain</span><span class="p">,</span> <span class="n">train</span><span class="p">,</span> <span class="n">y</span><span class="o">.</span><span class="n">dimension</span><span class="p">)</span>
+            <span class="k">if</span> <span class="n">dont_wrap</span><span class="p">:</span>
+                <span class="k">return</span> <span class="n">_next</span>
+            <span class="k">else</span><span class="p">:</span>
+                <span class="n">result</span><span class="p">[</span><span class="n">y</span><span class="p">]</span> <span class="o">=</span> <span class="n">_next</span>
+        <span class="k">return</span> <span class="n">result</span>
+
+    <span class="k">def</span> <span class="nf">Fit_ContinuousTarget</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">dim_y</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Fit a mixed-domain mapping with continuous target.&quot;&quot;&quot;</span>
+        <span class="k">if</span> <span class="n">dim_y</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
+            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">Fit_ContinuousTarget_1D</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="n">result</span> <span class="o">=</span> <span class="p">[]</span>
+            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">dim_y</span><span class="p">):</span>
+                <span class="n">result</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">Fit_ContinuousTarget_1D</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">[:,</span> <span class="n">i</span><span class="p">]))</span>
+            <span class="k">return</span> <span class="n">result</span>
+
+    <span class="k">def</span> <span class="nf">Fit_ContinuousTarget_1D</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Fit a mixed-domain mapping with 1-dimensional continuous target.&quot;&quot;&quot;</span>
+        <span class="n">continuous_data</span><span class="p">,</span> <span class="n">categorical_data</span><span class="p">,</span> <span class="n">category_shape</span> <span class="o">=</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">Split_data_into_categorical_and_continuous</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
+
+        <span class="n">category_count</span> <span class="o">=</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">CategoryCount</span><span class="p">(</span><span class="n">category_shape</span><span class="p">)</span>
+        <span class="k">if</span> <span class="n">category_count</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
+            <span class="c1"># Avoid errors in np.ravel_multi_index and improve performance by treating this case separately</span>
+            <span class="n">_map</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_map</span><span class="o">.</span><span class="n">Get_Fit_Continuous</span><span class="p">(</span><span class="n">continuous_data</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
+            <span class="k">return</span> <span class="n">MixedMap</span><span class="p">(</span><span class="n">_map</span><span class="p">,</span> <span class="n">var_ids</span><span class="o">=</span><span class="n">x</span><span class="o">.</span><span class="n">keys</span><span class="p">(),</span> <span class="n">dtype</span><span class="o">=</span><span class="n">y</span><span class="o">.</span><span class="n">dtype</span><span class="p">)</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="c1"># Fit once per category</span>
+            <span class="n">category_index</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ravel_multi_index</span><span class="p">(</span><span class="n">categorical_data</span><span class="p">,</span> <span class="n">category_shape</span><span class="p">)</span>
+            <span class="n">maps</span> <span class="o">=</span> <span class="p">{}</span>
+            <span class="k">for</span> <span class="n">cX</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">category_count</span><span class="p">):</span>
+                <span class="n">filter_x</span> <span class="o">=</span> <span class="p">(</span><span class="n">category_index</span> <span class="o">==</span> <span class="n">cX</span><span class="p">)</span>
+                <span class="n">filtered_y</span> <span class="o">=</span> <span class="n">y</span><span class="p">[</span><span class="n">filter_x</span><span class="p">]</span>
+                <span class="n">filtered_x</span> <span class="o">=</span> <span class="n">continuous_data</span><span class="p">[:,</span> <span class="n">filter_x</span><span class="p">]</span>
+                <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">count_nonzero</span><span class="p">(</span><span class="n">filter_x</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
+                    <span class="n">maps</span><span class="p">[</span><span class="n">cX</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_map</span><span class="o">.</span><span class="n">Get_Fit_Continuous</span><span class="p">(</span><span class="n">filtered_x</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="n">filtered_y</span><span class="p">)</span>
+                <span class="k">else</span><span class="p">:</span>
+                    <span class="n">maps</span><span class="p">[</span><span class="n">cX</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
+            <span class="k">return</span> <span class="n">MixedMap</span><span class="p">(</span><span class="n">maps</span><span class="p">,</span> <span class="n">var_ids</span><span class="o">=</span><span class="n">x</span><span class="o">.</span><span class="n">keys</span><span class="p">(),</span> <span class="n">dtype</span><span class="o">=</span><span class="n">y</span><span class="o">.</span><span class="n">dtype</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">Fit_CategoricalTarget_MarkovKernel</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">y_category_count</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Fit a mixed-domain probabilistic mapping (a Markov-kernel) with categorical target.&quot;&quot;&quot;</span>
+        <span class="n">continuous_data</span><span class="p">,</span> <span class="n">categorical_data</span><span class="p">,</span> <span class="n">category_shape</span> <span class="o">=</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">Split_data_into_categorical_and_continuous</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
+
+        <span class="n">category_count</span> <span class="o">=</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">CategoryCount</span><span class="p">(</span><span class="n">category_shape</span><span class="p">)</span>
+        <span class="n">category_index</span> <span class="o">=</span> <span class="kc">None</span>
+        <span class="k">if</span> <span class="n">category_count</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
+            <span class="c1"># Avoid errors in np.ravel_multi_index and improve performance by treating this case separately</span>
+            <span class="n">category_index</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="n">continuous_data</span><span class="p">)[</span><span class="mi">1</span><span class="p">])</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="n">category_index</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ravel_multi_index</span><span class="p">(</span><span class="n">categorical_data</span><span class="p">,</span> <span class="n">category_shape</span><span class="p">)</span>
+
+        <span class="c1"># Compute the transfer-matrix</span>
+        <span class="n">transfer_matrix</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Fit_Enriched_TransferMatrix</span><span class="p">(</span><span class="n">continuous_data</span><span class="p">,</span>
+                                                            <span class="n">category_index</span><span class="p">,</span> <span class="n">category_count</span><span class="p">,</span>
+                                                            <span class="n">y</span><span class="p">,</span> <span class="n">y_category_count</span><span class="p">)</span>
+        <span class="k">return</span> <span class="n">MixedMarkovKernel</span><span class="p">(</span><span class="n">transfer_matrix</span><span class="p">,</span> <span class="n">var_ids</span><span class="o">=</span><span class="n">x</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">y</span><span class="o">.</span><span class="n">dtype</span><span class="p">,</span> <span class="n">output_category_count</span><span class="o">=</span><span class="n">y_category_count</span><span class="p">)</span>
+
+    <span class="nd">@staticmethod</span>
+    <span class="k">def</span> <span class="nf">_Fit_TransferMatrix</span><span class="p">(</span><span class="n">x_categorical</span><span class="p">,</span> <span class="n">x_category_count</span><span class="p">,</span> <span class="n">y_categorical</span><span class="p">,</span> <span class="n">y_category_count</span><span class="p">):</span>
+        <span class="n">transfers</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">([</span><span class="n">x_category_count</span><span class="p">,</span> <span class="n">y_category_count</span><span class="p">])</span>
+        <span class="k">for</span> <span class="n">cX</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">x_category_count</span><span class="p">):</span>
+            <span class="n">filter_x</span> <span class="o">=</span> <span class="p">(</span><span class="n">x_categorical</span> <span class="o">==</span> <span class="n">cX</span><span class="p">)</span>
+            <span class="n">filtered_y</span> <span class="o">=</span> <span class="n">y_categorical</span><span class="p">[</span><span class="n">filter_x</span><span class="p">]</span>
+            <span class="n">normalization</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">count_nonzero</span><span class="p">(</span><span class="n">filter_x</span><span class="p">)</span>
+            <span class="k">if</span> <span class="n">normalization</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
+                <span class="k">for</span> <span class="n">cY</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">y_category_count</span><span class="p">):</span>
+                    <span class="n">transfers</span><span class="p">[</span><span class="n">cX</span><span class="p">,</span> <span class="n">cY</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">count_nonzero</span><span class="p">(</span><span class="n">filtered_y</span> <span class="o">==</span> <span class="n">cY</span><span class="p">)</span> <span class="o">/</span> <span class="n">normalization</span>
+            <span class="k">else</span><span class="p">:</span>
+                <span class="n">transfers</span><span class="p">[</span><span class="n">cX</span><span class="p">,</span> <span class="n">cY</span><span class="p">]</span> <span class="o">=</span> <span class="n">MixedMap</span><span class="o">.</span><span class="n">error_value</span>
+        <span class="k">return</span> <span class="n">transfers</span>
+
+    <span class="k">def</span> <span class="nf">_Fit_Enriched_TransferMatrix</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x_continuous</span><span class="p">,</span>
+                                     <span class="n">x_categorical</span><span class="p">,</span> <span class="n">x_category_count</span><span class="p">,</span>
+                                     <span class="n">y_categorical</span><span class="p">,</span> <span class="n">y_category_count</span><span class="p">):</span>
+        <span class="n">transfers</span> <span class="o">=</span> <span class="p">[]</span>
+        <span class="k">for</span> <span class="n">cX</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">x_category_count</span><span class="p">):</span>
+            <span class="n">filter_x</span> <span class="o">=</span> <span class="p">(</span><span class="n">x_categorical</span> <span class="o">==</span> <span class="n">cX</span><span class="p">)</span>
+            <span class="n">normalization</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">count_nonzero</span><span class="p">(</span><span class="n">filter_x</span><span class="p">)</span>
+            <span class="n">transfers_from_cX</span> <span class="o">=</span> <span class="p">[]</span>
+            <span class="n">transfers</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">transfers_from_cX</span><span class="p">)</span>
+            <span class="k">if</span> <span class="n">normalization</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
+                <span class="k">for</span> <span class="n">cY</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">y_category_count</span><span class="p">):</span>
+                    <span class="c1"># Use Bayes&#39; Theorem to avoid fitting densities conditional on continuous variables</span>
+                    <span class="n">filter_both</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">logical_and</span><span class="p">(</span><span class="n">x_categorical</span> <span class="o">==</span> <span class="n">cX</span><span class="p">,</span> <span class="n">y_categorical</span> <span class="o">==</span> <span class="n">cY</span><span class="p">)</span>
+                    <span class="n">p_y_given_discrete_x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">count_nonzero</span><span class="p">(</span><span class="n">filter_both</span><span class="p">)</span> <span class="o">/</span> <span class="n">normalization</span>
+                    <span class="n">p_continuous_x_given_discrete_x_and_y</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_density</span><span class="o">.</span><span class="n">Get_Fit_Density</span><span class="p">(</span>
+                        <span class="n">x_continuous</span><span class="p">[:,</span> <span class="n">filter_both</span><span class="p">]</span><span class="o">.</span><span class="n">T</span><span class="p">)</span>
+                    <span class="c1"># Avoid weird bugs in lambda-captures combined with for-loop scopes by using &quot;functools-&gt;partial&quot;</span>
+                    <span class="n">transfers_from_cX</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">partial</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_EvalFromBayes</span><span class="p">,</span> <span class="n">p_y_given_discrete_x</span><span class="o">=</span><span class="n">p_y_given_discrete_x</span><span class="p">,</span>
+                                                     <span class="n">p_continuous_x_given_discrete_x_and_y</span><span class="o">=</span><span class="n">p_continuous_x_given_discrete_x_and_y</span><span class="p">))</span>
+                    <span class="c1"># transfers_from_cX.append(lambda x_c: self._EvalFromBayes(x_c, p_y_given_discrete_x,</span>
+                    <span class="c1">#                                                        p_continuous_x_given_discrete_x_and_y))</span>
+            <span class="k">else</span><span class="p">:</span>
+                <span class="k">for</span> <span class="n">cY</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">y_category_count</span><span class="p">):</span>
+                    <span class="n">transfers_from_cX</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x_c</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">full</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="n">x_c</span><span class="p">)[</span><span class="mi">0</span><span class="p">],</span> <span class="n">MixedMap</span><span class="o">.</span><span class="n">error_value</span><span class="p">))</span>
+        <span class="k">return</span> <span class="n">transfers</span>
+
+    <span class="nd">@staticmethod</span>
+    <span class="k">def</span> <span class="nf">_EvalFromBayes</span><span class="p">(</span><span class="n">x_c</span><span class="p">,</span> <span class="n">p_y_given_discrete_x</span><span class="p">,</span> <span class="n">p_continuous_x_given_discrete_x_and_y</span><span class="p">):</span>
+        <span class="c1"># P( y | x_c, x_d ) = P( x_c | x_d, y ) P( Y | x_d ) / normalization independent of y</span>
+        <span class="k">return</span> <span class="n">p_continuous_x_given_discrete_x_and_y</span><span class="p">(</span><span class="n">x_c</span><span class="p">)</span> <span class="o">*</span> <span class="n">p_y_given_discrete_x</span>
+
+
+
+
+
+<span class="sd">&quot;&quot;&quot;-------------------------------------------------------------------------------------------</span>
+<span class="sd">--------------------------------   Natural Effect Estimation   -------------------------------</span>
+<span class="sd">-------------------------------------------------------------------------------------------&quot;&quot;&quot;</span>
+
+<span class="k">class</span> <span class="nc">NaturalEffects_StandardMediationSetup</span><span class="p">:</span>
+<span class="w">    </span><span class="sa">r</span><span class="sd">&quot;&quot;&quot;Setup for estimating natural effects in a &quot;standard&quot; mediation (triangle) graph.</span>
+
+<span class="sd">    Methods for the non-parametric estimation of mediation effects.</span>
+<span class="sd">    For (more) general graphs, see NaturalEffects_GraphMediation.</span>
+
+<span class="sd">    Actual fit-models can be chosen independently, for details see</span>
+<span class="sd">    technical appendix B in the mediation-tutorial.</span>
+
+<span class="sd">    See references and tigramite tutorial for an in-depth introduction.</span>
+
+<span class="sd">    References</span>
+<span class="sd">    ----------</span>
+
+<span class="sd">    J. Pearl. Direct and indirect effects. Proceedings of the Seventeenth Conference</span>
+<span class="sd">    on Uncertainty in Artificial intelligence, 2001.</span>
+
+<span class="sd">    J. Pearl. Interpretation and identification of causal mediation. Psychological</span>
+<span class="sd">    methods, 19(4):459, 2014.</span>
+
+<span class="sd">    I. Shpitser and T. J. VanderWeele. A complete graphical criterion for the adjust-</span>
+<span class="sd">    ment formula in mediation analysis. The international journal of biostatistics,</span>
+<span class="sd">    7(1), 2011.</span>
+
+<span class="sd">    Parameters</span>
+<span class="sd">    ----------</span>
+<span class="sd">    fit_setup : fit model</span>
+<span class="sd">        A fit model to use internally, e.g. mixed_fit.FitSetup(). See there or technical</span>
+<span class="sd">        appendix B of the tutorial.</span>
+<span class="sd">    source : toy_setup.VariableDescription</span>
+<span class="sd">        The (description of, e.g. toy_setup.ContinuousVariable()) the effect-source.</span>
+<span class="sd">    target : toy_setup.VariableDescription</span>
+<span class="sd">        The (description of, e.g. toy_setup.ContinuousVariable()) the effect-target.</span>
+<span class="sd">    mediator : toy_setup.VariableDescription</span>
+<span class="sd">        The (description of, e.g. toy_setup.ContinuousVariable()) the effect-mediator.</span>
+<span class="sd">    data : dictionary ( keys=toy_setup.VariableDescription, values=np.array(N) )</span>
+<span class="sd">        The data as map variable-description -&gt; samples; e.g. toy_setup.world.Observables(),</span>
+<span class="sd">        or toy_setup.VariablesFromDataframe( tigramite dataframe )</span>
+<span class="sd">    &quot;&quot;&quot;</span>
+
+    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fit_setup</span><span class="p">,</span> <span class="n">source</span><span class="p">,</span> <span class="n">target</span><span class="p">,</span> <span class="n">mediator</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">fit_setup</span> <span class="o">=</span> <span class="n">fit_setup</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">X</span> <span class="o">=</span> <span class="n">source</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">Y</span> <span class="o">=</span> <span class="n">target</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">M</span> <span class="o">=</span> <span class="n">mediator</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">x</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">source</span><span class="p">]</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">y</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">target</span><span class="p">]</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">m</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">mediator</span><span class="p">]</span>
+        <span class="n">X</span> <span class="o">=</span> <span class="n">source</span>
+        <span class="n">Y</span> <span class="o">=</span> <span class="n">target</span>
+        <span class="n">M</span> <span class="o">=</span> <span class="n">mediator</span>
+        <span class="n">x</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">source</span><span class="p">]</span>
+        <span class="n">y</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">target</span><span class="p">]</span>
+        <span class="n">m</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">mediator</span><span class="p">]</span>
+
+        <span class="bp">self</span><span class="o">.</span><span class="n">_E_Y_XM</span> <span class="o">=</span> <span class="kc">None</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">_P_Y_XM</span> <span class="o">=</span> <span class="kc">None</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">_P_M_X</span> <span class="o">=</span> <span class="kc">None</span>
+
+    <span class="k">def</span> <span class="nf">E_Y_XM_fixed_x_obs_m</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;[internal] Provide samples Y( fixed x, observed m ) from fit of E[Y|X,M]</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        x : single value of same type as single sample for X (float, int, or bool)</span>
+<span class="sd">            The fixed value of X.</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        Y( fixed x, observed m ) : np.array(N)</span>
+<span class="sd">            Samples of Y estimated from observations and fit.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_E_Y_XM</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">_E_Y_XM</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_setup</span><span class="o">.</span><span class="n">Fit</span><span class="p">({</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">M</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">m</span><span class="p">},</span> <span class="p">{</span><span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">y</span><span class="p">})</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_E_Y_XM</span><span class="p">({</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">full_like</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">M</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">m</span><span class="p">})</span>
+
+    <span class="k">def</span> <span class="nf">E_Y_XM_fixed_x_all_m</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;For categorical M, provide samples Y( fixed x, m_i ) for all categories m_i of M from fit of E[Y|X,M]</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        x : single value of same type as single sample for X (float, int, or bool)</span>
+<span class="sd">            The fixed value of X.</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        Y( fixed x, all  m_i ) : np.array(# of categories of M)</span>
+<span class="sd">            Samples of Y estimated from fit for all categories of the mediator M.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">assert</span> <span class="bp">self</span><span class="o">.</span><span class="n">M</span><span class="o">.</span><span class="n">is_categorical</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_E_Y_XM</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">_E_Y_XM</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_setup</span><span class="o">.</span><span class="n">Fit</span><span class="p">({</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">M</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">m</span><span class="p">},</span> <span class="p">{</span><span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">y</span><span class="p">})</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_E_Y_XM</span><span class="p">({</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">full</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">M</span><span class="o">.</span><span class="n">categories</span><span class="p">,</span> <span class="n">x</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">M</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">M</span><span class="o">.</span><span class="n">categories</span><span class="p">)})</span>
+
+    <span class="k">def</span> <span class="nf">P_Y_XM_fixed_x_obs_m</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Provide for all samples of M the likelihood P( Y | fixed x, observed m ) from fit of P[Y|X,M]</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        x : single value of same type as single sample for X (float, int, or bool)</span>
+<span class="sd">            The fixed value of X.</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        P( Y | fixed x, observed m ) : np.array(N, # categories of Y)</span>
+<span class="sd">            Likelihood of each category of Y given x and observations of m from fit.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_P_Y_XM</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">_P_Y_XM</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_setup</span><span class="o">.</span><span class="n">Fit</span><span class="p">({</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">M</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">m</span><span class="p">},</span> <span class="p">{</span><span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">y</span><span class="p">})</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_P_Y_XM</span><span class="p">({</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">full_like</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">M</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">m</span><span class="p">})</span>
+
+    <span class="k">def</span> <span class="nf">P_M_X</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Provide the likelihood P( M | fixed x ) from fit of P[M|X]</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        x : single value of same type as single sample for X (float, int, or bool)</span>
+<span class="sd">            The fixed value of X.</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        P( M | fixed x ) : np.array( # categories of M )</span>
+<span class="sd">            Likelihood of each category of M given x and observations of m from fit.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_P_M_X</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">_P_M_X</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_setup</span><span class="o">.</span><span class="n">Fit</span><span class="p">({</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">x</span><span class="p">},</span> <span class="p">{</span><span class="bp">self</span><span class="o">.</span><span class="n">M</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">m</span><span class="p">})</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_P_M_X</span><span class="p">({</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">:</span> <span class="n">x</span><span class="p">})</span>
+
+    <span class="k">def</span> <span class="nf">_ValidateRequest</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Sanity-check parameters passed to effect-estimation</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        cf. NDE, NIE</span>
+
+<span class="sd">        Throws</span>
+<span class="sd">        ------</span>
+<span class="sd">        Raises and exception if parameters are not meaningful</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="o">.</span><span class="n">is_categorical</span><span class="p">:</span>
+            <span class="c1"># both_int = isinstance(change_from, int) and isinstance(change_to, int) does not work with numpy</span>
+            <span class="n">both_int</span> <span class="o">=</span> <span class="n">change_from</span> <span class="o">%</span> <span class="mi">1</span> <span class="o">==</span> <span class="mf">0.0</span> <span class="ow">and</span> <span class="n">change_to</span> <span class="o">%</span> <span class="mi">1</span> <span class="o">==</span> <span class="mf">0.0</span>
+            <span class="k">if</span> <span class="ow">not</span> <span class="n">both_int</span><span class="p">:</span>
+                <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;Categorical variables can only be intervened to integer values.&quot;</span><span class="p">)</span>
+            <span class="k">if</span> <span class="n">change_from</span> <span class="o">&gt;=</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="o">.</span><span class="n">categories</span> <span class="ow">or</span> <span class="n">change_to</span> <span class="o">&gt;=</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="o">.</span><span class="n">categories</span> <span class="ow">or</span> <span class="n">change_from</span> <span class="o">&lt;</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">change_to</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span>
+                <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;Intervention on categorical variable was outside of valid category-range.&quot;</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">NDE</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">,</span> <span class="n">fct_of_nde</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute Natural Direct Effect (NDE)</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        change_from : single value of same type as single sample for X (float, int, or bool)</span>
+<span class="sd">            Reference-value to which X is set by intervention in the world seen by the mediator.</span>
+
+<span class="sd">        change_to : single value of same type as single sample for X (float, int, or bool)</span>
+<span class="sd">            Post-intervention-value to which X is set by intervention in the world seen by the effect (directly).</span>
+
+<span class="sd">        fct_of_nde : *callable* or None</span>
+<span class="sd">            Also in the case of a continuous Y the distribution, not just the expectation is identified.</span>
+<span class="sd">            However, a density-fit is not usually reasonable to do in practise. However, instead of</span>
+<span class="sd">            computing E[Y] can compute E[f(Y)] efficiently for any f. Assume f=id if None.</span>
+
+<span class="sd">        Throws</span>
+<span class="sd">        ------</span>
+<span class="sd">        Raises and exception if parameters are not meaningful</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        NDE : If Y is categorical -&gt; np.array( # categories Y, 2 )</span>
+<span class="sd">            The probabilities the categories of Y (after, before) changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by Y from change_from to change_to, while keeping M as if X remained at change_from.</span>
+
+<span class="sd">        NDE : If Y is continuous -&gt; float</span>
+<span class="sd">            The change in the expectation-value of Y induced by changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by Y from change_from to change_to, while keeping M as if X remained at change_from.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">_ValidateRequest</span><span class="p">(</span><span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">)</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="o">.</span><span class="n">is_categorical</span><span class="p">:</span>
+            <span class="k">assert</span> <span class="n">fct_of_nde</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">,</span> <span class="s2">&quot;Categorical estimate returns full density-estimate anyway.&quot;</span>
+            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_NDE_categorical_target</span><span class="p">(</span><span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">)</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_NDE_continuous_target</span><span class="p">(</span><span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">,</span> <span class="n">fct_of_nde</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">NIE</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute Natural Indirect Effect (NIE)</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        change_from : single value of same type as single sample for X (float, int, or bool)</span>
+<span class="sd">           Reference-value to which X is set by intervention in the world seen by the effect (directly).</span>
+
+<span class="sd">        change_to : single value of same type as single sample for X (float, int, or bool)</span>
+<span class="sd">            Post-intervention-value to which X is set by intervention in the world seen by the mediator.</span>
+
+<span class="sd">        Throws</span>
+<span class="sd">        ------</span>
+<span class="sd">        Raises and exception if parameters are not meaningful</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        NIE : If Y is categorical -&gt; np.array( # categories Y, 2 )</span>
+<span class="sd">            The probabilities the categories of Y (after, before) changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by M from change_from to change_to, while keeping the value as (directly) seen by Y,</span>
+<span class="sd">            as if X remained at change_from.</span>
+
+<span class="sd">        NIE : If Y is continuous -&gt; float</span>
+<span class="sd">            The change in the expectation-value of Y induced by changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by M from change_from to change_to, while keeping the value as (directly) seen by Y,</span>
+<span class="sd">            as if X remained at change_from.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">_ValidateRequest</span><span class="p">(</span><span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">)</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="o">.</span><span class="n">is_categorical</span><span class="p">:</span>
+            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_NIE_categorical_target</span><span class="p">(</span><span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">)</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_NIE_continuous_target</span><span class="p">(</span><span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">_NDE_continuous_target</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">,</span> <span class="n">fct_of_nde</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute NDE (continuous Y)</span>
+
+<span class="sd">        See &#39;NDE&#39; above.</span>
+
+<span class="sd">        Computed from mediation-formula</span>
+<span class="sd">        (see [Pearl 2001] or [Shpitser, VanderWeele], see references above)</span>
+<span class="sd">        by &quot;double&quot;-regression.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="n">difference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">E_Y_XM_fixed_x_obs_m</span><span class="p">(</span><span class="n">change_to</span><span class="p">)</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">E_Y_XM_fixed_x_obs_m</span><span class="p">(</span><span class="n">change_from</span><span class="p">)</span>
+
+        <span class="k">if</span> <span class="n">fct_of_nde</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
+            <span class="n">difference</span> <span class="o">=</span> <span class="n">fct_of_nde</span><span class="p">(</span><span class="n">difference</span><span class="p">)</span>
+
+        <span class="c1"># sklearn predicts nan if too far from data ... (but might be irrelevant, check separately)</span>
+        <span class="n">valid_samples</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">isfinite</span><span class="p">(</span><span class="n">difference</span><span class="p">)</span>
+        <span class="n">Difference</span> <span class="o">=</span> <span class="n">toy_setup</span><span class="o">.</span><span class="n">ContinuousVariable</span><span class="p">()</span>
+        <span class="n">X</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span>
+        <span class="n">x</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">x</span>
+        <span class="n">E_Difference_X</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_setup</span><span class="o">.</span><span class="n">Fit</span><span class="p">({</span><span class="n">X</span><span class="p">:</span> <span class="n">x</span><span class="p">[</span><span class="n">valid_samples</span><span class="p">]},</span> <span class="p">{</span><span class="n">Difference</span><span class="p">:</span> <span class="n">difference</span><span class="p">[</span><span class="n">valid_samples</span><span class="p">]})</span>
+        <span class="k">return</span> <span class="n">E_Difference_X</span><span class="p">({</span><span class="n">X</span><span class="p">:</span> <span class="p">[</span><span class="n">change_from</span><span class="p">]})</span>
+
+    <span class="k">def</span> <span class="nf">_NDE_categorical_target_full_density</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">actual_value</span><span class="p">,</span> <span class="n">counterfactual_value</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute NDE as full density (categorical Y)</span>
+
+<span class="sd">        See &#39;NDE&#39; above.</span>
+
+<span class="sd">        Computed from mediation-formula</span>
+<span class="sd">        (see [Pearl 2001] or [Shpitser, VanderWeele], see references above)</span>
+<span class="sd">        by &quot;double&quot;-regression.</span>
+
+<span class="sd">        Note: According to (see p.13)</span>
+<span class="sd">        [Shpitser, VanderWeele: A Complete Graphical Criterion for theAdjustment Formula in Mediation Analysis]</span>
+<span class="sd">        not just the expectation-value, but the full counterfactual distribution can be obtained via mediation-formula.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="n">P_Y</span> <span class="o">=</span> <span class="n">toy_setup</span><span class="o">.</span><span class="n">ContinuousVariable</span><span class="p">(</span><span class="n">dimension</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="o">.</span><span class="n">categories</span><span class="p">)</span>
+        <span class="n">P_Y_samples</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">P_Y_XM_fixed_x_obs_m</span><span class="p">(</span><span class="n">actual_value</span><span class="p">)</span>
+        <span class="n">P_Y_X</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_setup</span><span class="o">.</span><span class="n">Fit</span><span class="p">({</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">x</span><span class="p">},</span> <span class="p">{</span><span class="n">P_Y</span><span class="p">:</span> <span class="n">P_Y_samples</span><span class="p">})</span>
+
+        <span class="k">return</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">Call_map</span><span class="p">(</span><span class="n">P_Y_X</span><span class="p">,</span> <span class="p">{</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">:</span> <span class="p">[</span><span class="n">counterfactual_value</span><span class="p">]})</span>
+
+    <span class="k">def</span> <span class="nf">_NDE_categorical_target</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">actual_value</span><span class="p">,</span> <span class="n">counterfactual_value</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute NDE by evaluating density (categorical Y)</span>
+
+<span class="sd">        See &#39;NDE&#39; and &#39;_NDE_categorical_target_full_density&#39; above.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="c1"># returns (counterfactual probabilities, total effect)</span>
+        <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">_NDE_categorical_target_full_density</span><span class="p">(</span><span class="n">counterfactual_value</span><span class="p">,</span> <span class="n">actual_value</span><span class="p">),</span>
+                         <span class="bp">self</span><span class="o">.</span><span class="n">_NDE_categorical_target_full_density</span><span class="p">(</span><span class="n">actual_value</span><span class="p">,</span> <span class="n">actual_value</span><span class="p">)])</span><span class="o">.</span><span class="n">T</span>
+
+    <span class="k">def</span> <span class="nf">_NIE_continuous_target</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute NIE (continuous Y)</span>
+
+<span class="sd">        See &#39;NIE&#39; above.</span>
+
+<span class="sd">        Computed from mediation-formula</span>
+<span class="sd">        (see [Pearl 2001] or [Shpitser, VanderWeele], see references above)</span>
+<span class="sd">        by &quot;double&quot;-regression.</span>
+
+<span class="sd">        If M is categorical, after fixing X=x, the fitted P( Y | X=x, M=m ), is actually</span>
+<span class="sd">        categorical (a transfer matrix), because it takes values only in</span>
+<span class="sd">        im( P ) = { P( Y | X=x, M=m_0 ), ...,  P( Y | X=x, M=m_k ) } where</span>
+<span class="sd">        m_0, ..., m_k are the categories of M. This is clearly a finite set.</span>
+<span class="sd">        Since the distribution over this finite subset of the continuous Val(Y)</span>
+<span class="sd">        is very non-gaussian, &quot;max likelihood by least square estimation&quot; can fail horribly.</span>
+<span class="sd">        Hence we fit a transfer-matrix instead.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="n">X</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span>
+        <span class="n">M</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">M</span>
+        <span class="n">x</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">x</span>
+        <span class="n">m</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">m</span>
+
+        <span class="k">if</span> <span class="n">M</span><span class="o">.</span><span class="n">is_categorical</span><span class="p">:</span>
+            <span class="c1"># if the image of the mapping in double-regression is finite, use a density fit instead</span>
+            <span class="n">p_M_X01</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">P_M_X</span><span class="p">([</span><span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">])</span>
+            <span class="n">E_YX0</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">E_Y_XM_fixed_x_all_m</span><span class="p">(</span><span class="n">change_from</span><span class="p">)</span>
+            <span class="c1"># sum over finite M:</span>
+            <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">E_YX0</span><span class="p">,</span> <span class="n">p_M_X01</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">p_M_X01</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
+
+        <span class="k">else</span><span class="p">:</span>
+            <span class="n">Estimate</span> <span class="o">=</span> <span class="n">toy_setup</span><span class="o">.</span><span class="n">ContinuousVariable</span><span class="p">()</span>
+            <span class="n">y_at_original_x</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">E_Y_XM_fixed_x_obs_m</span><span class="p">(</span><span class="n">change_from</span><span class="p">)</span>
+            <span class="n">ModifiedY</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_setup</span><span class="o">.</span><span class="n">Fit</span><span class="p">({</span><span class="n">X</span><span class="p">:</span> <span class="n">x</span><span class="p">},</span> <span class="p">{</span><span class="n">Estimate</span><span class="p">:</span> <span class="n">y_at_original_x</span><span class="p">})</span>
+            <span class="k">return</span> <span class="p">(</span><span class="n">MixedData</span><span class="o">.</span><span class="n">Call_map</span><span class="p">(</span><span class="n">ModifiedY</span><span class="p">,</span> <span class="p">{</span><span class="n">X</span><span class="p">:</span> <span class="p">[</span><span class="n">change_to</span><span class="p">]})</span>
+                    <span class="o">-</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">Call_map</span><span class="p">(</span><span class="n">ModifiedY</span><span class="p">,</span> <span class="p">{</span><span class="n">X</span><span class="p">:</span> <span class="p">[</span><span class="n">change_from</span><span class="p">]}))</span>
+
+    <span class="k">def</span> <span class="nf">_NIE_categorical_target</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute NIE (continuous Y)</span>
+
+<span class="sd">        See &#39;NIE&#39; above.</span>
+
+<span class="sd">        Computed from mediation-formula</span>
+<span class="sd">        (see [Pearl 2001] or [Shpitser, VanderWeele], see references above)</span>
+<span class="sd">        by &quot;double&quot;-regression.</span>
+
+<span class="sd">        Similar to before (see _NIE_continuous_target), treat categorical M differently.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="n">X</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span>
+        <span class="n">M</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">M</span>
+        <span class="n">x</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">x</span>
+        <span class="n">m</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">m</span>
+        <span class="n">py_at_original_x</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">P_Y_XM_fixed_x_obs_m</span><span class="p">(</span><span class="n">change_from</span><span class="p">)</span>
+
+        <span class="k">if</span> <span class="n">M</span><span class="o">.</span><span class="n">is_categorical</span><span class="p">:</span>
+            <span class="c1"># if the image of the mapping in double-regression is finite, use a density fit instead</span>
+            <span class="n">p_M_X01</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">P_M_X</span><span class="p">([</span><span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">])</span>
+            <span class="c1"># sum over finite M:</span>
+            <span class="n">result</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="o">.</span><span class="n">categories</span><span class="p">,</span> <span class="mi">2</span><span class="p">])</span>  <span class="c1"># 2 is for TE &amp; CF</span>
+            <span class="k">for</span> <span class="n">cM</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">M</span><span class="o">.</span><span class="n">categories</span><span class="p">):</span>
+                <span class="n">result</span> <span class="o">+=</span> <span class="n">np</span><span class="o">.</span><span class="n">outer</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">py_at_original_x</span><span class="p">[</span><span class="n">m</span> <span class="o">==</span> <span class="n">cM</span><span class="p">],</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">),</span> <span class="n">p_M_X01</span><span class="p">[:,</span> <span class="n">cM</span><span class="p">])</span>
+            <span class="k">return</span> <span class="n">result</span>
+
+        <span class="k">else</span><span class="p">:</span>
+            <span class="n">Estimate</span> <span class="o">=</span> <span class="n">toy_setup</span><span class="o">.</span><span class="n">ContinuousVariable</span><span class="p">(</span><span class="n">dimension</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="o">.</span><span class="n">categories</span><span class="p">)</span>
+            <span class="n">ModifiedY</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_setup</span><span class="o">.</span><span class="n">Fit</span><span class="p">({</span><span class="n">X</span><span class="p">:</span> <span class="n">x</span><span class="p">},</span> <span class="p">{</span><span class="n">Estimate</span><span class="p">:</span> <span class="n">py_at_original_x</span><span class="p">})</span>
+            <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">MixedData</span><span class="o">.</span><span class="n">Call_map</span><span class="p">(</span><span class="n">ModifiedY</span><span class="p">,</span> <span class="p">{</span><span class="n">X</span><span class="p">:</span> <span class="p">[</span><span class="n">change_to</span><span class="p">]}),</span>
+                             <span class="n">MixedData</span><span class="o">.</span><span class="n">Call_map</span><span class="p">(</span><span class="n">ModifiedY</span><span class="p">,</span> <span class="p">{</span><span class="n">X</span><span class="p">:</span> <span class="p">[</span><span class="n">change_from</span><span class="p">]})])</span><span class="o">.</span><span class="n">T</span>
+
+    <span class="k">def</span> <span class="nf">NDE_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">list_of_points</span><span class="p">,</span> <span class="n">cf_delta</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="n">normalize_by_delta</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">fct_of_nde</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute NDE as grided (unsmoothed) function</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        list_of_points : np.array( K )</span>
+<span class="sd">            List of reference-values at which to estimate NDEs</span>
+
+<span class="sd">        cf_delta : float</span>
+<span class="sd">            The change from reference-value to effect-value (change_from=reference, change_to=ref + delta)</span>
+
+<span class="sd">        normalize_by_delta : bool</span>
+<span class="sd">            Normalize the effect by dividing by cf_delta.</span>
+
+<span class="sd">        fct_of_nde : *callable* or None</span>
+<span class="sd">            Also in the case of a continuous Y the distribution, not just the expectation is identified.</span>
+<span class="sd">            However, a density-fit is not usually reasonable to do in practise. However, instead of</span>
+<span class="sd">            computing E[Y] can compute E[f(Y)] efficiently for any f. Assume f=id if None.</span>
+
+<span class="sd">        Throws</span>
+<span class="sd">        ------</span>
+<span class="sd">        Raises and exception if parameters are not meaningful</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        NDE : If Y is categorical -&gt; np.array( K = # grid points, # categories Y, 2 )</span>
+<span class="sd">            For each grid-point:</span>
+<span class="sd">            The probabilities the categories of Y (after, before) changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by Y from change_from to change_to, while keeping M as if X remained at change_from.</span>
+
+<span class="sd">        NDE : If Y is continuous -&gt; np.array( K = # grid points )</span>
+<span class="sd">            For each grid-point:</span>
+<span class="sd">            The change in the expectation-value of Y induced by changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by Y from change_from to change_to, while keeping M as if X remained at change_from.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">return</span> <span class="n">_Fct_on_grid</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">NDE</span><span class="p">,</span> <span class="n">list_of_points</span><span class="p">,</span> <span class="n">cf_delta</span><span class="p">,</span> <span class="n">normalize_by_delta</span><span class="p">,</span> <span class="n">fct_of_nde</span><span class="o">=</span><span class="n">fct_of_nde</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">NIE_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">list_of_points</span><span class="p">,</span> <span class="n">cf_delta</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="n">normalize_by_delta</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute NIE as grided (unsmoothed) function</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        list_of_points : np.array( K )</span>
+<span class="sd">            List of reference-values at which to estimate NIEs</span>
+
+<span class="sd">        cf_delta : float</span>
+<span class="sd">            The change from reference-value to effect-value (change_from=reference, change_to=ref + delta)</span>
+
+<span class="sd">        normalize_by_delta : bool</span>
+<span class="sd">            Normalize the effect by dividing by cf_delta.</span>
+
+<span class="sd">        Throws</span>
+<span class="sd">        ------</span>
+<span class="sd">        Raises and exception if parameters are not meaningful</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        NIE : If Y is categorical -&gt; np.array( K = # grid points, # categories Y, 2 )</span>
+<span class="sd">            For each grid-point:</span>
+<span class="sd">            The probabilities the categories of Y (after, before) changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by M from change_from to change_to, while keeping the value of X &quot;seen&quot; (directly)</span>
+<span class="sd">            by Y as if X remained at change_from.</span>
+
+<span class="sd">        NIE : If Y is continuous -&gt; np.array( K = # grid points )</span>
+<span class="sd">            For each grid-point:</span>
+<span class="sd">            The change in the expectation-value of Y induced by changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by M from change_from to change_to, while keeping the value of X &quot;seen&quot; (directly)</span>
+<span class="sd">            by Y as if X remained at change_from.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">return</span> <span class="n">_Fct_on_grid</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">NIE</span><span class="p">,</span> <span class="n">list_of_points</span><span class="p">,</span> <span class="n">cf_delta</span><span class="p">,</span> <span class="n">normalize_by_delta</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">NDE_smoothed</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">min_x</span><span class="p">,</span> <span class="n">max_x</span><span class="p">,</span> <span class="n">cf_delta</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="n">steps</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">smoothing_gaussian_sigma_in_steps</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span>
+                     <span class="n">normalize_by_delta</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">fct_of_nde</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute NDE as smoothed function</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        min_x : float</span>
+<span class="sd">            Lower bound of interval on which reference-values for X are taken</span>
+
+<span class="sd">        max_x : float</span>
+<span class="sd">            Upper bound of interval on which reference-values for X are taken</span>
+
+<span class="sd">        cf_delta : float</span>
+<span class="sd">            The change from reference-value to effect-value (change_from=reference, change_to=ref + delta)</span>
+
+<span class="sd">        steps : uint</span>
+<span class="sd">            Number of intermediate values to compute in the interval [min_x, max_x]</span>
+
+<span class="sd">        smoothing_gaussian_sigma_in_steps : uint</span>
+<span class="sd">            The width of the Gauß-kernel used for smoothing, given in steps.</span>
+
+<span class="sd">        normalize_by_delta : bool</span>
+<span class="sd">            Normalize the effect by dividing by cf_delta.</span>
+
+<span class="sd">        fct_of_nde : *callable* or None</span>
+<span class="sd">            Also in the case of a continuous Y the distribution, not just the expectation is identified.</span>
+<span class="sd">            However, a density-fit is not usually reasonable to do in practise. However, instead of</span>
+<span class="sd">            computing E[Y] can compute E[f(Y)] efficiently for any f. Assume f=id if None.</span>
+
+<span class="sd">        Throws</span>
+<span class="sd">        ------</span>
+<span class="sd">        Raises and exception if parameters are not meaningful</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        NDE : If Y is categorical -&gt; np.array( # steps, # categories Y, 2 )</span>
+<span class="sd">            For each grid-point:</span>
+<span class="sd">            The probabilities the categories of Y (after, before) changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by Y from change_from to change_to, while keeping M as if X remained at change_from.</span>
+
+<span class="sd">        NDE : If Y is continuous -&gt; np.array( # steps )</span>
+<span class="sd">            For each grid-point:</span>
+<span class="sd">            The change in the expectation-value of Y induced by changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by Y from change_from to change_to, while keeping M as if X remained at change_from.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">return</span> <span class="n">_Fct_smoothed</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">NDE</span><span class="p">,</span> <span class="n">min_x</span><span class="p">,</span> <span class="n">max_x</span><span class="p">,</span> <span class="n">cf_delta</span><span class="p">,</span> <span class="n">steps</span><span class="p">,</span> <span class="n">smoothing_gaussian_sigma_in_steps</span><span class="p">,</span>
+                             <span class="n">normalize_by_delta</span><span class="p">,</span> <span class="n">fct_of_nde</span><span class="o">=</span><span class="n">fct_of_nde</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">NIE_smoothed</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">min_x</span><span class="p">,</span> <span class="n">max_x</span><span class="p">,</span> <span class="n">cf_delta</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="n">steps</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">smoothing_gaussian_sigma_in_steps</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span>
+                     <span class="n">normalize_by_delta</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute NIE as smoothed function</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        min_x : float</span>
+<span class="sd">            Lower bound of interval on which reference-values for X are taken</span>
+
+<span class="sd">        max_x : float</span>
+<span class="sd">            Upper bound of interval on which reference-values for X are taken</span>
+
+<span class="sd">        cf_delta : float</span>
+<span class="sd">            The change from reference-value to effect-value (change_from=reference, change_to=ref + delta)</span>
+
+<span class="sd">        steps : uint</span>
+<span class="sd">            Number of intermediate values to compute in the interval [min_x, max_x]</span>
+
+<span class="sd">        smoothing_gaussian_sigma_in_steps : uint</span>
+<span class="sd">            The width of the Gauß-kernel used for smoothing, given in steps.</span>
+
+<span class="sd">        normalize_by_delta : bool</span>
+<span class="sd">            Normalize the effect by dividing by cf_delta.</span>
+
+<span class="sd">        Throws</span>
+<span class="sd">        ------</span>
+<span class="sd">        Raises and exception if parameters are not meaningful</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        NIE : If Y is categorical -&gt; np.array( # steps, # categories Y, 2 )</span>
+<span class="sd">            For each grid-point:</span>
+<span class="sd">            The probabilities the categories of Y (after, before) changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by M from change_from to change_to, while keeping the value of X &quot;seen&quot; (directly)</span>
+<span class="sd">            by Y as if X remained at change_from.</span>
+
+<span class="sd">        NDE : If Y is continuous -&gt; np.array( # steps )</span>
+<span class="sd">            For each grid-point:</span>
+<span class="sd">            The change in the expectation-value of Y induced by changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by M from change_from to change_to, while keeping the value of X &quot;seen&quot; (directly)</span>
+<span class="sd">            by Y as if X remained at change_from.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">return</span> <span class="n">_Fct_smoothed</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">NIE</span><span class="p">,</span> <span class="n">min_x</span><span class="p">,</span> <span class="n">max_x</span><span class="p">,</span> <span class="n">cf_delta</span><span class="p">,</span> <span class="n">steps</span><span class="p">,</span> <span class="n">smoothing_gaussian_sigma_in_steps</span><span class="p">,</span>
+                             <span class="n">normalize_by_delta</span><span class="p">)</span>
+
+
+<span class="k">class</span> <span class="nc">NaturalEffects_GraphMediation</span><span class="p">:</span>
+<span class="w">    </span><span class="sa">r</span><span class="sd">&quot;&quot;&quot;Setup for estimating natural effects in a (general) causal graph.</span>
+
+<span class="sd">    Methods for the non-parametric estimation of mediation effects by adjustment.</span>
+
+<span class="sd">    Actual fit-models can be chosen independently, for details see</span>
+<span class="sd">    technical appendix B in the mediation-tutorial.</span>
+
+<span class="sd">    See references and tigramite tutorial for an in-depth introduction.</span>
+
+<span class="sd">    References</span>
+<span class="sd">    ----------</span>
+
+<span class="sd">    J. Pearl. Direct and indirect effects. Proceedings of the Seventeenth Conference</span>
+<span class="sd">    on Uncertainty in Artificial intelligence, 2001.</span>
+
+<span class="sd">    J. Pearl. Interpretation and identification of causal mediation. Psychological</span>
+<span class="sd">    methods, 19(4):459, 2014.</span>
+
+<span class="sd">    I. Shpitser and T. J. VanderWeele. A complete graphical criterion for the adjust-</span>
+<span class="sd">    ment formula in mediation analysis. The international journal of biostatistics,</span>
+<span class="sd">    7(1), 2011.</span>
+
+<span class="sd">    Parameters</span>
+<span class="sd">    ----------</span>
+<span class="sd">    graph : np.array( [N, N] or [N, N, tau_max+1] depending on graph_type ) of 3-character patterns</span>
+<span class="sd">        The causal graph, see &#39;Causal Effects&#39; tutorial. E.g. returned by causal discovery method</span>
+<span class="sd">        (see &quot;Tutorials/Causal Discovery/CD Overview&quot;) or by a toymodel (see toy_setup.Model.GetGroundtruthGraph or</span>
+<span class="sd">        the Mediation tutorial).</span>
+<span class="sd">    graph_type : string</span>
+<span class="sd">        The type of graph, tested for &#39;dag&#39; and &#39;stationary_dag&#39; (time-series). See &#39;Causal Effects&#39; tutorial.</span>
+<span class="sd">    tau_max : uint</span>
+<span class="sd">        Maximum lag to be considered (can be relevant for adjustment sets, passed to &#39;Causal Effects&#39; class).</span>
+<span class="sd">    fit_setup : fit model</span>
+<span class="sd">        A fit model to use internally, e.g. mixed_fit.FitSetup(). See there or technical</span>
+<span class="sd">        appendix B of the tutorial.</span>
+<span class="sd">    observations_data : dictionary ( keys=toy_setup.VariableDescription, values=np.array(N) )</span>
+<span class="sd">        The data as map variable-description -&gt; samples; e.g. toy_setup.world.Observables(),</span>
+<span class="sd">        or toy_setup.VariablesFromDataframe( tigramite dataframe )</span>
+<span class="sd">    effect_source : toy_setup.VariableDescription or (idx, -lag)</span>
+<span class="sd">        The (description of, e.g. toy_setup.ContinuousVariable()) the effect-source.</span>
+<span class="sd">    effect_target : toy_setup.VariableDescriptionor (idx, -lag)</span>
+<span class="sd">        The (description of, e.g. toy_setup.ContinuousVariable()) the effect-target.</span>
+<span class="sd">    blocked_mediators : iterable of Variable-descriptions or &#39;all&#39;</span>
+<span class="sd">        Which mediators to &#39;block&#39; (consider indirect), *un*\ blocked mediators are considered as</span>
+<span class="sd">        contributions to the *direct* effect.</span>
+<span class="sd">    adjustment_set : iterable of Variable-descriptions or &#39;auto&#39;</span>
+<span class="sd">        Adjustment-set to use. Will be validated if specified explicitly, if &#39;auto&#39;, will try</span>
+<span class="sd">        to use an &#39;optimal&#39; set, fall back to [Perkovic et al]&#39;s adjustment-set (which should always</span>
+<span class="sd">        work if single-set adjustment as in [Shpitser, VanderWeele] os possible; this follows</span>
+<span class="sd">        from combining results of [Shpitser, VanderWeele] and [Perkovic et al]).</span>
+<span class="sd">        See &#39;Causal Effects&#39; and its tutorial for more info and references on (optimal) adjustment.</span>
+<span class="sd">    only_check_validity : bool</span>
+<span class="sd">        If True, do not set up an estimator, only check if an optimal adjustment-set exists (or the</span>
+<span class="sd">        explicitly specified one is valid). Call this.Valid() to extract the result.</span>
+<span class="sd">    fall_back_to_total_effect : bool</span>
+<span class="sd">        If True, if no mediators are blocked, use mediation implementation to estimate the total effect.</span>
+<span class="sd">        In this case, estimating the total effect through the &#39;Causal Effects&#39; class might be easier,</span>
+<span class="sd">        however, for comparison to other estimates, using this option might yield more consistent results.</span>
+<span class="sd">    _internal_provide_cfx : *None* or tigramite.CausalEffects</span>
+<span class="sd">        Set to None. Used when called from CausalMediation, which already has a causal-effects class.</span>
+<span class="sd">    &quot;&quot;&quot;</span>
+
+    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">graph</span><span class="p">,</span> <span class="n">graph_type</span><span class="p">,</span> <span class="n">tau_max</span><span class="p">,</span> <span class="n">fit_setup</span><span class="p">,</span> <span class="n">observations_data</span><span class="p">,</span> <span class="n">effect_source</span><span class="p">,</span> <span class="n">effect_target</span><span class="p">,</span>
+                 <span class="n">blocked_mediators</span><span class="o">=</span><span class="s2">&quot;all&quot;</span><span class="p">,</span> <span class="n">adjustment_set</span><span class="o">=</span><span class="s2">&quot;auto&quot;</span><span class="p">,</span> <span class="n">only_check_validity</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
+                 <span class="n">fall_back_to_total_effect</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">_internal_provide_cfx</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+
+        <span class="n">data</span> <span class="o">=</span> <span class="n">toy_setup</span><span class="o">.</span><span class="n">DataHandler</span><span class="p">(</span><span class="n">observations_data</span><span class="p">)</span>
+
+        <span class="bp">self</span><span class="o">.</span><span class="n">Source</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">GetVariableAuto</span><span class="p">(</span><span class="n">effect_source</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">Target</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">GetVariableAuto</span><span class="p">(</span><span class="n">effect_target</span><span class="p">)</span>
+
+        <span class="k">if</span> <span class="n">blocked_mediators</span> <span class="o">!=</span> <span class="s2">&quot;all&quot;</span><span class="p">:</span>
+            <span class="n">blocked_mediators</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">GetVariablesAuto</span><span class="p">(</span><span class="n">blocked_mediators</span><span class="p">)</span>
+        <span class="k">if</span> <span class="n">adjustment_set</span> <span class="o">!=</span> <span class="s2">&quot;auto&quot;</span><span class="p">:</span>
+            <span class="n">adjustment_set</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">GetVariablesAuto</span><span class="p">(</span><span class="n">adjustment_set</span><span class="p">)</span>
+
+        <span class="n">X</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">Source</span><span class="p">]</span>
+        <span class="n">Y</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">Target</span><span class="p">]</span>
+
+        <span class="c1"># Use tigramite&#39;s total effect estimation utility to help generate adjustment-sets and mediators</span>
+        <span class="n">cfx_xy</span> <span class="o">=</span> <span class="n">_internal_provide_cfx</span> <span class="k">if</span> <span class="n">_internal_provide_cfx</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span>\
+            <span class="n">CausalEffects</span><span class="p">(</span><span class="n">graph</span><span class="p">,</span> <span class="n">graph_type</span><span class="o">=</span><span class="n">graph_type</span><span class="p">,</span> <span class="n">X</span><span class="o">=</span><span class="p">[</span><span class="n">X</span><span class="p">],</span> <span class="n">Y</span><span class="o">=</span><span class="p">[</span><span class="n">Y</span><span class="p">])</span>
+
+        <span class="c1"># ----- MEDIATORS -----</span>
+        <span class="c1"># Validate &quot;blocked mediators&quot; are actually mediators, or find &quot;all&quot;</span>
+        <span class="n">all_mediators</span> <span class="o">=</span> <span class="n">blocked_mediators</span> <span class="o">==</span> <span class="s2">&quot;all&quot;</span>
+        <span class="k">if</span> <span class="n">all_mediators</span><span class="p">:</span>
+            <span class="n">M</span> <span class="o">=</span> <span class="n">cfx_xy</span><span class="o">.</span><span class="n">M</span>
+            <span class="n">blocked_mediators</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">ReverseLookupMulti</span><span class="p">(</span><span class="n">M</span><span class="p">)</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="n">M</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">blocked_mediators</span><span class="p">]</span>
+            <span class="k">if</span> <span class="ow">not</span> <span class="nb">set</span><span class="p">(</span><span class="n">M</span><span class="p">)</span> <span class="o">&lt;=</span> <span class="nb">set</span><span class="p">(</span><span class="n">cfx_xy</span><span class="o">.</span><span class="n">M</span><span class="p">):</span>
+                <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;Blocked mediators, if specified, must actually be mediators, try using&quot;</span>
+                                <span class="s2">&quot;set-intersection with causal_effects_instance_xy.M instead.&quot;</span><span class="p">)</span>
+        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">M</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">fall_back_to_total_effect</span><span class="p">:</span>
+            <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;There are no mediators, use total-effect estimation instead or set &quot;</span>
+                            <span class="s2">&quot;fall_back_to_total_effect=True!&quot;</span><span class="p">)</span>
+
+        <span class="c1"># ----- ADJUSTMENT -----</span>
+        <span class="c1"># Use tigramite&#39;s total effect estimation utility to help validate adjustment-sets and mediators</span>
+        <span class="n">cfx_xm</span> <span class="o">=</span> <span class="n">CausalEffects</span><span class="p">(</span><span class="n">graph</span><span class="p">,</span> <span class="n">graph_type</span><span class="o">=</span><span class="n">graph_type</span><span class="p">,</span> <span class="n">X</span><span class="o">=</span><span class="p">[</span><span class="n">X</span><span class="p">],</span> <span class="n">Y</span><span class="o">=</span><span class="n">M</span><span class="p">)</span>
+        <span class="n">cfx_xm_y</span> <span class="o">=</span> <span class="n">CausalEffects</span><span class="p">(</span><span class="n">graph</span><span class="p">,</span> <span class="n">graph_type</span><span class="o">=</span><span class="n">graph_type</span><span class="p">,</span> <span class="n">X</span><span class="o">=</span><span class="p">[</span><span class="n">X</span><span class="p">]</span> <span class="o">+</span> <span class="nb">list</span><span class="p">(</span><span class="n">M</span><span class="p">),</span> <span class="n">Y</span><span class="o">=</span><span class="p">[</span><span class="n">Y</span><span class="p">])</span>
+
+        <span class="k">def</span> <span class="nf">valid</span><span class="p">(</span><span class="n">S</span><span class="p">):</span>
+            <span class="k">return</span> <span class="n">cfx_xm</span><span class="o">.</span><span class="n">_check_validity</span><span class="p">(</span><span class="n">S</span><span class="p">)</span> <span class="ow">and</span> <span class="n">cfx_xm_y</span><span class="o">.</span><span class="n">_check_validity</span><span class="p">(</span><span class="n">S</span><span class="p">)</span>
+
+        <span class="n">adjustment_set_auto</span> <span class="o">=</span> <span class="p">(</span><span class="n">adjustment_set</span> <span class="o">==</span> <span class="s2">&quot;auto&quot;</span><span class="p">)</span>
+
+        <span class="k">if</span> <span class="n">adjustment_set_auto</span><span class="p">:</span>
+            <span class="c1"># first try optimal set (for small cf_delta, optimality for the causal effect should imply</span>
+            <span class="c1"># optimality for the nde by continuity for the estimator variance)</span>
+            <span class="n">Z</span> <span class="o">=</span> <span class="n">cfx_xy</span><span class="o">.</span><span class="n">get_optimal_set</span><span class="p">()</span>
+
+            <span class="k">if</span> <span class="ow">not</span> <span class="n">valid</span><span class="p">(</span><span class="n">Z</span><span class="p">)</span> <span class="ow">and</span> <span class="n">adjustment_set_auto</span><span class="p">:</span>
+                <span class="c1"># fall back to adjust, which should work if any single adjustmentset works</span>
+                <span class="n">Z</span> <span class="o">=</span> <span class="n">cfx_xy</span><span class="o">.</span><span class="n">_get_adjust_set</span><span class="p">()</span>
+
+            <span class="n">adjustment_set</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">ReverseLookupMulti</span><span class="p">(</span><span class="n">Z</span><span class="p">)</span>
+
+        <span class="k">else</span><span class="p">:</span>
+            <span class="n">Z</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">adjustment_set</span><span class="p">]</span>
+
+        <span class="bp">self</span><span class="o">.</span><span class="n">valid</span> <span class="o">=</span> <span class="n">valid</span><span class="p">(</span><span class="n">Z</span><span class="p">)</span>
+        <span class="k">if</span> <span class="n">only_check_validity</span><span class="p">:</span>
+            <span class="k">return</span>
+
+        <span class="c1"># Output appropriate error msgs if not valid</span>
+        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">valid</span><span class="p">:</span>
+            <span class="k">if</span> <span class="n">adjustment_set_auto</span><span class="p">:</span>
+                <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span>
+                    <span class="s2">&quot;The graph-effect you are trying to estimate is not identifiable via one-step adjustment, &quot;</span>
+                    <span class="s2">&quot;try using a different query &quot;</span>
+                    <span class="s2">&quot;or refine the causal graph by expert knowledge. &quot;</span>
+                    <span class="s2">&quot;For the implemented method, there must be an adjustment-set, valid for both X u M -&gt; Y and &quot;</span>
+                    <span class="s2">&quot;X -&gt; Y. If such a set exists, Perkovic&#39;s Adjust(X,Y) is valid, which was tried as &quot;</span>
+                    <span class="s2">&quot;fallback because adjustment-set=&#39;auto&#39; was used.&quot;</span><span class="p">)</span>
+            <span class="k">else</span><span class="p">:</span>
+                <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span>
+                    <span class="s2">&quot;The adjustment-set specified is not valid for one-step adjustment, &quot;</span>
+                    <span class="s2">&quot;try using or a different adjustment-set (or set it to &#39;auto&#39;), a different query &quot;</span>
+                    <span class="s2">&quot;or refine the causal graph by expert knowledge. &quot;</span>
+                    <span class="s2">&quot;For the implemented method, there must be an adjustment-set, valid for both X u M -&gt; Y and &quot;</span>
+                    <span class="s2">&quot;X -&gt; Y. If such a set exists, Perkovic&#39;s Adjust(X,Y) is valid, which is tried as &quot;</span>
+                    <span class="s2">&quot;fallback if adjustment-set=&#39;auto&#39; is used.&quot;</span><span class="p">)</span>
+
+        <span class="c1"># ----- STORE RESULTS ON INSTANCE -----</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sources</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">Get</span><span class="p">(</span><span class="s2">&quot;Source&quot;</span><span class="p">,</span> <span class="p">[</span><span class="n">X</span><span class="p">],</span> <span class="n">tau_max</span><span class="o">=</span><span class="n">tau_max</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">X</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>  <span class="c1"># currently univariate anyway</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">targets</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">Get</span><span class="p">(</span><span class="s2">&quot;Target&quot;</span><span class="p">,</span> <span class="p">[</span><span class="n">Y</span><span class="p">],</span> <span class="n">tau_max</span><span class="o">=</span><span class="n">tau_max</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">Y</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
+        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">M</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">M_ids</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mediators</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">Get</span><span class="p">(</span><span class="s2">&quot;Mediator&quot;</span><span class="p">,</span> <span class="n">M</span><span class="p">,</span> <span class="n">tau_max</span><span class="o">=</span><span class="n">tau_max</span><span class="p">)</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">M_ids</span> <span class="o">=</span> <span class="kc">None</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">mediators</span> <span class="o">=</span> <span class="p">{}</span>
+
+        <span class="bp">self</span><span class="o">.</span><span class="n">BlockedMediators</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">ReverseLookupMulti</span><span class="p">(</span><span class="n">M</span><span class="p">)</span>
+
+        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">Z</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">Z_ids</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">adjustment</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">Get</span><span class="p">(</span><span class="s2">&quot;Adjustment&quot;</span><span class="p">,</span> <span class="n">Z</span><span class="p">,</span> <span class="n">tau_max</span><span class="o">=</span><span class="n">tau_max</span><span class="p">)</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">Z_ids</span> <span class="o">=</span> <span class="kc">None</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">adjustment</span> <span class="o">=</span> <span class="p">{}</span>
+
+        <span class="bp">self</span><span class="o">.</span><span class="n">AdjustmentSet</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">ReverseLookupMulti</span><span class="p">(</span><span class="n">Z</span><span class="p">)</span>
+
+        <span class="bp">self</span><span class="o">.</span><span class="n">fit_setup</span> <span class="o">=</span> <span class="n">fit_setup</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">_E_Y_XMZ</span> <span class="o">=</span> <span class="kc">None</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">_P_Y_XMZ</span> <span class="o">=</span> <span class="kc">None</span>
+
+    <span class="k">def</span> <span class="nf">E_Y_XMZ_fixed_x_obs_mz</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Provide samples Y( fixed x, observed m, z ) from fit of E[Y|X,M,Z]</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        x : single value of same type as single sample for X (float, int, or bool)</span>
+<span class="sd">            The fixed value of X.</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        Y( fixed x, observed m, z ) : np.array(N)</span>
+<span class="sd">            Samples of Y estimated from observations and fit.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">assert</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="o">.</span><span class="n">is_categorical</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_E_Y_XMZ</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">_E_Y_XMZ</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_setup</span><span class="o">.</span><span class="n">Fit</span><span class="p">({</span><span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">sources</span><span class="p">,</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">mediators</span><span class="p">,</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">adjustment</span><span class="p">},</span> <span class="bp">self</span><span class="o">.</span><span class="n">targets</span><span class="p">)</span>
+
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_E_Y_XMZ</span><span class="p">({</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">full_like</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sources</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">],</span> <span class="n">x</span><span class="p">),</span>
+                              <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">mediators</span><span class="p">,</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">adjustment</span><span class="p">})</span>
+
+    <span class="k">def</span> <span class="nf">P_Y_XMZ_fixed_x_obs_mz</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Provide for all samples of M, Z the likelihood P( Y | fixed x, observed m, z ) from fit of P[Y|X,M,Z]</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        x : single value of same type as single sample for X (float, int, or bool)</span>
+<span class="sd">            The fixed value of X.</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        P( Y | fixed x, observed m, z ) : np.array(N, # categories of Y)</span>
+<span class="sd">            Likelihood of each category of Y given x and observations of m, z from fit.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">assert</span> <span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="o">.</span><span class="n">is_categorical</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_P_Y_XMZ</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">_P_Y_XMZ</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_setup</span><span class="o">.</span><span class="n">Fit</span><span class="p">({</span><span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">sources</span><span class="p">,</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">mediators</span><span class="p">,</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">adjustment</span><span class="p">},</span> <span class="bp">self</span><span class="o">.</span><span class="n">targets</span><span class="p">)</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_P_Y_XMZ</span><span class="p">({</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">full_like</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sources</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">],</span> <span class="n">x</span><span class="p">),</span>
+                              <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">mediators</span><span class="p">,</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">adjustment</span><span class="p">})</span>
+
+    <span class="k">def</span> <span class="nf">Valid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get validity of adjustment-set</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        Valid : bool</span>
+<span class="sd">            Validity of adjustment set. (see constructor-parameter &#39;only_check_validity&#39;)</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">valid</span>
+
+    <span class="k">def</span> <span class="nf">NDE</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute Natural Direct Effect (NDE)</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        change_from : single value of same type as single sample for X (float, int, or bool)</span>
+<span class="sd">            Reference-value to which X is set by intervention in the world seen by the (blocked) mediators.</span>
+
+<span class="sd">        change_to : single value of same type as single sample for X (float, int, or bool)</span>
+<span class="sd">            Post-intervention-value to which X is set by intervention in the world seen by the effect (directly).</span>
+
+<span class="sd">        Throws</span>
+<span class="sd">        ------</span>
+<span class="sd">        Raises and exception if parameters are not meaningful or if adjustment-set is not valid.</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        NDE : If Y is categorical -&gt; np.array( # categories Y, 2 )</span>
+<span class="sd">            The probabilities the categories of Y (after, before) changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by Y from change_from to change_to, while keeping (blocked) M as if X remained at change_from.</span>
+
+<span class="sd">        NDE : If Y is continuous -&gt; float</span>
+<span class="sd">            The change in the expectation-value of Y induced by changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by Y from change_from to change_to, while keeping (blocked) M as if X remained at change_from.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">valid</span><span class="p">:</span>
+            <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;Valid adjustment-set is required!&quot;</span><span class="p">)</span>
+        <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="o">.</span><span class="n">ValidValue</span><span class="p">(</span><span class="n">change_from</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="o">.</span><span class="n">ValidValue</span><span class="p">(</span><span class="n">change_to</span><span class="p">)):</span>
+            <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;NDE change must be at valid values of the source-variable (e.g. categorical, and within &quot;</span>
+                            <span class="s2">&quot;the range [0,num-categories).&quot;</span><span class="p">)</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="o">.</span><span class="n">is_categorical</span><span class="p">:</span>
+            <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">_NDE_categorical_target_full_density</span><span class="p">(</span><span class="n">change_to</span><span class="p">,</span> <span class="n">change_from</span><span class="p">),</span>
+                             <span class="bp">self</span><span class="o">.</span><span class="n">_NDE_categorical_target_full_density</span><span class="p">(</span><span class="n">change_from</span><span class="p">,</span> <span class="n">change_from</span><span class="p">)])</span><span class="o">.</span><span class="n">T</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_NDE_continuous_target</span><span class="p">(</span><span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">_NDE_continuous_target</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">change_from</span><span class="p">,</span> <span class="n">change_to</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute NDE (continuous Y)</span>
+
+<span class="sd">        See &#39;NDE&#39; above.</span>
+
+<span class="sd">        Computed from mediation-formula</span>
+<span class="sd">        (see [Pearl 2001] or [Shpitser, VanderWeele], see references above)</span>
+<span class="sd">        by &quot;triple&quot;-regression.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="n">difference</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">E_Y_XMZ_fixed_x_obs_mz</span><span class="p">(</span><span class="n">change_to</span><span class="p">)</span>
+                      <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">E_Y_XMZ_fixed_x_obs_mz</span><span class="p">(</span><span class="n">change_from</span><span class="p">))</span>
+
+        <span class="n">Difference</span> <span class="o">=</span> <span class="n">toy_setup</span><span class="o">.</span><span class="n">ContinuousVariable</span><span class="p">()</span>
+        <span class="n">E_Difference_X</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_setup</span><span class="o">.</span><span class="n">Fit</span><span class="p">({</span><span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">sources</span><span class="p">,</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">adjustment</span><span class="p">},</span>
+                                            <span class="p">{</span><span class="n">Difference</span><span class="p">:</span> <span class="n">difference</span><span class="p">})</span>
+
+        <span class="n">E_NDE_per_c</span> <span class="o">=</span> <span class="n">E_Difference_X</span><span class="p">({</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">full_like</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sources</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">],</span> <span class="n">change_from</span><span class="p">),</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">adjustment</span><span class="p">})</span>
+
+        <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">E_NDE_per_c</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">_NDE_categorical_target_full_density</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cf_x</span><span class="p">,</span> <span class="n">reference_x</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute NDE as full density (categorical Y)</span>
+
+<span class="sd">        See &#39;NDE&#39; above.</span>
+
+<span class="sd">        Computed from mediation-formula</span>
+<span class="sd">        (see [Pearl 2001] or [Shpitser, VanderWeele], see references above)</span>
+<span class="sd">        by &quot;double&quot;-regression.</span>
+
+<span class="sd">        Note: According to (see p.13)</span>
+<span class="sd">        [Shpitser, VanderWeele: A Complete Graphical Criterion for theAdjustment Formula in Mediation Analysis]</span>
+<span class="sd">        not just the expectation-value, but the full counterfactual distribution can be obtained via mediation-formula.</span>
+
+<span class="sd">        Note: If all M and Z are categorical, after fixing X=x, the fitted P( Y | X=x, M=m ), is actually</span>
+<span class="sd">        categorical (a transfer matrix), because it takes values only in</span>
+<span class="sd">        im( P ) = { P( Y | X=x, M=m_0 ), ...,  P( Y | X=x, M=m_k ) } where</span>
+<span class="sd">        m_0, ..., m_k are the categories of M. This is clearly a finite set.</span>
+<span class="sd">        Since the distribution over this finite subset of the continuous Val(Y)</span>
+<span class="sd">        is very non-gaussian, &quot;max likelihood by least square estimation&quot; can fail horribly.</span>
+<span class="sd">        Hence we fit a transfer-matrix instead.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="n">p_y_values</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">P_Y_XMZ_fixed_x_obs_mz</span><span class="p">(</span><span class="n">cf_x</span><span class="p">)</span>
+
+        <span class="k">if</span> <span class="p">(</span><span class="n">MixedData</span><span class="o">.</span><span class="n">IsPurelyCategorical</span><span class="p">({</span><span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">mediators</span><span class="p">,</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">adjustment</span><span class="p">})</span>
+                <span class="ow">and</span> <span class="nb">len</span><span class="p">({</span><span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">mediators</span><span class="p">,</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">adjustment</span><span class="p">})</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">):</span>
+            <span class="c1"># If there are mediators or adjustment</span>
+            <span class="c1"># and they are purely categorical, then the mapping (M u Z) -&gt; P_Y</span>
+            <span class="c1"># has finite image, treating it as categorical gives better results</span>
+
+            <span class="n">labels_y</span><span class="p">,</span> <span class="n">transformed_y</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">unique</span><span class="p">(</span><span class="n">p_y_values</span><span class="p">,</span> <span class="n">return_inverse</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
+            <span class="n">P_Y</span> <span class="o">=</span> <span class="n">toy_setup</span><span class="o">.</span><span class="n">CategoricalVariable</span><span class="p">(</span><span class="n">categories</span><span class="o">=</span><span class="n">labels_y</span><span class="p">)</span>
+            <span class="n">P_P_Y_xz</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_setup</span><span class="o">.</span><span class="n">Fit</span><span class="p">({</span><span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">sources</span><span class="p">,</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">adjustment</span><span class="p">},</span> <span class="p">{</span><span class="n">P_Y</span><span class="p">:</span> <span class="n">transformed_y</span><span class="p">})</span>
+
+            <span class="n">C_NDE_per_c</span> <span class="o">=</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">Call_map</span><span class="p">(</span><span class="n">P_P_Y_xz</span><span class="p">,</span>
+                                                       <span class="p">{</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">full_like</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sources</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">],</span> <span class="n">reference_x</span><span class="p">),</span>
+                                                        <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">adjustment</span><span class="p">})</span>
+            <span class="nb">print</span><span class="p">(</span><span class="n">labels_y</span><span class="p">)</span>
+            <span class="nb">print</span><span class="p">(</span><span class="n">C_NDE_per_c</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
+            <span class="nb">print</span><span class="p">(</span><span class="n">labels_y</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
+            <span class="n">P_NDE_per_c</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">matmul</span><span class="p">(</span><span class="n">C_NDE_per_c</span><span class="p">,</span> <span class="n">labels_y</span><span class="p">)</span>
+            <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">P_NDE_per_c</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>  <span class="c1"># Axis 1 is p of different categories</span>
+
+        <span class="k">else</span><span class="p">:</span>
+            <span class="n">P_Y</span> <span class="o">=</span> <span class="n">toy_setup</span><span class="o">.</span><span class="n">ContinuousVariable</span><span class="p">(</span><span class="n">dimension</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="o">.</span><span class="n">categories</span><span class="p">)</span>
+            <span class="n">E_P_Y_xz</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_setup</span><span class="o">.</span><span class="n">Fit</span><span class="p">({</span><span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">sources</span><span class="p">,</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">adjustment</span><span class="p">},</span> <span class="p">{</span><span class="n">P_Y</span><span class="p">:</span> <span class="n">p_y_values</span><span class="p">})</span>
+
+            <span class="n">P_NDE_per_c</span> <span class="o">=</span> <span class="n">MixedData</span><span class="o">.</span><span class="n">Call_map</span><span class="p">(</span><span class="n">E_P_Y_xz</span><span class="p">,</span>
+                                                       <span class="p">{</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">full_like</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sources</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">],</span> <span class="n">reference_x</span><span class="p">),</span>
+                                                        <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">adjustment</span><span class="p">})</span>
+
+            <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">P_NDE_per_c</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>  <span class="c1"># Axis 0 is p of different categories</span>
+
+    <span class="k">def</span> <span class="nf">NDE_smoothed</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">min_x</span><span class="p">,</span> <span class="n">max_x</span><span class="p">,</span> <span class="n">cf_delta</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="n">steps</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">smoothing_gaussian_sigma_in_steps</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span>
+                     <span class="n">normalize_by_delta</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute NDE as smoothed function</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        min_x : float</span>
+<span class="sd">            Lower bound of interval on which reference-values for X are taken</span>
+
+<span class="sd">        max_x : float</span>
+<span class="sd">            Upper bound of interval on which reference-values for X are taken</span>
+
+<span class="sd">        cf_delta : float</span>
+<span class="sd">            The change from reference-value to effect-value (change_from=reference, change_to=ref + delta)</span>
+
+<span class="sd">        steps : uint</span>
+<span class="sd">            Number of intermediate values to compute in the interval [min_x, max_x]</span>
+
+<span class="sd">        smoothing_gaussian_sigma_in_steps : uint</span>
+<span class="sd">            The width of the Gauß-kernel used for smoothing, given in steps.</span>
+
+<span class="sd">        normalize_by_delta : bool</span>
+<span class="sd">            Normalize the effect by dividing by cf_delta.</span>
+
+<span class="sd">        Throws</span>
+<span class="sd">        ------</span>
+<span class="sd">        Raises and exception if parameters are not meaningful, adjustment-set is not valid or</span>
+<span class="sd">        normalization requested makes no sense (normalizing probabilites by delta).</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        NDE : If Y is categorical -&gt; np.array( # steps, # categories Y, 2 )</span>
+<span class="sd">            For each grid-point:</span>
+<span class="sd">            The probabilities the categories of Y (after, before) changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by Y from change_from to change_to, while keeping (blocked) M as if X remained at change_from.</span>
+
+<span class="sd">        NDE : If Y is continuous -&gt; np.array( # steps )</span>
+<span class="sd">            For each grid-point:</span>
+<span class="sd">            The change in the expectation-value of Y induced by changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by Y from change_from to change_to, while keeping (blocked) M as if X remained at change_from.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="o">.</span><span class="n">is_categorical</span> <span class="ow">and</span> <span class="n">normalize_by_delta</span><span class="p">:</span>
+            <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;Do not normalize categorical output-probabilities by delta. (They are probabilities, &quot;</span>
+                            <span class="s2">&quot;so normalizing them in this way makes no sense.) Normalize the difference instead.&quot;</span><span class="p">)</span>
+        <span class="k">return</span> <span class="n">_Fct_smoothed</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">NDE</span><span class="p">,</span> <span class="n">min_x</span><span class="p">,</span> <span class="n">max_x</span><span class="p">,</span> <span class="n">cf_delta</span><span class="p">,</span> <span class="n">steps</span><span class="p">,</span> <span class="n">smoothing_gaussian_sigma_in_steps</span><span class="p">,</span>
+                             <span class="n">normalize_by_delta</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">PrintInfo</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">detail</span><span class="o">=</span><span class="mi">1</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Print info about estimator.</span>
+
+<span class="sd">        Helper to quickly print blocked mediators, adjustment-set used and source-&gt;target.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Estimator for the effect of </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">Source</span><span class="o">.</span><span class="n">Info</span><span class="p">(</span><span class="n">detail</span><span class="p">)</span><span class="si">}</span><span class="s2"> on </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">Target</span><span class="o">.</span><span class="n">Info</span><span class="p">(</span><span class="n">detail</span><span class="p">)</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">PrintMediators</span><span class="p">(</span><span class="n">detail</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">PrintAdjustmentSet</span><span class="p">(</span><span class="n">detail</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">PrintMediators</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">detail</span><span class="o">=</span><span class="mi">1</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot; Print info about blocked mediators. &quot;&quot;&quot;</span>
+        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Blocked Mediators:&quot;</span><span class="p">)</span>
+        <span class="k">for</span> <span class="n">m</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">BlockedMediators</span><span class="p">:</span>
+            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot; - &quot;</span> <span class="o">+</span> <span class="n">m</span><span class="o">.</span><span class="n">Info</span><span class="p">(</span><span class="n">detail</span><span class="p">))</span>
+
+    <span class="k">def</span> <span class="nf">PrintAdjustmentSet</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">detail</span><span class="o">=</span><span class="mi">1</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot; Print info about adjustment-set. &quot;&quot;&quot;</span>
+        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Adjustment Set:&quot;</span><span class="p">)</span>
+        <span class="k">for</span> <span class="n">z</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">AdjustmentSet</span><span class="p">:</span>
+            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot; - &quot;</span> <span class="o">+</span> <span class="n">z</span><span class="o">.</span><span class="n">Info</span><span class="p">(</span><span class="n">detail</span><span class="p">))</span>
+
+
+
+
+<span class="sd">&quot;&quot;&quot;-------------------------------------------------------------------------------------------</span>
+<span class="sd">-------------------------------   Expose Tigramite Interface   -------------------------------</span>
+<span class="sd">-------------------------------------------------------------------------------------------&quot;&quot;&quot;</span>
+
+
+
+<div class="viewcode-block" id="CausalMediation"><a class="viewcode-back" href="../../index.html#tigramite.causal_mediation.CausalMediation">[docs]</a><span class="k">class</span> <span class="nc">CausalMediation</span><span class="p">(</span><span class="n">CausalEffects</span><span class="p">):</span>
+<span class="w">    </span><span class="sd">&quot;&quot;&quot;Non-linear, non-additive causal mediation analysis.</span>
+
+<span class="sd">    See the tutorial on Causal Mediation.</span>
+
+<span class="sd">    Extends the tigramite.CausalEffects class by natural-effect estimation for counter-factual mediation analysis.</span>
+<span class="sd">    Effects are estimated by adjustment, where adjustment-sets can be generated automatically (if they exist).</span>
+
+<span class="sd">    Actual fit-models can be chosen independently, for details see</span>
+<span class="sd">    technical appendix B in the mediation-tutorial.</span>
+
+<span class="sd">    See references and tigramite tutorial for an in-depth introduction.</span>
+
+<span class="sd">    References</span>
+<span class="sd">    ----------</span>
+<span class="sd">    J. Pearl. Direct and indirect effects. Proceedings of the Seventeenth Conference</span>
+<span class="sd">    on Uncertainty in Artificial intelligence, 2001.</span>
+
+<span class="sd">    J. Pearl. Interpretation and identification of causal mediation. Psychological</span>
+<span class="sd">    methods, 19(4):459, 2014.</span>
+
+<span class="sd">    I. Shpitser and T. J. VanderWeele. A complete graphical criterion for the adjust-</span>
+<span class="sd">    ment formula in mediation analysis. The international journal of biostatistics,</span>
+<span class="sd">    7(1), 2011.</span>
+
+<span class="sd">    Parameters</span>
+<span class="sd">    ----------</span>
+<span class="sd">    graph : np.array( [N, N] or [N, N, tau_max+1] depending on graph_type ) of 3-character patterns</span>
+<span class="sd">        The causal graph, see &#39;Causal Effects&#39; tutorial. E.g. returned by causal discovery method</span>
+<span class="sd">        (see &quot;Tutorials/Causal Discovery/CD Overview&quot;) or by a toymodel (see toy_setup.Model.GetGroundtruthGraph or</span>
+<span class="sd">        the Mediation tutorial).</span>
+<span class="sd">    graph_type : string</span>
+<span class="sd">        The type of graph, tested for &#39;dag&#39; and &#39;stationary_dag&#39; (time-series). See &#39;Causal Effects&#39; tutorial.</span>
+<span class="sd">    X : (idx, -lag)</span>
+<span class="sd">        Index of the effect-source.</span>
+<span class="sd">    Y : (idx, -lag)</span>
+<span class="sd">        Index of the effect-target.</span>
+<span class="sd">    S : None</span>
+<span class="sd">        Reserved. Must be None in current version.</span>
+<span class="sd">    hidden_variables : None</span>
+<span class="sd">        Reserved. Must be None in current version.</span>
+<span class="sd">    verbosity : uint</span>
+<span class="sd">        Tigramite.CausalEffects verbosity setting.</span>
+<span class="sd">    &quot;&quot;&quot;</span>
+    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">graph</span><span class="p">,</span> <span class="n">graph_type</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">Y</span><span class="p">,</span> <span class="n">S</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">hidden_variables</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
+        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">graph</span><span class="p">,</span> <span class="n">graph_type</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">Y</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">hidden_variables</span><span class="p">,</span> <span class="kc">False</span><span class="p">,</span> <span class="n">verbosity</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">BlockedMediators</span> <span class="o">=</span> <span class="kc">None</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">MediationEstimator</span> <span class="o">=</span> <span class="kc">None</span>
+        <span class="k">assert</span> <span class="n">hidden_variables</span> <span class="ow">is</span> <span class="kc">None</span>
+
+<div class="viewcode-block" id="CausalMediation.fit_natural_direct_effect"><a class="viewcode-back" href="../../index.html#tigramite.causal_mediation.CausalMediation.fit_natural_direct_effect">[docs]</a>    <span class="k">def</span> <span class="nf">fit_natural_direct_effect</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataframe</span><span class="p">,</span> <span class="n">mixed_data_estimator</span><span class="o">=</span><span class="n">FitSetup</span><span class="p">(),</span>
+                                  <span class="n">blocked_mediators</span><span class="o">=</span><span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="n">adjustment_set</span><span class="o">=</span><span class="s1">&#39;auto&#39;</span><span class="p">,</span>
+                                  <span class="n">use_mediation_impl_for_total_effect_fallback</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Fit a natural direct effect.</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        dataframe : tigramite.Dataframe</span>
+<span class="sd">            Observed data.</span>
+<span class="sd">        mixed_data_estimator : mixed_fit.FitSetup</span>
+<span class="sd">            The fit-configuration to use. See mixed_fit.FitSetup and the Mediation tutorial, Appendix B.</span>
+<span class="sd">        blocked_mediators : &#39;all&#39; or *iterable* of &lt; (idx, -lag) &gt;</span>
+<span class="sd">            Which mediators to &#39;block&#39; (consider indirect), *un*\ blocked mediators are considered as</span>
+<span class="sd">            contributions to the *direct* effect.</span>
+<span class="sd">        adjustment_set : &#39;auto&#39; or None or *iterable* &lt; (idx, -lag) &gt;</span>
+<span class="sd">            Adjustment-set to use. Will be validated if specified explicitly, if &#39;auto&#39; or None, will try</span>
+<span class="sd">            to use an &#39;optimal&#39; set, fall back to [Perkovic et al]&#39;s adjustment-set (which should always</span>
+<span class="sd">            work if single-set adjustment as in [Shpitser, VanderWeele] os possible; this follows</span>
+<span class="sd">            from combining results of [Shpitser, VanderWeele] and [Perkovic et al]).</span>
+<span class="sd">            See &#39;Causal Effects&#39; and its tutorial for more info and references on (optimal) adjustment.</span>
+<span class="sd">        use_mediation_impl_for_total_effect_fallback : bool</span>
+<span class="sd">            If True, if no mediators are blocked, use mediation implementation to estimate the total effect.</span>
+<span class="sd">            In this case, estimating the total effect through the &#39;Causal Effects&#39; class might be easier,</span>
+<span class="sd">            however, for comparison to other estimates, using this option might yield more consistent results.</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        estimator : NaturalEffects_GraphMediation</span>
+<span class="sd">            Typically, use predict_natural_direct_effect or predict_natural_direct_effect_function</span>
+<span class="sd">            to use the fitted estimator.</span>
+<span class="sd">            The internal NaturalEffects_GraphMediation (if needed).</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">if</span> <span class="n">adjustment_set</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
+            <span class="n">adjustment_set</span> <span class="o">=</span> <span class="s1">&#39;auto&#39;</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">BlockedMediators</span> <span class="o">=</span> <span class="n">blocked_mediators</span>
+        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">1</span><span class="p">:</span>
+            <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">&quot;Currently only implemented for univariate effects (source).&quot;</span><span class="p">)</span>
+        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">Y</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">1</span><span class="p">:</span>
+            <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">&quot;Currently only implemented for univariate effects (target).&quot;</span><span class="p">)</span>
+        <span class="p">[</span><span class="n">source</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span>
+        <span class="p">[</span><span class="n">target</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Y</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">MediationEstimator</span> <span class="o">=</span> <span class="n">NaturalEffects_GraphMediation</span><span class="p">(</span>
+            <span class="n">graph</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">graph</span><span class="p">,</span> <span class="n">graph_type</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">graph_type</span><span class="p">,</span> <span class="n">tau_max</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">tau_max</span><span class="p">,</span>
+            <span class="n">fit_setup</span><span class="o">=</span><span class="n">mixed_data_estimator</span><span class="p">,</span> <span class="n">observations_data</span><span class="o">=</span><span class="n">dataframe</span><span class="p">,</span>
+            <span class="n">effect_source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> <span class="n">effect_target</span><span class="o">=</span><span class="n">target</span><span class="p">,</span>
+            <span class="n">blocked_mediators</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">BlockedMediators</span><span class="p">,</span> <span class="n">adjustment_set</span><span class="o">=</span><span class="n">adjustment_set</span><span class="p">,</span> <span class="n">only_check_validity</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
+            <span class="n">fall_back_to_total_effect</span><span class="o">=</span><span class="n">use_mediation_impl_for_total_effect_fallback</span><span class="p">,</span>
+            <span class="n">_internal_provide_cfx</span><span class="o">=</span><span class="bp">self</span><span class="p">)</span>
+        <span class="c1"># return a NDE_Graph Estimator, but also remember it for predict_nde</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">MediationEstimator</span></div>
+
+<div class="viewcode-block" id="CausalMediation.predict_natural_direct_effect"><a class="viewcode-back" href="../../index.html#tigramite.causal_mediation.CausalMediation.predict_natural_direct_effect">[docs]</a>    <span class="k">def</span> <span class="nf">predict_natural_direct_effect</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">reference_value_x</span><span class="p">,</span> <span class="n">cf_intervention_value_x</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;*After fitting* a natural direct effect, predict its value at a specific point.</span>
+<span class="sd">        See also predict_natural_direct_effect_function.</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        reference_value_x : single value of same type as single sample for X (float, int, or bool)</span>
+<span class="sd">            Reference-value to which X is set by intervention in the world seen by the (blocked) mediators.</span>
+
+<span class="sd">        cf_intervention_value_x : single value of same type as single sample for X (float, int, or bool)</span>
+<span class="sd">            Post-intervention-value to which X is set by intervention in the world seen by the effect (directly).</span>
+
+<span class="sd">        Throws</span>
+<span class="sd">        ------</span>
+<span class="sd">        Raises and exception if parameters are not meaningful or if adjustment-set is not valid.</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        NDE : If Y is categorical -&gt; np.array( # categories Y, 2 )</span>
+<span class="sd">            The probabilities the categories of Y (after, before) changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by Y from change_from to change_to, while keeping (blocked) M as if X remained at change_from.</span>
+
+<span class="sd">        NDE : If Y is continuous -&gt; float</span>
+<span class="sd">            The change in the expectation-value of Y induced by changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by Y from change_from to change_to, while keeping (blocked) M as if X remained at change_from.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">MediationEstimator</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
+            <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;Call fit_natural_direct_effect_x before using predict_natural_direct_effect.&quot;</span><span class="p">)</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">MediationEstimator</span><span class="o">.</span><span class="n">NDE</span><span class="p">(</span><span class="n">change_from</span><span class="o">=</span><span class="n">reference_value_x</span><span class="p">,</span> <span class="n">change_to</span><span class="o">=</span><span class="n">cf_intervention_value_x</span><span class="p">)</span></div>
+
+<div class="viewcode-block" id="CausalMediation.predict_natural_direct_effect_function"><a class="viewcode-back" href="../../index.html#tigramite.causal_mediation.CausalMediation.predict_natural_direct_effect_function">[docs]</a>    <span class="k">def</span> <span class="nf">predict_natural_direct_effect_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">min_x</span><span class="p">,</span> <span class="n">max_x</span><span class="p">,</span> <span class="n">cf_delta</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span>
+                                               <span class="n">steps</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">smoothing_gaussian_sigma_in_steps</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span>
+                                               <span class="n">normalize_by_delta</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
+<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compute NDE as *smoothed* function</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        min_x : float</span>
+<span class="sd">            Lower bound of interval on which reference-values for X are taken</span>
+
+<span class="sd">        max_x : float</span>
+<span class="sd">            Upper bound of interval on which reference-values for X are taken</span>
+
+<span class="sd">        cf_delta : float</span>
+<span class="sd">            The change from reference-value to effect-value (change_from=reference, change_to=ref + delta)</span>
+
+<span class="sd">        steps : uint</span>
+<span class="sd">            Number of intermediate values to compute in the interval [min_x, max_x]</span>
+
+<span class="sd">        smoothing_gaussian_sigma_in_steps : uint</span>
+<span class="sd">            The width of the Gauß-kernel used for smoothing, given in steps.</span>
+
+<span class="sd">        normalize_by_delta : bool</span>
+<span class="sd">            Normalize the effect by dividing by cf_delta.</span>
+
+<span class="sd">        Throws</span>
+<span class="sd">        ------</span>
+<span class="sd">        Raises and exception if parameters are not meaningful, adjustment-set is not valid or</span>
+<span class="sd">        normalization requested makes no sense (normalizing probabilites by delta).</span>
+
+<span class="sd">        Returns</span>
+<span class="sd">        -------</span>
+<span class="sd">        NDE : If Y is categorical -&gt; np.array( # steps, # categories Y, 2 )</span>
+<span class="sd">            For each grid-point:</span>
+<span class="sd">            The probabilities the categories of Y (after, before) changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by Y from change_from to change_to, while keeping (blocked) M as if X remained at change_from.</span>
+
+<span class="sd">        NDE : If Y is continuous -&gt; np.array( # steps )</span>
+<span class="sd">            For each grid-point:</span>
+<span class="sd">            The change in the expectation-value of Y induced by changing the interventional value of X</span>
+<span class="sd">            as &quot;seen&quot; by Y from change_from to change_to, while keeping (blocked) M as if X remained at change_from.</span>
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">MediationEstimator</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
+            <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;Call fit_natural_direct_effect before using predict_natural_direct_effect_x.&quot;</span><span class="p">)</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">MediationEstimator</span><span class="o">.</span><span class="n">NDE_smoothed</span><span class="p">(</span><span class="n">min_x</span><span class="p">,</span> <span class="n">max_x</span><span class="p">,</span> <span class="n">cf_delta</span><span class="p">,</span>
+                                                    <span class="n">steps</span><span class="p">,</span> <span class="n">smoothing_gaussian_sigma_in_steps</span><span class="p">,</span>
+                                                    <span class="n">normalize_by_delta</span><span class="p">)</span></div></div>
+</pre></div>
+
+          </div>
+          
+        </div>
+      </div>
+      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
+        <div class="sphinxsidebarwrapper">
+<h1 class="logo"><a href="../../index.html">Tigramite</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+
+<div class="relations">
+<h3>Related Topics</h3>
+<ul>
+  <li><a href="../../index.html">Documentation overview</a><ul>
+  <li><a href="../index.html">Module code</a><ul>
+  </ul></li>
+  </ul></li>
+</ul>
+</div>
+<div id="searchbox" style="display: none" role="search">
+  <h3 id="searchlabel">Quick search</h3>
+    <div class="searchformwrapper">
+    <form class="search" action="../../search.html" method="get">
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
+      <input type="submit" value="Go" />
+    </form>
+    </div>
+</div>
+<script>document.getElementById('searchbox').style.display = "block"</script>
+
+
+
+
+
+
+
+
+        </div>
+      </div>
+      <div class="clearer"></div>
+    </div>
+    <div class="footer">
+      &copy;2023, Jakob Runge.
+      
+      |
+      Powered by <a href="http://sphinx-doc.org/">Sphinx 5.0.2</a>
+      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
+      
+    </div>
+
+    
+
+    
+  </body>
+</html>
\ No newline at end of file
diff --git a/docs/_build/_modules/tigramite/data_processing.html b/docs/_build/_modules/tigramite/data_processing.html
index 0999d6bc..de57f786 100644
--- a/docs/_build/_modules/tigramite/data_processing.html
+++ b/docs/_build/_modules/tigramite/data_processing.html
@@ -712,6 +712,35 @@ <h1>Source code for tigramite.data_processing</h1><div class="highlight"><pre>
                     <span class="n">vectorized_var</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">vector_var</span><span class="p">,</span> <span class="n">vector_lag</span> <span class="o">+</span> <span class="n">lag</span><span class="p">))</span>
             <span class="k">return</span> <span class="n">vectorized_var</span>
 
+
+
+        <span class="c1"># if extended_summary_graph_lag is not None:</span>
+        <span class="c1">#     assert self.vector_vars does not contain lagged microvariables # only space-vectors</span>
+        <span class="c1">#     assert tau_max == 1  # or 0 if mode is &#39;summary_graph&#39; /?</span>
+        <span class="c1">#     # Y = vectorize(Y)</span>
+        <span class="c1">#     varX, lagX = X[0]  # because X = [(i, -lag)]</span>
+            
+        <span class="c1">#     if lagX == 0:</span>
+        <span class="c1">#         pass #X = vectorize(X)</span>
+        <span class="c1">#     elif: lagX == -1:</span>
+        <span class="c1">#         X = [(varX, -lag) for lag in range(1, extended_summary_graph_lag + 1)]</span>
+        <span class="c1">#     else:</span>
+        <span class="c1">#         raise ValueError(&quot;Extended summary graph can only have tau_max = 1&quot;)</span>
+
+        <span class="c1">#     Znew = []</span>
+        <span class="c1">#     for z in Z:</span>
+        <span class="c1">#         varZ, lagZ = z   # z = (k, -1) or (k, -2) or (k, 0)</span>
+        <span class="c1">#         if: lagZ == 0:</span>
+        <span class="c1">#             Znew += z</span>
+        <span class="c1">#         elif: lagZ == -1:</span>
+        <span class="c1">#             Znew += [(varZ, -lag) for lag in range(1, extended_summary_graph_lag + 1)]   </span>
+        <span class="c1">#         elif: lagZ == -2:</span>
+        <span class="c1">#             Znew += [(varZ, -lag) for lag in range(2, 2*extended_summary_graph_lag + 1)]   </span>
+        <span class="c1">#         else:</span>
+        <span class="c1">#             raise ValueError(&quot;Extended summary graph can only have tau_max = 1&quot;)</span>
+        <span class="c1">#     Z = Znew</span>
+
+
         <span class="n">X</span> <span class="o">=</span> <span class="n">vectorize</span><span class="p">(</span><span class="n">X</span><span class="p">)</span> 
         <span class="n">Y</span> <span class="o">=</span> <span class="n">vectorize</span><span class="p">(</span><span class="n">Y</span><span class="p">)</span> 
         <span class="n">Z</span> <span class="o">=</span> <span class="n">vectorize</span><span class="p">(</span><span class="n">Z</span><span class="p">)</span> 
diff --git a/docs/_build/_modules/tigramite/models.html b/docs/_build/_modules/tigramite/models.html
index 6856905b..7af3271d 100644
--- a/docs/_build/_modules/tigramite/models.html
+++ b/docs/_build/_modules/tigramite/models.html
@@ -219,6 +219,7 @@ <h1>Source code for tigramite.models</h1><div class="highlight"><pre>
                 <span class="bp">self</span><span class="o">.</span><span class="n">fitted_data_transform</span><span class="p">[</span><span class="s1">&#39;S&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">S_transform</span>
 
             <span class="c1"># Now transform whole array</span>
+            <span class="c1"># TODO: Rather concatenate transformed arrays</span>
             <span class="n">all_transform</span> <span class="o">=</span> <span class="n">deepcopy</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data_transform</span><span class="p">)</span>
             <span class="n">array</span> <span class="o">=</span> <span class="n">all_transform</span><span class="o">.</span><span class="n">fit_transform</span><span class="p">(</span><span class="n">X</span><span class="o">=</span><span class="n">array</span><span class="o">.</span><span class="n">T</span><span class="p">)</span><span class="o">.</span><span class="n">T</span>
 
@@ -348,7 +349,7 @@ <h1>Source code for tigramite.models</h1><div class="highlight"><pre>
                 <span class="n">predictor_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hstack</span><span class="p">((</span><span class="n">intervention_array</span><span class="p">,</span> <span class="n">z_array</span><span class="p">))</span>
 
             <span class="n">predicted_vals</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_results</span><span class="p">[</span><span class="s1">&#39;model&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">predict</span><span class="p">(</span>
-            <span class="n">X</span><span class="o">=</span><span class="n">predictor_array</span><span class="p">,</span> <span class="o">**</span><span class="n">pred_params</span><span class="p">)</span>
+                                                    <span class="n">X</span><span class="o">=</span><span class="n">predictor_array</span><span class="p">,</span> <span class="o">**</span><span class="n">pred_params</span><span class="p">)</span>
 
             <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">conditions</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">conditions_data</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
 
@@ -366,7 +367,7 @@ <h1>Source code for tigramite.models</h1><div class="highlight"><pre>
                     <span class="n">X</span><span class="o">=</span><span class="n">conditions_array</span><span class="p">,</span> <span class="o">**</span><span class="n">pred_params</span><span class="p">)</span>
 
             <span class="k">if</span> <span class="n">transform_interventions_and_prediction</span> <span class="ow">and</span> <span class="n">fitted_data_transform</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
-                <span class="n">predicted_vals</span> <span class="o">=</span> <span class="n">fitted_data_transform</span><span class="p">[</span><span class="s1">&#39;Y&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">inverse_transform</span><span class="p">(</span><span class="n">X</span><span class="o">=</span><span class="n">predicted_vals</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span><span class="o">.</span><span class="n">squeeze</span><span class="p">()</span>
+                <span class="n">predicted_vals</span> <span class="o">=</span> <span class="n">fitted_data_transform</span><span class="p">[</span><span class="s1">&#39;Y&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">inverse_transform</span><span class="p">(</span><span class="n">X</span><span class="o">=</span><span class="n">predicted_vals</span><span class="p">)</span><span class="o">.</span><span class="n">squeeze</span><span class="p">()</span>
 
             <span class="n">pred_dict</span><span class="p">[</span><span class="n">index</span><span class="p">]</span> <span class="o">=</span> <span class="n">predicted_vals</span>
 
diff --git a/docs/_build/_modules/tigramite/plotting.html b/docs/_build/_modules/tigramite/plotting.html
index dbd0f501..6fe61f4a 100644
--- a/docs/_build/_modules/tigramite/plotting.html
+++ b/docs/_build/_modules/tigramite/plotting.html
@@ -484,9 +484,9 @@ <h1>Source code for tigramite.plotting</h1><div class="highlight"><pre>
 <span class="sd">    figsize : tuple of floats, optional (default: None)</span>
 <span class="sd">        Figure size if new figure is created. If None, default pyplot figsize</span>
 <span class="sd">        is used.</span>
-<span class="sd">    minimum : int, optional (default: -1)</span>
+<span class="sd">    minimum : float, optional (default: -1.)</span>
 <span class="sd">        Lower y-axis limit.</span>
-<span class="sd">    maximum : int, optional (default: 1)</span>
+<span class="sd">    maximum : float, optional (default: 1.)</span>
 <span class="sd">        Upper y-axis limit.</span>
 <span class="sd">    label_space_left : float, optional (default: 0.1)</span>
 <span class="sd">        Fraction of horizontal figure space to allocate left of plot for labels.</span>
@@ -4554,10 +4554,14 @@ <h1>Source code for tigramite.plotting</h1><div class="highlight"><pre>
     <span class="c1">#     verbosity=1)</span>
 
 
-    <span class="c1"># correlations = pcmci.get_lagged_dependencies(tau_max=20, val_only=True)[&#39;val_matrix&#39;]</span>
-    <span class="c1"># lag_func_matrix = plot_lagfuncs(val_matrix=correlations, setup_args={&#39;label_space_left&#39;:0.05, </span>
-    <span class="c1">#                                 &#39;x_base&#39;:5, &#39;y_base&#39;:.5})</span>
-    <span class="c1"># plt.show()</span>
+    <span class="n">correlations</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">rand</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span> <span class="o">-</span> <span class="mf">0.5</span> <span class="c1">#pcmci.get_lagged_dependencies(tau_max=20, val_only=True)[&#39;val_matrix&#39;]</span>
+    <span class="n">lag_func_matrix</span> <span class="o">=</span> <span class="n">plot_lagfuncs</span><span class="p">(</span><span class="n">val_matrix</span><span class="o">=</span><span class="n">correlations</span><span class="p">,</span> <span class="n">setup_args</span><span class="o">=</span><span class="p">{</span>
+                        <span class="s1">&#39;label_space_left&#39;</span><span class="p">:</span><span class="mf">0.05</span><span class="p">,</span> 
+                                    <span class="s1">&#39;minimum&#39;</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
+                                    <span class="s1">&#39;maximum&#39;</span><span class="p">:</span><span class="mf">.05</span><span class="p">,</span>
+                                    <span class="s1">&#39;x_base&#39;</span><span class="p">:</span><span class="mi">5</span><span class="p">,</span> 
+                                    <span class="s1">&#39;y_base&#39;</span><span class="p">:</span><span class="mf">.5</span><span class="p">})</span>
+    <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
 
     
     <span class="c1"># N = len(links)</span>
@@ -4593,36 +4597,36 @@ <h1>Source code for tigramite.plotting</h1><div class="highlight"><pre>
 
     <span class="c1"># val_matrix = np.zeros((4, 4, 3))</span>
 
-    <span class="c1"># Complete test case</span>
-    <span class="n">graph</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">2</span><span class="p">),</span> <span class="n">dtype</span><span class="o">=</span><span class="s1">&#39;&lt;U3&#39;</span><span class="p">)</span>
-    <span class="n">val_matrix</span> <span class="o">=</span> <span class="mf">0.</span><span class="o">*</span><span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">rand</span><span class="p">(</span><span class="o">*</span><span class="n">graph</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
-    <span class="n">val_matrix</span><span class="p">[:,:,</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.2</span>
-    <span class="n">graph</span><span class="p">[:]</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
-    <span class="c1"># graph[0, 1, 0] = &quot;&lt;-+&quot;</span>
-    <span class="c1"># graph[1, 0, 0] = &quot;+-&gt;&quot;</span>
-    <span class="n">graph</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;--&gt;&quot;</span>
-    <span class="n">graph</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;--&gt;&quot;</span>
+    <span class="c1"># # Complete test case</span>
+    <span class="c1"># graph = np.zeros((3,3,2), dtype=&#39;&lt;U3&#39;)</span>
+    <span class="c1"># val_matrix = 0.*np.random.rand(*graph.shape)</span>
+    <span class="c1"># val_matrix[:,:,0] = 0.2</span>
+    <span class="c1"># graph[:] = &quot;&quot;</span>
+    <span class="c1"># # graph[0, 1, 0] = &quot;&lt;-+&quot;</span>
+    <span class="c1"># # graph[1, 0, 0] = &quot;+-&gt;&quot;</span>
+    <span class="c1"># graph[0, 0, 1] = &quot;--&gt;&quot;</span>
+    <span class="c1"># graph[1, 1, 1] = &quot;--&gt;&quot;</span>
 
-    <span class="n">graph</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;+-&gt;&quot;</span>
-    <span class="c1"># graph[1, 0, 1] = &quot;o-o&quot;</span>
+    <span class="c1"># graph[0, 1, 1] = &quot;+-&gt;&quot;</span>
+    <span class="c1"># # graph[1, 0, 1] = &quot;o-o&quot;</span>
 
     <span class="c1"># graph[1, 2, 0] = &quot;&lt;-&gt;&quot;</span>
     <span class="c1"># graph[2, 1, 0] = &quot;&lt;-&gt;&quot;</span>
 
     <span class="c1"># graph[0, 2, 0] = &quot;x-x&quot;</span>
-    <span class="c1"># graph[2, 0, 0] = &quot;x-x&quot;</span>
-    <span class="n">nolinks</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">graph</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
-    <span class="c1"># nolinks[range(4), range(4), 1] = 1</span>
+    <span class="c1"># # graph[2, 0, 0] = &quot;x-x&quot;</span>
+    <span class="c1"># nolinks = np.zeros(graph.shape)</span>
+    <span class="c1"># # nolinks[range(4), range(4), 1] = 1</span>
 
-    <span class="c1"># graph = graph[:2, :2, :]</span>
+    <span class="c1"># # graph = graph[:2, :2, :]</span>
 
-    <span class="c1"># fig, axes = pyplot.subplots(nrows=1, ncols=1, figsize=(6, 5))</span>
+    <span class="c1"># # fig, axes = pyplot.subplots(nrows=1, ncols=1, figsize=(6, 5))</span>
 
 
-    <span class="c1"># import cartopy.crs as ccrs</span>
-    <span class="n">graph</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ones</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">dtype</span><span class="o">=</span><span class="s1">&#39;&lt;U3&#39;</span><span class="p">)</span>
-    <span class="n">graph</span><span class="p">[:]</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
-    <span class="n">graph</span><span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="p">:,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;+-&gt;&#39;</span> 
+    <span class="c1"># # import cartopy.crs as ccrs</span>
+    <span class="c1"># graph = np.ones((5, 5, 2), dtype=&#39;&lt;U3&#39;)</span>
+    <span class="c1"># graph[:] = &quot;&quot;</span>
+    <span class="c1"># graph[3, :, 1] = &#39;+-&gt;&#39; </span>
 
     <span class="c1"># fig = pyplot.figure(figsize=(8, 6))</span>
     <span class="c1"># fig = pyplot.figure(figsize=(10, 5))</span>
@@ -4639,18 +4643,18 @@ <h1>Source code for tigramite.plotting</h1><div class="highlight"><pre>
     <span class="c1">#         &#39;transform&#39;:ccrs.PlateCarree(), # t.PlateCarree()</span>
     <span class="c1">#         }</span>
 
-    <span class="n">plot_time_series_graph</span><span class="p">(</span><span class="n">graph</span><span class="o">=</span><span class="n">graph</span><span class="p">,</span>
-        <span class="c1"># fig_ax = (fig, ax),</span>
-        <span class="c1"># val_matrix=val_matrix,</span>
-        <span class="c1"># figsize=(5, 5),</span>
-        <span class="c1"># var_names = [&#39;Var %s&#39; %i for i in range(len(graph))],</span>
-        <span class="c1"># arrow_linewidth=6,</span>
-        <span class="c1"># label_space_left = label_space_left,</span>
-        <span class="c1"># label_space_top = label_space_top,</span>
-        <span class="c1"># # network_lower_bound=network_lower_bound,</span>
-        <span class="n">save_name</span><span class="o">=</span><span class="s2">&quot;tsg_test.pdf&quot;</span>
-        <span class="p">)</span>
-    <span class="n">pyplot</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>
+    <span class="c1"># plot_time_series_graph(graph=graph,</span>
+    <span class="c1">#     # fig_ax = (fig, ax),</span>
+    <span class="c1">#     # val_matrix=val_matrix,</span>
+    <span class="c1">#     # figsize=(5, 5),</span>
+    <span class="c1">#     # var_names = [&#39;Var %s&#39; %i for i in range(len(graph))],</span>
+    <span class="c1">#     # arrow_linewidth=6,</span>
+    <span class="c1">#     # label_space_left = label_space_left,</span>
+    <span class="c1">#     # label_space_top = label_space_top,</span>
+    <span class="c1">#     # # network_lower_bound=network_lower_bound,</span>
+    <span class="c1">#     save_name=&quot;tsg_test.pdf&quot;</span>
+    <span class="c1">#     )</span>
+    <span class="c1"># pyplot.tight_layout()</span>
 
     <span class="c1"># network_lower_bound = 0.</span>
     <span class="c1"># show_colorbar=True</span>
diff --git a/docs/_build/_sources/index.rst.txt b/docs/_build/_sources/index.rst.txt
index 42bce32f..da414491 100644
--- a/docs/_build/_sources/index.rst.txt
+++ b/docs/_build/_sources/index.rst.txt
@@ -80,6 +80,7 @@ Tigramite is a causal time series analysis python package. It allows to efficien
    tigramite.independence_tests.parcorr_wls.ParCorrWLS
    tigramite.independence_tests.regressionCI.RegressionCI
    tigramite.causal_effects.CausalEffects
+   tigramite.causal_mediation.CausalMediation
    tigramite.models.Models
    tigramite.models.LinearMediation
    tigramite.models.Prediction
@@ -161,6 +162,12 @@ Test statistics:
 .. autoclass:: tigramite.causal_effects.CausalEffects
    :members:
 
+:mod:`tigramite.causal_mediation`: Causal mediation analysis
+===========================================================
+
+.. autoclass:: tigramite.causal_mediation.CausalMediation
+   :members:
+
 
 :mod:`tigramite.models`: Time series modeling, mediation, and prediction
 ========================================================================
diff --git a/docs/_build/genindex.html b/docs/_build/genindex.html
index 5b337123..19437581 100644
--- a/docs/_build/genindex.html
+++ b/docs/_build/genindex.html
@@ -109,6 +109,8 @@ <h2 id="C">C</h2>
 <table style="width: 100%" class="indextable genindextable"><tr>
   <td style="width: 33%; vertical-align: top;"><ul>
       <li><a href="index.html#tigramite.causal_effects.CausalEffects">CausalEffects (class in tigramite.causal_effects)</a>
+</li>
+      <li><a href="index.html#tigramite.causal_mediation.CausalMediation">CausalMediation (class in tigramite.causal_mediation)</a>
 </li>
       <li><a href="index.html#tigramite.causal_effects.CausalEffects.check_optimality">check_optimality() (tigramite.causal_effects.CausalEffects method)</a>
 </li>
@@ -172,11 +174,13 @@ <h2 id="F">F</h2>
 </li>
       <li><a href="index.html#tigramite.models.Models.fit_full_model">fit_full_model() (tigramite.models.Models method)</a>
 </li>
-  </ul></td>
-  <td style="width: 33%; vertical-align: top;"><ul>
       <li><a href="index.html#tigramite.models.LinearMediation.fit_model">fit_model() (tigramite.models.LinearMediation method)</a>
 </li>
+  </ul></td>
+  <td style="width: 33%; vertical-align: top;"><ul>
       <li><a href="index.html#tigramite.models.LinearMediation.fit_model_bootstrap">fit_model_bootstrap() (tigramite.models.LinearMediation method)</a>
+</li>
+      <li><a href="index.html#tigramite.causal_mediation.CausalMediation.fit_natural_direct_effect">fit_natural_direct_effect() (tigramite.causal_mediation.CausalMediation method)</a>
 </li>
       <li><a href="index.html#tigramite.causal_effects.CausalEffects.fit_total_effect">fit_total_effect() (tigramite.causal_effects.CausalEffects method)</a>
 </li>
@@ -547,15 +551,19 @@ <h2 id="P">P</h2>
 </li>
       <li><a href="index.html#tigramite.plotting.plot_timeseries">plot_timeseries() (in module tigramite.plotting)</a>
 </li>
-  </ul></td>
-  <td style="width: 33%; vertical-align: top;"><ul>
       <li><a href="index.html#tigramite.plotting.plot_tsg">plot_tsg() (in module tigramite.plotting)</a>
 </li>
+  </ul></td>
+  <td style="width: 33%; vertical-align: top;"><ul>
       <li><a href="index.html#tigramite.models.Prediction.predict">predict() (tigramite.models.Prediction method)</a>
 </li>
       <li><a href="index.html#tigramite.causal_effects.CausalEffects.predict_bootstrap_of">predict_bootstrap_of() (tigramite.causal_effects.CausalEffects method)</a>
 </li>
       <li><a href="index.html#tigramite.models.Models.predict_full_model">predict_full_model() (tigramite.models.Models method)</a>
+</li>
+      <li><a href="index.html#tigramite.causal_mediation.CausalMediation.predict_natural_direct_effect">predict_natural_direct_effect() (tigramite.causal_mediation.CausalMediation method)</a>
+</li>
+      <li><a href="index.html#tigramite.causal_mediation.CausalMediation.predict_natural_direct_effect_function">predict_natural_direct_effect_function() (tigramite.causal_mediation.CausalMediation method)</a>
 </li>
       <li><a href="index.html#tigramite.causal_effects.CausalEffects.predict_total_effect">predict_total_effect() (tigramite.causal_effects.CausalEffects method)</a>
 </li>
diff --git a/docs/_build/index.html b/docs/_build/index.html
index f8bcbd3c..179c4e68 100644
--- a/docs/_build/index.html
+++ b/docs/_build/index.html
@@ -118,22 +118,25 @@ <h1>TIGRAMITE<a class="headerlink" href="#tigramite" title="Permalink to this he
 <tr class="row-odd"><td><p><a class="reference internal" href="#tigramite.causal_effects.CausalEffects" title="tigramite.causal_effects.CausalEffects"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.causal_effects.CausalEffects</span></code></a>(...)</p></td>
 <td><p>Causal effect estimation.</p></td>
 </tr>
-<tr class="row-even"><td><p><a class="reference internal" href="#tigramite.models.Models" title="tigramite.models.Models"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.models.Models</span></code></a>(dataframe, model[, ...])</p></td>
+<tr class="row-even"><td><p><a class="reference internal" href="#tigramite.causal_mediation.CausalMediation" title="tigramite.causal_mediation.CausalMediation"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.causal_mediation.CausalMediation</span></code></a>(...)</p></td>
+<td><p>Non-linear, non-additive causal mediation analysis.</p></td>
+</tr>
+<tr class="row-odd"><td><p><a class="reference internal" href="#tigramite.models.Models" title="tigramite.models.Models"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.models.Models</span></code></a>(dataframe, model[, ...])</p></td>
 <td><p>Base class for time series models.</p></td>
 </tr>
-<tr class="row-odd"><td><p><a class="reference internal" href="#tigramite.models.LinearMediation" title="tigramite.models.LinearMediation"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.models.LinearMediation</span></code></a>(dataframe)</p></td>
+<tr class="row-even"><td><p><a class="reference internal" href="#tigramite.models.LinearMediation" title="tigramite.models.LinearMediation"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.models.LinearMediation</span></code></a>(dataframe)</p></td>
 <td><p>Linear mediation analysis for time series models.</p></td>
 </tr>
-<tr class="row-even"><td><p><a class="reference internal" href="#tigramite.models.Prediction" title="tigramite.models.Prediction"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.models.Prediction</span></code></a>(dataframe, ...)</p></td>
+<tr class="row-odd"><td><p><a class="reference internal" href="#tigramite.models.Prediction" title="tigramite.models.Prediction"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.models.Prediction</span></code></a>(dataframe, ...)</p></td>
 <td><p>Prediction class for time series models.</p></td>
 </tr>
-<tr class="row-odd"><td><p><a class="reference internal" href="#module-tigramite.data_processing" title="tigramite.data_processing"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.data_processing</span></code></a></p></td>
+<tr class="row-even"><td><p><a class="reference internal" href="#module-tigramite.data_processing" title="tigramite.data_processing"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.data_processing</span></code></a></p></td>
 <td><p>Tigramite data processing functions.</p></td>
 </tr>
-<tr class="row-even"><td><p><a class="reference internal" href="#module-tigramite.toymodels.structural_causal_processes" title="tigramite.toymodels.structural_causal_processes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.toymodels.structural_causal_processes</span></code></a></p></td>
+<tr class="row-odd"><td><p><a class="reference internal" href="#module-tigramite.toymodels.structural_causal_processes" title="tigramite.toymodels.structural_causal_processes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.toymodels.structural_causal_processes</span></code></a></p></td>
 <td><p>Tigramite toymodels.</p></td>
 </tr>
-<tr class="row-odd"><td><p><a class="reference internal" href="#module-tigramite.plotting" title="tigramite.plotting"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.plotting</span></code></a></p></td>
+<tr class="row-even"><td><p><a class="reference internal" href="#module-tigramite.plotting" title="tigramite.plotting"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.plotting</span></code></a></p></td>
 <td><p>Tigramite plotting package.</p></td>
 </tr>
 </tbody>
@@ -3867,6 +3870,137 @@ <h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">
 
 </dd></dl>
 
+</section>
+<section id="tigramite-causal-mediation-causal-mediation-analysis">
+<h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">tigramite.causal_mediation</span></code>: Causal mediation analysis<a class="headerlink" href="#tigramite-causal-mediation-causal-mediation-analysis" title="Permalink to this heading">¶</a></h1>
+<dl class="py class">
+<dt class="sig sig-object py" id="tigramite.causal_mediation.CausalMediation">
+<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.causal_mediation.</span></span><span class="sig-name descname"><span class="pre">CausalMediation</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">graph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">graph_type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">S</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hidden_variables</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_mediation.html#CausalMediation"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_mediation.CausalMediation" title="Permalink to this definition">¶</a></dt>
+<dd><p>Non-linear, non-additive causal mediation analysis.</p>
+<p>See the tutorial on Causal Mediation.</p>
+<p>Extends the tigramite.CausalEffects class by natural-effect estimation for counter-factual mediation analysis.
+Effects are estimated by adjustment, where adjustment-sets can be generated automatically (if they exist).</p>
+<p>Actual fit-models can be chosen independently, for details see
+technical appendix B in the mediation-tutorial.</p>
+<p>See references and tigramite tutorial for an in-depth introduction.</p>
+<p class="rubric">References</p>
+<p>J. Pearl. Direct and indirect effects. Proceedings of the Seventeenth Conference
+on Uncertainty in Artificial intelligence, 2001.</p>
+<p>J. Pearl. Interpretation and identification of causal mediation. Psychological
+methods, 19(4):459, 2014.</p>
+<p>I. Shpitser and T. J. VanderWeele. A complete graphical criterion for the adjust-
+ment formula in mediation analysis. The international journal of biostatistics,
+7(1), 2011.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters<span class="colon">:</span></dt>
+<dd class="field-odd"><ul class="simple">
+<li><p><strong>graph</strong> (<em>np.array</em><em>( </em><em>[</em><em>N</em><em>, </em><em>N</em><em>] or </em><em>[</em><em>N</em><em>, </em><em>N</em><em>, </em><em>tau_max+1</em><em>] </em><em>depending on graph_type</em><em> ) </em><em>of 3-character patterns</em>) – The causal graph, see ‘Causal Effects’ tutorial. E.g. returned by causal discovery method
+(see “Tutorials/Causal Discovery/CD Overview”) or by a toymodel (see toy_setup.Model.GetGroundtruthGraph or
+the Mediation tutorial).</p></li>
+<li><p><strong>graph_type</strong> (<em>string</em>) – The type of graph, tested for ‘dag’ and ‘stationary_dag’ (time-series). See ‘Causal Effects’ tutorial.</p></li>
+<li><p><strong>X</strong> (<em>(</em><em>idx</em><em>, </em><em>-lag</em><em>)</em>) – Index of the effect-source.</p></li>
+<li><p><strong>Y</strong> (<em>(</em><em>idx</em><em>, </em><em>-lag</em><em>)</em>) – Index of the effect-target.</p></li>
+<li><p><strong>S</strong> (<em>None</em>) – Reserved. Must be None in current version.</p></li>
+<li><p><strong>hidden_variables</strong> (<em>None</em>) – Reserved. Must be None in current version.</p></li>
+<li><p><strong>verbosity</strong> (<em>uint</em>) – Tigramite.CausalEffects verbosity setting.</p></li>
+</ul>
+</dd>
+</dl>
+<dl class="py method">
+<dt class="sig sig-object py" id="tigramite.causal_mediation.CausalMediation.fit_natural_direct_effect">
+<span class="sig-name descname"><span class="pre">fit_natural_direct_effect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mixed_data_estimator=&lt;tigramite.causal_mediation.FitSetup</span> <span class="pre">object&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">blocked_mediators='all'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">adjustment_set='auto'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_mediation_impl_for_total_effect_fallback=False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_mediation.html#CausalMediation.fit_natural_direct_effect"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_mediation.CausalMediation.fit_natural_direct_effect" title="Permalink to this definition">¶</a></dt>
+<dd><p>Fit a natural direct effect.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters<span class="colon">:</span></dt>
+<dd class="field-odd"><ul class="simple">
+<li><p><strong>dataframe</strong> (<em>tigramite.Dataframe</em>) – Observed data.</p></li>
+<li><p><strong>mixed_data_estimator</strong> (<em>mixed_fit.FitSetup</em>) – The fit-configuration to use. See mixed_fit.FitSetup and the Mediation tutorial, Appendix B.</p></li>
+<li><p><strong>blocked_mediators</strong> (‘all’ or <em>iterable</em> of &lt; (idx, -lag) &gt;) – Which mediators to ‘block’ (consider indirect), <em>un</em>blocked mediators are considered as
+contributions to the <em>direct</em> effect.</p></li>
+<li><p><strong>adjustment_set</strong> (‘auto’ or None or <em>iterable</em> &lt; (idx, -lag) &gt;) – Adjustment-set to use. Will be validated if specified explicitly, if ‘auto’ or None, will try
+to use an ‘optimal’ set, fall back to [Perkovic et al]’s adjustment-set (which should always
+work if single-set adjustment as in [Shpitser, VanderWeele] os possible; this follows
+from combining results of [Shpitser, VanderWeele] and [Perkovic et al]).
+See ‘Causal Effects’ and its tutorial for more info and references on (optimal) adjustment.</p></li>
+<li><p><strong>use_mediation_impl_for_total_effect_fallback</strong> (<em>bool</em>) – If True, if no mediators are blocked, use mediation implementation to estimate the total effect.
+In this case, estimating the total effect through the ‘Causal Effects’ class might be easier,
+however, for comparison to other estimates, using this option might yield more consistent results.</p></li>
+</ul>
+</dd>
+<dt class="field-even">Returns<span class="colon">:</span></dt>
+<dd class="field-even"><p><strong>estimator</strong> – Typically, use predict_natural_direct_effect or predict_natural_direct_effect_function
+to use the fitted estimator.
+The internal NaturalEffects_GraphMediation (if needed).</p>
+</dd>
+<dt class="field-odd">Return type<span class="colon">:</span></dt>
+<dd class="field-odd"><p>NaturalEffects_GraphMediation</p>
+</dd>
+</dl>
+</dd></dl>
+
+<dl class="py method">
+<dt class="sig sig-object py" id="tigramite.causal_mediation.CausalMediation.predict_natural_direct_effect">
+<span class="sig-name descname"><span class="pre">predict_natural_direct_effect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">reference_value_x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cf_intervention_value_x</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_mediation.html#CausalMediation.predict_natural_direct_effect"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_mediation.CausalMediation.predict_natural_direct_effect" title="Permalink to this definition">¶</a></dt>
+<dd><p><em>After fitting</em> a natural direct effect, predict its value at a specific point.
+See also predict_natural_direct_effect_function.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters<span class="colon">:</span></dt>
+<dd class="field-odd"><ul class="simple">
+<li><p><strong>reference_value_x</strong> (<em>single value of same type as single sample for X</em><em> (</em><em>float</em><em>, </em><em>int</em><em>, or </em><em>bool</em><em>)</em>) – Reference-value to which X is set by intervention in the world seen by the (blocked) mediators.</p></li>
+<li><p><strong>cf_intervention_value_x</strong> (<em>single value of same type as single sample for X</em><em> (</em><em>float</em><em>, </em><em>int</em><em>, or </em><em>bool</em><em>)</em>) – Post-intervention-value to which X is set by intervention in the world seen by the effect (directly).</p></li>
+<li><p><strong>Throws</strong> – </p></li>
+<li><p><strong>------</strong> – </p></li>
+<li><p><strong>valid.</strong> (<em>Raises and exception if parameters are not meaningful</em><em> or </em><em>if adjustment-set is not</em>) – </p></li>
+</ul>
+</dd>
+<dt class="field-even">Returns<span class="colon">:</span></dt>
+<dd class="field-even"><p><ul class="simple">
+<li><p><strong>NDE</strong> (<em>If Y is categorical -&gt; np.array( # categories Y, 2 )</em>) – The probabilities the categories of Y (after, before) changing the interventional value of X
+as “seen” by Y from change_from to change_to, while keeping (blocked) M as if X remained at change_from.</p></li>
+<li><p><strong>NDE</strong> (<em>If Y is continuous -&gt; float</em>) – The change in the expectation-value of Y induced by changing the interventional value of X
+as “seen” by Y from change_from to change_to, while keeping (blocked) M as if X remained at change_from.</p></li>
+</ul>
+</p>
+</dd>
+</dl>
+</dd></dl>
+
+<dl class="py method">
+<dt class="sig sig-object py" id="tigramite.causal_mediation.CausalMediation.predict_natural_direct_effect_function">
+<span class="sig-name descname"><span class="pre">predict_natural_direct_effect_function</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">min_x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cf_delta</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">steps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">smoothing_gaussian_sigma_in_steps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">normalize_by_delta</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_mediation.html#CausalMediation.predict_natural_direct_effect_function"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_mediation.CausalMediation.predict_natural_direct_effect_function" title="Permalink to this definition">¶</a></dt>
+<dd><p>Compute NDE as <em>smoothed</em> function</p>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters<span class="colon">:</span></dt>
+<dd class="field-odd"><ul class="simple">
+<li><p><strong>min_x</strong> (<em>float</em>) – Lower bound of interval on which reference-values for X are taken</p></li>
+<li><p><strong>max_x</strong> (<em>float</em>) – Upper bound of interval on which reference-values for X are taken</p></li>
+<li><p><strong>cf_delta</strong> (<em>float</em>) – The change from reference-value to effect-value (change_from=reference, change_to=ref + delta)</p></li>
+<li><p><strong>steps</strong> (<em>uint</em>) – Number of intermediate values to compute in the interval [min_x, max_x]</p></li>
+<li><p><strong>smoothing_gaussian_sigma_in_steps</strong> (<em>uint</em>) – The width of the Gauß-kernel used for smoothing, given in steps.</p></li>
+<li><p><strong>normalize_by_delta</strong> (<em>bool</em>) – Normalize the effect by dividing by cf_delta.</p></li>
+<li><p><strong>Throws</strong> – </p></li>
+<li><p><strong>------</strong> – </p></li>
+<li><p><strong>meaningful</strong> (<em>Raises and exception if parameters are not</em>) – </p></li>
+<li><p><strong>or</strong> (<em>adjustment-set is not valid</em>) – </p></li>
+<li><p><strong>delta</strong><strong>)</strong><strong>.</strong> (<em>normalization requested makes no sense</em><em> (</em><em>normalizing probabilites by</em>) – </p></li>
+</ul>
+</dd>
+<dt class="field-even">Returns<span class="colon">:</span></dt>
+<dd class="field-even"><p><ul class="simple">
+<li><p><strong>NDE</strong> (<em>If Y is categorical -&gt; np.array( # steps, # categories Y, 2 )</em>) – For each grid-point:
+The probabilities the categories of Y (after, before) changing the interventional value of X
+as “seen” by Y from change_from to change_to, while keeping (blocked) M as if X remained at change_from.</p></li>
+<li><p><strong>NDE</strong> (<em>If Y is continuous -&gt; np.array( # steps )</em>) – For each grid-point:
+The change in the expectation-value of Y induced by changing the interventional value of X
+as “seen” by Y from change_from to change_to, while keeping (blocked) M as if X remained at change_from.</p></li>
+</ul>
+</p>
+</dd>
+</dl>
+</dd></dl>
+
+</dd></dl>
+
 </section>
 <section id="tigramite-models-time-series-modeling-mediation-and-prediction">
 <h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">tigramite.models</span></code>: Time series modeling, mediation, and prediction<a class="headerlink" href="#tigramite-models-time-series-modeling-mediation-and-prediction" title="Permalink to this heading">¶</a></h1>
@@ -6088,8 +6222,8 @@ <h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">
 <li><p><strong>var_names</strong> (<em>list</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – List of variable names. If None, range(N) is used.</p></li>
 <li><p><strong>figsize</strong> (<em>tuple of floats</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Figure size if new figure is created. If None, default pyplot figsize
 is used.</p></li>
-<li><p><strong>minimum</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: -1</em><em>)</em>) – Lower y-axis limit.</p></li>
-<li><p><strong>maximum</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Upper y-axis limit.</p></li>
+<li><p><strong>minimum</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: -1.</em><em>)</em>) – Lower y-axis limit.</p></li>
+<li><p><strong>maximum</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1.</em><em>)</em>) – Upper y-axis limit.</p></li>
 <li><p><strong>label_space_left</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.1</em><em>)</em>) – Fraction of horizontal figure space to allocate left of plot for labels.</p></li>
 <li><p><strong>label_space_top</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.05</em><em>)</em>) – Fraction of vertical figure space to allocate top of plot for labels.</p></li>
 <li><p><strong>legend_width</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.15</em><em>)</em>) – Fraction of horizontal figure space to allocate right of plot for
diff --git a/docs/_build/objects.inv b/docs/_build/objects.inv
index c140aaaf..81a90693 100644
Binary files a/docs/_build/objects.inv and b/docs/_build/objects.inv differ
diff --git a/docs/_build/searchindex.js b/docs/_build/searchindex.js
index d797528f..5cbdc984 100644
--- a/docs/_build/searchindex.js
+++ b/docs/_build/searchindex.js
@@ -1,1 +1,1 @@
-Search.setIndex({"docnames": ["index"], "filenames": ["index.rst"], "titles": ["Welcome to Tigramite\u2019s documentation!"], "terms": {"index": 0, "modul": 0, "search": 0, "page": 0, "github": 0, "repo": 0, "python": 0, "packag": 0, "It": 0, "allow": 0, "effici": 0, "estim": 0, "graph": 0, "from": 0, "high": 0, "dimension": 0, "dataset": 0, "discoveri": 0, "us": 0, "robust": 0, "forecast": 0, "direct": 0, "total": 0, "base": 0, "linear": 0, "well": 0, "non": 0, "parametr": 0, "applic": 0, "discret": 0, "continu": 0, "valu": 0, "also": 0, "includ": 0, "qualiti": 0, "result": 0, "pleas": 0, "cite": 0, "follow": 0, "paper": 0, "depend": 0, "which": 0, "method": 0, "you": 0, "overview": 0, "rung": 0, "j": 0, "gerhardu": 0, "A": 0, "varando": 0, "g": 0, "et": 0, "al": 0, "infer": 0, "nat": 0, "rev": 0, "earth": 0, "environ": 0, "2023": 0, "http": 0, "doi": 0, "org": 0, "10": 0, "1038": 0, "s43017": 0, "023": 0, "00431": 0, "y": 0, "p": 0, "nowack": 0, "m": 0, "kretschmer": 0, "flaxman": 0, "d": 0, "sejdinov": 0, "detect": 0, "quantifi": 0, "associ": 0, "larg": 0, "nonlinear": 0, "sci": 0, "adv": 0, "5": 0, "eaau4996": 0, "2019": 0, "advanc": 0, "sciencemag": 0, "content": 0, "11": 0, "2020": 0, "discov": 0, "contemporan": 0, "lag": 0, "relat": 0, "autocorrel": 0, "proceed": 0, "36th": 0, "confer": 0, "uncertainti": 0, "artifici": 0, "intellig": 0, "uai": 0, "toronto": 0, "canada": 0, "auai": 0, "press": 0, "uai2020": 0, "579_main_pap": 0, "pdf": 0, "recal": 0, "latent": 0, "confound": 0, "neural": 0, "inform": 0, "system": 0, "33": 0, "neurip": 0, "cc": 0, "hash": 0, "94e70705efae423efda1088614128d0b": 0, "abstract": 0, "html": 0, "elena": 0, "saggioro": 0, "jana": 0, "de": 0, "wilj": 0, "marlen": 0, "jakob": 0, "reconstruct": 0, "regim": 0, "relationship": 0, "observ": 0, "chao": 0, "1": 0, "novemb": 0, "30": 0, "113115": 0, "1063": 0, "0020538": 0, "2018": 0, "network": 0, "theoret": 0, "assumpt": 0, "practic": 0, "an": 0, "interdisciplinari": 0, "journal": 0, "scienc": 0, "28": 0, "7": 0, "075310": 0, "aip": 0, "scitat": 0, "5025050": 0, "natur": 0, "commun": 0, "perspect": 0, "www": 0, "com": 0, "articl": 0, "s41467": 0, "019": 0, "10105": 0, "3": 0, "necessari": 0, "suffici": 0, "graphic": 0, "optim": 0, "adjust": 0, "set": 0, "hidden": 0, "variabl": 0, "2021": 0, "34": 0, "class": 0, "2015": 0, "identifi": 0, "gatewai": 0, "complex": 0, "spatio": 0, "tempor": 0, "6": 0, "8502": 0, "ncomms9502": 0, "transfer": 0, "along": 0, "pathwai": 0, "phy": 0, "e": 0, "92": 0, "62829": 0, "1103": 0, "physrev": 0, "062829": 0, "cmiknn": 0, "nearest": 0, "neighbor": 0, "mutual": 0, "In": 0, "21st": 0, "intern": 0, "statist": 0, "mlr": 0, "v84": 0, "runge18a": 0, "datafram": 0, "cond_ind_test": 0, "verbos": 0, "0": 0, "sourc": 0, "framework": 0, "scale": 0, "thi": 0, "contain": 0, "sever": 0, "The": 0, "standard": 0, "address": 0, "describ": 0, "where": 0, "further": 0, "sub": 0, "variant": 0, "ar": 0, "discuss": 0, "pcmciplu": 0, "see": 0, "tutori": 0, "guidanc": 0, "appli": 0, "ha": 0, "differ": 0, "adapt": 0, "implement": 0, "mostli": 0, "hyperparamet": 0, "easi": 0, "parallel": 0, "separ": 0, "script": 0, "handl": 0, "mask": 0, "fals": 0, "control": 0, "confid": 0, "interv": 0, "note": 0, "structur": 0, "repres": 0, "shown": 0, "figur": 0, "node": 0, "defin": 0, "link": 0, "can": 0, "interpret": 0, "under": 0, "certain": 0, "assum": 0, "stationar": 0, "repeat": 0, "parent": 0, "mathcal": 0, "all": 0, "toward": 0, "blue": 0, "red": 0, "box": 0, "iter": 0, "flexibl": 0, "combin": 0, "ani": 0, "kind": 0, "its": 0, "type": 0, "These": 0, "avail": 0, "mci": 0, "particular": 0, "measur": 0, "strength": 0, "For": 0, "exampl": 0, "parcorr": 0, "normal": 0, "between": 0, "howev": 0, "interest": 0, "i": 0, "hypothet": 0, "intervent": 0, "mai": 0, "better": 0, "look": 0, "refer": 0, "w": 0, "paramet": 0, "object": 0, "among": 0, "other": 0, "attribut": 0, "yield": 0, "numpi": 0, "arrai": 0, "shape": 0, "t": 0, "n": 0, "option": 0, "same": 0, "extern": 0, "pass": 0, "callabl": 0, "condindtest": 0, "int": 0, "default": 0, "level": 0, "all_par": 0, "dictionari": 0, "form": 0, "2": 0, "pc": 0, "algorithm": 0, "val_min": 0, "tau": 0, "float": 0, "minimum": 0, "each": 0, "pval_max": 0, "maximum": 0, "step": 0, "number": 0, "sampl": 0, "length": 0, "dict": 0, "get_graph_from_pmatrix": 0, "p_matrix": 0, "alpha_level": 0, "tau_min": 0, "tau_max": 0, "link_assumpt": 0, "none": 0, "construct": 0, "threshold": 0, "alpha": 0, "take": 0, "account": 0, "matrix": 0, "fdr_method": 0, "05": 0, "signific": 0, "get": 0, "tau_mix": 0, "delai": 0, "link_typ": 0, "specifi": 0, "about": 0, "initi": 0, "entri": 0, "impli": 0, "must": 0, "exist": 0, "valid": 0, "o": 0, "addit": 0, "middl": 0, "mark": 0, "instead": 0, "Then": 0, "orient": 0, "need": 0, "consist": 0, "requir": 0, "acycl": 0, "hold": 0, "If": 0, "doe": 0, "appear": 0, "absent": 0, "That": 0, "have": 0, "return": 0, "descript": 0, "abov": 0, "get_lagged_depend": 0, "selected_link": 0, "val_onli": 0, "uncondit": 0, "_": 0, "matric": 0, "correct": 0, "new": 0, "4": 0, "fdr": 0, "deprec": 0, "replac": 0, "zero": 0, "undirect": 0, "larger": 0, "equal": 0, "bool": 0, "onli": 0, "comput": 0, "str": 0, "current": 0, "benjamini": 0, "hochberg": 0, "rate": 0, "fdr_bh": 0, "val_matrix": 0, "conf_matrix": 0, "percentil": 0, "print_result": 0, "return_dict": 0, "print": 0, "output": 0, "kei": 0, "print_significant_link": 0, "ambiguous_tripl": 0, "latter": 0, "ambigu": 0, "conflict": 0, "like": 0, "list": 0, "tripl": 0, "return_parents_dict": 0, "include_lagzero_par": 0, "sort": 0, "unclear": 0, "edgemark": 0, "x": 0, "whether": 0, "should": 0, "parents_dict": 0, "return_significant_link": 0, "pq_matrix": 0, "include_lagzero_link": 0, "boolean": 0, "Will": 0, "remov": 0, "futur": 0, "run_bivci": 0, "bivci": 0, "run_fullci": 0, "fullci": 0, "run_mci": 0, "max_conds_pi": 0, "max_conds_px": 0, "unrestrict": 0, "z": 0, "run_pc_stabl": 0, "save_iter": 0, "pc_alpha": 0, "max_conds_dim": 0, "max_combin": 0, "made": 0, "self": 0, "multi": 0, "ahead": 0, "greater": 0, "save": 0, "everi": 0, "across": 0, "given": 0, "score": 0, "get_model_selection_criterion": 0, "cardin": 0, "pc_1": 0, "origin": 0, "run_pcalg": 0, "01": 0, "lagged_par": 0, "max_conds_px_lag": 0, "mode": 0, "contemp_collider_rul": 0, "major": 0, "conflict_resolut": 0, "true": 0, "run": 0, "contemp_cond": 0, "ci": 0, "As": 0, "part": 0, "superset": 0, "pc1": 0, "conserv": 0, "rule": 0, "collid": 0, "phase": 0, "detail": 0, "lead": 0, "order": 0, "when": 0, "regard": 0, "adjac": 0, "sepset": 0, "relev": 0, "run_pcalg_non_timeseries_data": 0, "simpli": 0, "call": 0, "run_pcmci": 0, "wrapper": 0, "around": 0, "comprehens": 0, "analyt": 0, "numer": 0, "present": 0, "here": 0, "we": 0, "briefli": 0, "summar": 0, "two": 0, "procedur": 0, "select": 0, "tild": 0, "j_t": 0, "reduc": 0, "avoid": 0, "irrelev": 0, "momentari": 0, "i_": 0, "perp": 0, "j_": 0, "common": 0, "driver": 0, "indirect": 0, "main": 0, "free": 0, "tau_": 0, "max": 0, "chosen": 0, "accord": 0, "expect": 0, "recommend": 0, "rather": 0, "choic": 0, "peak": 0, "seen": 0, "sinc": 0, "hypothesi": 0, "do": 0, "precis": 0, "assess": 0, "role": 0, "regular": 0, "techniqu": 0, "criteria": 0, "respect": 0, "import": 0, "pp": 0, "structural_causal_process": 0, "random": 0, "seed": 0, "plai": 0, "incom": 0, "suppli": 0, "format": 0, "coeff": 0, "links_coeff": 0, "8": 0, "var_process": 0, "1000": 0, "pval": 0, "00000": 0, "val": 0, "588": 0, "606": 0, "447": 0, "618": 0, "499": 0, "run_pcmciplu": 0, "reset_lagged_link": 0, "contrast": 0, "full": 0, "up": 0, "markov": 0, "equival": 0, "faith": 0, "four": 0, "widehat": 0, "b": 0, "_t": 0, "skeleton": 0, "through": 0, "subset": 0, "conduct": 0, "motif": 0, "unshield": 0, "remain": 0, "Its": 0, "string": 0, "denot": 0, "unori": 0, "could": 0, "direction": 0, "undecid": 0, "due": 0, "importantli": 0, "alwai": 0, "dag": 0, "first": 0, "one": 0, "member": 0, "averag": 0, "over": 0, "fit": 0, "anoth": 0, "togeth": 0, "fulli": 0, "mean": 0, "matter": 0, "last": 0, "restrict": 0, "found": 0, "consid": 0, "again": 0, "improv": 0, "power": 0, "runtim": 0, "001": 0, "005": 0, "025": 0, "learn": 0, "specif": 0, "introduc": 0, "explain": 0, "still": 0, "experiment": 0, "being": 0, "fine": 0, "tune": 0, "actual": 0, "invit": 0, "feedback": 0, "work": 0, "best": 0, "experi": 0, "run_lpcmci": 0, "constructor": 0, "old": [], "some": 0, "might": 0, "nest": 0, "lag_i": 0, "compon": 0, "background": 0, "knowledg": 0, "possibl": 0, "correspond": 0, "claim": 0, "ancestor": 0, "i_t": 0, "neither": 0, "nor": 0, "wai": 0, "impos": 0, "automat": 0, "There": 0, "No": 0, "either": 0, "smaller": 0, "than": 0, "dpag": 0, "window": 0, "aumax": [], "au_max": [], "underli": 0, "n_preliminary_iter": 0, "determin": 0, "preliminari": 0, "k": 0, "max_cond_px": 0, "pair": 0, "au": [], "s2": 0, "_run_ancestral_removal_phas": 0, "apds_t": 0, "c": 0, "higher": 0, "s3": 0, "_run_non_ancestral_removal_phas": 0, "napds_t": 0, "max_p_glob": 0, "max_p_non_ancestr": 0, "second": 0, "_run_dsep_removal_phas": 0, "max_q_glob": 0, "most": 0, "mani": 0, "sum": 0, "more": 0, "max_pds_set": 0, "element": 0, "opposit": 0, "prelim_with_collider_rul": 0, "pseudocod": 0, "line": 0, "22": 0, "18": 0, "directli": 0, "befor": 0, "parents_of_lag": 0, "pa": 0, "prelim_onli": 0, "stop": 0, "after": 0, "perform": 0, "break_once_separ": 0, "break": 0, "command": 0, "no_non_ancestral_phas": 0, "execut": 0, "use_a_pds_t_for_major": 0, "instruct": 0, "adj": 0, "orient_contemp": 0, "orient_comtemp": 0, "update_middle_mark": 0, "pseudoc": 0, "mmr": 0, "prelim_rul": 0, "exclud": 0, "r9": 0, "prime": 0, "r10": 0, "fix_all_edges_before_final_orient": 0, "np": 0, "inf": 0, "termin": 0, "although": 0, "empti": 0, "nevertheless": 0, "sound": 0, "check": 0, "appropri": 0, "forc": 0, "auto_first": 0, "pseudcod": 0, "autodepend": 0, "priorit": 0, "even": 0, "remember_only_par": 0, "been": 0, "point": 0, "wa": 0, "later": 0, "tail": 0, "re": 0, "no_apr": 0, "apr": 0, "except": 0, "never": 0, "conveni": 0, "post": 0, "purpos": 0, "wildcard": 0, "st": [], "edg": 0, "star": 0, "prediction_model": 0, "extract": 0, "persist": 0, "finit": 0, "within": 0, "ignor": 0, "missing_flag": 0, "miss": 0, "sklearn": 0, "linear_model": 0, "linearregress": 0, "regress": 0, "ie": 0, "eg": 0, "gpdc": 0, "gaussianprocessregressor": 0, "nearestneighbor": 0, "anneal": 0, "run_rpcmci": 0, "num_regim": 0, "max_transit": 0, "switch_thr": 0, "num_iter": 0, "20": 0, "max_ann": 0, "n_job": 0, "transit": 0, "singl": 0, "switch": 0, "cpu": 0, "joblib": 0, "paral": 0, "n_regim": 0, "One": 0, "hot": 0, "encod": 0, "causal_result": 0, "converg": 0, "diff_g_f": 0, "tupl": 0, "consecut": 0, "error_free_ann": 0, "without": 0, "error": 0, "independence_tests_bas": 0, "42": 0, "mask_typ": 0, "fixed_thr": 0, "sig_sampl": 0, "500": 0, "sig_blocklength": 0, "conf_lev": 0, "9": 0, "conf_sampl": 0, "100": 0, "conf_blocklength": 0, "recycle_residu": 0, "provid": 0, "shuffl": 0, "bootstrap": 0, "inherit": 0, "randomst": 0, "default_rng": 0, "xy": 0, "xz": 0, "yz": 0, "xyz": 0, "shuffle_test": 0, "block": 0, "decai": 0, "autocovari": 0, "nan": 0, "side": 0, "residu": 0, "store": 0, "faster": 0, "cost": 0, "consider": 0, "memori": 0, "get_analytic_confid": 0, "df": 0, "concret": 0, "overrid": 0, "get_analytic_signific": 0, "dim": 0, "get_bootstrap_confid": 0, "dependence_measur": 0, "95": 0, "data_typ": 0, "With": 0, "row": 0, "column": 0, "get_dependence_measur": 0, "binari": 0, "individu": 0, "0s": 0, "1s": 0, "conf_low": 0, "conf_upp": 0, "upper": 0, "lower": 0, "bound": 0, "get_confid": 0, "child": 0, "var": 0, "make": 0, "sure": 0, "size": 0, "instanti": 0, "get_fixed_thres_signific": 0, "signfic": 0, "get_measur": 0, "get_shuffle_signific": 0, "return_null_dist": 0, "properti": 0, "print_info": 0, "run_test": 0, "cut_off": 0, "2xtau_max": 0, "alpha_or_thr": 0, "signficic": 0, "both": 0, "_get_single_residu": 0, "max_lag": 0, "max_lag_or_tau_max": 0, "how": 0, "cutoff": 0, "begin": 0, "guarante": 0, "compar": 0, "multipl": 0, "much": 0, "decis": 0, "run_test_raw": 0, "x_type": 0, "y_type": 0, "z_type": 0, "input": 0, "dimens": 0, "set_datafram": 0, "flag": 0, "set_mask_typ": 0, "setter": 0, "ensur": 0, "clash": 0, "kwarg": 0, "partial": 0, "correl": 0, "ordinari": 0, "least": 0, "squar": 0, "ol": 0, "pearson": 0, "To": 0, "out": 0, "beta_x": 0, "epsilon_": 0, "beta_i": 0, "rho": 0, "left": 0, "r_x": 0, "r_y": 0, "right": 0, "student": 0, "distribut": 0, "d_z": 0, "degre": 0, "freedom": 0, "argument": 0, "coeffici": 0, "less": 0, "featur": 0, "corrected_a": 0, "akaik": 0, "criterion": 0, "modulo": 0, "constant": 0, "leav": 0, "cross": 0, "asymptot": 0, "aic": 0, "target": 0, "unshuffl": 0, "robust_parcorr": 0, "robustparcorr": 0, "paranorm": 0, "transform": 0, "margin": 0, "firstli": 0, "phi": 0, "circ": 0, "hat": 0, "f": 0, "quantil": 0, "empir": 0, "idea": 0, "stem": 0, "literatur": 0, "nonparanorm": 0, "han": 0, "liu": 0, "john": 0, "lafferti": 0, "larri": 0, "wasserman": 0, "semiparametr": 0, "mach": 0, "2295": 0, "2328": 0, "2009": 0, "fang": 0, "ming": 0, "yuan": 0, "gaussian": 0, "copula": 0, "ann": 0, "40": 0, "2293": 0, "2326": 0, "2012a": 0, "naftali": 0, "harri": 0, "mathia": 0, "drton": 0, "machin": 0, "research": 0, "14": 0, "3365": 0, "3383": 0, "2013": 0, "afterward": 0, "now": 0, "uniform": 0, "plu": 0, "trafo2norm": 0, "thre": 0, "1e": 0, "code": 0, "small": 0, "too": 0, "close": 0, "similarli": 0, "null_dist_filenam": 0, "gp_param": 0, "distanc": 0, "gp": 0, "scikit": 0, "kernel": 0, "let": 0, "them": 0, "cython": 0, "null": 0, "precomput": 0, "generate_and_save_nulldist": 0, "npz": 0, "file": 0, "f_x": 0, "f_y": 0, "sim": 0, "sigma": 0, "bandwidth": 0, "optimz": 0, "r": 0, "pre": 0, "otherwis": 0, "dure": 0, "gabor": 0, "szeke": 0, "maria": 0, "l": 0, "rizzo": 0, "nail": 0, "bakirov": 0, "arxiv": 0, "ab": 0, "0803": 0, "4101": 0, "otion": 0, "path": 0, "gaussprocreg": 0, "sample_s": 0, "pairwis": 0, "generate_nulldist": 0, "dist": 0, "disk": 0, "add": 0, "gauss_pr": 0, "null_dist": 0, "name": 0, "add_to_null_dist": 0, "just": 0, "load": 0, "nulldist": 0, "wide": 0, "rang": 0, "beforehand": 0, "log": 0, "likelihood": 0, "neg": 0, "Is": 0, "gpdc_torch": 0, "gpdctorch": 0, "gpytorch": 0, "dcor": 0, "pip": 0, "gaussprocregtorch": 0, "knn": 0, "shuffle_neighbor": 0, "rank": 0, "worker": 0, "model_selection_fold": 0, "come": 0, "joint": 0, "densiti": 0, "frenzel": 0, "pomp": 0, "lett": 0, "99": 0, "204101": 0, "2007": 0, "suitabl": 0, "cmisymb": 0, "cmi": 0, "iint": 0, "frac": 0, "cdot": 0, "dx": 0, "dy": 0, "dz": 0, "psi": 0, "sum_": 0, "k_": 0, "digamma": 0, "hyper": 0, "cube": 0, "subspac": 0, "view": 0, "smooth": 0, "unlik": 0, "fix": 0, "bia": 0, "varianc": 0, "slightli": 0, "while": 0, "quantiti": 0, "scipi": 0, "spatial": 0, "ckdtree": 0, "fraction": 0, "henc": 0, "absolut": 0, "surrog": 0, "processor": 0, "fold": 0, "get_conditional_entropi": 0, "entropi": 0, "h": 0, "prl": 0, "overwrit": 0, "preserv": 0, "permut": 0, "those": 0, "x_i": 0, "x_j": 0, "z_j": 0, "niehgbor": 0, "z_i": 0, "n_symb": 0, "categor": 0, "symbol": 0, "local": 0, "mix": 0, "cmiknnmix": 0, "crosstab": 0, "conting": 0, "approxim": 0, "probabl": 0, "mass": 0, "drawn": 0, "oracle_conditional_independ": 0, "oracleci": 0, "observed_var": 0, "selection_var": 0, "graph_is_mag": 0, "oracl": 0, "link_coeff": 0, "ground": 0, "truth": 0, "unit": 0, "altern": 0, "digest": 0, "func": 0, "definin": 0, "check_shortest_path": 0, "starts_with": 0, "ends_with": 0, "forbidden_nod": 0, "only_non_causal_path": 0, "check_optimality_cond": 0, "optimality_cond_des_ym": 0, "optimality_cond_i": 0, "return_path": 0, "non_rep": 0, "au_i": 0, "au_j": 0, "alreadi": 0, "truncat": 0, "breadth": 0, "start": 0, "end": 0, "veri": 0, "long": 0, "constrain": 0, "has_path": 0, "ancestr": 0, "compute_ancestor": 0, "anc_all_x": 0, "anc_all_i": 0, "anc_all_z": 0, "arrohead": 0, "compat": 0, "get_graph_from_link": 0, "mag": 0, "admg": 0, "project": 0, "oper": 0, "pearl": 0, "get_links_from_graph": 0, "case": 0, "ad": 0, "canon": 0, "richardson": 0, "spirt": 0, "2002": 0, "support": 0, "evalu": 0, "els": 0, "Not": 0, "dummi": 0, "parcorr_mult": 0, "parcorrmult": 0, "correlation_typ": 0, "max_corr": 0, "multivari": 0, "mult_corr": 0, "gsquar": 0, "chi2": 0, "2000": 0, "stat": 0, "formula": 0, "bishop": 0, "fienberg": 0, "holland": 0, "1975": 0, "theori": 0, "mit": 0, "cambridg": 0, "p_valu": 0, "chi": 0, "dof": 0, "parcorr_wl": 0, "parcorrwl": 0, "gt_std_matrix": 0, "expert_knowledg": 0, "heteroskedast": 0, "window_s": 0, "robustifi": 0, "weight": 0, "wl": 0, "known": 0, "thei": 0, "neighbour": 0, "homoskedast": 0, "term": 0, "deviat": 0, "nois": 0, "nb_node": 0, "expert": 0, "regressionci": 0, "vs": 0, "notion": 0, "devianc": 0, "emploi": 0, "significantli": 0, "hypothes": 0, "accept": 0, "approach": 0, "univari": 0, "moreov": 0, "multinomi": 0, "causaleffect": 0, "graph_typ": 0, "hidden_vari": 0, "check_sm_overlap": 0, "potenti": 0, "backdoor": 0, "variou": 0, "wright": 0, "depth": 0, "introduct": 0, "8485ae387a981d783f8764e508151cd9": 0, "caus": 0, "overlap": 0, "check_xys_path": 0, "proper": 0, "clean": 0, "check_optim": 0, "thm": 0, "fit_bootstrap_of": 0, "method_arg": 0, "boot_sampl": 0, "boot_blocklength": 0, "construct_arrai": 0, "shift": 0, "bootsrap": 0, "predict_bootstrap_of": 0, "draw": 0, "fit_total_effect": 0, "adjustment_set": 0, "conditional_estim": 0, "data_transform": 0, "ignore_identifi": 0, "oset": 0, "minimized_optim": 0, "minim": 0, "colliders_minimized_optim": 0, "preprocess": 0, "prior": 0, "standardscal": 0, "simpl": 0, "user": 0, "fit_wright_effect": 0, "considerd": 0, "complic": 0, "static": 0, "get_dict_from_graph": 0, "parents_onli": 0, "helper": 0, "convert": 0, "get_graph_from_dict": 0, "get_medi": 0, "get_optimal_set": 0, "alternative_condit": 0, "return_separate_set": 0, "theorem": 0, "colliders_onli": 0, "invalid": 0, "collider_par": 0, "oset_": 0, "return_individual_bootstrap_result": 0, "confidence_interv": 0, "predict_total_effect": 0, "intervention_data": 0, "conditions_data": 0, "pred_param": 0, "return_further_pred_result": 0, "aggregation_func": 0, "transform_interventions_and_predict": 0, "len": 0, "predictor": 0, "entir": 0, "invers": 0, "estimate_confid": 0, "predict_wright_effect": 0, "conditional_model": 0, "care": 0, "inverse_transform": 0, "fit_full_model": 0, "selected_vari": 0, "empty_predictors_funct": 0, "return_data": 0, "integ": 0, "fit_result": 0, "get_coef": 0, "get_general_fitted_model": 0, "get_general_predict": 0, "get_val_matrix": 0, "fit_model": 0, "give": 0, "deriv": 0, "linearmedi": 0, "model_param": 0, "etc": 0, "ce": 0, "mce": 0, "ac": 0, "suscept": 0, "amc": 0, "chain": 0, "x_t": 0, "eta": 0, "y_t": 0, "x_": 0, "z_t": 0, "y_": 0, "25": 0, "37": 0, "true_par": 0, "med": 0, "get_coeff": 0, "get_c": 0, "get_mc": 0, "get_all_ac": 0, "get_all_amc": 0, "250648072987": 0, "36897445": 0, "25718002": 0, "24365041": 0, "38250406": 0, "12532404": 0, "fit_model_bootstrap": 0, "boostrap": 0, "version": 0, "cube_root": 0, "from_autocorrel": 0, "generate_noise_from": [], "root": 0, "get_ac": 0, "lag_mod": 0, "absmax": 0, "exclude_i": 0, "eman": 0, "all_lag": 0, "itself": 0, "exclude_j": 0, "affect": 0, "previou": 0, "exclude_k": 0, "exclude_self_effect": 0, "themselv": 0, "get_amc": 0, "get_bootstrap_of": 0, "function_arg": 0, "incl": 0, "get_ce_max": 0, "get_conditional_mc": 0, "notk": 0, "go": 0, "get_joint_c": 0, "count": 0, "joint_c": 0, "get_joint_ce_matrix": 0, "taui": 0, "tauj": 0, "stand": 0, "joint_ce_matrix": 0, "2d": 0, "get_joint_mc": 0, "joint_mc": 0, "minu": 0, "get_mediation_graph_data": 0, "include_neighbor": 0, "path_val_matrix": 0, "path_node_arrai": 0, "tsg_path_val_matrix": 0, "graph_data": 0, "color": 0, "get_tsg": 0, "link_matrix": 0, "analyz": 0, "sig_thr": 0, "array_lik": 0, "tsg": 0, "symmetr": 0, "net_to_tsg": 0, "translat": 0, "tsg_to_net": 0, "train_indic": 0, "test_indic": 0, "train": 0, "target_predictor": 0, "selected_target": 0, "instanc": 0, "get_predictor": 0, "steps_ahead": 0, "get_test_arrai": 0, "get_train_arrai": 0, "new_data": 0, "cut": 0, "off": 0, "below": 0, "vector_var": 0, "var_nam": 0, "datatim": 0, "analysis_mod": 0, "reference_point": 0, "time_offset": 0, "remove_missing_upto_maxlag": 0, "definit": 0, "OR": 0, "whose": 0, "t_i": 0, "vari": 0, "dismiss": 0, "slice": 0, "occur": 0, "bias": 0, "section": 0, "supplement": 0, "sciadv": 0, "vector": 0, "pars": 0, "creat": 0, "match": 0, "enumer": 0, "timelabel": 0, "1d": 0, "rel": 0, "share": 0, "axi": 0, "t_max": 0, "largest_time_step": 0, "bigger": 0, "At": 0, "align": 0, "agre": 0, "offset": 0, "_initialized_from": 0, "3d": 0, "map": 0, "represent": 0, "identifii": 0, "max_": 0, "largest": 0, "latest": 0, "random_st": 0, "extraz": 0, "return_cleaned_xyz": 0, "do_check": 0, "remove_overlap": 0, "n_en": 0, "var1": 0, "var2": 0, "varlag": 0, "assign": 0, "duplic": 0, "saniti": 0, "2xtau_max_futur": 0, "t_miss": 0, "principl": 0, "would": 0, "n_sampl": 0, "print_array_info": 0, "info": 0, "typic": 0, "varx": 0, "get_acf": 0, "autocorr": 0, "get_block_length": 0, "mader": 0, "eq": 0, "pfeifer": 0, "2005": 0, "multidimension": 0, "jointli": 0, "curv": 0, "fail": 0, "limit": 0, "neurosci": 0, "volum": 0, "219": 0, "issu": 0, "15": 0, "octob": 0, "285": 0, "291": 0, "block_len": 0, "lowhighpass_filt": 0, "cutperiod": 0, "pass_period": 0, "low": 0, "butterworth": 0, "filter": 0, "twice": 0, "onc": 0, "forward": 0, "backward": 0, "period": 0, "act": 0, "ordinal_patt_arrai": 0, "array_mask": 0, "symbolifi": 0, "ordin": 0, "pattern": 0, "uniqu": 0, "faculti": 0, "symb_arrai": 0, "shorter": 0, "2011": 0, "coupl": 0, "83": 0, "12": 0, "051122": 0, "label": 0, "embed": 0, "patt": 0, "patt_mask": 0, "patt_tim": 0, "quantile_bin_arrai": 0, "bin": 0, "smooth_width": 0, "width": 0, "heavisid": 0, "rtype": 0, "intervention_typ": 0, "hard": 0, "time_bin_with_mask": 0, "time_bin_length": 0, "bindata": 0, "outer": 0, "cdf": 0, "normal_data": 0, "parents_neighbors_coeff": 0, "inv_inno_cov": 0, "initial_valu": 0, "autoregress": 0, "innov": 0, "var_network": 0, "friendli": 0, "weighted_avg_and_std": 0, "std": 0, "check_stationar": 0, "stationari": 0, "dag_to_link": 0, "generate_structural_causal_process": 0, "dependency_func": 0, "dependency_coeff": 0, "auto_coeff": 0, "contemp_fract": 0, "noise_dist": 0, "noise_mean": 0, "noise_sigma": 0, "noise_se": 0, "randomli": 0, "characterist": 0, "frawn": 0, "arbitrari": 0, "factor": 0, "weibul": 0, "def": 0, "beta": 0, "links_to_graph": 0, "transient_fract": 0, "interven": 0, "randn": 0, "un": 0, "soft": 0, "percentag": 0, "transient": 0, "realiz": 0, "nonvalid": 0, "infin": 0, "lag1": 0, "coef1": 0, "lag2": 0, "coef2": 0, "nonzero": 0, "covari": 0, "inno_cov": 0, "debug": 0, "no_nois": 0, "disabl": 0, "max_delai": 0, "true_parent_neighbor": 0, "id": 0, "parent_node_id": 0, "time_lag": 0, "plot_densityplot": 0, "setup_arg": 0, "add_densityplot_arg": 0, "selected_dataset": 0, "show_marginal_densities_on_diagon": 0, "setup_density_matrix": 0, "add_densityplot": 0, "diagon": 0, "show": 0, "seaborn": 0, "doc": 0, "overlaid": 0, "plot_graph": 0, "fig_ax": 0, "figsiz": 0, "save_nam": 0, "link_colorbar_label": 0, "node_colorbar_label": 0, "auto": 0, "link_width": 0, "link_attribut": 0, "node_po": 0, "arrow_linewidth": 0, "vmin_edg": 0, "vmax_edg": 0, "edge_tick": 0, "cmap_edg": 0, "rdbu_r": 0, "vmin_nod": 0, "vmax_nod": 0, "node_tick": 0, "cmap_nod": 0, "node_s": 0, "node_aspect": 0, "arrowhead_s": 0, "curved_radiu": 0, "label_fonts": 0, "tick_label_s": 0, "node_label_s": 0, "link_label_fonts": 0, "lag_arrai": 0, "show_colorbar": 0, "inner_edge_styl": 0, "dash": 0, "special_nod": 0, "show_autodependency_lag": 0, "straight": 0, "arrow": 0, "maxim": 0, "magnitud": 0, "posit": 0, "coordin": 0, "via": 0, "ax": 0, "basemap": 0, "ccr": 0, "platecarre": 0, "cartopi": 0, "linewidth": 0, "colorbar": 0, "tick": 0, "colormap": 0, "orrd": 0, "ratio": 0, "heigth": 0, "varibl": 0, "head": 0, "fancyarrowpatch": 0, "curvatur": 0, "fontsiz": 0, "opac": 0, "arang": 0, "plot_lagfunc": 0, "add_lagfunc_arg": 0, "lagfunct": 0, "setup_matrix": 0, "add_lagfunc": 0, "plot_mediation_graph": 0, "standard_color_link": 0, "black": 0, "standard_color_nod": 0, "lightgrei": 0, "visual": 0, "plot_mediation_time_series_graph": 0, "top": 0, "bottom": 0, "plot_scatterplot": 0, "add_scatterplot_arg": 0, "scatter": 0, "setup_scatter_matrix": 0, "add_scatterplot": 0, "plot_time_series_graph": 0, "auxiliari": 0, "auxadmg": 0, "style": 0, "inner_edg": 0, "special": 0, "plot_timeseri": 0, "var_unit": 0, "time_label": 0, "grey_masked_sampl": 0, "show_meanlin": 0, "data_linewidth": 0, "skip_ticks_data_x": 0, "skip_ticks_data_i": 0, "adjust_plot": 0, "stack": 0, "panel": 0, "subplot": 0, "fig": 0, "pyplot": 0, "grei": 0, "fill": 0, "horizont": 0, "skip": 0, "tickmark": 0, "plot_tsg": 0, "anc_x": 0, "anc_i": 0, "anc_xi": 0, "help": 0, "label_space_left": 0, "label_space_top": 0, "legend_width": 0, "legend_fonts": 0, "plot_gridlin": 0, "setup": 0, "space": 0, "alloc": 0, "vertic": 0, "legend": 0, "grid": 0, "matrix_lag": 0, "label_color": 0, "snskdeplot_arg": 0, "cmap": 0, "snskdeplot_diagonal_arg": 0, "depict": 0, "sn": 0, "kdeplot": 0, "adjustfig": 0, "show_label": 0, "x_base": 0, "y_base": 0, "lag_unit": 0, "comparison": 0, "two_sided_thr": 0, "marker": 0, "markers": 0, "po": 0, "matplotlib": 0, "savefig": 0, "scatterplot": 0, "write_csv": 0, "digit": 0, "write": 0, "csv": 0, "g\u00fcnther": 0, "u": 0, "ninad": 0, "context": 0, "infinit": 0, "node_classif": 0, "enabl": 0, "unobserv": 0, "classif": 0, "time_context": 0, "space_context": 0, "time_dummi": 0, "space_dummi": 0, "dummy_par": 0, "observed_context_par": 0, "dummy_ci_test": 0, "system_search": 0, "context_search": 0, "dummy_search": 0, "time_context_nod": 0, "space_context_nod": 0, "system_nod": 0, "add_found_context_link_assumpt": 0, "assume_exogenous_context": 0, "observed_context_nod": 0, "amend": 0, "clean_link_assumpt": 0, "clean_system_link_assumpt": 0, "contextu": 0, "discover_dummy_system_link": 0, "context_system_result": 0, "run_jpcmciplu": 0, "discover_lagged_and_context_system_link": 0, "discover_lagged_context_system_link": 0, "discover_system_system_link": 0, "lagged_context_dummy_par": 0, "remove_dummy_link_assumpt": 0, "obtain": 0, "next": 0, "c_t": 0, "c_": 0, "mathbf": 0, "setminu": 0, "condition": 0, "By": 0, "final": 0, "cd": 0, "involv": 0, "multioutput": 0, "multioutputregressor": 0, "extend": 0, "get_residuals_cov_mean": 0, "predict_full_model": 0, "classifi": 0, "treat": 0, "resolv": 0, "manner": 0, "bic": 0, "ref": 0, "bold": 0, "taumax": 0, "ast": 0, "But": 0, "pairwisemultci": 0, "suggest": 0, "tsagri": 0, "michail": 0, "constraint": 0, "19": 0, "furthermor": 0, "our": 0, "util": 0, "theirs": 0, "structural_causal_process_ensembl": 0, "ensemble_se": 0, "ensembl": 0, "docstr": 0, "ii": 0}, "objects": {"tigramite.causal_effects": [[0, 0, 1, "", "CausalEffects"]], "tigramite.causal_effects.CausalEffects": [[0, 1, 1, "", "check_XYS_paths"], [0, 1, 1, "", "check_optimality"], [0, 1, 1, "", "fit_bootstrap_of"], [0, 1, 1, "", "fit_total_effect"], [0, 1, 1, "", "fit_wright_effect"], [0, 1, 1, "", "get_dict_from_graph"], [0, 1, 1, "", "get_graph_from_dict"], [0, 1, 1, "", "get_mediators"], [0, 1, 1, "", "get_optimal_set"], [0, 1, 1, "", "predict_bootstrap_of"], [0, 1, 1, "", "predict_total_effect"], [0, 1, 1, "", "predict_wright_effect"]], "tigramite": [[0, 2, 0, "-", "data_processing"], [0, 2, 0, "-", "plotting"]], "tigramite.data_processing": [[0, 0, 1, "", "DataFrame"], [0, 4, 1, "", "get_acf"], [0, 4, 1, "", "get_block_length"], [0, 4, 1, "", "lowhighpass_filter"], [0, 4, 1, "", "ordinal_patt_array"], [0, 4, 1, "", "quantile_bin_array"], [0, 4, 1, "", "smooth"], [0, 4, 1, "", "structural_causal_process"], [0, 4, 1, "", "time_bin_with_mask"], [0, 4, 1, "", "trafo2normal"], [0, 4, 1, "", "var_process"], [0, 4, 1, "", "weighted_avg_and_std"]], "tigramite.data_processing.DataFrame": [[0, 1, 1, "", "construct_array"], [0, 1, 1, "", "print_array_info"]], "tigramite.data_processing.DataFrame.self": [[0, 3, 1, "", "M"], [0, 3, 1, "", "N"], [0, 3, 1, "", "T"], [0, 3, 1, "", "_initialized_from"], [0, 3, 1, "", "analysis_mode"], [0, 3, 1, "", "bootstrap"], [0, 3, 1, "", "data_type"], [0, 3, 1, "", "datasets"], [0, 3, 1, "", "datatime"], [0, 3, 1, "", "largest_time_step"], [0, 3, 1, "", "mask"], [0, 3, 1, "", "missing_flag"], [0, 3, 1, "", "reference_points"], [0, 3, 1, "", "time_offsets"], [0, 3, 1, "", "values"], [0, 3, 1, "", "var_names"]], "tigramite.independence_tests.cmiknn": [[0, 0, 1, "", "CMIknn"]], "tigramite.independence_tests.cmiknn.CMIknn": [[0, 1, 1, "", "get_conditional_entropy"], [0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"]], "tigramite.independence_tests.cmisymb": [[0, 0, 1, "", "CMIsymb"]], "tigramite.independence_tests.cmisymb.CMIsymb": [[0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"]], "tigramite.independence_tests.gpdc": [[0, 0, 1, "", "GPDC"]], "tigramite.independence_tests.gpdc.GPDC": [[0, 1, 1, "", "generate_and_save_nulldists"], [0, 1, 1, "", "generate_nulldist"], [0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"]], "tigramite.independence_tests.gpdc_torch": [[0, 0, 1, "", "GPDCtorch"]], "tigramite.independence_tests.gpdc_torch.GPDCtorch": [[0, 1, 1, "", "generate_and_save_nulldists"], [0, 1, 1, "", "generate_nulldist"], [0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"]], "tigramite.independence_tests.gsquared": [[0, 0, 1, "", "Gsquared"]], "tigramite.independence_tests.gsquared.Gsquared": [[0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_dependence_measure"], [0, 5, 1, "", "measure"]], "tigramite.independence_tests.independence_tests_base": [[0, 0, 1, "", "CondIndTest"]], "tigramite.independence_tests.independence_tests_base.CondIndTest": [[0, 1, 1, "", "get_analytic_confidence"], [0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_bootstrap_confidence"], [0, 1, 1, "", "get_confidence"], [0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_fixed_thres_significance"], [0, 1, 1, "", "get_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"], [0, 1, 1, "", "print_info"], [0, 1, 1, "", "run_test"], [0, 1, 1, "", "run_test_raw"], [0, 1, 1, "", "set_dataframe"], [0, 1, 1, "", "set_mask_type"]], "tigramite.independence_tests.oracle_conditional_independence": [[0, 0, 1, "", "OracleCI"]], "tigramite.independence_tests.oracle_conditional_independence.OracleCI": [[0, 1, 1, "", "check_shortest_path"], [0, 1, 1, "", "get_confidence"], [0, 1, 1, "", "get_graph_from_links"], [0, 1, 1, "", "get_links_from_graph"], [0, 1, 1, "", "get_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 5, 1, "", "measure"], [0, 1, 1, "", "run_test"], [0, 1, 1, "", "set_dataframe"]], "tigramite.independence_tests.parcorr": [[0, 0, 1, "", "ParCorr"]], "tigramite.independence_tests.parcorr.ParCorr": [[0, 1, 1, "", "get_analytic_confidence"], [0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"]], "tigramite.independence_tests.parcorr_mult": [[0, 0, 1, "", "ParCorrMult"]], "tigramite.independence_tests.parcorr_mult.ParCorrMult": [[0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"], [0, 1, 1, "", "mult_corr"]], "tigramite.independence_tests.parcorr_wls": [[0, 0, 1, "", "ParCorrWLS"]], "tigramite.independence_tests.parcorr_wls.ParCorrWLS": [[0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"]], "tigramite.independence_tests.regressionCI": [[0, 0, 1, "", "RegressionCI"]], "tigramite.independence_tests.regressionCI.RegressionCI": [[0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_dependence_measure"], [0, 5, 1, "", "measure"], [0, 1, 1, "", "set_dataframe"]], "tigramite.independence_tests.robust_parcorr": [[0, 0, 1, "", "RobustParCorr"]], "tigramite.independence_tests.robust_parcorr.RobustParCorr": [[0, 1, 1, "", "get_analytic_confidence"], [0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"], [0, 1, 1, "", "trafo2normal"]], "tigramite.jpcmciplus": [[0, 0, 1, "", "JPCMCIplus"]], "tigramite.jpcmciplus.JPCMCIplus": [[0, 3, 1, "", "N"], [0, 3, 1, "", "T"], [0, 1, 1, "", "add_found_context_link_assumptions"], [0, 3, 1, "", "all_parents"], [0, 1, 1, "", "assume_exogenous_context"], [0, 1, 1, "", "clean_link_assumptions"], [0, 1, 1, "", "clean_system_link_assumptions"], [0, 1, 1, "", "discover_dummy_system_links"], [0, 1, 1, "", "discover_lagged_context_system_links"], [0, 1, 1, "", "discover_system_system_links"], [0, 3, 1, "", "dummy_ci_test"], [0, 3, 1, "", "dummy_parents"], [0, 3, 1, "", "iterations"], [0, 3, 1, "", "mode"], [0, 3, 1, "", "observed_context_parents"], [0, 3, 1, "", "pval_max"], [0, 1, 1, "", "remove_dummy_link_assumptions"], [0, 1, 1, "", "run_jpcmciplus"], [0, 3, 1, "", "space_context_nodes"], [0, 3, 1, "", "space_dummy"], [0, 3, 1, "", "system_nodes"], [0, 3, 1, "", "time_context_nodes"], [0, 3, 1, "", "time_dummy"], [0, 3, 1, "", "val_min"]], "tigramite.lpcmci": [[0, 0, 1, "", "LPCMCI"]], "tigramite.lpcmci.LPCMCI": [[0, 1, 1, "", "run_lpcmci"]], "tigramite.models": [[0, 0, 1, "", "LinearMediation"], [0, 0, 1, "", "Models"], [0, 0, 1, "", "Prediction"]], "tigramite.models.LinearMediation": [[0, 1, 1, "", "fit_model"], [0, 1, 1, "", "fit_model_bootstrap"], [0, 1, 1, "", "get_ace"], [0, 1, 1, "", "get_acs"], [0, 1, 1, "", "get_all_ace"], [0, 1, 1, "", "get_all_acs"], [0, 1, 1, "", "get_all_amce"], [0, 1, 1, "", "get_amce"], [0, 1, 1, "", "get_bootstrap_of"], [0, 1, 1, "", "get_ce"], [0, 1, 1, "", "get_ce_max"], [0, 1, 1, "", "get_coeff"], [0, 1, 1, "", "get_conditional_mce"], [0, 1, 1, "", "get_joint_ce"], [0, 1, 1, "", "get_joint_ce_matrix"], [0, 1, 1, "", "get_joint_mce"], [0, 1, 1, "", "get_mce"], [0, 1, 1, "", "get_mediation_graph_data"], [0, 1, 1, "", "get_tsg"], [0, 1, 1, "", "get_val_matrix"], [0, 1, 1, "", "net_to_tsg"], [0, 1, 1, "", "tsg_to_net"]], "tigramite.models.Models": [[0, 1, 1, "", "fit_full_model"], [0, 1, 1, "", "get_coefs"], [0, 1, 1, "", "get_general_fitted_model"], [0, 1, 1, "", "get_general_prediction"], [0, 1, 1, "", "get_residuals_cov_mean"], [0, 1, 1, "", "get_val_matrix"], [0, 1, 1, "", "predict_full_model"]], "tigramite.models.Prediction": [[0, 1, 1, "", "fit"], [0, 1, 1, "", "get_predictors"], [0, 1, 1, "", "get_test_array"], [0, 1, 1, "", "get_train_array"], [0, 1, 1, "", "predict"]], "tigramite.pcmci": [[0, 0, 1, "", "PCMCI"]], "tigramite.pcmci.PCMCI": [[0, 3, 1, "", "N"], [0, 3, 1, "", "T"], [0, 3, 1, "", "all_parents"], [0, 1, 1, "", "get_graph_from_pmatrix"], [0, 1, 1, "", "get_lagged_dependencies"], [0, 3, 1, "", "iterations"], [0, 1, 1, "", "print_results"], [0, 1, 1, "", "print_significant_links"], [0, 3, 1, "", "pval_max"], [0, 1, 1, "", "return_parents_dict"], [0, 1, 1, "", "return_significant_links"], [0, 1, 1, "", "run_bivci"], [0, 1, 1, "", "run_fullci"], [0, 1, 1, "", "run_mci"], [0, 1, 1, "", "run_pc_stable"], [0, 1, 1, "", "run_pcalg"], [0, 1, 1, "", "run_pcalg_non_timeseries_data"], [0, 1, 1, "", "run_pcmci"], [0, 1, 1, "", "run_pcmciplus"], [0, 3, 1, "", "val_min"]], "tigramite.plotting": [[0, 4, 1, "", "plot_densityplots"], [0, 4, 1, "", "plot_graph"], [0, 4, 1, "", "plot_lagfuncs"], [0, 4, 1, "", "plot_mediation_graph"], [0, 4, 1, "", "plot_mediation_time_series_graph"], [0, 4, 1, "", "plot_scatterplots"], [0, 4, 1, "", "plot_time_series_graph"], [0, 4, 1, "", "plot_timeseries"], [0, 4, 1, "", "plot_tsg"], [0, 0, 1, "", "setup_density_matrix"], [0, 0, 1, "", "setup_matrix"], [0, 0, 1, "", "setup_scatter_matrix"], [0, 4, 1, "", "write_csv"]], "tigramite.plotting.setup_density_matrix": [[0, 1, 1, "", "add_densityplot"], [0, 1, 1, "", "adjustfig"]], "tigramite.plotting.setup_matrix": [[0, 1, 1, "", "add_lagfuncs"], [0, 1, 1, "", "savefig"]], "tigramite.plotting.setup_scatter_matrix": [[0, 1, 1, "", "add_scatterplot"], [0, 1, 1, "", "adjustfig"]], "tigramite.rpcmci": [[0, 0, 1, "", "RPCMCI"]], "tigramite.rpcmci.RPCMCI": [[0, 1, 1, "", "run_rpcmci"]], "tigramite.toymodels": [[0, 2, 0, "-", "structural_causal_processes"]], "tigramite.toymodels.structural_causal_processes": [[0, 4, 1, "", "check_stationarity"], [0, 4, 1, "", "dag_to_links"], [0, 4, 1, "", "generate_structural_causal_process"], [0, 4, 1, "", "links_to_graph"], [0, 4, 1, "", "structural_causal_process"], [0, 4, 1, "", "structural_causal_process_ensemble"], [0, 4, 1, "", "var_process"]]}, "objtypes": {"0": "py:class", "1": "py:method", "2": "py:module", "3": "py:attribute", "4": "py:function", "5": "py:property"}, "objnames": {"0": ["py", "class", "Python class"], "1": ["py", "method", "Python method"], "2": ["py", "module", "Python module"], "3": ["py", "attribute", "Python attribute"], "4": ["py", "function", "Python function"], "5": ["py", "property", "Python property"]}, "titleterms": {"welcom": 0, "tigramit": 0, "s": 0, "document": 0, "indic": 0, "tabl": 0, "pcmci": 0, "lpcmci": 0, "rpcmci": 0, "independence_test": 0, "condit": 0, "independ": 0, "test": 0, "causal_effect": 0, "causal": 0, "effect": 0, "analysi": 0, "model": 0, "time": 0, "seri": 0, "mediat": 0, "predict": 0, "data_process": 0, "data": 0, "process": 0, "function": 0, "toymodel": 0, "toi": 0, "gener": 0, "plot": 0, "jpcmciplu": 0}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 6, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.viewcode": 1, "sphinx": 56}})
\ No newline at end of file
+Search.setIndex({"docnames": ["index"], "filenames": ["index.rst"], "titles": ["Welcome to Tigramite\u2019s documentation!"], "terms": {"index": 0, "modul": 0, "search": 0, "page": 0, "github": 0, "repo": 0, "python": 0, "packag": 0, "It": 0, "allow": 0, "effici": 0, "estim": 0, "graph": 0, "from": 0, "high": 0, "dimension": 0, "dataset": 0, "discoveri": 0, "us": 0, "robust": 0, "forecast": 0, "direct": 0, "total": 0, "base": 0, "linear": 0, "well": 0, "non": 0, "parametr": 0, "applic": 0, "discret": 0, "continu": 0, "valu": 0, "also": 0, "includ": 0, "qualiti": 0, "result": 0, "pleas": 0, "cite": 0, "follow": 0, "paper": 0, "depend": 0, "which": 0, "method": 0, "you": 0, "overview": 0, "rung": 0, "j": 0, "gerhardu": 0, "A": 0, "varando": 0, "g": 0, "et": 0, "al": 0, "infer": 0, "nat": 0, "rev": 0, "earth": 0, "environ": 0, "2023": 0, "http": 0, "doi": 0, "org": 0, "10": 0, "1038": 0, "s43017": 0, "023": 0, "00431": 0, "y": 0, "p": 0, "nowack": 0, "m": 0, "kretschmer": 0, "flaxman": 0, "d": 0, "sejdinov": 0, "detect": 0, "quantifi": 0, "associ": 0, "larg": 0, "nonlinear": 0, "sci": 0, "adv": 0, "5": 0, "eaau4996": 0, "2019": 0, "advanc": 0, "sciencemag": 0, "content": 0, "11": 0, "2020": 0, "discov": 0, "contemporan": 0, "lag": 0, "relat": 0, "autocorrel": 0, "proceed": 0, "36th": 0, "confer": 0, "uncertainti": 0, "artifici": 0, "intellig": 0, "uai": 0, "toronto": 0, "canada": 0, "auai": 0, "press": 0, "uai2020": 0, "579_main_pap": 0, "pdf": 0, "recal": 0, "latent": 0, "confound": 0, "neural": 0, "inform": 0, "system": 0, "33": 0, "neurip": 0, "cc": 0, "hash": 0, "94e70705efae423efda1088614128d0b": 0, "abstract": 0, "html": 0, "elena": 0, "saggioro": 0, "jana": 0, "de": 0, "wilj": 0, "marlen": 0, "jakob": 0, "reconstruct": 0, "regim": 0, "relationship": 0, "observ": 0, "chao": 0, "1": 0, "novemb": 0, "30": 0, "113115": 0, "1063": 0, "0020538": 0, "2018": 0, "network": 0, "theoret": 0, "assumpt": 0, "practic": 0, "an": 0, "interdisciplinari": 0, "journal": 0, "scienc": 0, "28": 0, "7": 0, "075310": 0, "aip": 0, "scitat": 0, "5025050": 0, "natur": 0, "commun": 0, "perspect": 0, "www": 0, "com": 0, "articl": 0, "s41467": 0, "019": 0, "10105": 0, "3": 0, "necessari": 0, "suffici": 0, "graphic": 0, "optim": 0, "adjust": 0, "set": 0, "hidden": 0, "variabl": 0, "2021": 0, "34": 0, "class": 0, "2015": 0, "identifi": 0, "gatewai": 0, "complex": 0, "spatio": 0, "tempor": 0, "6": 0, "8502": 0, "ncomms9502": 0, "transfer": 0, "along": 0, "pathwai": 0, "phy": 0, "e": 0, "92": 0, "62829": 0, "1103": 0, "physrev": 0, "062829": 0, "cmiknn": 0, "nearest": 0, "neighbor": 0, "mutual": 0, "In": 0, "21st": 0, "intern": 0, "statist": 0, "mlr": 0, "v84": 0, "runge18a": 0, "datafram": 0, "cond_ind_test": 0, "verbos": 0, "0": 0, "sourc": 0, "framework": 0, "scale": 0, "thi": 0, "contain": 0, "sever": 0, "The": 0, "standard": 0, "address": 0, "describ": 0, "where": 0, "further": 0, "sub": 0, "variant": 0, "ar": 0, "discuss": 0, "pcmciplu": 0, "see": 0, "tutori": 0, "guidanc": 0, "appli": 0, "ha": 0, "differ": 0, "adapt": 0, "implement": 0, "mostli": 0, "hyperparamet": 0, "easi": 0, "parallel": 0, "separ": 0, "script": 0, "handl": 0, "mask": 0, "fals": 0, "control": 0, "confid": 0, "interv": 0, "note": 0, "structur": 0, "repres": 0, "shown": 0, "figur": 0, "node": 0, "defin": 0, "link": 0, "can": 0, "interpret": 0, "under": 0, "certain": 0, "assum": 0, "stationar": 0, "repeat": 0, "parent": 0, "mathcal": 0, "all": 0, "toward": 0, "blue": 0, "red": 0, "box": 0, "iter": 0, "flexibl": 0, "combin": 0, "ani": 0, "kind": 0, "its": 0, "type": 0, "These": 0, "avail": 0, "mci": 0, "particular": 0, "measur": 0, "strength": 0, "For": 0, "exampl": 0, "parcorr": 0, "normal": 0, "between": 0, "howev": 0, "interest": 0, "i": 0, "hypothet": 0, "intervent": 0, "mai": 0, "better": 0, "look": 0, "refer": 0, "w": 0, "paramet": 0, "object": 0, "among": 0, "other": 0, "attribut": 0, "yield": 0, "numpi": 0, "arrai": 0, "shape": 0, "t": 0, "n": 0, "option": 0, "same": 0, "extern": 0, "pass": 0, "callabl": 0, "condindtest": 0, "int": 0, "default": 0, "level": 0, "all_par": 0, "dictionari": 0, "form": 0, "2": 0, "pc": 0, "algorithm": 0, "val_min": 0, "tau": 0, "float": 0, "minimum": 0, "each": 0, "pval_max": 0, "maximum": 0, "step": 0, "number": 0, "sampl": 0, "length": 0, "dict": 0, "get_graph_from_pmatrix": 0, "p_matrix": 0, "alpha_level": 0, "tau_min": 0, "tau_max": 0, "link_assumpt": 0, "none": 0, "construct": 0, "threshold": 0, "alpha": 0, "take": 0, "account": 0, "matrix": 0, "fdr_method": 0, "05": 0, "signific": 0, "get": 0, "tau_mix": 0, "delai": 0, "link_typ": 0, "specifi": 0, "about": 0, "initi": 0, "entri": 0, "impli": 0, "must": 0, "exist": 0, "valid": 0, "o": 0, "addit": 0, "middl": 0, "mark": 0, "instead": 0, "Then": 0, "orient": 0, "need": 0, "consist": 0, "requir": 0, "acycl": 0, "hold": 0, "If": 0, "doe": 0, "appear": 0, "absent": 0, "That": 0, "have": 0, "return": 0, "descript": 0, "abov": 0, "get_lagged_depend": 0, "selected_link": 0, "val_onli": 0, "uncondit": 0, "_": 0, "matric": 0, "correct": 0, "new": 0, "4": 0, "fdr": 0, "deprec": 0, "replac": 0, "zero": 0, "undirect": 0, "larger": 0, "equal": 0, "bool": 0, "onli": 0, "comput": 0, "str": 0, "current": 0, "benjamini": 0, "hochberg": 0, "rate": 0, "fdr_bh": 0, "val_matrix": 0, "conf_matrix": 0, "percentil": 0, "print_result": 0, "return_dict": 0, "print": 0, "output": 0, "kei": 0, "print_significant_link": 0, "ambiguous_tripl": 0, "latter": 0, "ambigu": 0, "conflict": 0, "like": 0, "list": 0, "tripl": 0, "return_parents_dict": 0, "include_lagzero_par": 0, "sort": 0, "unclear": 0, "edgemark": 0, "x": 0, "whether": 0, "should": 0, "parents_dict": 0, "return_significant_link": 0, "pq_matrix": 0, "include_lagzero_link": 0, "boolean": 0, "Will": 0, "remov": 0, "futur": 0, "run_bivci": 0, "bivci": 0, "run_fullci": 0, "fullci": 0, "run_mci": 0, "max_conds_pi": 0, "max_conds_px": 0, "unrestrict": 0, "z": 0, "run_pc_stabl": 0, "save_iter": 0, "pc_alpha": 0, "max_conds_dim": 0, "max_combin": 0, "made": 0, "self": 0, "multi": 0, "ahead": 0, "greater": 0, "save": 0, "everi": 0, "across": 0, "given": 0, "score": 0, "get_model_selection_criterion": 0, "cardin": 0, "pc_1": 0, "origin": 0, "run_pcalg": 0, "01": 0, "lagged_par": 0, "max_conds_px_lag": 0, "mode": 0, "contemp_collider_rul": 0, "major": 0, "conflict_resolut": 0, "true": 0, "run": 0, "contemp_cond": 0, "ci": 0, "As": 0, "part": 0, "superset": 0, "pc1": 0, "conserv": 0, "rule": 0, "collid": 0, "phase": 0, "detail": 0, "lead": 0, "order": 0, "when": 0, "regard": 0, "adjac": 0, "sepset": 0, "relev": 0, "run_pcalg_non_timeseries_data": 0, "simpli": 0, "call": 0, "run_pcmci": 0, "wrapper": 0, "around": 0, "comprehens": 0, "analyt": 0, "numer": 0, "present": 0, "here": 0, "we": 0, "briefli": 0, "summar": 0, "two": 0, "procedur": 0, "select": 0, "tild": 0, "j_t": 0, "reduc": 0, "avoid": 0, "irrelev": 0, "momentari": 0, "i_": 0, "perp": 0, "j_": 0, "common": 0, "driver": 0, "indirect": 0, "main": 0, "free": 0, "tau_": 0, "max": 0, "chosen": 0, "accord": 0, "expect": 0, "recommend": 0, "rather": 0, "choic": 0, "peak": 0, "seen": 0, "sinc": 0, "hypothesi": 0, "do": 0, "precis": 0, "assess": 0, "role": 0, "regular": 0, "techniqu": 0, "criteria": 0, "respect": 0, "import": 0, "pp": 0, "structural_causal_process": 0, "random": 0, "seed": 0, "plai": 0, "incom": 0, "suppli": 0, "format": 0, "coeff": 0, "links_coeff": 0, "8": 0, "var_process": 0, "1000": 0, "pval": 0, "00000": 0, "val": 0, "588": 0, "606": 0, "447": 0, "618": 0, "499": 0, "run_pcmciplu": 0, "reset_lagged_link": 0, "contrast": 0, "full": 0, "up": 0, "markov": 0, "equival": 0, "faith": 0, "four": 0, "widehat": 0, "b": 0, "_t": 0, "skeleton": 0, "through": 0, "subset": 0, "conduct": 0, "motif": 0, "unshield": 0, "remain": 0, "Its": 0, "string": 0, "denot": 0, "unori": 0, "could": 0, "direction": 0, "undecid": 0, "due": 0, "importantli": 0, "alwai": 0, "dag": 0, "first": 0, "one": 0, "member": 0, "averag": 0, "over": 0, "fit": 0, "anoth": 0, "togeth": 0, "fulli": 0, "mean": 0, "matter": 0, "last": 0, "restrict": 0, "found": 0, "consid": 0, "again": 0, "improv": 0, "power": 0, "runtim": 0, "001": 0, "005": 0, "025": 0, "learn": 0, "specif": 0, "introduc": 0, "explain": 0, "still": 0, "experiment": 0, "being": 0, "fine": 0, "tune": 0, "actual": 0, "invit": 0, "feedback": 0, "work": 0, "best": 0, "experi": 0, "run_lpcmci": 0, "constructor": 0, "old": [], "some": 0, "might": 0, "nest": 0, "lag_i": 0, "compon": 0, "background": 0, "knowledg": 0, "possibl": 0, "correspond": 0, "claim": 0, "ancestor": 0, "i_t": 0, "neither": 0, "nor": 0, "wai": 0, "impos": 0, "automat": 0, "There": 0, "No": 0, "either": 0, "smaller": 0, "than": 0, "dpag": 0, "window": 0, "aumax": [], "au_max": [], "underli": 0, "n_preliminary_iter": 0, "determin": 0, "preliminari": 0, "k": 0, "max_cond_px": 0, "pair": 0, "au": [], "s2": 0, "_run_ancestral_removal_phas": 0, "apds_t": 0, "c": 0, "higher": 0, "s3": 0, "_run_non_ancestral_removal_phas": 0, "napds_t": 0, "max_p_glob": 0, "max_p_non_ancestr": 0, "second": 0, "_run_dsep_removal_phas": 0, "max_q_glob": 0, "most": 0, "mani": 0, "sum": 0, "more": 0, "max_pds_set": 0, "element": 0, "opposit": 0, "prelim_with_collider_rul": 0, "pseudocod": 0, "line": 0, "22": 0, "18": 0, "directli": 0, "befor": 0, "parents_of_lag": 0, "pa": 0, "prelim_onli": 0, "stop": 0, "after": 0, "perform": 0, "break_once_separ": 0, "break": 0, "command": 0, "no_non_ancestral_phas": 0, "execut": 0, "use_a_pds_t_for_major": 0, "instruct": 0, "adj": 0, "orient_contemp": 0, "orient_comtemp": 0, "update_middle_mark": 0, "pseudoc": 0, "mmr": 0, "prelim_rul": 0, "exclud": 0, "r9": 0, "prime": 0, "r10": 0, "fix_all_edges_before_final_orient": 0, "np": 0, "inf": 0, "termin": 0, "although": 0, "empti": 0, "nevertheless": 0, "sound": 0, "check": 0, "appropri": 0, "forc": 0, "auto_first": 0, "pseudcod": 0, "autodepend": 0, "priorit": 0, "even": 0, "remember_only_par": 0, "been": 0, "point": 0, "wa": 0, "later": 0, "tail": 0, "re": 0, "no_apr": 0, "apr": 0, "except": 0, "never": 0, "conveni": 0, "post": 0, "purpos": 0, "wildcard": 0, "st": [], "edg": 0, "star": 0, "prediction_model": 0, "extract": 0, "persist": 0, "finit": 0, "within": 0, "ignor": 0, "missing_flag": 0, "miss": 0, "sklearn": 0, "linear_model": 0, "linearregress": 0, "regress": 0, "ie": 0, "eg": 0, "gpdc": 0, "gaussianprocessregressor": 0, "nearestneighbor": 0, "anneal": 0, "run_rpcmci": 0, "num_regim": 0, "max_transit": 0, "switch_thr": 0, "num_iter": 0, "20": 0, "max_ann": 0, "n_job": 0, "transit": 0, "singl": 0, "switch": 0, "cpu": 0, "joblib": 0, "paral": 0, "n_regim": 0, "One": 0, "hot": 0, "encod": 0, "causal_result": 0, "converg": 0, "diff_g_f": 0, "tupl": 0, "consecut": 0, "error_free_ann": 0, "without": 0, "error": 0, "independence_tests_bas": 0, "42": 0, "mask_typ": 0, "fixed_thr": 0, "sig_sampl": 0, "500": 0, "sig_blocklength": 0, "conf_lev": 0, "9": 0, "conf_sampl": 0, "100": 0, "conf_blocklength": 0, "recycle_residu": 0, "provid": 0, "shuffl": 0, "bootstrap": 0, "inherit": 0, "randomst": 0, "default_rng": 0, "xy": 0, "xz": 0, "yz": 0, "xyz": 0, "shuffle_test": 0, "block": 0, "decai": 0, "autocovari": 0, "nan": 0, "side": 0, "residu": 0, "store": 0, "faster": 0, "cost": 0, "consider": 0, "memori": 0, "get_analytic_confid": 0, "df": 0, "concret": 0, "overrid": 0, "get_analytic_signific": 0, "dim": 0, "get_bootstrap_confid": 0, "dependence_measur": 0, "95": 0, "data_typ": 0, "With": 0, "row": 0, "column": 0, "get_dependence_measur": 0, "binari": 0, "individu": 0, "0s": 0, "1s": 0, "conf_low": 0, "conf_upp": 0, "upper": 0, "lower": 0, "bound": 0, "get_confid": 0, "child": 0, "var": 0, "make": 0, "sure": 0, "size": 0, "instanti": 0, "get_fixed_thres_signific": 0, "signfic": 0, "get_measur": 0, "get_shuffle_signific": 0, "return_null_dist": 0, "properti": 0, "print_info": 0, "run_test": 0, "cut_off": 0, "2xtau_max": 0, "alpha_or_thr": 0, "signficic": 0, "both": 0, "_get_single_residu": 0, "max_lag": 0, "max_lag_or_tau_max": 0, "how": 0, "cutoff": 0, "begin": 0, "guarante": 0, "compar": 0, "multipl": 0, "much": 0, "decis": 0, "run_test_raw": 0, "x_type": 0, "y_type": 0, "z_type": 0, "input": 0, "dimens": 0, "set_datafram": 0, "flag": 0, "set_mask_typ": 0, "setter": 0, "ensur": 0, "clash": 0, "kwarg": 0, "partial": 0, "correl": 0, "ordinari": 0, "least": 0, "squar": 0, "ol": 0, "pearson": 0, "To": 0, "out": 0, "beta_x": 0, "epsilon_": 0, "beta_i": 0, "rho": 0, "left": 0, "r_x": 0, "r_y": 0, "right": 0, "student": 0, "distribut": 0, "d_z": 0, "degre": 0, "freedom": 0, "argument": 0, "coeffici": 0, "less": 0, "featur": 0, "corrected_a": 0, "akaik": 0, "criterion": 0, "modulo": 0, "constant": 0, "leav": 0, "cross": 0, "asymptot": 0, "aic": 0, "target": 0, "unshuffl": 0, "robust_parcorr": 0, "robustparcorr": 0, "paranorm": 0, "transform": 0, "margin": 0, "firstli": 0, "phi": 0, "circ": 0, "hat": 0, "f": 0, "quantil": 0, "empir": 0, "idea": 0, "stem": 0, "literatur": 0, "nonparanorm": 0, "han": 0, "liu": 0, "john": 0, "lafferti": 0, "larri": 0, "wasserman": 0, "semiparametr": 0, "mach": 0, "2295": 0, "2328": 0, "2009": 0, "fang": 0, "ming": 0, "yuan": 0, "gaussian": 0, "copula": 0, "ann": 0, "40": 0, "2293": 0, "2326": 0, "2012a": 0, "naftali": 0, "harri": 0, "mathia": 0, "drton": 0, "machin": 0, "research": 0, "14": 0, "3365": 0, "3383": 0, "2013": 0, "afterward": 0, "now": 0, "uniform": 0, "plu": 0, "trafo2norm": 0, "thre": 0, "1e": 0, "code": 0, "small": 0, "too": 0, "close": 0, "similarli": 0, "null_dist_filenam": 0, "gp_param": 0, "distanc": 0, "gp": 0, "scikit": 0, "kernel": 0, "let": 0, "them": 0, "cython": 0, "null": 0, "precomput": 0, "generate_and_save_nulldist": 0, "npz": 0, "file": 0, "f_x": 0, "f_y": 0, "sim": 0, "sigma": 0, "bandwidth": 0, "optimz": 0, "r": 0, "pre": 0, "otherwis": 0, "dure": 0, "gabor": 0, "szeke": 0, "maria": 0, "l": 0, "rizzo": 0, "nail": 0, "bakirov": 0, "arxiv": 0, "ab": 0, "0803": 0, "4101": 0, "otion": 0, "path": 0, "gaussprocreg": 0, "sample_s": 0, "pairwis": 0, "generate_nulldist": 0, "dist": 0, "disk": 0, "add": 0, "gauss_pr": 0, "null_dist": 0, "name": 0, "add_to_null_dist": 0, "just": 0, "load": 0, "nulldist": 0, "wide": 0, "rang": 0, "beforehand": 0, "log": 0, "likelihood": 0, "neg": 0, "Is": 0, "gpdc_torch": 0, "gpdctorch": 0, "gpytorch": 0, "dcor": 0, "pip": 0, "gaussprocregtorch": 0, "knn": 0, "shuffle_neighbor": 0, "rank": 0, "worker": 0, "model_selection_fold": 0, "come": 0, "joint": 0, "densiti": 0, "frenzel": 0, "pomp": 0, "lett": 0, "99": 0, "204101": 0, "2007": 0, "suitabl": 0, "cmisymb": 0, "cmi": 0, "iint": 0, "frac": 0, "cdot": 0, "dx": 0, "dy": 0, "dz": 0, "psi": 0, "sum_": 0, "k_": 0, "digamma": 0, "hyper": 0, "cube": 0, "subspac": 0, "view": 0, "smooth": 0, "unlik": 0, "fix": 0, "bia": 0, "varianc": 0, "slightli": 0, "while": 0, "quantiti": 0, "scipi": 0, "spatial": 0, "ckdtree": 0, "fraction": 0, "henc": 0, "absolut": 0, "surrog": 0, "processor": 0, "fold": 0, "get_conditional_entropi": 0, "entropi": 0, "h": 0, "prl": 0, "overwrit": 0, "preserv": 0, "permut": 0, "those": 0, "x_i": 0, "x_j": 0, "z_j": 0, "niehgbor": 0, "z_i": 0, "n_symb": 0, "categor": 0, "symbol": 0, "local": 0, "mix": 0, "cmiknnmix": 0, "crosstab": 0, "conting": 0, "approxim": 0, "probabl": 0, "mass": 0, "drawn": 0, "oracle_conditional_independ": 0, "oracleci": 0, "observed_var": 0, "selection_var": 0, "graph_is_mag": 0, "oracl": 0, "link_coeff": 0, "ground": 0, "truth": 0, "unit": 0, "altern": 0, "digest": 0, "func": 0, "definin": 0, "check_shortest_path": 0, "starts_with": 0, "ends_with": 0, "forbidden_nod": 0, "only_non_causal_path": 0, "check_optimality_cond": 0, "optimality_cond_des_ym": 0, "optimality_cond_i": 0, "return_path": 0, "non_rep": 0, "au_i": 0, "au_j": 0, "alreadi": 0, "truncat": 0, "breadth": 0, "start": 0, "end": 0, "veri": 0, "long": 0, "constrain": 0, "has_path": 0, "ancestr": 0, "compute_ancestor": 0, "anc_all_x": 0, "anc_all_i": 0, "anc_all_z": 0, "arrohead": 0, "compat": 0, "get_graph_from_link": 0, "mag": 0, "admg": 0, "project": 0, "oper": 0, "pearl": 0, "get_links_from_graph": 0, "case": 0, "ad": 0, "canon": 0, "richardson": 0, "spirt": 0, "2002": 0, "support": 0, "evalu": 0, "els": 0, "Not": 0, "dummi": 0, "parcorr_mult": 0, "parcorrmult": 0, "correlation_typ": 0, "max_corr": 0, "multivari": 0, "mult_corr": 0, "gsquar": 0, "chi2": 0, "2000": 0, "stat": 0, "formula": 0, "bishop": 0, "fienberg": 0, "holland": 0, "1975": 0, "theori": 0, "mit": 0, "cambridg": 0, "p_valu": 0, "chi": 0, "dof": 0, "parcorr_wl": 0, "parcorrwl": 0, "gt_std_matrix": 0, "expert_knowledg": 0, "heteroskedast": 0, "window_s": 0, "robustifi": 0, "weight": 0, "wl": 0, "known": 0, "thei": 0, "neighbour": 0, "homoskedast": 0, "term": 0, "deviat": 0, "nois": 0, "nb_node": 0, "expert": 0, "regressionci": 0, "vs": 0, "notion": 0, "devianc": 0, "emploi": 0, "significantli": 0, "hypothes": 0, "accept": 0, "approach": 0, "univari": 0, "moreov": 0, "multinomi": 0, "causaleffect": 0, "graph_typ": 0, "hidden_vari": 0, "check_sm_overlap": 0, "potenti": 0, "backdoor": 0, "variou": 0, "wright": 0, "depth": 0, "introduct": 0, "8485ae387a981d783f8764e508151cd9": 0, "caus": 0, "overlap": 0, "check_xys_path": 0, "proper": 0, "clean": 0, "check_optim": 0, "thm": 0, "fit_bootstrap_of": 0, "method_arg": 0, "boot_sampl": 0, "boot_blocklength": 0, "construct_arrai": 0, "shift": 0, "bootsrap": 0, "predict_bootstrap_of": 0, "draw": 0, "fit_total_effect": 0, "adjustment_set": 0, "conditional_estim": 0, "data_transform": 0, "ignore_identifi": 0, "oset": 0, "minimized_optim": 0, "minim": 0, "colliders_minimized_optim": 0, "preprocess": 0, "prior": 0, "standardscal": 0, "simpl": 0, "user": 0, "fit_wright_effect": 0, "considerd": 0, "complic": 0, "static": 0, "get_dict_from_graph": 0, "parents_onli": 0, "helper": 0, "convert": 0, "get_graph_from_dict": 0, "get_medi": 0, "get_optimal_set": 0, "alternative_condit": 0, "return_separate_set": 0, "theorem": 0, "colliders_onli": 0, "invalid": 0, "collider_par": 0, "oset_": 0, "return_individual_bootstrap_result": 0, "confidence_interv": 0, "predict_total_effect": 0, "intervention_data": 0, "conditions_data": 0, "pred_param": 0, "return_further_pred_result": 0, "aggregation_func": 0, "transform_interventions_and_predict": 0, "len": 0, "predictor": 0, "entir": 0, "invers": 0, "estimate_confid": 0, "predict_wright_effect": 0, "conditional_model": 0, "care": 0, "inverse_transform": 0, "fit_full_model": 0, "selected_vari": 0, "empty_predictors_funct": 0, "return_data": 0, "integ": 0, "fit_result": 0, "get_coef": 0, "get_general_fitted_model": 0, "get_general_predict": 0, "get_val_matrix": 0, "fit_model": 0, "give": 0, "deriv": 0, "linearmedi": 0, "model_param": 0, "etc": 0, "ce": 0, "mce": 0, "ac": 0, "suscept": 0, "amc": 0, "chain": 0, "x_t": 0, "eta": 0, "y_t": 0, "x_": 0, "z_t": 0, "y_": 0, "25": 0, "37": 0, "true_par": 0, "med": 0, "get_coeff": 0, "get_c": 0, "get_mc": 0, "get_all_ac": 0, "get_all_amc": 0, "250648072987": 0, "36897445": 0, "25718002": 0, "24365041": 0, "38250406": 0, "12532404": 0, "fit_model_bootstrap": 0, "boostrap": 0, "version": 0, "cube_root": 0, "from_autocorrel": 0, "generate_noise_from": [], "root": 0, "get_ac": 0, "lag_mod": 0, "absmax": 0, "exclude_i": 0, "eman": 0, "all_lag": 0, "itself": 0, "exclude_j": 0, "affect": 0, "previou": 0, "exclude_k": 0, "exclude_self_effect": 0, "themselv": 0, "get_amc": 0, "get_bootstrap_of": 0, "function_arg": 0, "incl": 0, "get_ce_max": 0, "get_conditional_mc": 0, "notk": 0, "go": 0, "get_joint_c": 0, "count": 0, "joint_c": 0, "get_joint_ce_matrix": 0, "taui": 0, "tauj": 0, "stand": 0, "joint_ce_matrix": 0, "2d": 0, "get_joint_mc": 0, "joint_mc": 0, "minu": 0, "get_mediation_graph_data": 0, "include_neighbor": 0, "path_val_matrix": 0, "path_node_arrai": 0, "tsg_path_val_matrix": 0, "graph_data": 0, "color": 0, "get_tsg": 0, "link_matrix": 0, "analyz": 0, "sig_thr": 0, "array_lik": 0, "tsg": 0, "symmetr": 0, "net_to_tsg": 0, "translat": 0, "tsg_to_net": 0, "train_indic": 0, "test_indic": 0, "train": 0, "target_predictor": 0, "selected_target": 0, "instanc": 0, "get_predictor": 0, "steps_ahead": 0, "get_test_arrai": 0, "get_train_arrai": 0, "new_data": 0, "cut": 0, "off": 0, "below": 0, "vector_var": 0, "var_nam": 0, "datatim": 0, "analysis_mod": 0, "reference_point": 0, "time_offset": 0, "remove_missing_upto_maxlag": 0, "definit": 0, "OR": 0, "whose": 0, "t_i": 0, "vari": 0, "dismiss": 0, "slice": 0, "occur": 0, "bias": 0, "section": 0, "supplement": 0, "sciadv": 0, "vector": 0, "pars": 0, "creat": 0, "match": 0, "enumer": 0, "timelabel": 0, "1d": 0, "rel": 0, "share": 0, "axi": 0, "t_max": 0, "largest_time_step": 0, "bigger": 0, "At": 0, "align": 0, "agre": 0, "offset": 0, "_initialized_from": 0, "3d": 0, "map": 0, "represent": 0, "identifii": 0, "max_": 0, "largest": 0, "latest": 0, "random_st": 0, "extraz": 0, "return_cleaned_xyz": 0, "do_check": 0, "remove_overlap": 0, "n_en": 0, "var1": 0, "var2": 0, "varlag": 0, "assign": 0, "duplic": 0, "saniti": 0, "2xtau_max_futur": 0, "t_miss": 0, "principl": 0, "would": 0, "n_sampl": 0, "print_array_info": 0, "info": 0, "typic": 0, "varx": 0, "get_acf": 0, "autocorr": 0, "get_block_length": 0, "mader": 0, "eq": 0, "pfeifer": 0, "2005": 0, "multidimension": 0, "jointli": 0, "curv": 0, "fail": 0, "limit": 0, "neurosci": 0, "volum": 0, "219": 0, "issu": 0, "15": 0, "octob": 0, "285": 0, "291": 0, "block_len": 0, "lowhighpass_filt": 0, "cutperiod": 0, "pass_period": 0, "low": 0, "butterworth": 0, "filter": 0, "twice": 0, "onc": 0, "forward": 0, "backward": 0, "period": 0, "act": 0, "ordinal_patt_arrai": 0, "array_mask": 0, "symbolifi": 0, "ordin": 0, "pattern": 0, "uniqu": 0, "faculti": 0, "symb_arrai": 0, "shorter": 0, "2011": 0, "coupl": 0, "83": 0, "12": 0, "051122": 0, "label": 0, "embed": 0, "patt": 0, "patt_mask": 0, "patt_tim": 0, "quantile_bin_arrai": 0, "bin": 0, "smooth_width": 0, "width": 0, "heavisid": 0, "rtype": 0, "intervention_typ": 0, "hard": 0, "time_bin_with_mask": 0, "time_bin_length": 0, "bindata": 0, "outer": 0, "cdf": 0, "normal_data": 0, "parents_neighbors_coeff": 0, "inv_inno_cov": 0, "initial_valu": 0, "autoregress": 0, "innov": 0, "var_network": 0, "friendli": 0, "weighted_avg_and_std": 0, "std": 0, "check_stationar": 0, "stationari": 0, "dag_to_link": 0, "generate_structural_causal_process": 0, "dependency_func": 0, "dependency_coeff": 0, "auto_coeff": 0, "contemp_fract": 0, "noise_dist": 0, "noise_mean": 0, "noise_sigma": 0, "noise_se": 0, "randomli": 0, "characterist": 0, "frawn": 0, "arbitrari": 0, "factor": 0, "weibul": 0, "def": 0, "beta": 0, "links_to_graph": 0, "transient_fract": 0, "interven": 0, "randn": 0, "un": 0, "soft": 0, "percentag": 0, "transient": 0, "realiz": 0, "nonvalid": 0, "infin": 0, "lag1": 0, "coef1": 0, "lag2": 0, "coef2": 0, "nonzero": 0, "covari": 0, "inno_cov": 0, "debug": 0, "no_nois": 0, "disabl": 0, "max_delai": 0, "true_parent_neighbor": 0, "id": 0, "parent_node_id": 0, "time_lag": 0, "plot_densityplot": 0, "setup_arg": 0, "add_densityplot_arg": 0, "selected_dataset": 0, "show_marginal_densities_on_diagon": 0, "setup_density_matrix": 0, "add_densityplot": 0, "diagon": 0, "show": 0, "seaborn": 0, "doc": 0, "overlaid": 0, "plot_graph": 0, "fig_ax": 0, "figsiz": 0, "save_nam": 0, "link_colorbar_label": 0, "node_colorbar_label": 0, "auto": 0, "link_width": 0, "link_attribut": 0, "node_po": 0, "arrow_linewidth": 0, "vmin_edg": 0, "vmax_edg": 0, "edge_tick": 0, "cmap_edg": 0, "rdbu_r": 0, "vmin_nod": 0, "vmax_nod": 0, "node_tick": 0, "cmap_nod": 0, "node_s": 0, "node_aspect": 0, "arrowhead_s": 0, "curved_radiu": 0, "label_fonts": 0, "tick_label_s": 0, "node_label_s": 0, "link_label_fonts": 0, "lag_arrai": 0, "show_colorbar": 0, "inner_edge_styl": 0, "dash": 0, "special_nod": 0, "show_autodependency_lag": 0, "straight": 0, "arrow": 0, "maxim": 0, "magnitud": 0, "posit": 0, "coordin": 0, "via": 0, "ax": 0, "basemap": 0, "ccr": 0, "platecarre": 0, "cartopi": 0, "linewidth": 0, "colorbar": 0, "tick": 0, "colormap": 0, "orrd": 0, "ratio": 0, "heigth": 0, "varibl": 0, "head": 0, "fancyarrowpatch": 0, "curvatur": 0, "fontsiz": 0, "opac": 0, "arang": 0, "plot_lagfunc": 0, "add_lagfunc_arg": 0, "lagfunct": 0, "setup_matrix": 0, "add_lagfunc": 0, "plot_mediation_graph": 0, "standard_color_link": 0, "black": 0, "standard_color_nod": 0, "lightgrei": 0, "visual": 0, "plot_mediation_time_series_graph": 0, "top": 0, "bottom": 0, "plot_scatterplot": 0, "add_scatterplot_arg": 0, "scatter": 0, "setup_scatter_matrix": 0, "add_scatterplot": 0, "plot_time_series_graph": 0, "auxiliari": 0, "auxadmg": 0, "style": 0, "inner_edg": 0, "special": 0, "plot_timeseri": 0, "var_unit": 0, "time_label": 0, "grey_masked_sampl": 0, "show_meanlin": 0, "data_linewidth": 0, "skip_ticks_data_x": 0, "skip_ticks_data_i": 0, "adjust_plot": 0, "stack": 0, "panel": 0, "subplot": 0, "fig": 0, "pyplot": 0, "grei": 0, "fill": 0, "horizont": 0, "skip": 0, "tickmark": 0, "plot_tsg": 0, "anc_x": 0, "anc_i": 0, "anc_xi": 0, "help": 0, "label_space_left": 0, "label_space_top": 0, "legend_width": 0, "legend_fonts": 0, "plot_gridlin": 0, "setup": 0, "space": 0, "alloc": 0, "vertic": 0, "legend": 0, "grid": 0, "matrix_lag": 0, "label_color": 0, "snskdeplot_arg": 0, "cmap": 0, "snskdeplot_diagonal_arg": 0, "depict": 0, "sn": 0, "kdeplot": 0, "adjustfig": 0, "show_label": 0, "x_base": 0, "y_base": 0, "lag_unit": 0, "comparison": 0, "two_sided_thr": 0, "marker": 0, "markers": 0, "po": 0, "matplotlib": 0, "savefig": 0, "scatterplot": 0, "write_csv": 0, "digit": 0, "write": 0, "csv": 0, "g\u00fcnther": 0, "u": 0, "ninad": 0, "context": 0, "infinit": 0, "node_classif": 0, "enabl": 0, "unobserv": 0, "classif": 0, "time_context": 0, "space_context": 0, "time_dummi": 0, "space_dummi": 0, "dummy_par": 0, "observed_context_par": 0, "dummy_ci_test": 0, "system_search": 0, "context_search": 0, "dummy_search": 0, "time_context_nod": 0, "space_context_nod": 0, "system_nod": 0, "add_found_context_link_assumpt": 0, "assume_exogenous_context": 0, "observed_context_nod": 0, "amend": 0, "clean_link_assumpt": 0, "clean_system_link_assumpt": 0, "contextu": 0, "discover_dummy_system_link": 0, "context_system_result": 0, "run_jpcmciplu": 0, "discover_lagged_and_context_system_link": 0, "discover_lagged_context_system_link": 0, "discover_system_system_link": 0, "lagged_context_dummy_par": 0, "remove_dummy_link_assumpt": 0, "obtain": 0, "next": 0, "c_t": 0, "c_": 0, "mathbf": 0, "setminu": 0, "condition": 0, "By": 0, "final": 0, "cd": 0, "involv": 0, "multioutput": 0, "multioutputregressor": 0, "extend": 0, "get_residuals_cov_mean": 0, "predict_full_model": 0, "classifi": 0, "treat": 0, "resolv": 0, "manner": 0, "bic": 0, "ref": 0, "bold": 0, "taumax": 0, "ast": 0, "But": 0, "pairwisemultci": 0, "suggest": 0, "tsagri": 0, "michail": 0, "constraint": 0, "19": 0, "furthermor": 0, "our": 0, "util": 0, "theirs": 0, "structural_causal_process_ensembl": 0, "ensemble_se": 0, "ensembl": 0, "docstr": 0, "ii": 0, "causalmedi": 0, "counter": 0, "factual": 0, "technic": 0, "appendix": 0, "seventeenth": 0, "2001": 0, "identif": 0, "psycholog": 0, "459": 0, "2014": 0, "shpitser": 0, "vanderweel": 0, "complet": 0, "ment": 0, "biostatist": 0, "charact": 0, "toy_setup": 0, "getgroundtruthgraph": 0, "stationary_dag": 0, "idx": 0, "reserv": 0, "uint": 0, "fit_natural_direct_effect": 0, "mixed_data_estim": 0, "fitsetup": 0, "blocked_medi": 0, "use_mediation_impl_for_total_effect_fallback": 0, "mixed_fit": 0, "configur": 0, "contribut": 0, "explicitli": 0, "try": 0, "fall": 0, "back": 0, "perkov": 0, "os": 0, "easier": 0, "predict_natural_direct_effect": 0, "predict_natural_direct_effect_funct": 0, "naturaleffects_graphmedi": 0, "reference_value_x": 0, "cf_intervention_value_x": 0, "world": 0, "throw": 0, "rais": 0, "meaning": 0, "nde": 0, "categori": 0, "chang": 0, "change_from": 0, "change_to": 0, "keep": 0, "induc": 0, "min_x": 0, "max_x": 0, "cf_delta": 0, "smoothing_gaussian_sigma_in_step": 0, "normalize_by_delta": 0, "taken": 0, "delta": 0, "intermedi": 0, "gau\u00df": 0, "divid": 0, "request": 0, "sens": 0, "probabilit": 0}, "objects": {"tigramite.causal_effects": [[0, 0, 1, "", "CausalEffects"]], "tigramite.causal_effects.CausalEffects": [[0, 1, 1, "", "check_XYS_paths"], [0, 1, 1, "", "check_optimality"], [0, 1, 1, "", "fit_bootstrap_of"], [0, 1, 1, "", "fit_total_effect"], [0, 1, 1, "", "fit_wright_effect"], [0, 1, 1, "", "get_dict_from_graph"], [0, 1, 1, "", "get_graph_from_dict"], [0, 1, 1, "", "get_mediators"], [0, 1, 1, "", "get_optimal_set"], [0, 1, 1, "", "predict_bootstrap_of"], [0, 1, 1, "", "predict_total_effect"], [0, 1, 1, "", "predict_wright_effect"]], "tigramite.causal_mediation": [[0, 0, 1, "", "CausalMediation"]], "tigramite.causal_mediation.CausalMediation": [[0, 1, 1, "", "fit_natural_direct_effect"], [0, 1, 1, "", "predict_natural_direct_effect"], [0, 1, 1, "", "predict_natural_direct_effect_function"]], "tigramite": [[0, 2, 0, "-", "data_processing"], [0, 2, 0, "-", "plotting"]], "tigramite.data_processing": [[0, 0, 1, "", "DataFrame"], [0, 4, 1, "", "get_acf"], [0, 4, 1, "", "get_block_length"], [0, 4, 1, "", "lowhighpass_filter"], [0, 4, 1, "", "ordinal_patt_array"], [0, 4, 1, "", "quantile_bin_array"], [0, 4, 1, "", "smooth"], [0, 4, 1, "", "structural_causal_process"], [0, 4, 1, "", "time_bin_with_mask"], [0, 4, 1, "", "trafo2normal"], [0, 4, 1, "", "var_process"], [0, 4, 1, "", "weighted_avg_and_std"]], "tigramite.data_processing.DataFrame": [[0, 1, 1, "", "construct_array"], [0, 1, 1, "", "print_array_info"]], "tigramite.data_processing.DataFrame.self": [[0, 3, 1, "", "M"], [0, 3, 1, "", "N"], [0, 3, 1, "", "T"], [0, 3, 1, "", "_initialized_from"], [0, 3, 1, "", "analysis_mode"], [0, 3, 1, "", "bootstrap"], [0, 3, 1, "", "data_type"], [0, 3, 1, "", "datasets"], [0, 3, 1, "", "datatime"], [0, 3, 1, "", "largest_time_step"], [0, 3, 1, "", "mask"], [0, 3, 1, "", "missing_flag"], [0, 3, 1, "", "reference_points"], [0, 3, 1, "", "time_offsets"], [0, 3, 1, "", "values"], [0, 3, 1, "", "var_names"]], "tigramite.independence_tests.cmiknn": [[0, 0, 1, "", "CMIknn"]], "tigramite.independence_tests.cmiknn.CMIknn": [[0, 1, 1, "", "get_conditional_entropy"], [0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"]], "tigramite.independence_tests.cmisymb": [[0, 0, 1, "", "CMIsymb"]], "tigramite.independence_tests.cmisymb.CMIsymb": [[0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"]], "tigramite.independence_tests.gpdc": [[0, 0, 1, "", "GPDC"]], "tigramite.independence_tests.gpdc.GPDC": [[0, 1, 1, "", "generate_and_save_nulldists"], [0, 1, 1, "", "generate_nulldist"], [0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"]], "tigramite.independence_tests.gpdc_torch": [[0, 0, 1, "", "GPDCtorch"]], "tigramite.independence_tests.gpdc_torch.GPDCtorch": [[0, 1, 1, "", "generate_and_save_nulldists"], [0, 1, 1, "", "generate_nulldist"], [0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"]], "tigramite.independence_tests.gsquared": [[0, 0, 1, "", "Gsquared"]], "tigramite.independence_tests.gsquared.Gsquared": [[0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_dependence_measure"], [0, 5, 1, "", "measure"]], "tigramite.independence_tests.independence_tests_base": [[0, 0, 1, "", "CondIndTest"]], "tigramite.independence_tests.independence_tests_base.CondIndTest": [[0, 1, 1, "", "get_analytic_confidence"], [0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_bootstrap_confidence"], [0, 1, 1, "", "get_confidence"], [0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_fixed_thres_significance"], [0, 1, 1, "", "get_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"], [0, 1, 1, "", "print_info"], [0, 1, 1, "", "run_test"], [0, 1, 1, "", "run_test_raw"], [0, 1, 1, "", "set_dataframe"], [0, 1, 1, "", "set_mask_type"]], "tigramite.independence_tests.oracle_conditional_independence": [[0, 0, 1, "", "OracleCI"]], "tigramite.independence_tests.oracle_conditional_independence.OracleCI": [[0, 1, 1, "", "check_shortest_path"], [0, 1, 1, "", "get_confidence"], [0, 1, 1, "", "get_graph_from_links"], [0, 1, 1, "", "get_links_from_graph"], [0, 1, 1, "", "get_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 5, 1, "", "measure"], [0, 1, 1, "", "run_test"], [0, 1, 1, "", "set_dataframe"]], "tigramite.independence_tests.parcorr": [[0, 0, 1, "", "ParCorr"]], "tigramite.independence_tests.parcorr.ParCorr": [[0, 1, 1, "", "get_analytic_confidence"], [0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"]], "tigramite.independence_tests.parcorr_mult": [[0, 0, 1, "", "ParCorrMult"]], "tigramite.independence_tests.parcorr_mult.ParCorrMult": [[0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"], [0, 1, 1, "", "mult_corr"]], "tigramite.independence_tests.parcorr_wls": [[0, 0, 1, "", "ParCorrWLS"]], "tigramite.independence_tests.parcorr_wls.ParCorrWLS": [[0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"]], "tigramite.independence_tests.regressionCI": [[0, 0, 1, "", "RegressionCI"]], "tigramite.independence_tests.regressionCI.RegressionCI": [[0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_dependence_measure"], [0, 5, 1, "", "measure"], [0, 1, 1, "", "set_dataframe"]], "tigramite.independence_tests.robust_parcorr": [[0, 0, 1, "", "RobustParCorr"]], "tigramite.independence_tests.robust_parcorr.RobustParCorr": [[0, 1, 1, "", "get_analytic_confidence"], [0, 1, 1, "", "get_analytic_significance"], [0, 1, 1, "", "get_dependence_measure"], [0, 1, 1, "", "get_model_selection_criterion"], [0, 1, 1, "", "get_shuffle_significance"], [0, 5, 1, "", "measure"], [0, 1, 1, "", "trafo2normal"]], "tigramite.jpcmciplus": [[0, 0, 1, "", "JPCMCIplus"]], "tigramite.jpcmciplus.JPCMCIplus": [[0, 3, 1, "", "N"], [0, 3, 1, "", "T"], [0, 1, 1, "", "add_found_context_link_assumptions"], [0, 3, 1, "", "all_parents"], [0, 1, 1, "", "assume_exogenous_context"], [0, 1, 1, "", "clean_link_assumptions"], [0, 1, 1, "", "clean_system_link_assumptions"], [0, 1, 1, "", "discover_dummy_system_links"], [0, 1, 1, "", "discover_lagged_context_system_links"], [0, 1, 1, "", "discover_system_system_links"], [0, 3, 1, "", "dummy_ci_test"], [0, 3, 1, "", "dummy_parents"], [0, 3, 1, "", "iterations"], [0, 3, 1, "", "mode"], [0, 3, 1, "", "observed_context_parents"], [0, 3, 1, "", "pval_max"], [0, 1, 1, "", "remove_dummy_link_assumptions"], [0, 1, 1, "", "run_jpcmciplus"], [0, 3, 1, "", "space_context_nodes"], [0, 3, 1, "", "space_dummy"], [0, 3, 1, "", "system_nodes"], [0, 3, 1, "", "time_context_nodes"], [0, 3, 1, "", "time_dummy"], [0, 3, 1, "", "val_min"]], "tigramite.lpcmci": [[0, 0, 1, "", "LPCMCI"]], "tigramite.lpcmci.LPCMCI": [[0, 1, 1, "", "run_lpcmci"]], "tigramite.models": [[0, 0, 1, "", "LinearMediation"], [0, 0, 1, "", "Models"], [0, 0, 1, "", "Prediction"]], "tigramite.models.LinearMediation": [[0, 1, 1, "", "fit_model"], [0, 1, 1, "", "fit_model_bootstrap"], [0, 1, 1, "", "get_ace"], [0, 1, 1, "", "get_acs"], [0, 1, 1, "", "get_all_ace"], [0, 1, 1, "", "get_all_acs"], [0, 1, 1, "", "get_all_amce"], [0, 1, 1, "", "get_amce"], [0, 1, 1, "", "get_bootstrap_of"], [0, 1, 1, "", "get_ce"], [0, 1, 1, "", "get_ce_max"], [0, 1, 1, "", "get_coeff"], [0, 1, 1, "", "get_conditional_mce"], [0, 1, 1, "", "get_joint_ce"], [0, 1, 1, "", "get_joint_ce_matrix"], [0, 1, 1, "", "get_joint_mce"], [0, 1, 1, "", "get_mce"], [0, 1, 1, "", "get_mediation_graph_data"], [0, 1, 1, "", "get_tsg"], [0, 1, 1, "", "get_val_matrix"], [0, 1, 1, "", "net_to_tsg"], [0, 1, 1, "", "tsg_to_net"]], "tigramite.models.Models": [[0, 1, 1, "", "fit_full_model"], [0, 1, 1, "", "get_coefs"], [0, 1, 1, "", "get_general_fitted_model"], [0, 1, 1, "", "get_general_prediction"], [0, 1, 1, "", "get_residuals_cov_mean"], [0, 1, 1, "", "get_val_matrix"], [0, 1, 1, "", "predict_full_model"]], "tigramite.models.Prediction": [[0, 1, 1, "", "fit"], [0, 1, 1, "", "get_predictors"], [0, 1, 1, "", "get_test_array"], [0, 1, 1, "", "get_train_array"], [0, 1, 1, "", "predict"]], "tigramite.pcmci": [[0, 0, 1, "", "PCMCI"]], "tigramite.pcmci.PCMCI": [[0, 3, 1, "", "N"], [0, 3, 1, "", "T"], [0, 3, 1, "", "all_parents"], [0, 1, 1, "", "get_graph_from_pmatrix"], [0, 1, 1, "", "get_lagged_dependencies"], [0, 3, 1, "", "iterations"], [0, 1, 1, "", "print_results"], [0, 1, 1, "", "print_significant_links"], [0, 3, 1, "", "pval_max"], [0, 1, 1, "", "return_parents_dict"], [0, 1, 1, "", "return_significant_links"], [0, 1, 1, "", "run_bivci"], [0, 1, 1, "", "run_fullci"], [0, 1, 1, "", "run_mci"], [0, 1, 1, "", "run_pc_stable"], [0, 1, 1, "", "run_pcalg"], [0, 1, 1, "", "run_pcalg_non_timeseries_data"], [0, 1, 1, "", "run_pcmci"], [0, 1, 1, "", "run_pcmciplus"], [0, 3, 1, "", "val_min"]], "tigramite.plotting": [[0, 4, 1, "", "plot_densityplots"], [0, 4, 1, "", "plot_graph"], [0, 4, 1, "", "plot_lagfuncs"], [0, 4, 1, "", "plot_mediation_graph"], [0, 4, 1, "", "plot_mediation_time_series_graph"], [0, 4, 1, "", "plot_scatterplots"], [0, 4, 1, "", "plot_time_series_graph"], [0, 4, 1, "", "plot_timeseries"], [0, 4, 1, "", "plot_tsg"], [0, 0, 1, "", "setup_density_matrix"], [0, 0, 1, "", "setup_matrix"], [0, 0, 1, "", "setup_scatter_matrix"], [0, 4, 1, "", "write_csv"]], "tigramite.plotting.setup_density_matrix": [[0, 1, 1, "", "add_densityplot"], [0, 1, 1, "", "adjustfig"]], "tigramite.plotting.setup_matrix": [[0, 1, 1, "", "add_lagfuncs"], [0, 1, 1, "", "savefig"]], "tigramite.plotting.setup_scatter_matrix": [[0, 1, 1, "", "add_scatterplot"], [0, 1, 1, "", "adjustfig"]], "tigramite.rpcmci": [[0, 0, 1, "", "RPCMCI"]], "tigramite.rpcmci.RPCMCI": [[0, 1, 1, "", "run_rpcmci"]], "tigramite.toymodels": [[0, 2, 0, "-", "structural_causal_processes"]], "tigramite.toymodels.structural_causal_processes": [[0, 4, 1, "", "check_stationarity"], [0, 4, 1, "", "dag_to_links"], [0, 4, 1, "", "generate_structural_causal_process"], [0, 4, 1, "", "links_to_graph"], [0, 4, 1, "", "structural_causal_process"], [0, 4, 1, "", "structural_causal_process_ensemble"], [0, 4, 1, "", "var_process"]]}, "objtypes": {"0": "py:class", "1": "py:method", "2": "py:module", "3": "py:attribute", "4": "py:function", "5": "py:property"}, "objnames": {"0": ["py", "class", "Python class"], "1": ["py", "method", "Python method"], "2": ["py", "module", "Python module"], "3": ["py", "attribute", "Python attribute"], "4": ["py", "function", "Python function"], "5": ["py", "property", "Python property"]}, "titleterms": {"welcom": 0, "tigramit": 0, "s": 0, "document": 0, "indic": 0, "tabl": 0, "pcmci": 0, "lpcmci": 0, "rpcmci": 0, "independence_test": 0, "condit": 0, "independ": 0, "test": 0, "causal_effect": 0, "causal": 0, "effect": 0, "analysi": 0, "model": 0, "time": 0, "seri": 0, "mediat": 0, "predict": 0, "data_process": 0, "data": 0, "process": 0, "function": 0, "toymodel": 0, "toi": 0, "gener": 0, "plot": 0, "jpcmciplu": 0, "causal_medi": 0}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 6, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.viewcode": 1, "sphinx": 56}})
\ No newline at end of file
diff --git a/docs/_images/tigramite_logo_header.png b/docs/_images/tigramite_logo_header.png
new file mode 100644
index 00000000..6a6ada14
Binary files /dev/null and b/docs/_images/tigramite_logo_header.png differ
diff --git a/docs/index.rst b/docs/index.rst
index 42bce32f..da414491 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -80,6 +80,7 @@ Tigramite is a causal time series analysis python package. It allows to efficien
    tigramite.independence_tests.parcorr_wls.ParCorrWLS
    tigramite.independence_tests.regressionCI.RegressionCI
    tigramite.causal_effects.CausalEffects
+   tigramite.causal_mediation.CausalMediation
    tigramite.models.Models
    tigramite.models.LinearMediation
    tigramite.models.Prediction
@@ -161,6 +162,12 @@ Test statistics:
 .. autoclass:: tigramite.causal_effects.CausalEffects
    :members:
 
+:mod:`tigramite.causal_mediation`: Causal mediation analysis
+===========================================================
+
+.. autoclass:: tigramite.causal_mediation.CausalMediation
+   :members:
+
 
 :mod:`tigramite.models`: Time series modeling, mediation, and prediction
 ========================================================================
diff --git a/setup.py b/setup.py
index b99bc5ff..c5988826 100644
--- a/setup.py
+++ b/setup.py
@@ -60,7 +60,7 @@ def run(self):
 # Run the setup
 setup(
     name="tigramite",
-    version="5.2.5.0",
+    version="5.2.5.1",
     packages=["tigramite", "tigramite.independence_tests", "tigramite.toymodels"],
     license="GNU General Public License v3.0",
     description="Tigramite causal inference for time series",


Test patch:
diff --git a/tests/test_PairwiseMultCI.py b/tests/test_PairwiseMultCI.py
index cc3db3fa..4b23959b 100644
--- a/tests/test_PairwiseMultCI.py
+++ b/tests/test_PairwiseMultCI.py
@@ -82,23 +82,103 @@ def pairwise_mult_ci(request):
     (46, 0, 1000),
 ])
 
-def data_sample_c_cc_c(request):
+def data_sample_c_cc_cc(request):
     # Set the random seed
     seed, true_dep, T = request.param
     np.random.seed(seed)
-    x = np.random.normal(0, 1, T).reshape(T, 1)
-    y1 = np.random.normal(0, 1, T).reshape(T, 1)
+    z1 = np.random.normal(0, 1, T).reshape(T, 1)
+    z2 = np.random.normal(0, 1, T).reshape(T, 1)
+    z = np.hstack((z1,z2))
+    x = np.random.normal(0, 1, T).reshape(T, 1) + z1 + z2
+    y1 = np.random.normal(0, 1, T).reshape(T, 1) + z1 + z2
     y2 = true_dep * x + y1 + 0.3 * np.random.normal(0, 1, T).reshape(T, 1)
     y = np.hstack((y1,y2))
-    z = np.random.normal(0, 1, T).reshape(T, 1)
+
     # Return data xyz
     return x, y, z
 
-def test_pairwise_mult_ci(pairwise_mult_ci, data_sample_c_cc_c):
+def test_pairwise_mult_ci(pairwise_mult_ci, data_sample_c_cc_cc):
     # Get the data sample values
-    x, y, z = data_sample_c_cc_c
+    x, y, z = data_sample_c_cc_cc
     # Get the analytic significance
     test_result = pairwise_mult_ci.run_test_raw(x = x, y = y, z = z, alpha_or_thres=1)
     val = test_result[0]
     pval = test_result[1]
     np.testing.assert_allclose(pval, 0.5, atol=0.5)
+
+@pytest.fixture(params=[
+    # Generate PairwiseMultCI test instances
+    # test PairwiseMultCI for different combinations of:
+    # learn_augmented_cond_sets, significance (of the univariate tests),  alpha_pre, pre_step_sample_fraction, cond_ind_test, cond_ind_test_thres, cond_ind_test_thres_pre
+    ('False', 'fixed_thres', 0.0, 0.0, ParCorr, 1, 0.5),
+    ('False', 'analytic', 0.0, 0.0, ParCorr, None, None),
+    ('False', 'shuffle_test', 0.0, 0.0, ParCorr, None, None),
+    ('False', 'analytic', 0.0, 0.0, RobustParCorr, None, None),
+    ('False', 'shuffle_test', 0.0, 0.0, RobustParCorr, None, None),
+    ('False', 'shuffle_test', 0.0, 0.0, CMIknn, None, None),
+])
+
+def pairwise_mult_ci2(request):
+    # Unpack the parameters
+    learn_augmented_cond_sets, sig, alpha_pre, pre_step_sample_fraction, cond_ind_test, cond_ind_test_thres, cond_ind_test_thres_pre = request.param
+    # Generate the par_corr_wls independence test
+    if sig != "fixed_thres":
+        return PairwiseMultCI(learn_augmented_cond_sets = learn_augmented_cond_sets, cond_ind_test = cond_ind_test(significance = sig),
+                          alpha_pre = alpha_pre,
+                          pre_step_sample_fraction = pre_step_sample_fraction), cond_ind_test(significance = sig)
+    else:
+        return PairwiseMultCI(learn_augmented_cond_sets = learn_augmented_cond_sets, cond_ind_test = cond_ind_test(significance = sig),
+                          alpha_pre = None,
+                          pre_step_sample_fraction=pre_step_sample_fraction,
+                          significance= sig,
+                          fixed_thres_pre = 2
+                          ), cond_ind_test(significance = sig)
+
+
+"""def compare_ci(request):
+    # Unpack the parameters
+    learn_augmented_cond_sets, sig, alpha_pre, pre_step_sample_fraction, cond_ind_test, cond_ind_test_thres, cond_ind_test_thres_pre = request.param
+    # Generate the par_corr_wls independence test
+    return cond_ind_test(significance = sig)
+"""
+@pytest.fixture(params=[
+    # Generate PairwiseMultCI test instances
+    # test PairwiseMultCI for different combinations of:
+    # seed,  true_dep, T (=sample size)
+    (123, 0, 100),
+    (123, 0.2, 100),
+    (123, 0.5, 100),
+    (123, 0, 1000),
+    (46, 0, 100),
+    (46, 0.2, 100),
+    (46, 0.5, 100),
+    (46, 0, 100),
+])
+
+
+def data_sample_c_cc_cc2(request):
+    # Set the random seed
+    seed, true_dep, T = request.param
+    np.random.seed(seed)
+    z1 = np.random.normal(0, 1, T).reshape(T, 1)
+    z2 = np.random.normal(0, 1, T).reshape(T, 1)
+    z = np.hstack((z1,z2))
+    x = np.random.normal(0, 1, T).reshape(T, 1) + z1 + z2
+    y = np.random.normal(0, 1, T).reshape(T, 1) + z1 + z2 + true_dep * x
+
+
+    # Return data xyz
+    return x, y, z
+
+def test_compare_pairwise_mult_ci(pairwise_mult_ci2, data_sample_c_cc_cc2):
+    # Get the data sample values
+    x, y, z = data_sample_c_cc_cc2
+    # Get the analytic significance
+    test_result = pairwise_mult_ci2[0].run_test_raw(x = x, y = y, z = z, alpha_or_thres=1)
+    test_result2 = pairwise_mult_ci2[1].run_test_raw(x=x, y=y, z=z, alpha_or_thres=1)
+    val = test_result[0]
+    pval = test_result[1]
+    val2 = test_result2[0]
+    pval2 = test_result2[1]
+    np.testing.assert_allclose(val, val2, rtol=0.2)
+    np.testing.assert_allclose(pval, pval2, atol=0.2)
\ No newline at end of file
diff --git a/tigramite/independence_tests/pairwise_CI.py b/tigramite/independence_tests/pairwise_CI.py
index caaf68b0..6cec1334 100644
--- a/tigramite/independence_tests/pairwise_CI.py
+++ b/tigramite/independence_tests/pairwise_CI.py
@@ -194,14 +194,14 @@ def calculate_dep_measure_and_significance(self, array, xyz, data_type = None, c
                     if fixed_thres_bool == False:
                         p_vals_pre[j, jj] = self.cond_ind_test.run_test_raw(x_s1[j].reshape(size_first_block, 1),
                                                                        y_s1[jj].reshape(size_first_block, 1),
-                                                                       z_s1.reshape(size_first_block, dim_z),
+                                                                       z_s1.T,
                                                                        x_type = x_type_s1,
                                                                        y_type = y_type_s1,
                                                                        z_type = z_type_s1)[1]
                     else:
                         vals_pre[j, jj] = self.cond_ind_test.run_test_raw(x_s1[j].reshape(size_first_block, 1),
                                                                        y_s1[jj].reshape(size_first_block, 1),
-                                                                       z_s1.reshape(size_first_block, dim_z),
+                                                                       z_s1.T,
                                                                        x_type = x_type_s1,
                                                                        y_type = y_type_s1,
                                                                        z_type = z_type_s1,
@@ -233,6 +233,7 @@ def calculate_dep_measure_and_significance(self, array, xyz, data_type = None, c
                     indicesX = np.setdiff1d(indep_set[0][indicesY_locs], j)
                 lix = indicesX.shape[0]
                 liy = indicesY.shape[0]
+
                 if lix + liy > 0:
                     if (lix > liy):
                         if x_type_s2 is not None:
@@ -240,16 +241,16 @@ def calculate_dep_measure_and_significance(self, array, xyz, data_type = None, c
                         if fixed_thres_bool == False:
                             test_result = self.cond_ind_test.run_test_raw(x_s2[j].reshape(T - size_first_block, 1),
                                                         y_s2[jj].reshape(T - size_first_block, 1),
-                                                        np.hstack((z_s2.reshape(T - size_first_block, dim_z),
-                                                                    x_s2[indicesX].reshape(T - size_first_block, lix))),
+                                                        np.hstack((z_s2.T,
+                                                                    x_s2[indicesX].T)),
                                                         x_type = x_type_s2,
                                                         y_type = y_type_s2,
                                                         z_type = z_type_s2)
                         else:
                             test_result = self.cond_ind_test.run_test_raw(x_s2[j].reshape(T - size_first_block, 1),
                                                         y_s2[jj].reshape(T - size_first_block, 1),
-                                                        np.hstack((z_s2.reshape(T - size_first_block, dim_z),
-                                                                    x_s2[indicesX].reshape(T - size_first_block, lix))),
+                                                        np.hstack((z_s2.T,
+                                                                    x_s2[indicesX].T)),
                                                         x_type = x_type_s2,
                                                         y_type = y_type_s2,
                                                         z_type = z_type_s2,
@@ -260,16 +261,16 @@ def calculate_dep_measure_and_significance(self, array, xyz, data_type = None, c
                         if fixed_thres_bool == False:
                             test_result = self.cond_ind_test.run_test_raw(x_s2[j].reshape(T - size_first_block, 1),
                                                         y_s2[jj].reshape(T - size_first_block, 1),
-                                                        np.hstack((z_s2.reshape(T - size_first_block, dim_z),
-                                                                    y_s2[indicesY].reshape(T - size_first_block, liy))),
+                                                        np.hstack((z_s2.T,
+                                                                    y_s2[indicesY].T)),
                                                         x_type = x_type_s2,
                                                         y_type = y_type_s2,
                                                         z_type = z_type_s2)
                         else:
                             test_result = self.cond_ind_test.run_test_raw(x_s2[j].reshape(T - size_first_block, 1),
                                                         y_s2[jj].reshape(T - size_first_block, 1),
-                                                        np.hstack((z_s2.reshape(T - size_first_block, dim_z),
-                                                                    y_s2[indicesY].reshape(T - size_first_block, liy))),
+                                                        np.hstack((z_s2.T,
+                                                                    y_s2[indicesY].T)),
                                                         x_type = x_type_s2,
                                                         y_type = y_type_s2,
                                                         z_type = z_type_s2,
@@ -279,14 +280,15 @@ def calculate_dep_measure_and_significance(self, array, xyz, data_type = None, c
                     if fixed_thres_bool == False:
                         test_result = self.cond_ind_test.run_test_raw(x_s2[j].reshape(T - size_first_block, 1),
                                                                       y_s2[jj].reshape(T - size_first_block, 1),
-                                                                      z_s2.reshape(T - size_first_block, dim_z),
+                                                                      z_s2.T,
                                                                       x_type = x_type_s2,
                                                                       y_type = y_type_s2,
                                                                       z_type = z_type_s2)
+
                     else:
                         test_result = self.cond_ind_test.run_test_raw(x_s2[j].reshape(T - size_first_block, 1),
                                                                       y_s2[jj].reshape(T - size_first_block, 1),
-                                                                      z_s2.reshape(T - size_first_block, dim_z),
+                                                                      z_s2.T,
                                                                       x_type = x_type_s2,
                                                                       y_type = y_type_s2,
                                                                       z_type = z_type_s2,
@@ -329,7 +331,27 @@ def get_analytic_significance(self, value = None, T = None, dim = None, xyz = No
     from tigramite.independence_tests.robust_parcorr import RobustParCorr
     from tigramite.independence_tests.cmiknn import CMIknn
     alpha = 0.05
-    ci = PairwiseMultCI(learn_augmented_cond_sets = True, fixed_thres_pre = 0.5, cond_ind_test = RobustParCorr(significance = "fixed_thres"))
+    #np.random.seed(seed = 123)
+    ci = PairwiseMultCI(cond_ind_test = RobustParCorr())
+    ci2 = RobustParCorr()
+    T = 100
+
+    z1 = np.random.normal(0, 1, T).reshape(T, 1)
+    z2 = np.random.normal(0, 1, T).reshape(T, 1)
+    z3 = np.random.normal(0, 1, T).reshape(T, 1)
+    z4 = np.random.normal(0, 1, T).reshape(T, 1)
+    z5 = np.random.normal(0, 1, T).reshape(T, 1)
+    z6 = np.random.normal(0, 1, T).reshape(T, 1)
+    x = np.random.normal(0, 1, T).reshape(T, 1) + z1 + z2
+    y = np.random.normal(0, 1, T).reshape(T, 1) + z1 + z2
+
+    #print(x)
+    #print(np.hstack((z1, z2, z3, z4, z5, z6)))
+    print("start")
+    print(ci.run_test_raw(x, y, np.hstack((z1, z2, z3, z4, z5, z6))))
+    print(ci2.run_test_raw(x, y, np.hstack((z1, z2, z3, z4, z5, z6))))
+    print("end")
+
     #ci = PairwiseMultCI(cond_ind_test=RobustParCorr(significance = "fixed_thres"), fixed_thres_pre = 0.3, learn_augmented_cond_sets= True)
     # ci = PairwiseMultCI(cond_ind_test=ParCorr(significance="fixed_thres"))
     # ci = PairwiseMultCI(cond_ind_test=ParCorr(significance="analytic"))
@@ -337,12 +359,13 @@ def get_analytic_significance(self, value = None, T = None, dim = None, xyz = No
     reals = 1
     rate = np.zeros(reals)
     #np.random.seed(1203)
+    '''
     for t in range(reals):
         # continuous example
         x1 = np.random.normal(0, 1, T).reshape(T, 1)
         x2 = np.random.normal(0, 1, T).reshape(T, 1)
         y1 = np.random.normal(0, 1, T).reshape(T, 1)
-        y2 = -50 * x1 + y1 + 0.3 * np.random.normal(0, 1, T).reshape(T, 1)
+        y2 = y1 + 0.3 * np.random.normal(0, 1, T).reshape(T, 1)
         z = np.random.normal(0, 1, T).reshape(T, 1)
         # discrete example
         #x = np.random.binomial(n=10, p=0.5, size=T).reshape(T, 1)
@@ -357,4 +380,4 @@ def get_analytic_significance(self, value = None, T = None, dim = None, xyz = No
         print("test_stat ", test_stat)
         print("pval ", pval)
     print(np.mean(rate))
-
+'''