{"id":1753,"date":"2024-09-02T10:16:54","date_gmt":"2024-09-02T08:16:54","guid":{"rendered":"https:\/\/lorentzen.ch\/?p=1753"},"modified":"2024-09-02T12:17:15","modified_gmt":"2024-09-02T10:17:15","slug":"explaining-a-causal-forest","status":"publish","type":"post","link":"https:\/\/lorentzen.ch\/index.php\/2024\/09\/02\/explaining-a-causal-forest\/","title":{"rendered":"Explaining a Causal Forest"},"content":{"rendered":"\n<p>We use a causal forest [1] to model the treatment effect in a randomized controlled clinical trial. Then, we explain this black-box model with usual explainability tools. These will reveal segments where the treatment works better or worse, just like a forest plot, but multivariately.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Data<\/h2>\n\n\n\n<p>For illustration, we use patient-level data of a 2-arm trial of rectal indomethacin against placebo to prevent post-ERCP pancreatitis (602 patients) [2]. The dataset is available in the package {medicaldata}.<\/p>\n\n\n\n<p>The data is in fantastic shape, so we don\u2019t need to spend a lot of time with data preparation.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>We integer encode factors.<\/li>\n\n\n\n<li>We select meaningful features, basically those shown in the forest plot of [2] (Figure 4) without low-information features and without hospital.<\/li>\n<\/ol>\n\n\n\n<p>The marginal estimate of the treatment effect is -0.078, i.e., indomethacin reduces the probability of post-ERCP pancreatitis by 7.8 percentage points. Our aim is to develop and interpret a model to see if this value is associated with certain covariates.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;r&quot;,&quot;mime&quot;:&quot;text\/x-rsrc&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;R&quot;,&quot;language&quot;:&quot;R&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;r&quot;}\">library(medicaldata)\nsuppressPackageStartupMessages(library(dplyr))\nlibrary(grf)          #  causal_forest()\nlibrary(ggplot2)\nlibrary(patchwork)    #  Combine ggplots\nlibrary(hstats)       #  Friedman's H, PDP\nlibrary(kernelshap)   #  General SHAP\nlibrary(shapviz)      #  SHAP plots\n\nW &lt;- as.integer(indo_rct$rx) - 1L      # 0=placebo, 1=treatment\ntable(W)\n#   0   1 \n# 307 295\n\nY &lt;- as.numeric(indo_rct$outcome) - 1  # Y=1: post-ERCP pancreatitis (bad)\nmean(Y)  # 0.1312292\n\nmean(Y[W == 1]) - mean(Y[W == 0])      # -0.07785568\n\nxvars &lt;- c(\n  &quot;age&quot;,         # Age in years\n  &quot;male&quot;,        # Male (1=yes)\n  &quot;pep&quot;,         # Previous post-ERCP pancreatitis (1=yes)\n  &quot;recpanc&quot;,     # History of recurrent Pancreatitis (1=yes)\n  &quot;type&quot;,        # Sphincter of oddi dysfunction type\/level (0=no, to 3=type 3)\n  &quot;difcan&quot;,      # Cannulation of the papilla was difficult (1=yes)\n  &quot;psphinc&quot;,     # Pancreatic sphincterotomy performed (1=yes)\n  &quot;bsphinc&quot;,     # Biliary sphincterotomy performed (1=yes)\n  &quot;pdstent&quot;,     # Pancreatic stent (1=yes)\n  &quot;train&quot;        # Trainee involved in stenting (1=yes)\n)\n\nX &lt;- indo_rct |&gt;\n  mutate_if(is.factor, function(v) as.integer(v) - 1L) |&gt; \n  rename(male = gender) |&gt; \n  select_at(xvars)\n\nhead(X)\n            \n# age  male   pep recpanc  type difcan psphinc bsphinc pdstent train\n#  26     0     0       1     1      0       0       0       0     1\n#  24     1     1       0     0      0       0       1       0     0\n#  57     0     0       0     2      0       0       0       0     0\n#  29     0     0       0     1      0       0       1       1     1\n#  38     0     1       0     1      0       1       1       1     1\n#  59     0     0       0     1      1       0       1       1     0\n            \nsummary(X)\n            \n#     age             male             pep            recpanc     \n# Min.   :19.00   Min.   :0.0000   Min.   :0.0000   Min.   :0.000  \n# 1st Qu.:35.00   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.000  \n# Median :45.00   Median :0.0000   Median :0.0000   Median :0.000  \n# Mean   :45.27   Mean   :0.2093   Mean   :0.1595   Mean   :0.299  \n# 3rd Qu.:54.00   3rd Qu.:0.0000   3rd Qu.:0.0000   3rd Qu.:1.000  \n# Max.   :90.00   Max.   :1.0000   Max.   :1.0000   Max.   :1.000  \n#      type           difcan          psphinc          bsphinc      \n# Min.   :0.000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  \n# 1st Qu.:1.000   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.0000  \n# Median :2.000   Median :0.0000   Median :1.0000   Median :1.0000  \n# Mean   :1.743   Mean   :0.2608   Mean   :0.5698   Mean   :0.5714  \n# 3rd Qu.:2.000   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000  \n# Max.   :3.000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  \n#    pdstent           train       \n# Min.   :0.0000   Min.   :0.0000  \n# 1st Qu.:1.0000   1st Qu.:0.0000  \n# Median :1.0000   Median :0.0000  \n# Mean   :0.8239   Mean   :0.4701  \n# 3rd Qu.:1.0000   3rd Qu.:1.0000  \n# Max.   :1.0000   Max.   :1.0000  <\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">The model<\/h2>\n\n\n\n<p>We use the {grf} package to fit a&nbsp;<em>causal forest<\/em>&nbsp;[1], a tree-ensemble trying to estimate conditional average treatment effects (CATE) E[Y(1) &#8211; Y(0) | X = x]. As such, it can be used to study treatment effect&nbsp;<em>inhomogeneity<\/em>.<\/p>\n\n\n\n<p>In contrast to a typical random forest:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><em>Honest trees<\/em>&nbsp;are grown: Within trees, part of the data is used for splitting, and the other part for calculating the node values. This anti-overfitting is implemented for all random forests in {grf}.<\/li>\n\n\n\n<li>Splits are selected to produce child nodes with maximally different treatment effects (under some additional constraints).<\/li>\n<\/ul>\n\n\n\n<p><em>Note:<\/em>&nbsp;With about 13%, the complication rate is relatively low. Thus, the treatment effect (measured on absolute scale) can become small for certain segments simply because the complication rate is close to 0. Ideally, we could model&nbsp;<em>relative<\/em>&nbsp;treatment effects or odds ratios, but I have not found this option in {grf} so far.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;r&quot;,&quot;mime&quot;:&quot;text\/x-rsrc&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;R&quot;,&quot;language&quot;:&quot;R&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;r&quot;}\">fit &lt;- causal_forest(\n  X = X,\n  Y = Y,\n  W = W,\n  num.trees = 1000,\n  mtry = 4,\n  sample.fraction = 0.7,\n  seed = 1,\n  ci.group.size = 1,\n)<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Explain the model with \u201cclassic\u201d techniques<\/h2>\n\n\n\n<p>After looking at tree split importance, we study the effects via partial dependence plots and Friedman\u2019s H. These only require a&nbsp;<code>predict()<\/code>&nbsp;function and a reference dataset.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;r&quot;,&quot;mime&quot;:&quot;text\/x-rsrc&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;R&quot;,&quot;language&quot;:&quot;R&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;r&quot;}\">imp &lt;- sort(setNames(variable_importance(fit), xvars))\npar(mai = c(0.7, 2, 0.2, 0.2))\nbarplot(imp, horiz = TRUE, las = 1, col = &quot;orange&quot;)\n\npred_fun &lt;- function(object, newdata, ...) {\n  predict(object, newdata, ...)$predictions\n}\n\npdps &lt;- lapply(xvars, function(v) plot(partial_dep(fit, v, X = X, pred_fun = pred_fun)))\nwrap_plots(pdps, guides = &quot;collect&quot;, ncol = 3) &amp;\n  ylim(c(-0.11, -0.06)) &amp;\n  ylab(&quot;Treatment effect&quot;)\n               \nH &lt;- hstats(fit, X = X, pred_fun = pred_fun, verbose = FALSE)\nplot(H)\n\npartial_dep(fit, v = &quot;age&quot;, X = X, BY = &quot;bsphinc&quot;, pred_fun = pred_fun) |&gt; \n  plot()<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Variable importance<\/h3>\n\n\n\n<p>Variable importance of the causal forest can be measured by the relative counts each feature had been used to split on (in the first 4 levels). The most important variable is&nbsp;<code>age<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"853\" src=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-5-1024x853.png\" alt=\"\" class=\"wp-image-1760\" srcset=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-5-1024x853.png 1024w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-5-300x250.png 300w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-5-768x640.png 768w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-5.png 1152w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Main effects<\/h3>\n\n\n\n<p>To study the main effects&nbsp;<em>on the CATE<\/em>, we consider partial dependence plots (PDP). Such plot shows how the average prediction depends on the values of a feature, keeping all other feature values constant (can be unnatural.)<\/p>\n\n\n\n<p>We can see that the treatment effect is strongest for persons up to age 35, then reduces until 45. For older patients, the effect increases again.<\/p>\n\n\n\n<p>Remember: Negative values mean a stronger (positive) treatment effect.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"896\" height=\"1024\" src=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-6-896x1024.png\" alt=\"\" class=\"wp-image-1761\" srcset=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-6-896x1024.png 896w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-6-263x300.png 263w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-6-768x878.png 768w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-6.png 1344w\" sizes=\"auto, (max-width: 896px) 100vw, 896px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Interaction strength<\/h3>\n\n\n\n<p>Between what covariates are there strong interactions?<\/p>\n\n\n\n<p>A model agnostic way to assess pairwise interaction strength is Friedman\u2019s H statistic [3]. It measures the error when approximating the two-dimensional partial dependence function of the two features by their univariate partial dependence functions. A value of zero means there is no interaction. A value of\u00a0\u03b1\u00a0means that about\u00a0100\u03b1%\u00a0of the joint effect (variability) comes from the interaction.<\/p>\n\n\n\n<p>This measure is shown on the&nbsp;<em>right<\/em>&nbsp;hand side of the plot. More than 15% of the joint effect variability of age and biliary sphincterotomy (<code>bsphinc<\/code>) comes from their interaction.<\/p>\n\n\n\n<p>Typically, pairwise H-statistics are calculated only for the most important variables or those with high&nbsp;<em>overall<\/em>&nbsp;interaction strength. Overall interaction strength (left hand side of the plot) can be measured by a version of Friedman\u2019s H. It shows how much of the prediction variability comes from interactions with that feature.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"853\" src=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-7-1024x853.png\" alt=\"\" class=\"wp-image-1762\" srcset=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-7-1024x853.png 1024w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-7-300x250.png 300w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-7-768x640.png 768w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-7.png 1152w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Visualize strong interaction<\/h3>\n\n\n\n<p>Interactions can be visualized, e.g., by a stratified PDP. We can see that the treatment effect is associated with age mainly for persons with biliary sphincterotomy.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"853\" src=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-4-1024x853.png\" alt=\"\" class=\"wp-image-1759\" srcset=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-4-1024x853.png 1024w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-4-300x250.png 300w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-4-768x640.png 768w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-4.png 1152w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">SHAP Analysis<\/h2>\n\n\n\n<p>A \u201cmodern\u201d way to explain the model is based on SHAP [4]. It decomposes the (centered) predictions into additive contributions of the covariates.<\/p>\n\n\n\n<p>Because there is no TreeSHAP shipped with {grf}, we use the much slower Kernel SHAP algorithm implemented in {kernelshap} that works for any model.<\/p>\n\n\n\n<p>First, we explain the prediction of a single data row, then we decompose many predictions. These decompositions can be analysed by simple descriptive plots to gain insights about the model as a whole.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;r&quot;,&quot;mime&quot;:&quot;text\/x-rsrc&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;R&quot;,&quot;language&quot;:&quot;R&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;r&quot;}\"># Explaining one CATE\nkernelshap(fit, X = X[1, ], bg_X = X, pred_fun = pred_fun) |&gt; \n  shapviz() |&gt; \n  sv_waterfall() +\n  xlab(&quot;Prediction&quot;)\n\n# Explaining all CATEs globally\nsystem.time(  # 13 min\n  ks &lt;- kernelshap(fit, X = X, pred_fun = pred_fun)  \n)\nshap_values &lt;- shapviz(ks)\n\nsv_importance(shap_values)\nsv_importance(shap_values, kind = &quot;bee&quot;)\nsv_dependence(shap_values, v = xvars) +\n  plot_layout(ncol = 3) &amp;\n  ylim(c(-0.04, 0.03))<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Explain one CATE<\/h3>\n\n\n\n<p>Explaining the CATE corresponding to the feature values of the first patient via waterfall plot.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"853\" src=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-3-1024x853.png\" alt=\"\" class=\"wp-image-1757\" srcset=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-3-1024x853.png 1024w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-3-300x250.png 300w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-3-768x640.png 768w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-3.png 1152w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">SHAP importance plot<\/h3>\n\n\n\n<p>The bars show average absolute SHAP values. For instance, we can say that biliary sphincterotomy impacts the treatment effect on average by more than +- 0.01 (but we don\u2019t see&nbsp;<em>how<\/em>).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"853\" src=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-8-1024x853.png\" alt=\"\" class=\"wp-image-1763\" srcset=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-8-1024x853.png 1024w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-8-300x250.png 300w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-8-768x640.png 768w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-8.png 1152w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">SHAP summary plot<\/h3>\n\n\n\n<p>One-dimensional plot of SHAP values with scaled feature values on the color scale, sorted in the same order as the SHAP importance plot. Compared to the SHAP importance barplot, for instance, we can additionally see that biliary sphincterotomy&nbsp;<em>weakens<\/em>&nbsp;the treatment effect (positive SHAP value).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"853\" src=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-1-1024x853.png\" alt=\"\" class=\"wp-image-1755\" srcset=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-1-1024x853.png 1024w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-1-300x250.png 300w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-1-768x640.png 768w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-1.png 1152w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">SHAP dependence plots<\/h3>\n\n\n\n<p>Scatterplots of SHAP values against corresponding feature values. Vertical scatter (at given x value) indicates presence of interactions. A candidate of an interacting feature is selected on the color scale. For instance, we see a similar pattern in the age effect on the treatment effect as in the partial dependence plot. Thanks to the color scale, we also see that the age effect depends on biliary sphincterotomy.<\/p>\n\n\n\n<p>Remember that SHAP values are on centered prediction scale. Still, a positive value means a weaker treatment effect.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"922\" height=\"1024\" src=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-922x1024.png\" alt=\"\" class=\"wp-image-1754\" style=\"width:825px;height:auto\" srcset=\"https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-922x1024.png 922w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-270x300.png 270w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-768x853.png 768w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image-1382x1536.png 1382w, https:\/\/lorentzen.ch\/wp-content\/uploads\/2024\/09\/image.png 1728w\" sizes=\"auto, (max-width: 922px) 100vw, 922px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Wrap-up<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>{grf} is a fantastic package. You can expect more on it here.<\/li>\n\n\n\n<li>Causal forests are an interesting way to directly model treatment effects.<\/li>\n\n\n\n<li>Standard explainability methods can be used to explain the black-box.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">References<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Athey, Susan, Julie Tibshirani, and Stefan Wager. \u201cGeneralized Random Forests\u201d. Annals of Statistics, 47(2), 2019.<\/li>\n\n\n\n<li>Elmunzer BJ et al.&nbsp;A randomized trial of rectal indomethacin to prevent post-ERCP pancreatitis. N Engl J Med. 2012 Apr 12;366(15):1414-22. doi: 10.1056\/NEJMoa1111103.<\/li>\n\n\n\n<li>Friedman, Jerome H., and Bogdan E. Popescu. Predictive Learning via Rule Ensembles. The Annals of Applied Statistics 2, no. 3 (2008): 916-54.<\/li>\n\n\n\n<li>Scott M. Lundberg and Su-In Lee. A Unified Approach to Interpreting Model Predictions. Advances in Neural Information Processing Systems 30 (2017).<\/li>\n<\/ol>\n\n\n\n<p><a href=\"https:\/\/github.com\/lorentzenchr\/notebooks\/blob\/master\/blogposts\/2024-09-02%20causal_rf.R\">The full R notebook<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Causal forests model treatment effect inhomogeneity. We use XAI tools to interpret such model to see which features are associated with the treatment effect.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,17,9],"tags":[5],"class_list":["post-1753","post","type-post","status-publish","format-standard","hentry","category-machine-learning","category-programming","category-statistics","tag-r"],"featured_image_src":null,"author_info":{"display_name":"Michael Mayer","author_link":"https:\/\/lorentzen.ch\/index.php\/author\/michael\/"},"_links":{"self":[{"href":"https:\/\/lorentzen.ch\/index.php\/wp-json\/wp\/v2\/posts\/1753","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lorentzen.ch\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lorentzen.ch\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lorentzen.ch\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lorentzen.ch\/index.php\/wp-json\/wp\/v2\/comments?post=1753"}],"version-history":[{"count":5,"href":"https:\/\/lorentzen.ch\/index.php\/wp-json\/wp\/v2\/posts\/1753\/revisions"}],"predecessor-version":[{"id":1769,"href":"https:\/\/lorentzen.ch\/index.php\/wp-json\/wp\/v2\/posts\/1753\/revisions\/1769"}],"wp:attachment":[{"href":"https:\/\/lorentzen.ch\/index.php\/wp-json\/wp\/v2\/media?parent=1753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lorentzen.ch\/index.php\/wp-json\/wp\/v2\/categories?post=1753"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lorentzen.ch\/index.php\/wp-json\/wp\/v2\/tags?post=1753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}