Running 'AFT-Ex.R' [7s]
  Comparing 'AFT-Ex.Rout' to 'AFT-Ex.Rout.save' ... OK
  Running 'GBSG2.R' [5s]
  Running 'KM-Ex.R' [4s]
  Comparing 'KM-Ex.Rout' to 'KM-Ex.Rout.save' ... OK
  Running 'faithful.R' [9s]
  Comparing 'faithful.Rout' to 'faithful.Rout.save' ... OK
  Running 'orm-Ex.R' [23s]
  Comparing 'orm-Ex.Rout' to 'orm-Ex.Rout.save' ... OK
  Running 'timedep_covar.R' [14s]
  Running 'truncreg-Ex.R' [4s]
  Comparing 'truncreg-Ex.Rout' to 'truncreg-Ex.Rout.save' ... OK
  Running 'udist-Ex.R' [5s]
  Comparing 'udist-Ex.Rout' to 'udist-Ex.Rout.save' ... OK
Running the tests in 'tests/timedep_covar.R' failed.
Complete output:
  > 
  > library("mlt")
  Loading required package: basefun
  Loading required package: variables
  > library("survival")
  > library("flexsurv")
  > 
  > chk <- function(x, y, ...) {
  + 
  +     ret <- all.equal(x, y, ...)
  +     if (isTRUE(ret)) return(ret)
  +     print(ret)
  +     return(TRUE)
  + }
  > tol <- .001
  > 
  > ### right-censored veteran data
  > ### exponential model
  > fit1 <- coxph(Surv(time, status) ~ karno + age + trt, veteran)
  > fit2 <- survreg(Surv(time, status) ~ karno + age + trt, veteran, dist = "exponential")
  > fit3 <- flexsurvreg(Surv(time, status) ~ karno + age + trt, data= veteran, dist = "exponential")
  > 
  > veteran$ytime <- with(veteran, Surv(time, status))
  > dy <- numeric_var("ytime", support = c(0.1, 1000))
  > by <- log_basis(dy, ui = "increasing")
  > m <- mlt(ctm(by, shift = ~ karno + age + trt, data = veteran, todistr = "MinExtr"),
  +          data = veteran, fixed = c("log(ytime)" = 1))
  > 
  > stopifnot(chk(fit3$logliki, m$logliki(coef(m)[-2], weights(m)), 
  +                     tol = tol, check.attributes = FALSE))
  > 
  > stopifnot(chk(logLik(fit2), logLik(m), tol = tol))
  > stopifnot(chk(logLik(fit3), logLik(m), tol = tol, 
  +               check.attributes = FALSE))
  > 
  > ### Weibull model
  > fit2 <- survreg(Surv(time, status) ~ karno + age + trt, veteran, dist = "weibull")
  > fit3 <- flexsurvreg(Surv(time, status) ~ karno + age + trt, data= veteran, dist = "weibull")
  > 
  > veteran$ytime <- with(veteran, Surv(time, status))
  > dy <- numeric_var("ytime", support = c(0.1, 1000))
  > # by <- Bernstein_basis(dy, order = 10, ui = "increasing")
  > by <- log_basis(dy, ui = "increasing")
  > m <- mlt(ctm(by, shift = ~ karno + age + trt, data = veteran, todistr = "MinExtr"),
  +          data = veteran)
  > 
  > stopifnot(chk(fit3$logliki, m$logliki(coef(m), weights(m)), 
  +               tol = tol, check.attributes = FALSE))
  > 
  > stopifnot(chk(logLik(fit2), logLik(m), tol = tol))
  > stopifnot(chk(logLik(fit3), logLik(m), tol = tol,
  +               check.attributes = FALSE))
  > 
  > ### now with time-dependent covariates
  > vet2 <- survSplit(Surv(time, status) ~., veteran,
  +                   cut=c(60, 120), episode ="timegroup")
  > vet2$timegroup <- factor(vet2$timegroup)
  > vet2$ytime <- with(vet2, Surv(tstart, time, status))
  > 
  > ## exponential model
  > suppressWarnings(fit3 <- flexsurvreg(Surv(tstart, time, status) ~ 
  +     karno + karno:timegroup + age + trt, data= vet2, dist = "exponential"))
  > m <- mlt(ctm(by, shift = ~ karno + karno:timegroup + age + trt, data = vet2, todistr = "MinExtr"),
  +          data = vet2, fixed = c("log(ytime)" = 1))
  > 
  > stopifnot(chk(fit3$logliki, m$logliki(coef(m)[-2], weights(m)), 
  +               tol = tol, check.attributes = FALSE))
  > stopifnot(chk(logLik(fit3), logLik(m), tol = tol, check.attributes = FALSE))
  > 
  > ### Weibull model
  > fit3 <- flexsurvreg(Surv(tstart, time, status) ~ karno + karno:timegroup +
  +                      age + trt, data= vet2, dist = "weibull")
  > m <- mlt(ctm(by, shift = ~ karno + karno:timegroup + age + trt, data = vet2, todistr = "MinExtr"),
  +          data = vet2, scale = TRUE)
  > 
  > stopifnot(chk(fit3$logliki, m$logliki(coef(m), weights(m)), 
  +               tol = tol, check.attributes = FALSE))
  > stopifnot(chk(logLik(fit3), logLik(m), tol = tol, check.attributes = FALSE))
  > 
  > ## Cox model, see ?survival::survSplit
  > fit1 <- coxph(Surv(tstart, time, status) ~ karno + karno:strata(timegroup) +
  +               age + trt, data= vet2)
  > 
  > ### refit this model using mlt
  > btg <- as.basis(vet2$timegroup)
  > by <- Bernstein_basis(dy, order = 3, ui = "increasing")
  > m <- mlt(ctm(by, interacting = btg, 
  +          shift = ~ karno + karno:timegroup + age + trt, data = vet2, todistr = "MinExtr"),
  +          data = vet2, scale = TRUE)
  Error in optim(par = par, fn = fun, gr = gradient, control = control.optim,  : 
    non-finite value supplied by optim
  Error in ret$convergence : $ operator is invalid for atomic vectors
  Error in ret$par : $ operator is invalid for atomic vectors
  Calls: mlt -> do.call -> .mlt_fit -> <Anonymous>
  Execution halted