Getting Started with Crumble.jl
Crumble.jl targets mediation problems where direct and indirect effects may be estimated flexibly with machine learning.
This page keeps the examples lightweight for documentation purposes. The code is shown in the same structure you would use in real analyses.
Setup
Example: Binary Treatment and Binary Mediator
print(result)CrumbleResult
Effect type: N
Estimates:
Direct Effect 0.0008 (SE: 1.2327) [95% CI: -2.4153, 2.4169]
Average Treatment Effect -0.0004 (SE: 1.2338) [95% CI: -2.4187, 2.4179]
Indirect Effect -0.0012 (SE: 1.2336) [95% CI: -2.4191, 2.4168]Tidy Output
Crumble.tidy(result)3×6 DataFrame
| Row | estimand | estimate | std_error | conf_low | conf_high | p_value |
|---|---|---|---|---|---|---|
| String | Float64 | Float64 | Float64 | Float64 | Float64 | |
| 1 | direct | 0.000797718 | 1.23272 | -2.41533 | 2.41692 | 0.999484 |
| 2 | ate | -0.000383004 | 1.23382 | -2.41867 | 2.4179 | 0.999752 |
| 3 | indirect | -0.00118072 | 1.23365 | -2.41913 | 2.41676 | 0.999236 |
Use print(result) for the formatted summary and tidy(result) when you want a DataFrame for downstream reporting.