Just like in title: I'd like to change x-axis limits for partykit::lmtree (mob) plots.
Toy example
Let shape of Y~X+X^2 regression depend on A:
A <- rep(1:5, each=4)
X <- 1:20
Y <- X*A+(A<3)*X^2+rnorm(20, mean=10)
Now build lmtree with polynomial term and plot:
library(partykit)
mytree <- lmtree(Y~poly(X,2,raw=T) | A, minsize=3)
plot(mytree)
Limits of X-axis are clearly based on range of poly(X,2,raw=T) not on range of X. How can I change them?
What I have tried
- Use
tp_args=list(xlim=c(1,20)). This failed because (I think) there is noxlimparameter innode_bivplot()that controls plots. - Find some other parameter of
node_bivplot()that controls axes. I can't see any. - Use
Y~X+I(X^2)insidelmtree. This produces separate plots forXandI(X^2)on each leaf.

Currently, the
xscaleandyscalearguments (grid graphics equivalents to the base graphics argumentsxlimandylim) are set internally innode_bivplot()and cannot be modified through arguments.In your case I would recommend to set up the two regressors from the polynomial manually (
X + I(X^2)) and then only create a terminal panel for the first of these two regressors (which = 1):