/ ifelse(exposure == 0, 1 - .fitted, .fitted))
  
  # fit correctly bootsrapped ipw model
  lm(outcome ~ exposure, data = .df, weights = wts) %&gt;% 
    tidy()
}
```
]

---

&lt;span class = "num"&gt;1&lt;/span&gt; &lt;h3&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;  &amp;nbsp; Create a function to run your analysis once on a sample of your data&lt;/h3&gt; 

.small[

```r
fit_ipw &lt;- function(split, ...) { 
  .df &lt;- analysis(split) 
  
  # fit propensity score model
  propensity_model &lt;- glm(
    exposure 