Skip to content

Commit

Permalink
deploy: 0724002
Browse files Browse the repository at this point in the history
  • Loading branch information
s3alfisc committed Oct 7, 2024
1 parent 866c3a7 commit eab3c10
Show file tree
Hide file tree
Showing 19 changed files with 2,387 additions and 2,389 deletions.
84 changes: 42 additions & 42 deletions compare-fixest-pyfixest.html

Large diffs are not rendered by default.

80 changes: 39 additions & 41 deletions difference-in-differences.html

Large diffs are not rendered by default.

Binary file modified difference-in-differences_files/figure-html/cell-8-output-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified difference-in-differences_files/figure-html/cell-9-output-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions marginaleffects.html
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ <h1 class="title">Marginal Effects and Hypothesis Tests via <code>marginaleffect


<p>We can compute marginal effects and linear and non-linear hypothesis tests via the excellent <a href="https://github.com/vincentarelbundock/pymarginaleffects">marginaleffects</a> package.</p>
<div id="373be119" class="cell" data-execution_count="1">
<div id="d6599225" class="cell" data-execution_count="1">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> marginaleffects <span class="im">import</span> hypotheses</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> pyfixest <span class="im">as</span> pf</span>
Expand All @@ -263,7 +263,7 @@ <h1 class="title">Marginal Effects and Hypothesis Tests via <code>marginaleffect
</div>
<div class="cell-output cell-output-display">

<div id="pQ4Xdo"></div>
<div id="cbe9Yu"></div>
<script type="text/javascript" data-lets-plot-script="library">
if(!window.letsPlotCallQueue) {
window.letsPlotCallQueue = [];
Expand All @@ -287,17 +287,17 @@ <h1 class="title">Marginal Effects and Hypothesis Tests via <code>marginaleffect
var div = document.createElement("div");
div.style.color = 'darkred';
div.textContent = 'Error loading Lets-Plot JS';
document.getElementById("pQ4Xdo").appendChild(div);
document.getElementById("cbe9Yu").appendChild(div);
};
var e = document.getElementById("pQ4Xdo");
var e = document.getElementById("cbe9Yu");
e.appendChild(script);
})()
</script>

</div>
<div class="cell-output cell-output-display">

<div id="10aS0g"></div>
<div id="IunZKD"></div>
<script type="text/javascript" data-lets-plot-script="library">
if(!window.letsPlotCallQueue) {
window.letsPlotCallQueue = [];
Expand All @@ -321,9 +321,9 @@ <h1 class="title">Marginal Effects and Hypothesis Tests via <code>marginaleffect
var div = document.createElement("div");
div.style.color = 'darkred';
div.textContent = 'Error loading Lets-Plot JS';
document.getElementById("10aS0g").appendChild(div);
document.getElementById("IunZKD").appendChild(div);
};
var e = document.getElementById("10aS0g");
var e = document.getElementById("IunZKD");
e.appendChild(script);
})()
</script>
Expand Down Expand Up @@ -390,7 +390,7 @@ <h1 class="title">Marginal Effects and Hypothesis Tests via <code>marginaleffect
</div>
<p>Suppose we were interested in testing the hypothesis that <span class="math inline">\(X_{1} = X_{2}\)</span>. Given the relatively large differences in coefficients and small standard errors, we will likely reject the null that the two parameters are equal.</p>
<p>We can run the formal test via the <code>hypotheses</code> function from the <code>marginaleffects</code> package.</p>
<div id="cffd93aa" class="cell" data-execution_count="2">
<div id="c13f83a5" class="cell" data-execution_count="2">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>hypotheses(fit, <span class="st">"X1 - X2 = 0"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="2">
<div><style>
Expand Down Expand Up @@ -446,7 +446,7 @@ <h2 class="anchored" data-anchor-id="non-linear-hypothesis-tests-ratio-estimates
<p>We can also test run-linear hypotheses, in which case <code>marginaleffects</code> will automatically compute correct standard errors based on the estimated covariance matrix and the Delta method. This is for example useful for computing inferential statistics for the “relative uplift” in an AB test.</p>
<p>For the moment, let’s assume that <span class="math inline">\(X1\)</span> is a randomly assigned treatment variable. As before, <span class="math inline">\(Y\)</span> is our variable / KPI of interest.</p>
<p>Under randomization, the model intercept measures the “baseline”, i.e.&nbsp;the population average of <span class="math inline">\(Y\)</span> in the absence of treatment. To compute a relative uplift, we might compute</p>
<div id="0cac20cf" class="cell" data-execution_count="3">
<div id="0897174b" class="cell" data-execution_count="3">
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>(fit.coef().xs(<span class="st">"X1"</span>) <span class="op">/</span> fit.coef().xs(<span class="st">"Intercept"</span>) <span class="op">-</span> <span class="dv">1</span>) <span class="op">*</span> <span class="dv">100</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="3">
<pre><code>-211.71906665561212</code></pre>
Expand All @@ -473,7 +473,7 @@ <h3 class="anchored" data-anchor-id="the-multivariate-delta-method">The Multivar
<section id="using-the-delta-method-via-marginaleffects" class="level3">
<h3 class="anchored" data-anchor-id="using-the-delta-method-via-marginaleffects">Using the Delta Method via <code>marginaleffects</code>:</h3>
<p>We can employ the Delta Method via <code>marginaleffects</code> via the <code>hypotheses</code> function:</p>
<div id="2bdbf656" class="cell" data-execution_count="4">
<div id="a0e24e99" class="cell" data-execution_count="4">
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>hypotheses(fit, <span class="st">"(X1 / Intercept - 1) * 100 = 0"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="4">
<div><style>
Expand Down
Loading

0 comments on commit eab3c10

Please sign in to comment.