Typical models estimating treatment effects assume that the treatment effect is the same for all individuals. Model-based recursive partitioning allows to relax this assumption and to estimate stratified treatment effects (model-based trees) or even personalised treatment effects (model-based forests). With model-based trees one can compute treatment effects for different strata of individuals. The strata are found in a data-driven fashion and depend on characteristics of the individuals. Model-based random forests allow for a similarity estimation between individuals in terms of model parameters (e.g. intercept and treatment effect). The similarity measure can then be used to estimate personalised models. The R package

Studies in various fields randomly assign individuals to one of two groups with different exposure and then measure a response. For example, in clinical trials patients are assigned to one of two treatment groups where usually one treatment group receives a new treatment or drug and the other treatment group receives the standard of care or a placebo. Other examples are in A-B testing in marketing studies or any other two group comparisons such as the mathematics exam discussed below, where students were divided into different exam groups and received slightly different exam tasks. In the following we will refer to the two groups as

Treatment effect estimation is often done using simple models with the binary treatment indicator as only covariate. In the example of a clinical trial the treatment indicator would be 1 if the patient receives the new treatment and 0 if the patient receives standard of care. In R such a simple model can be estimated as follows:

with

For cases where the assumption that all individuals have the same intercept and treatment effect is too strict the R package

Note that

Again here the potential effect-modifying variables are taken by default as all variables not given in the model formula and can be defined using the

In the following we will present an example application for model-based trees and personalised models. For this we need to load the package and – to ensure reproducibility – set a random seed. Also for visualisations we need packages

To investigate the correlation between exam group and exam performance, we compute a simple linear model regressing the percentage points of correct answers on the exam group.

The estimates and confidence intervals of this model can be computed via

The model can be visualised by plotting the estimated densities (see Figure

Density estimates of base model for the Mathematics Exam data.

Both the estimates and confidence intervals and the density curves suggest that there is almost no difference between the two groups. But does this really hold for all types of students?

A tree based on this model can be computed and visualised in only two lines of code:

We restrict the depth of the tree to two (

The tree (see Figure

Personalised model tree for the Mathematics Exam datam.

Estimating personalised models is almost as simple as the stratified models:

Dependence plots with the group effect (treatment effect) on the y-axis and the student characteristics on the x-axis are a good way of visualising the personalised models and for getting knowledge about the interactions between student characteristics and the exam group. Note that the plot is related to but not the same as the classical partial dependence plot [

Dependence plot for percentage of tests successfully solved.

For categorical variables such as the number of previous attempts to pass the exam (

Dependence plots for the number of previous attempts and gender.

With the tools provided by the

The R package

The basis for these functionalities is provided by the

The

All packages on CRAN undergo standard checks for compatibility with the R package ecosystem. The R package contains examples and tests. These were run and checked on Linux 86_64 and Windows.

Should work on all operating systems that run R.

R (version 3.1.0 or higher)

None.

R, partykit package (version 1.2 or higher)

Same as the authors: Heidi Seibold, Achim Zeileis and Torsten Hothorn.

English

The software is intentionally written to make usage as simple as possible. The most prominent use case are clinical trials where the assumption of an average treatment effect for all patients is too strict and the efficacy of the treatment depends on patient characteristics (e.g. gender, biomarkers, etc.). For subgroup analyses (stratified treatment effects) model-based trees (

We encourage users to use the party tag on Stackoverflow (

The authors have no competing interests to declare.