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)