Skip to content

Commit 64c22ea

Browse files
clean up outcome model slides and use real code
1 parent fa0daba commit 64c22ea

9 files changed

+194
-36
lines changed

exercises/09-outcome-model-exercises.qmd

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,27 @@ Bootstrap this result 1000 times.
4545
set.seed(1234)
4646
4747
ipw_results <- ____(___, 1000, apparent = TRUE) |>
48-
mutate(results = map(splits, _____))
48+
mutate(boot_fits = map(splits, _____))
4949
```
5050

51+
Check out the distribution of estimates (**no need to change this code**)
52+
53+
```{r}
54+
#| eval: false
55+
ipw_results |>
56+
mutate(
57+
estimate = map_dbl(
58+
boot_fits,
59+
# pull the `estimate` for `qsmk` for each fit
60+
\(.fit) .fit |>
61+
filter(term == "qsmk") |>
62+
pull(estimate)
63+
)
64+
) |>
65+
ggplot(aes(estimate)) +
66+
geom_histogram(fill = "#D55E00FF", color = "white", alpha = 0.8) +
67+
theme_minimal()
68+
```
5169

5270
Calculate the confidence interval
5371

slides/raw/01-causal_modeling_whole_game.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ fit_ipw <- function(split, ...) {
511511
#| cache: true
512512
#| code-line-numbers: "|2-3"
513513
# fit ipw model to bootstrapped samples
514-
ipw_results <- bootstraps(nhefs_complete, 1000, apparent = TRUE) |>
514+
ipw_results <- bootstraps(nhefs_complete_uc, 1000, apparent = TRUE) |>
515515
mutate(results = map(splits, fit_ipw))
516516
```
517517

slides/raw/09-outcome-model.html

