<p>The model-based GLM tree you have specified tries to fit the following model:
logit(prob) = alpha_tree(x1-x4) * t, where alpha_tree(x1-x4) is a subgroup-specific coefficient from the tree (based on partitioning variables x1-x4) for the treatment indicator t. Thus, this model does not include the possibility for an intercept or global main effects of x1 and x2 - as simulated in your data. As these main effects are quite pronounced the model has no other possibility except to capture these by further splits. Hence, the large tree in your example.</p>

<p>In the classic MOB framework (Zeileis <em>et al.</em> 2008, Journal of Computational and Graphical Statistics, <a href="http://dx.doi.org/10.1198/106186008X319331" rel="nofollow noreferrer">doi:10.1198/106186008X319331</a>), the only option would be to include every relevant regressor in the model to be partitioned, i.e., logit(mu) = beta0_tree(x1-x4) + beta1_tree(x1_x4) * x1 + beta2_tree(x1-x4) * x2 + alpha_tree(x1-x4) * t. This works and will detect subgroups with respect to only the treatment effect alpha * t as well but, of course, loses some efficiency because it re-estimates the beta coefficients in every subgroup as well. A discussion of this approach specifically for subgroup analyses is available in Seibold <em>et al.</em> (2016a), The International Journal of Biostatistics, <a href="http://dx.doi.org/10.1515/ijb-2015-0032" rel="nofollow noreferrer">doi:10.1515/ijb-2015-0032</a>.</p>

