Running ‘test-pmodel-test.R’ [17s/26s]
  Running ‘test-pmodel.R’ [30s/45s]
  Comparing ‘test-pmodel.Rout’ to ‘test-pmodel.Rout.save’ ... OK
  Running ‘test-pmtree.R’ [4s/6s]
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.
  > plot(tr, terminal_panel = node_pmterminal(tr, plotfun = survreg_plot, 
  +                                           confint = TRUE))
  > summary(tr)
  Stratified model for node(s) 2, 4, 5
  
  Model call:
  survreg(formula = Surv(time, cens) ~ horTh, data = GBSG2, model = TRUE)
  
  Coefficients:
              node 2 node 4 node 5
  (Intercept) 7.8590 7.2936  6.981
  horThyes    0.4001 0.3039  0.163
  
  Number of obervations:
  node 2 node 4 node 5 
     376    223     87 
  
  Objective function:
  (1093.18) + (1037.81) + (457.96) = 2588.95> summary(tr, node = 1:2)
  Stratified model for node(s) 1, 2
  
  Model call:
  survreg(formula = Surv(time, cens) ~ horTh, data = GBSG2, model = TRUE)
  
  Coefficients:
              node 1 node 2
  (Intercept)  7.608 7.8590
  horThyes     0.306 0.4001
  
  Number of obervations:
  node 1 node 2 
     686    376 
  
  Objective function:
    node 1   node 2 
  2632.096 1093.182 
  > 
  > coef(tr)
    (Intercept)  horThyes
  2    7.859026 0.4001011
  4    7.293645 0.3038557
  5    6.980875 0.1630104
  > coef(tr, node = 1)
    (Intercept)  horThyes
  1    7.608449 0.3059506
  > coef(bmod)
  (Intercept)    horThyes 
    7.6084486   0.3059506 
  > 
  > logLik(bmod)
  'log Lik.' -2632.096 (df=3)
  > logLik(tr)
  'log Lik.' -2588.953 (df=9)
  > 
  > 
  > ### glm binomial 
  > set.seed(2)
  > n <- 1000
  > trt <- factor(rep(1:2, each = n/2))
  > age <- sample(40:60, size = n, replace = TRUE)
  > eff <- -1 + I(trt == 2) + 1 * I(trt == 2) * I(age > 50)
  > expit <- function(x) 1/(1 + exp(-x))
  > 
  > success <- rbinom(n = n, size = 1, prob = expit(eff))
  > 
  > dat <- data.frame(success, trt, age)
  > library("plyr")
  > dattab <- ddply(.data = dat, .variables = .(trt, age), 
  +                 function(x) data.frame(nsuccess = sum(x$success),
  +                                        nfailure = NROW(x) - sum(x$success)))
  > 
  > bmod1 <- glm(success ~ trt, family = binomial)
  > bmod2 <- glm(success ~ trt, family = "binomial")
  > bmod3 <- glm(success ~ trt, data = dat, family = binomial)
  > bmod4 <- glm(cbind(nsuccess, nfailure) ~ trt, data = dattab, family = binomial)
  > 
  > (tr1 <- pmtree(bmod1, data = dat))
  [1] root
  |   [2] age <= 50
  |   |   [3] age <= 42: n = 153
  |   |       (Intercept)        trt2 
  |   |        -0.1300531   0.5027284 
  |   |   [4] age > 42: n = 371
  |   |       (Intercept)        trt2 
  |   |        -0.9932518   0.7773634 
  |   [5] age > 50: n = 476
  |       (Intercept)        trt2 
  |        -0.7958013   1.9056497 
  
  Number of inner nodes:    2
  Number of terminal nodes: 3
  Number of parameters per node: 2
  Objective function: 621.198
  > (tr2 <- pmtree(bmod2, data = dat))
  [1] root
  |   [2] age <= 50
  |   |   [3] age <= 42: n = 153
  |   |       (Intercept)        trt2 
  |   |        -0.1300531   0.5027284 
  |   |   [4] age > 42: n = 371
  |   |       (Intercept)        trt2 
  |   |        -0.9932518   0.7773634 
  |   [5] age > 50: n = 476
  |       (Intercept)        trt2 
  |        -0.7958013   1.9056497 
  
  Number of inner nodes:    2
  Number of terminal nodes: 3
  Number of parameters per node: 2
  Objective function: 621.198
  > (tr3 <- pmtree(bmod3))
  No data given. I'm using data set dat from the current environment parent.frame(). 
                     Please check if that is what you want.
  [1] root
  |   [2] age <= 50
  |   |   [3] age <= 42: n = 153
  |   |       (Intercept)        trt2 
  |   |        -0.1300531   0.5027284 
  |   |   [4] age > 42: n = 371
  |   |       (Intercept)        trt2 
  |   |        -0.9932518   0.7773634 
  |   [5] age > 50: n = 476
  |       (Intercept)        trt2 
  |        -0.7958013   1.9056497 
  
  Number of inner nodes:    2
  Number of terminal nodes: 3
  Number of parameters per node: 2
  Objective function: 621.198
  > (tr4 <- pmtree(bmod4))
  No data given. I'm using data set dattab from the current environment parent.frame(). 
                     Please check if that is what you want.
  [1] root
  |   [2] age <= 50
  |   |   [3] age <= 43: n = 8
  |   |       (Intercept)        trt2 
  |   |        -0.4367177   0.7420993 
  |   |   [4] age > 43: n = 14
  |   |       (Intercept)        trt2 
  |   |        -0.9253406   0.6662319 
  |   [5] age > 50: n = 20
  |       (Intercept)        trt2 
  |        -0.7958013   1.9056497 
  
  Number of inner nodes:    2
  Number of terminal nodes: 3
  Number of parameters per node: 2
  Objective function: 94.40128
  > 
  > (mtr1 <- glmtree(success ~ trt | age, data = dat, family = binomial))
  Generalized linear model tree (family: binomial)
  
  Model formula:
  success ~ trt | age
  
  Fitted party:
  [1] root
  |   [2] age <= 50
  |   |   [3] age <= 42: n = 153
  |   |       (Intercept)        trt2 
  |   |        -0.1300531   0.5027284 
  |   |   [4] age > 42: n = 371
  |   |       (Intercept)        trt2 
  |   |        -0.9932518   0.7773634 
  |   [5] age > 50: n = 476
  |       (Intercept)        trt2 
  |        -0.7958013   1.9056497 
  
  Number of inner nodes:    2
  Number of terminal nodes: 3
  Number of parameters per node: 2
  Objective function (negative log-likelihood): 621.198
  > # (mtr2 <- glmtree(cbind(nsuccess, nfailure) ~ trt | age, data = dattab, family = binomial))
  > 
  > library("strucchange")
  Loading required package: zoo
  
  Attaching package: 'zoo'
  
  The following objects are masked from 'package:base':
  
      as.Date, as.Date.numeric
  
  Loading required package: sandwich
  > sctest(tr3)
  Error in UseMethod("estfun") : 
    no applicable method for 'estfun' applied to an object of class "c('pmtree', 'constparty', 'party')"
  Calls: sctest -> sctest.default -> gefp -> scores
  Execution halted