R Under development (unstable) (2024-11-07 r87302 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library("model4you") Loading required package: partykit Loading required package: grid Loading required package: libcoin Loading required package: mvtnorm > > set.seed(2018) > n <- 160 > trt <- factor(rep(0:1, each = n/2)) > y <- 4 + (trt == 1) + rnorm(n) > z <- matrix(rnorm(n * 2), ncol = 2) > > dat <- data.frame(y, trt, z) > > mod <- lm(y ~ trt, data = dat) > > ## Note that ntree should usually be higher > frst <- pmforest(mod, ntree = 20) No data given. I'm using data set dat from the current environment parent.frame(). Please check if that is what you want. > pmods <- pmodel(frst, fun = identity) > > sum(objfun(pmods)) [1] -179.7791 > > ## Note that B should be at least 100 > ## The low B is just for demonstration > ## purposes. > tst <- pmtest(forest = frst, + pmodels = pmods, + B = 5) No data given. I'm using data set dat from the current environment parent.frame(). Please check if that is what you want. > tst $pvalue [1] 0 $objfun base_model personalised_models sim hypothesis diff 1 -161.3734 -179.7791 FALSE H[1] -18.40569 sim_1 -155.1617 -182.4686 TRUE H[0] -27.30692 sim_2 -180.4936 -220.7145 TRUE H[0] -40.22091 sim_3 -153.3232 -173.0736 TRUE H[0] -19.75034 sim_4 -135.1752 -157.5817 TRUE H[0] -22.40648 sim_5 -112.2658 -133.9999 TRUE H[0] -21.73409 attr(,"class") [1] "heterogeneity_test" > > proc.time() user system elapsed 13.67 0.70 14.35