Lines changed: 95 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -427,49 +427,122 @@ <h2>Outcome Model</h2>
427427
<h2>1. Create a function to run your analysis once on a sample of your data</h2>
428428
<div class="small">
429429
<div class="cell" data-layout-align="center">
430-
<div class="sourceCode cell-code" id="cb2" data-code-line-numbers="|1-2|4-9|11-14|16-18"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1"></a>fit_ipw <span class="ot">&lt;-</span> <span class="cf">function</span>(split, ...) {</span>
430+
<div class="sourceCode cell-code" id="cb2" data-code-line-numbers="|1-2|5-13|16-18|21-22"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1"></a>fit_ipw <span class="ot">&lt;-</span> <span class="cf">function</span>(split, ...) {</span>
431431
<span id="cb2-2"><a href="#cb2-2"></a> .df <span class="ot">&lt;-</span> <span class="fu">analysis</span>(split)</span>
432432
<span id="cb2-3"><a href="#cb2-3"></a> </span>
433433
<span id="cb2-4"><a href="#cb2-4"></a> <span class="co"># fit propensity score model</span></span>
434434
<span id="cb2-5"><a href="#cb2-5"></a> propensity_model <span class="ot">&lt;-</span> <span class="fu">glm</span>(</span>
435-
<span id="cb2-6"><a href="#cb2-6"></a> exposure <span class="sc">~</span> confounder_1 <span class="sc">+</span> confounder_2 <span class="sc">+</span> ...</span>
436-
<span id="cb2-7"><a href="#cb2-7"></a> <span class="at">family =</span> <span class="fu">binomial</span>(), </span>
437-
<span id="cb2-8"><a href="#cb2-8"></a> <span class="at">data =</span> .df</span>
438-
<span id="cb2-9"><a href="#cb2-9"></a> )</span>
439-
<span id="cb2-10"><a href="#cb2-10"></a> </span>
440-
<span id="cb2-11"><a href="#cb2-11"></a> <span class="co"># calculate inverse probability weights</span></span>
441-
<span id="cb2-12"><a href="#cb2-12"></a> .df <span class="ot">&lt;-</span> propensity_model <span class="sc">|&gt;</span></span>
442-
<span id="cb2-13"><a href="#cb2-13"></a> <span class="fu">augment</span>(<span class="at">type.predict =</span> <span class="st">"response"</span>, <span class="at">data =</span> .df) <span class="sc">|&gt;</span></span>
443-
<span id="cb2-14"><a href="#cb2-14"></a> <span class="fu">mutate</span>(<span class="at">wts =</span> <span class="dv">1</span> <span class="sc">/</span> <span class="fu">ifelse</span>(exposure <span class="sc">==</span> <span class="dv">0</span>, <span class="dv">1</span> <span class="sc">-</span> .fitted, .fitted))</span>
444-
<span id="cb2-15"><a href="#cb2-15"></a> </span>
445-
<span id="cb2-16"><a href="#cb2-16"></a> <span class="co"># fit correctly bootsrapped ipw model</span></span>
446-
<span id="cb2-17"><a href="#cb2-17"></a> <span class="fu">lm</span>(outcome <span class="sc">~</span> exposure, <span class="at">data =</span> .df, <span class="at">weights =</span> wts) <span class="sc">|&gt;</span></span>
447-
<span id="cb2-18"><a href="#cb2-18"></a> <span class="fu">tidy</span>()</span>
448-
<span id="cb2-19"><a href="#cb2-19"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
435+
<span id="cb2-6"><a href="#cb2-6"></a> qsmk <span class="sc">~</span> sex <span class="sc">+</span> </span>
436+
<span id="cb2-7"><a href="#cb2-7"></a> race <span class="sc">+</span> age <span class="sc">+</span> <span class="fu">I</span>(age<span class="sc">^</span><span class="dv">2</span>) <span class="sc">+</span> education <span class="sc">+</span> </span>
437+
<span id="cb2-8"><a href="#cb2-8"></a> smokeintensity <span class="sc">+</span> <span class="fu">I</span>(smokeintensity<span class="sc">^</span><span class="dv">2</span>) <span class="sc">+</span> </span>
438+
<span id="cb2-9"><a href="#cb2-9"></a> smokeyrs <span class="sc">+</span> <span class="fu">I</span>(smokeyrs<span class="sc">^</span><span class="dv">2</span>) <span class="sc">+</span> exercise <span class="sc">+</span> active <span class="sc">+</span> </span>
439+
<span id="cb2-10"><a href="#cb2-10"></a> wt71 <span class="sc">+</span> <span class="fu">I</span>(wt71<span class="sc">^</span><span class="dv">2</span>), </span>
440+
<span id="cb2-11"><a href="#cb2-11"></a> <span class="at">family =</span> <span class="fu">binomial</span>(), </span>
441+
<span id="cb2-12"><a href="#cb2-12"></a> <span class="at">data =</span> .df</span>
442+
<span id="cb2-13"><a href="#cb2-13"></a> )</span>
443+
<span id="cb2-14"><a href="#cb2-14"></a> </span>
444+
<span id="cb2-15"><a href="#cb2-15"></a> <span class="co"># calculate inverse probability weights</span></span>
445+
<span id="cb2-16"><a href="#cb2-16"></a> .df <span class="ot">&lt;-</span> propensity_model <span class="sc">|&gt;</span></span>
446+
<span id="cb2-17"><a href="#cb2-17"></a> <span class="fu">augment</span>(<span class="at">type.predict =</span> <span class="st">"response"</span>, <span class="at">data =</span> .df) <span class="sc">|&gt;</span></span>
447+
<span id="cb2-18"><a href="#cb2-18"></a> <span class="fu">mutate</span>(<span class="at">wts =</span> <span class="fu">wt_ate</span>(.fitted, qsmk, <span class="at">exposure_type =</span> <span class="st">"binary"</span>))</span>
448+
<span id="cb2-19"><a href="#cb2-19"></a> </span>
449+
<span id="cb2-20"><a href="#cb2-20"></a> <span class="co"># fit correctly bootstrapped ipw model</span></span>
450+
<span id="cb2-21"><a href="#cb2-21"></a> <span class="fu">lm</span>(wt82_71 <span class="sc">~</span> qsmk, <span class="at">data =</span> .df, <span class="at">weights =</span> wts) <span class="sc">|&gt;</span></span>
451+
<span id="cb2-22"><a href="#cb2-22"></a> <span class="fu">tidy</span>()</span>
452+
<span id="cb2-23"><a href="#cb2-23"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
449453
</div>
450454
</div>
451455
</section>
452456
<section id="use-rsample-to-bootstrap-our-causal-effect" class="slide level2">
453457
<h2>2. Use {rsample} to bootstrap our causal effect</h2>
454458
<div class="cell" data-layout-align="center">
455-
<div class="sourceCode cell-code" id="cb3" data-code-line-numbers="|4|5"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1"></a><span class="fu">library</span>(rsample)</span>
459+
<div class="sourceCode cell-code" id="cb3" data-code-line-numbers="|4-8"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1"></a><span class="fu">library</span>(rsample)</span>
456460
<span id="cb3-2"><a href="#cb3-2"></a></span>
457461
<span id="cb3-3"><a href="#cb3-3"></a><span class="co"># fit ipw model to bootstrapped samples</span></span>
458-
<span id="cb3-4"><a href="#cb3-4"></a>ipw_results <span class="ot">&lt;-</span> <span class="fu">bootstraps</span>(df, <span class="dv">1000</span>, <span class="at">apparent =</span> <span class="cn">TRUE</span>) <span class="sc">|&gt;</span></span>
459-
<span id="cb3-5"><a href="#cb3-5"></a> <span class="fu">mutate</span>(<span class="at">results =</span> <span class="fu">map</span>(splits, fit_ipw)) </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
462+
<span id="cb3-4"><a href="#cb3-4"></a>bootstrapped_nhefs <span class="ot">&lt;-</span> <span class="fu">bootstraps</span>(</span>
463+
<span id="cb3-5"><a href="#cb3-5"></a> nhefs_complete_uc, </span>
464+
<span id="cb3-6"><a href="#cb3-6"></a> <span class="at">times =</span> <span class="dv">1000</span>, </span>
465+
<span id="cb3-7"><a href="#cb3-7"></a> <span class="at">apparent =</span> <span class="cn">TRUE</span></span>
466+
<span id="cb3-8"><a href="#cb3-8"></a>)</span>
467+
<span id="cb3-9"><a href="#cb3-9"></a></span>
468+
<span id="cb3-10"><a href="#cb3-10"></a>bootstrapped_nhefs</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
469+
</div>
470+
471+
</section>
472+
<section id="use-rsample-to-bootstrap-our-causal-effect-output" class="slide level2 output-location-slide"><h2>2. Use {rsample} to bootstrap our causal effect</h2><div class="cell output-location-slide" data-layout-align="center">
473+
<div class="cell-output cell-output-stdout">
474+
<pre><code># Bootstrap sampling with apparent sample
475+
# A tibble: 1,001 × 2
476+
splits id
477+
&lt;list&gt; &lt;chr&gt;
478+
1 &lt;split [1566/587]&gt; Bootstrap0001
479+
2 &lt;split [1566/555]&gt; Bootstrap0002
480+
3 &lt;split [1566/590]&gt; Bootstrap0003
481+
4 &lt;split [1566/599]&gt; Bootstrap0004
482+
5 &lt;split [1566/580]&gt; Bootstrap0005
483+
6 &lt;split [1566/574]&gt; Bootstrap0006
484+
7 &lt;split [1566/572]&gt; Bootstrap0007
485+
8 &lt;split [1566/569]&gt; Bootstrap0008
486+
9 &lt;split [1566/562]&gt; Bootstrap0009
487+
10 &lt;split [1566/581]&gt; Bootstrap0010
488+
# ℹ 991 more rows</code></pre>
489+
</div>
490+
</div></section><section id="use-rsample-to-bootstrap-our-causal-effect-1" class="slide level2">
491+
<h2>2. Use {rsample} to bootstrap our causal effect</h2>
492+
<div class="cell" data-layout-align="center">
493+
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1"></a><span class="fu">fit_ipw</span>(bootstrapped_nhefs<span class="sc">$</span>splits[[<span class="dv">1</span>]])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
494+
<div class="cell-output cell-output-stdout">
495+
<pre><code># A tibble: 2 × 5
496+
term estimate std.error statistic p.value
497+
&lt;chr&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt;
498+
1 (Intercept) 1.83 0.288 6.34 2.93e-10
499+
2 qsmk 3.44 0.407 8.44 7.05e-17</code></pre>
500+
</div>
460501
</div>
461502
</section>
503+
<section id="use-rsample-to-bootstrap-our-causal-effect-2" class="slide level2">
504+
<h2>2. Use {rsample} to bootstrap our causal effect</h2>
505+
<div class="cell" data-layout-align="center" data-hash="09-outcome-model_cache/revealjs/unnamed-chunk-6_c36ed8a218cdecbdeba4d712e8ce45bb">
506+
<div class="sourceCode cell-code" id="cb7" data-code-line-numbers="|2"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1"></a>ipw_results <span class="ot">&lt;-</span> bootstrapped_nhefs <span class="sc">|&gt;</span> </span>
507+
<span id="cb7-2"><a href="#cb7-2"></a> <span class="fu">mutate</span>(<span class="at">boot_fits =</span> <span class="fu">map</span>(splits, fit_ipw)) </span>
508+
<span id="cb7-3"><a href="#cb7-3"></a></span>
509+
<span id="cb7-4"><a href="#cb7-4"></a>ipw_results</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
510+
</div>
511+
512+
</section>
513+
<section id="use-rsample-to-bootstrap-our-causal-effect-2-output" class="slide level2 output-location-slide"><h2>2. Use {rsample} to bootstrap our causal effect</h2><div class="cell output-location-slide" data-layout-align="center" data-hash="09-outcome-model_cache/revealjs/unnamed-chunk-6_c36ed8a218cdecbdeba4d712e8ce45bb">
514+
<div class="cell-output cell-output-stdout">
515+
<pre><code># Bootstrap sampling with apparent sample
516+
# A tibble: 1,001 × 3
517+
splits id boot_fits
518+
&lt;list&gt; &lt;chr&gt; &lt;list&gt;
519+
1 &lt;split [1566/587]&gt; Bootstrap0001 &lt;tibble [2 × 5]&gt;
520+
2 &lt;split [1566/555]&gt; Bootstrap0002 &lt;tibble [2 × 5]&gt;
521+
3 &lt;split [1566/590]&gt; Bootstrap0003 &lt;tibble [2 × 5]&gt;
522+
4 &lt;split [1566/599]&gt; Bootstrap0004 &lt;tibble [2 × 5]&gt;
523+
5 &lt;split [1566/580]&gt; Bootstrap0005 &lt;tibble [2 × 5]&gt;
524+
6 &lt;split [1566/574]&gt; Bootstrap0006 &lt;tibble [2 × 5]&gt;
525+
7 &lt;split [1566/572]&gt; Bootstrap0007 &lt;tibble [2 × 5]&gt;
526+
8 &lt;split [1566/569]&gt; Bootstrap0008 &lt;tibble [2 × 5]&gt;
527+
9 &lt;split [1566/562]&gt; Bootstrap0009 &lt;tibble [2 × 5]&gt;
528+
10 &lt;split [1566/581]&gt; Bootstrap0010 &lt;tibble [2 × 5]&gt;
529+
# ℹ 991 more rows</code></pre>
530+
</div>
531+
</div></section><section id="use-rsample-to-bootstrap-our-causal-effect-3" class="slide level2">
532+
<h2>2. Use {rsample} to bootstrap our causal effect</h2>
533+
534+
<img data-src="09-outcome-model_files/figure-revealjs/unnamed-chunk-7-1.png" style="width:80.0%" class="r-stretch quarto-figure-center"></section>
462535
<section id="pull-out-the-causal-effect" class="slide level2">
463536
<h2>3. Pull out the causal effect</h2>
464537
<div class="cell" data-layout-align="center">
465-
<div class="sourceCode cell-code" id="cb4" data-code-line-numbers="|2"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1"></a><span class="co"># get t-statistic-based CIs</span></span>
466-
<span id="cb4-2"><a href="#cb4-2"></a>boot_estimate <span class="ot">&lt;-</span> <span class="fu">int_t</span>(ipw_results, results) <span class="sc">|&gt;</span> </span>
467-
<span id="cb4-3"><a href="#cb4-3"></a> <span class="fu">filter</span>(term <span class="sc">==</span> <span class="st">"exposure"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
538+
<div class="sourceCode cell-code" id="cb9" data-code-line-numbers="|2"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1"></a><span class="co"># get t-statistic-based CIs</span></span>
539+
<span id="cb9-2"><a href="#cb9-2"></a>boot_estimate <span class="ot">&lt;-</span> <span class="fu">int_t</span>(ipw_results, boot_fits) <span class="sc">|&gt;</span> </span>
540+
<span id="cb9-3"><a href="#cb9-3"></a> <span class="fu">filter</span>(term <span class="sc">==</span> <span class="st">"exposure"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
468541
</div>
469542
</section>
470543
<section id="your-turn" class="slide level2">
471544
<h2><em>Your Turn</em></h2>
472-
<p></p><div class="countdown" id="timer_0c369917" data-update-every="1" tabindex="0" style="right:0;bottom:0;"> <div class="countdown-controls"><button class="countdown-bump-down"></button><button class="countdown-bump-up">+</button></div> <code class="countdown-time"><span class="countdown-digits minutes">12</span><span class="countdown-digits colon">:</span><span class="countdown-digits seconds">00</span></code> </div><p></p>
545+
<p></p><div class="countdown" id="timer_ee2d5071" data-update-every="1" tabindex="0" style="right:0;bottom:0;"> <div class="countdown-controls"><button class="countdown-bump-down"></button><button class="countdown-bump-up">+</button></div> <code class="countdown-time"><span class="countdown-digits minutes">12</span><span class="countdown-digits colon">:</span><span class="countdown-digits seconds">00</span></code> </div><p></p>
473546
<h3 id="create-a-function-called-ipw_fit-that-fits-the-propensity-score-model-and-the-weighted-outcome-model-for-the-effect-between-extra_magic_morning-and-avg_spostmin">Create a function called <code>ipw_fit</code> that fits the propensity score model and the weighted outcome model for the effect between <code>extra_magic_morning</code> and <code>avg_spostmin</code></h3>
474547
<h3 id="using-the-bootstraps-and-int_t-functions-to-estimate-the-final-effect.">Using the <code>bootstraps()</code> and <code>int_t()</code> functions to estimate the final effect.</h3>
475548
<div class="footer footer-default">

slides/raw/09-outcome-model.qmd

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,27 @@ title: "Fitting the outcome model"
33
author: "Malcolm Barrett"
44
date: "2021-09-01 (updated: `r Sys.Date()`)"
55
format: "kakashi-revealjs"
6-
knitr:
7-
opts_chunk:
8-
eval: false
96
---
107

118
```{r}
9+
#| label: setup
1210
#| include: false
1311
options(
1412
tibble.max_extra_cols = 6,
1513
tibble.width = 60
1614
)
15+
library(tidyverse)
16+
library(broom)
17+
library(propensity)
18+
library(causaldata)
19+
nhefs_complete_uc <- nhefs_complete |>
20+
filter(censored == 0)
1721
```
1822

1923
## Outcome Model {.large}
2024

2125
```{r}
26+
#| eval: false
2227
library(broom)
2328
2429
lm(outcome ~ exposure, data = df, weights = wts) |>
@@ -42,24 +47,28 @@ lm(outcome ~ exposure, data = df, weights = wts) |>
4247
::: {.small}
4348

4449
```{r}
45-
#| code-line-numbers: "|1-2|4-9|11-14|16-18"
50+
#| code-line-numbers: "|1-2|5-13|16-18|21-22"
4651
fit_ipw <- function(split, ...) {
4752
.df <- analysis(split)
4853
4954
# fit propensity score model
5055
propensity_model <- glm(
51-
exposure ~ confounder_1 + confounder_2 + ...
56+
qsmk ~ sex +
57+
race + age + I(age^2) + education +
58+
smokeintensity + I(smokeintensity^2) +
59+
smokeyrs + I(smokeyrs^2) + exercise + active +
60+
wt71 + I(wt71^2),
5261
family = binomial(),
5362
data = .df
5463
)
5564
5665
# calculate inverse probability weights
5766
.df <- propensity_model |>
5867
augment(type.predict = "response", data = .df) |>
59-
mutate(wts = 1 / ifelse(exposure == 0, 1 - .fitted, .fitted))
68+
mutate(wts = wt_ate(.fitted, qsmk, exposure_type = "binary"))
6069
61-
# fit correctly bootsrapped ipw model
62-
lm(outcome ~ exposure, data = .df, weights = wts) |>
70+
# fit correctly bootstrapped ipw model
71+
lm(wt82_71 ~ qsmk, data = .df, weights = wts) |>
6372
tidy()
6473
}
6574
```
@@ -68,21 +77,65 @@ fit_ipw <- function(split, ...) {
6877
## 2. Use {rsample} to bootstrap our causal effect
6978

7079
```{r}
71-
#| code-line-numbers: "|4|5"
80+
#| code-line-numbers: "|4-8"
81+
#| output-location: slide
7282
library(rsample)
7383
7484
# fit ipw model to bootstrapped samples
75-
ipw_results <- bootstraps(df, 1000, apparent = TRUE) |>
76-
mutate(results = map(splits, fit_ipw))
85+
bootstrapped_nhefs <- bootstraps(
86+
nhefs_complete_uc,
87+
times = 1000,
88+
apparent = TRUE
89+
)
90+
91+
bootstrapped_nhefs
92+
```
93+
94+
## 2. Use {rsample} to bootstrap our causal effect
95+
96+
```{r}
97+
fit_ipw(bootstrapped_nhefs$splits[[1]])
98+
```
99+
100+
## 2. Use {rsample} to bootstrap our causal effect
101+
102+
```{r}
103+
#| cache: true
104+
#| output-location: slide
105+
#| code-line-numbers: "|2"
106+
ipw_results <- bootstrapped_nhefs |>
107+
mutate(boot_fits = map(splits, fit_ipw))
108+
109+
ipw_results
77110
```
78111

112+
## 2. Use {rsample} to bootstrap our causal effect
113+
114+
```{r}
115+
#| echo: false
116+
ipw_results |>
117+
mutate(
118+
estimate = map_dbl(
119+
boot_fits,
120+
# pull the `estimate` for `qsmk` for each fit
121+
\(.fit) .fit |>
122+
filter(term == "qsmk") |>
123+
pull(estimate)
124+
)
125+
) |>
126+
ggplot(aes(estimate)) +
127+
geom_histogram(fill = "#D55E00FF", color = "white", alpha = 0.8) +
128+
theme_minimal()
129+
```
130+
131+
79132
## 3. Pull out the causal effect
80133

81134
```{r}
82135
#| code-line-numbers: "|2"
83136
#| eval: false
84137
# get t-statistic-based CIs
85-
boot_estimate <- int_t(ipw_results, results) |>
138+
boot_estimate <- int_t(ipw_results, boot_fits) |>
86139
filter(term == "exposure")
87140
```
88141

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
tidyverse
2+
ggplot2
3+
tibble
4+
tidyr
5+
readr
6+
purrr
7+
dplyr
8+
stringr
9+
forcats
10+
lubridate
11+
broom
12+
propensity
13+
causaldata
14+
rsample
3.12 KB
Binary file not shown.
84.4 MB
Binary file not shown.
150 Bytes
Binary file not shown.
67 KB
Loading

0 commit comments

Comments
 (0)