{"id":40362436,"url":"https://github.com/nt-williams/crumble","last_synced_at":"2026-01-20T10:31:37.824Z","repository":{"id":246434460,"uuid":"804618777","full_name":"nt-williams/crumble","owner":"nt-williams","description":"General targeted machine learning for modern causal mediation analysis","archived":false,"fork":false,"pushed_at":"2025-12-18T00:39:34.000Z","size":122,"stargazers_count":12,"open_issues_count":5,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-12-21T10:59:38.333Z","etag":null,"topics":["causal-inference","machine-learning","mediation"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nt-williams.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-22T23:58:34.000Z","updated_at":"2025-12-18T00:39:38.000Z","dependencies_parsed_at":"2024-08-05T01:56:27.387Z","dependency_job_id":"0b8be78f-a6d8-413d-8068-9d72ee6595e5","html_url":"https://github.com/nt-williams/crumble","commit_stats":null,"previous_names":["nt-williams/crumble"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nt-williams/crumble","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nt-williams%2Fcrumble","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nt-williams%2Fcrumble/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nt-williams%2Fcrumble/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nt-williams%2Fcrumble/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nt-williams","download_url":"https://codeload.github.com/nt-williams/crumble/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nt-williams%2Fcrumble/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28601815,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T09:39:28.479Z","status":"ssl_error","status_checked_at":"2026-01-20T09:38:10.511Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["causal-inference","machine-learning","mediation"],"created_at":"2026-01-20T10:31:37.761Z","updated_at":"2026-01-20T10:31:37.814Z","avatar_url":"https://github.com/nt-williams.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\nbibliography: inst/references.bib\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n\u003e crumble (verb): break or fall apart into small fragments\n\n# crumble\n\n\u003c!-- badges: start --\u003e\n\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) [![CRAN status](https://www.r-pkg.org/badges/version/crumble)](https://CRAN.R-project.org/package=crumble) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n\n\u003c!-- badges: end --\u003e\n\n*crumble* implements a modern, unified estimation strategy [@liu2024general] for common mediation estimands: natural effects [@pearl2022], organic effects [@lok2015], interventional effects [@vansteelandt2017], recanting twins [@vo2024], in causal inference in combination with modified treatment policies. It makes use of recent advancements in \"Riesz-learning\" to estimate a set of required nuisance parameters using deep learning. The result is a software package that is capable of estimating mediation effects with binary, categorical, continuous, or multivariate exposures with high-dimensional mediators and mediator-outcome confounders using machine learning.\n\nThis work was supported by the National Institute on Drug Abuse [R00DA042127].\n\n### Installation\n\n```{r eval=FALSE}\nremotes::install_github(\"nt-williams/crumble\")\n```\n\n### Features\n\n| Feature                   | Status  |\n|---------------------------|:-------:|\n| Recanting twins           |    ✓    |\n| Natural effects           |    ✓    |\n| Organic effects           |    ✓    |\n| Interventional effects    |    ✓    |\n| Modified treatment Policy |    ✓    |\n| Static intervention       |    ✓    |\n| Dynamic intervention      |    ✓    |\n| Continuous treatment      |    ✓    |\n| Binary treatment          |    ✓    |\n| Categorical treatment     |    ✓    |\n| Multivariate treatment    |    ✓    |\n| Missingness in treatment  |         |\n| Continuous outcome        |    ✓    |\n| Binary outcome            |    ✓    |\n| Censored outcome          |    ✓    |\n| Survey weights            | Planned |\n| Super learner             |    ✓    |\n| Clustered data            | Planned |\n| Parallel processing       |    ✓    |\n| GPU support               |    ✓    |\n| Progress bars             |    ✓    |\n\n### Example(s)\n\n```{r eval=FALSE}\nlibrary(crumble)\nlibrary(mlr3extralearners)\n\ndata(weight_behavior, package = \"mma\")\n\nweight_behavior \u003c- na.omit(weight_behavior)\n\nset.seed(2345)\n```\n\n##### Recanting twins\n\n```{r eval=FALSE}\ncrumble(\n\tdata = weight_behavior,\n\ttrt = \"sports\", \n\toutcome = \"bmi\",\n\tcovar = c(\"age\", \"sex\", \"tvhours\"),\n\tmediators = c(\"exercises\", \"overweigh\"),\n\tmoc = \"snack\",\n\td0 = \\(data, trt) factor(rep(1, nrow(data)), levels = c(\"1\", \"2\")), \n\td1 = \\(data, trt) factor(rep(2, nrow(data)), levels = c(\"1\", \"2\")), \n\teffect = \"RT\",\n\tlearners = c(\"mean\", \"glm\", \"earth\", \"ranger\"), \n\tnn_module = sequential_module(),\n\tcontrol = crumble_control(crossfit_folds = 1L, epochs = 20L)\n)\n#\u003e ✔ Permuting Z-prime variables... 1/1 tasks [2.5s]\n#\u003e ✔ Fitting outcome regressions... 1/1 folds [25.6s]             \n#\u003e ✔ Computing alpha n density ratios... 1/1 folds [39.7s]        \n#\u003e ✔ Computing alpha r density ratios... 1/1 folds [41.6s]        \n#\u003e \n#\u003e ══ Results `crumble()` ═════════════════════════════════════════\n#\u003e \n#\u003e ── E[Y(d1) - Y(d0)] \n#\u003e       Estimate: 1.0537\n#\u003e     Std. error: 0.3009\n#\u003e         95% CI: (0.4639, 1.6435)\n#\u003e \n#\u003e ── Path: A -\u003e Y \n#\u003e       Estimate: 0.0366\n#\u003e     Std. error: 0.1842\n#\u003e         95% CI: (-0.3245, 0.3976)\n#\u003e \n#\u003e ── Path: A -\u003e Z -\u003e Y \n#\u003e       Estimate: -0.0202\n#\u003e     Std. error: 0.0238\n#\u003e         95% CI: (-0.0668, 0.0264)\n#\u003e \n#\u003e ── Path: A -\u003e Z -\u003e M -\u003e Y \n#\u003e       Estimate: -6e-04\n#\u003e     Std. error: 0.0099\n#\u003e         95% CI: (-0.02, 0.0189)\n#\u003e \n#\u003e ── Path: A -\u003e M -\u003e Y \n#\u003e       Estimate: 1.0506\n#\u003e     Std. error: 0.2162\n#\u003e         95% CI: (0.627, 1.4743)\n#\u003e \n#\u003e ── Intermediate Confounding \n#\u003e       Estimate: -0.0127\n#\u003e     Std. error: 0.0261\n#\u003e         95% CI: (-0.0638, 0.0384)\n```\n\n##### Natural effects\n\n```{r eval=FALSE}\ncrumble(\n\tdata = weight_behavior,\n\ttrt = \"sports\", \n\toutcome = \"bmi\",\n\tcovar = c(\"age\", \"sex\", \"tvhours\"),\n\tmediators = c(\"exercises\", \"overweigh\"),\n\td0 = \\(data, trt) factor(rep(1, nrow(data)), levels = c(\"1\", \"2\")), \n\td1 = \\(data, trt) factor(rep(2, nrow(data)), levels = c(\"1\", \"2\")), \n\teffect = \"N\",\n\tlearners = c(\"mean\", \"glm\", \"earth\", \"ranger\"), \n\tnn_module = sequential_module(),\n\tcontrol = crumble_control(crossfit_folds = 1L, epochs = 20L)\n)\n#\u003e ✔ Fitting outcome regressions... 1/1 folds [10.6s]             \n#\u003e ✔ Computing alpha n density ratios... 1/1 folds [53.1s]        \n#\u003e \n#\u003e ══ Results `crumble()` ═════════════════════════════════════════\n#\u003e \n#\u003e ── E[Y(d1) - Y(d0)] \n#\u003e       Estimate: 1.0289\n#\u003e     Std. error: 0.28\n#\u003e         95% CI: (0.48, 1.5777)\n#\u003e \n#\u003e ── Natural Direct Effect \n#\u003e       Estimate: 0.0165\n#\u003e     Std. error: 0.1717\n#\u003e         95% CI: (-0.3201, 0.3531)\n#\u003e \n#\u003e ── Natural Indirect Effect \n#\u003e       Estimate: 1.0124\n#\u003e     Std. error: 0.2178\n#\u003e         95% CI: (0.5856, 1.4393)\n```\n\n##### Organic effects\n\n```{r eval=FALSE}\ncrumble(\n\tdata = weight_behavior,\n\ttrt = \"sports\", \n\toutcome = \"bmi\",\n\tcovar = c(\"age\", \"sex\", \"tvhours\"),\n\tmediators = c(\"exercises\", \"overweigh\"),\n\td0 = \\(data, trt) factor(rep(1, nrow(data)), levels = c(\"1\", \"2\")), \n\td1 = \\(data, trt) factor(rep(2, nrow(data)), levels = c(\"1\", \"2\")), \n\teffect = \"O\",\n\tlearners = c(\"mean\", \"glm\", \"earth\", \"ranger\"), \n\tnn_module = sequential_module(),\n\tcontrol = crumble_control(crossfit_folds = 1L, epochs = 20L)\n)\n#\u003e ✔ Fitting outcome regressions... 1/1 folds [10.7s]             \n#\u003e ✔ Computing alpha n density ratios... 1/1 folds [48.2s]        \n#\u003e \n#\u003e ══ Results `crumble()` ═════════════════════════════════════════\n#\u003e \n#\u003e ── Organic Direct Effect \n#\u003e       Estimate: 0.011\n#\u003e     Std. error: 0.1772\n#\u003e         95% CI: (-0.3364, 0.3584)\n#\u003e \n#\u003e ── Organic Indirect Effect \n#\u003e       Estimate: 1.0278\n#\u003e     Std. error: 0.2231\n#\u003e         95% CI: (0.5904, 1.4651)#\u003e \n```\n\n##### Randomized interventional effects\n\n```{r eval=FALSE}\ncrumble(\n\tdata = weight_behavior,\n\ttrt = \"sports\", \n\toutcome = \"bmi\",\n\tcovar = c(\"age\", \"sex\", \"tvhours\"),\n\tmediators = c(\"exercises\", \"overweigh\"),\n\tmoc = \"snack\",\n\td0 = \\(data, trt) factor(rep(1, nrow(data)), levels = c(\"1\", \"2\")), \n\td1 = \\(data, trt) factor(rep(2, nrow(data)), levels = c(\"1\", \"2\")), \n\teffect = \"RI\",\n\tlearners = c(\"mean\", \"glm\", \"earth\", \"ranger\"), \n\tnn_module = sequential_module(),\n\tcontrol = crumble_control(crossfit_folds = 1L, epochs = 20L)\n)\n#\u003e ✔ Permuting Z-prime variables... 1/1 tasks [2s]\n#\u003e ✔ Fitting outcome regressions... 1/1 folds [14.2s]             \n#\u003e ✔ Computing alpha r density ratios... 1/1 folds [1m 23.2s]     \n#\u003e \n#\u003e ══ Results `crumble()` ═════════════════════════════════════════\n#\u003e \n#\u003e ── Randomized Direct Effect \n#\u003e       Estimate: 0.0162\n#\u003e     Std. error: 0.1774\n#\u003e         95% CI: (-0.3315, 0.364)\n#\u003e \n#\u003e ── Randomized Indirect Effect \n#\u003e       Estimate: 1.0304\n#\u003e     Std. error: 0.2296\n#\u003e         95% CI: (0.5805, 0.4662)\n```\n\n#### References\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnt-williams%2Fcrumble","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnt-williams%2Fcrumble","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnt-williams%2Fcrumble/lists"}