<p>Recently, we have suggested an adaptation of MOB that we called PALM tree for partially additive linear model trees (Seibold <em>et al.</em> 2016b, <a href="http://arxiv.org/abs/1612.07498" rel="nofollow noreferrer">http://arxiv.org/abs/1612.07498</a>). This allows to fit models of the type logit(mu) = beta0 + beta1 * x1 + beta2 * x2 + alpha_tree(x1-x4) * t as you simulated in your question.</p>

<p>Implementations of both the classic GLM-based MOB tree and the PALM tree are available as <code>glmtree()</code> and <code>palmtree()</code>, respectively, in <code>partykit</code> which is recommended over the old <code>party</code> implementation. Applying these to your simulated data above, yields the following. First, it is important that all categorical partitioning variables are also flagged as <code>factor</code> variables (in order to choose the right parameter instability tests):</p>

<pre><code>dt &lt;- transform(dt, x3 = factor(x3))
</code></pre>

<p>Then, we can fit the model from which you have simulated with only a subgroup-specific treatment effect, a global main effect of x1 and x2, and partitioning based on x1, x2, x3, x4.</p>

<pre><code>library("partykit")
tr1 &lt;- palmtree(y ~ t - 1 | x1 + x2 | x1 + x2 + x3 + x4, data = dt,
  family = binomial, minsize = 100)
tr1
## Partially additive generalized linear model tree (family: binomial)
## 
## Model formula:
## y ~ t - 1 | x1 + x2 + x3 + x4
## 
## Fitted party:
## [1] root
## |   [2] x1 &lt;= -0.21797: n = 399
## |                t 
## |       -0.9245345 
## |   [3] x1 &gt; -0.21797: n = 601
## |               t 
## |       0.6033979 
## 
## Number of inner nodes:    1
## Number of terminal nodes: 2
## Number of parameters per node: 1
## Objective function (negative log-likelihood): 432.5717
## 
## Linear fixed effects (from palm model):
## (Intercept)          x1          x2 
##   0.7140397   1.7589675  -1.1335779 
</code></pre>

<p>Thus, this covers the most important parts of the data-generating process but fails to detect the interaction with x2.</p>

<pre><code>plot(tr1)
</code></pre>

<p><a href="https://i.stack.imgur.com/JZ65h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JZ65h.png" alt="tr1"></a></p>

<p>I played around with setting other seeds or using BIC-based post-pruning (combined with a large significance level) which sometimes could also discover the interaction with x2. Presumably, a larger sample would yield the "true" tree more often, as well. Thus, the model seems to be in principle capable to fit the model you simulated, just not in this particular setting.</p>

<p>Personally, I would always let both the intercept <em>and</em> the treatment effect vary across subgroups. Because if there are any main effects that I overlooked this is likely to yield a better model. If an intercept is included in every subgroup, then it is nicer to code both <code>y</code> and <code>t</code> as factors, yielding nicer plots in the visualization:</p>

<pre><code>dt &lt;- transform(dt, y = factor(y), t = factor(t))
tr2 &lt;- palmtree(y ~ t | x1 + x2 | x1 + x2 + x3 + x4, data = dt,
  family = binomial, minsize = 100)
tr2
## Partially additive generalized linear model tree (family: binomial)
## 
## Model formula:
## y ~ t | x1 + x2 + x3 + x4
## 
## Fitted party:
## [1] root
## |   [2] x1 &lt;= -0.26515: n = 382
## |       (Intercept)          t1 
## |         0.9839353  -1.1376981 
## |   [3] x1 &gt; -0.26515: n = 618
## |       (Intercept)          t1 
## |         0.5331386   0.6566111 
## 
## Number of inner nodes:    1
## Number of terminal nodes: 2
## Number of parameters per node: 2
## Objective function (negative log-likelihood): 432.3303
## 
## Linear fixed effects (from palm model):
##        x1        x2 
##  1.964397 -1.078958 
</code></pre>

<p>For this data, this fits almost the same model as above. But the display is much easier to read, showing the large difference in absolute treatment effect between the two groups:</p>

<pre><code>plot(tr2)
</code></pre>

<p><a href="https://i.stack.imgur.com/1mKSY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1mKSY.png" alt="tr2"></a></p>

<p>Finally, if using a plain old MOB without the possibility to include additive main effects, we should include the regressors x1 and x2 in every subgroup:</p>

<pre><code>tr3 &lt;- glmtree(y ~ t + x1 + x2 | x1 + x2 + x3 + x4, data = dt,
  family = binomial, minsize = 100)
tr3
## Generalized linear model tree (family: binomial)
## 
## Model formula:
## y ~ t + x1 + x2 | x1 + x2 + x3 + x4
## 
## Fitted party:
## [1] root
## |   [2] x1 &lt;= -0.26515: n = 382
## |       (Intercept)          t1          x1          x2 
## |         0.5570219  -1.0511317   1.2533975  -1.3899679 
## |   [3] x1 &gt; -0.26515: n = 618
## |       (Intercept)          t1          x1          x2 
## |         0.3573041   0.6943206   2.2910053  -0.9570403 
## 
## Number of inner nodes:    1
## Number of terminal nodes: 2
## Number of parameters per node: 4
## Objective function (negative log-likelihood): 429.2406
</code></pre>

<p>Again, this essentially finds the same subgroups as before. However, it loses a bit of efficiency because more regression coefficients have to be estimated in each subgroup while only the <code>t</code> coefficient really changes between the subgroups.</p>

<pre><code>plot(tr3, tp_args = list(which = 1))
</code></pre>

<p><a href="https://i.stack.imgur.com/Bo2KC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bo2KC.png" alt="tr3"></a></p>
subgroup identification with regression tree
<p>I am very interested in a recent paper on "Tutorial in biostatistics: data-driven subgroup identification and analysis in clinical trials " (DOI: 10.1002/sim.7064), and I want to reproduce results in the section "Performance of the tree-based regression approach". However, the partitioning tree seems not get the result as I want.</p>

<pre><code>set.seed(123)
n &lt;- 1000
x1 &lt;- rnorm(n)
x2 &lt;- runif(n)
t &lt;- rbinom(n,1,0.5)
x3 &lt;- rbinom(n,1,0.3)
x4 &lt;- rnorm(n)
z &lt;-1+ 2*x1-1.8*x2+(x1&gt;=-0.3)*(x2&gt;=0.4)*t-(x1&lt; -0.3)*(x2&lt;0.4)*t
pr = 1/(1+exp(-z))
y = rbinom(n,1,pr)
dt &lt;- data.frame(x1,x2,x3,x4,t,y)

library(party)
mb &lt;- mob(y~t-1|x1+x2+x3+x4,
  data=dt,
  model = glinearModel,
  family = binomial(),
  control=mob_control(minsplit=100))
plot(mb)
</code></pre>

<p><a href="https://i.stack.imgur.com/xlarg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xlarg.png" alt="regression tree"></a></p>

<p>The figure is shown above. It is supposed to split on x1 and x2 at cutoff values of -0.3 and 0.4 defined in the simulation. However, it doesn't appear to do so.x1 dominated the node partition and x2 seems not an important determinant of the partitioning process. What's wrong with the code? </p>