Running ‘test-pmodel.R’ [16s/16s]
  Running ‘test-pmtree.R’
Running the tests in ‘tests/test-pmodel.R’ failed.
Complete output:
  > library("model4you")
  Loading required package: partykit
  Loading required package: grid
  Loading required package: libcoin
  Loading required package: mvtnorm
  Loading required package: rpart
  > library("mvtnorm") 
  > library("survival")
  > 
  > ## function to simulate the data
  > sim_data <- function(n = 500, p = 10, beta = 3, sd = 1){
  +   
  +   ## treatment
  +   lev <- c("C", "A")
  +   a <- rep(factor(lev, labels = lev, levels = lev), length = n)
  +   
  +   ## correlated z variables
  +   sigma <- diag(p) 
  +   sigma[sigma == 0] <- 0.2
  +   ztemp <- rmvnorm(n, sigma = sigma)
  +   z <- (pnorm(ztemp) * 2 * pi) - pi  
  +   colnames(z) <- paste0("z", 1:ncol(z))
  +   z1 <- z[,1]
  +   
  +   ## outcome
  +   y <- 7 + 0.2 * (a %in% "A") + beta * cos(z1) * (a %in% "A") + rnorm(n, 0, sd)
  +   
  +   data.frame(y = y, a = a, z)
  + }
  > 
  > ## simulate data
  > set.seed(123)
  > beta <- 3
  > ntrain <- 500
  > ntest <- 100
  > simdata <- simdata_s <- sim_data(p = 5, beta = beta, n = ntrain)
  > tsimdata <- tsimdata_s <- sim_data(p = 5, beta = beta, n = ntest)
  > simdata_s$cens <- rep(1, ntrain)
  > tsimdata_s$cens <- rep(1, ntest)
  > 
  > ## base model
  > basemodel_lm <- lm(y ~ a, data = simdata)
  > basemodel_wb <- survreg(Surv(y, cens) ~ a, data = simdata_s)
  > 
  > ## forest
  > frst_lm <- pmforest(basemodel_lm, ntree = 10, 
  +                     perturb = list(replace = FALSE, fraction = 0.632),
  +                     control = ctree_control(mincriterion = 0, lookahead = TRUE))
  No data given. I'm using data set simdata from the current environment parent.frame(). 
                     Please check if that is what you want.
  > frst_wb <- pmforest(basemodel_wb, ntree = 10, 
  +                     perturb = list(replace = FALSE, fraction = 0.632),
  +                     control = ctree_control(mincriterion = 0, lookahead = TRUE))
  No data given. I'm using data set simdata_s from the current environment parent.frame(). 
                     Please check if that is what you want.
  > 
  > ## personalised models
  > coefs_lm <- pmodel(x = frst_lm, newdata = tsimdata)
  > summary(coefs_lm)
    (Intercept)          aA          
   Min.   :6.083   Min.   :-2.06955  
   1st Qu.:6.838   1st Qu.:-0.67986  
   Median :7.097   Median :-0.02111  
   Mean   :7.044   Mean   : 0.03952  
   3rd Qu.:7.269   3rd Qu.: 0.72868  
   Max.   :7.662   Max.   : 2.27505  
  > 
  > 
  > coeffun <- function(model) {
  +   ## model coefficients
  +   coefs <- c(coef(model), scale = model$scale)
  +   
  +   ## difference in median survival 
  +   p = 0.5
  +   coefs["median_s0"] <- qweibull(p = p, shape = 1/coefs["scale"], 
  +                                  scale = exp(coefs["(Intercept)"]))
  +   coefs["median_s1"] <- qweibull(p = p, shape = 1/coefs["scale"], 
  +                                  scale = exp(coefs["(Intercept)"] + coefs["aA"]))
  +   coefs["median_sdiff"] <- coefs["median_s1"] - coefs["median_s0"]
  +   
  +   return(coefs)
  + }
  > coefs_wb <- pmodel(x = frst_wb, newdata = tsimdata_s,
  +                    fun = coeffun)
  > summary(coefs_wb)
    (Intercept)          aA               scale          median_s0    
   Min.   :1.837   Min.   :-0.18402   Min.   :0.1242   Min.   :5.564  
   1st Qu.:1.973   1st Qu.: 0.03964   1st Qu.:0.1734   1st Qu.:6.649  
   Median :1.997   Median : 0.09375   Median :0.2025   Median :6.852  
   Mean   :1.989   Mean   : 0.09052   Mean   :0.2074   Mean   :6.783  
   3rd Qu.:2.017   3rd Qu.: 0.15010   3rd Qu.:0.2349   3rd Qu.:6.975  
   Max.   :2.058   Max.   : 0.35433   Max.   :0.3334   Max.   :7.293  
     median_s1      median_sdiff    
   Min.   :5.619   Min.   :-1.1664  
   1st Qu.:6.853   1st Qu.: 0.2761  
   Median :7.501   Median : 0.6648  
   Mean   :7.459   Mean   : 0.6755  
   3rd Qu.:7.984   3rd Qu.: 1.0902  
   Max.   :9.126   Max.   : 2.5114  
  > 
  > 
  > ## Variable importance
  > set.seed(123)
  > (vi_lm <- varimp(frst_lm))
  Error in `[[.partynode`(`*tmp*`, idn) : 'x' is incorrect node
  Calls: varimp ... gettree.pmforest -> .add_modelinfo -> [[ -> [[.partynode
  Execution halted
Running the tests in ‘tests/test-pmtree.R’ failed.
Complete output:
  > library("model4you")
  Loading required package: partykit
  Loading required package: grid
  Loading required package: libcoin
  Loading required package: mvtnorm
  Loading required package: rpart
  > library("survival")
  > 
  > ### survreg
  > set.seed(1)
  > data(GBSG2, package = "TH.data")
  > 
  > ## base model
  > bmod <- survreg(Surv(time, cens) ~ horTh, data = GBSG2, model = TRUE)
  > survreg_plot(bmod)
  > 
  > ## partitioned model
  > tr <- pmtree(bmod)
  No data given. I'm using data set GBSG2 from the current environment parent.frame(). 
                     Please check if that is what you want.
  Error in `[[.partynode`(tree_ret, idn) : 'x' is incorrect node
  Calls: pmtree -> .add_modelinfo -> [[ -> [[.partynode
  Execution halted