Skip to content

Commit 3f4f39c

Browse files
committed
medx
1 parent bcea298 commit 3f4f39c

File tree

52 files changed

+7128
-497
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+7128
-497
lines changed

.Rhistory

Lines changed: 496 additions & 496 deletions
Large diffs are not rendered by default.

Images/mediation/s0.png

65 KB
Loading

Images/mediation/s1.png

54.3 KB
Loading

Images/mediation/s2.png

95.5 KB
Loading

Images/mediation/s3b.png

116 KB
Loading

Images/mediation/s4b.png

105 KB
Loading

Images/mediation/spm.png

86.9 KB
Loading

Images/mediation/sse.png

107 KB
Loading

Images/mediation/ssteps.png

154 KB
Loading

docs/mediation.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,7 @@ <h2 id="toc-title">Table of contents</h2>
13311331
<li><a href="#baron-and-kenny-approach" id="toc-baron-and-kenny-approach" class="nav-link" data-scroll-target="#baron-and-kenny-approach">Baron and Kenny Approach</a></li>
13321332
<li><a href="#justification-of-mediation-analysis" id="toc-justification-of-mediation-analysis" class="nav-link" data-scroll-target="#justification-of-mediation-analysis">Justification of Mediation Analysis</a></li>
13331333
<li><a href="#mediation-example" id="toc-mediation-example" class="nav-link" data-scroll-target="#mediation-example">Mediation Example</a></li>
1334+
<li><a href="#mediation-software" id="toc-mediation-software" class="nav-link" data-scroll-target="#mediation-software">Mediation Software</a></li>
13341335
</ul></li>
13351336
</ul>
13361337
</nav>
@@ -1391,6 +1392,10 @@ <h3 class="anchored" data-anchor-id="justification-of-mediation-analysis"><a hre
13911392
<section id="mediation-example" class="level3">
13921393
<h3 class="anchored" data-anchor-id="mediation-example"><a href="mediation3.html">Mediation Example</a></h3>
13931394
<p>In the chapter, the focus is on decomposing the “total effect” of a given exposure, OA (<span class="math inline">\(A\)</span>), on the outcome CVD (<span class="math inline">\(Y\)</span>) into its natural direct effect (NDE; <span class="math inline">\(A \rightarrow Y\)</span>) and a natural indirect effect (NIE) that routes through a mediator, in this case, pain medication (<span class="math inline">\(M\)</span>). Initially, the required data is loaded and preprocessed. The mediation analysis involves several steps: (1) Preparing the data and ensuring it has the necessary variables; (2) Modifying data for different exposures and duplicating it; (3) Computing weights for the mediation based on logistic regressions, where the weights are applied to factor in the mediator’s effect; (4) Building a weighted outcome model, which is a logistic regression to evaluate the outcome. To quantify these effects, the chapter derives point estimates for the total effect, direct effect, and indirect effect. Furthermore, confidence intervals for these effects are determined using bootstrap methods. The results, including the proportion mediated by pain medication, are visualized using graphs. The chapter also delves into considerations of non-linearity and potential interactions between variables.</p>
1395+
</section>
1396+
<section id="mediation-software" class="level3">
1397+
<h3 class="anchored" data-anchor-id="mediation-software"><a href="mediation4.html">Mediation Software</a></h3>
1398+
<p>This tutorial walks through two complementary approaches to causal mediation: a manual inverse probability weighting (IPW) method that follows the step-by-step construction in the <a href="mediation0.html">slides</a>, and a parametric approach using the <code>regmedint</code> package. After creating a complete-case dataset with binary exposure, mediator and outcome, we build counterfactual copies of each observation, derive mediator weights from a logistic regression, and fit a weighted outcome model to obtain the natural direct effect, natural indirect effect, total effect and proportion mediated. We then fit an equivalent mediation model using <code>regmedint</code>, which computes the same estimands via parametric standardization and delta–method standard errors. Both approaches yield broadly consistent conclusions, with similar total and mediated effects, while small differences arise from the different estimating strategies and the evaluation of <code>regmedint</code> effects at the mean covariate profile. For clarity, all analyses here intentionally ignore the complex survey design to focus on illustrating mediation concepts.</p>
13941399
<div class="callout callout-style-default callout-tip callout-titled">
13951400
<div class="callout-header d-flex align-content-center">
13961401
<div class="callout-icon-container">

0 commit comments

Comments
 (0)