model4you (version 0.9-5)

pmtest: Test if personalised models improve upon base model.

Description

This is a rudimentary test if there is heterogeneity in the model parameters. The null-hypothesis is: the base model is the correct model.

Usage

pmtest(forest, pmodels = NULL, data = NULL, B = 100)

# S3 method for heterogeneity_test plot(x, ...)

Arguments

forest

pmforest object.

pmodels

pmodel_identity object (pmodel(..., fun = identity)).

data

data.

B

number of bootstrap samples.

x

object of class heterogeneity_test.

...

ignored.

Value

list where the first element is the p-value und the second element is a data.frame with all neccessary infos to compute the p-value.

The test statistic is the difference in objective function between the base model and the personalised models. To compute the distribution under the Null we draw parametric bootstrap samples from the base model. For each bootstrap sample we again compute the difference in objective function between the base model and the personalised models. If the difference in the original data is greater than the difference in the bootstrap samples, we reject the null-hypothesis.

Examples

Run this code
# NOT RUN {
set.seed(123)
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) 
pmods <- pmodel(frst, fun = identity)

## Note that B should be at least 100
## The low B is just for demonstration 
## purposes.
tst <- pmtest(forest = frst, 
              pmodels = pmods, 
              B = 10) 
tst$pvalue
tst
plot(tst)
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace