# Impact of weights on structural change tests in partykit

I am using the R partykit package to do recursive partitioning of linear regression models and am having trouble understanding how I should expect observation weights to affect the parameter instability tests that are used to determine which variable to split on. A key point of confusion is why the scale of the weights alone is affecting the tests. For example, suppose we are working with some sort of consumer product and we want to weight observations by sales volumes so that products with very low volume do not get alot of weight. I would not expect that I would have to worry about defining the sales in thousands vs. millions (the relative weight is not affected). However, in the code example below, changing the scale of the weight argument to lmtree() scales the test statistic from the parameter instability test up or down by the same amount, with the p-value also changing.

library(partykit)
library(data.table)

n <- 500
TT <- 12
dat <- rbind(
data.table(tt=rep(1:TT, n), x1=rep(runif(n), each=TT), weight=1)
)
dat[x1<=0.5, y := 0.1*TT+rnorm(.N)]
dat[x1>.5, y := 0.2*TT + rnorm(.N)]

tree <- lmtree(y ~ tt | x1, data=dat, weight=weight/10, verbose=T, maxdepth=2)


The lmtree() function as well as the the underlying mob() function distinguish weights being used as case weights (default) or proportionality weights. In the former case, the number of observations is the sum of weights. This is useful for not repeating exactly identical observations. In the latter case, it is the number of non-zero weights which is the way weights are usually employed in lm().
To control which type of weights should be used set caseweights = TRUE (default) or caseweights = FALSE. See ?mob_control.
• Thanks @Achim. When caseweights=FALSE the number of observations indeed does not change with the scale of the weight variable. However, the test statistic for the parameter instability test gets scaled, implying that the decision whether to split the data is still dependent on the scale of the proportionality weights, which seems counter intuitive. Can you comment? Dec 18 '17 at 14:16