Running ‘check_methods.R’ [3s/3s]
  Running ‘check_mvord_data.R’ [2s/2s]
  Running ‘check_mvord_errors.R’ [2s/2s]
  Running ‘check_set_threshold_type.R’ [2s/3s]
  Running ‘check_toy_example.R’ [2s/3s]
  Running ‘check_transf_sigmas.R’ [1s/2s]
  Running ‘check_transf_thresholds.R’ [2s/2s]
Running the tests in ‘tests/check_toy_example.R’ failed.
Complete output:
  > library(mvord)
  Loading required package: minqa
  Loading required package: BB
  Loading required package: ucminf
  Loading required package: dfoptim
  > library(MASS)
  > 
  > 
  > #data(data_toy_example)
  > tolerance <- 1e-6
  > 
  > mult.obs <- 2
  > sigma <- matrix(c(1,0.8,0.8,1), ncol = 2)
  > betas <- list(c(0.8,-0.5),
  +               c(0.8,-0.5))
  > thresholds <- list(c(-1,1),c(-1,1))
  > nobs <- 100
  > suppressWarnings(RNGversion("3.5.0"))
  > set.seed(2017)
  > errors <-  mvrnorm(n = nobs, mu = rep(0, mult.obs), Sigma = sigma)
  > 
  > X1 <- rnorm(nobs, 0, 1)
  > X2 <- rnorm(nobs, 0, 1)
  > 
  > pred <- cbind(X1, X2)
  > 
  > y <- sapply(1:mult.obs, function(j) pred %*% betas[[j]] + errors[, j], simplify = "array")
  > y.ord <- sapply(1:mult.obs, function(j) cut(y[, , j], c(min(y[, , j]) - 1,
  +                                                         c(thresholds[[j]]), max(y[, , j]) + 1),
  +                                             labels = FALSE), simplify = "array")
  > 
  > predictors.fixed <- lapply(1:mult.obs, function(j) pred)
  > y <- as.data.frame(y.ord)
  > 
  > for(i in 1:mult.obs){
  +   y[, i] <- factor(y[, i], levels = sort(unique(y[, i])),
  +                    ordered = TRUE)
  + }
  > 
  > 
  > 
  > 
  > data_toy_example <- cbind.data.frame(y, predictors.fixed[[1]])
  > colnames(data_toy_example) <- c("Y1","Y2", "X1", "X2")
  > w <- c(rep(1/20, 20), rep(1/30, 30), rep(1/20, 20), rep(1/30, 30))
  > 
  > 
  > 
  > # convert data_toy_example into long format
  > df <- cbind.data.frame("i" = rep(1:100,2),
  +                        "j" = rep(1:2,each = 100),
  +                        "Y" = c(data_toy_example$Y1, data_toy_example$Y2),
  +                        "X1" = rep(data_toy_example$X1,2),
  +                        "X2" = rep(data_toy_example$X2,2),
  +                        "f1" = factor(sample(rep(data_toy_example$Y2,2)),
  +                                      ordered = FALSE),
  +                        "f2" = factor(rep(data_toy_example$Y1,2), ordered = FALSE),
  +                        w    = rep(w,2))
  > df$X3 <- cut(df$X2, c(-Inf, -0.2, 0.2, Inf))
  > 
  > 
  > 
  > # library(ROI)
  > # ROI_solver <- function(starting.values, objFun, control){
  > #     n <- length(starting.values)
  > #     op <- OP(objective = F_objective(objFun, n = n),
  > #              bounds = V_bound(li = seq_len(n), lb = rep.int(-Inf, n)))
  > #     optRes <- ROI_solve(op, solver = "nlminb",
  > #         control = c(list(start = starting.values),
  > #                     control))
  > #     list(optpar    = optRes$solution,
  > #          objective = optRes$objval) # a vector of length equal to number of parameters to optimize
  > # }
  > #
  > #
  > #
  > 
  > # Test MMO() ----
  > 
  > ## Coef constraints as vector ----
  > 
  > res <- mvord(formula = MMO(Y) ~  0 + X1 + X2,
  +              data = df,
  +              link = mvprobit(),
  +              error.structure = cor_general(~1),
  +              threshold.constraints = c(1,1),
  +              coef.constraints = c(1,1),
  +              contrasts = list(f1 = function(x)
  +                contr.treatment(nlevels(df$f1), base = 1),
  +                f2 = "contr.sum"),
  +              control= mvord.control(solver="BFGS",se=TRUE))
  Warning message:
  In mvord(formula = MMO(Y) ~ 0 + X1 + X2, data = df, link = mvprobit(),  :
    Variables f1 and f2 are absent, the contrasts will be ignored.
  > options(digits = 22)
  > 
  > res.summary <- summary(res, short = FALSE)
  
  Call: mvord(formula = MMO(Y) ~ 0 + X1 + X2, data = df, error.structure = cor_general(~1), 
      link = mvprobit(), coef.constraints = c(1, 1), threshold.constraints = c(1, 
          1), contrasts = list(f1 = function(x) contr.treatment(nlevels(df$f1), 
          base = 1), f2 = "contr.sum"), control = mvord.control(solver = "BFGS", 
          se = TRUE))
  
  Formula: MMO(Y) ~ 0 + X1 + X2
  
      link threshold nsubjects ndim   logPL  CLAIC  CLBIC fevals
  mvprobit  flexible       100    2 -134.91 280.34 294.06     32
  
  Thresholds:
                       Estimate              Std. Error                z value
  1 1|2 -0.96257386663499888702  0.16613952738603396386 -5.7937700000000003087
  1 2|3  1.03347036873238828925  0.15004482537615168591  6.8877399999999999736
  2 1|2 -0.96257386663499888702  0.16613952738603396386 -5.7937700000000003087
  2 2|3  1.03347036873238828925  0.15004482537615168591  6.8877399999999999736
          Pr(>|z|)    
  1 1|2 6.8825e-09 ***
  1 2|3 5.6684e-12 ***
  2 1|2 6.8825e-09 ***
  2 2|3 5.6684e-12 ***
  ---
  Signif. codes:  
    0 '***' 0.001000000000000000020817 '**' 0.01000000000000000020817 '*'
    0.05000000000000000277556 '.' 0.1000000000000000055511 ' ' 1
  
  Coefficients:
                      Estimate              Std. Error                z value
  X1 1  0.63801035062442590373  0.13576747301354935571  4.6992900000000004113
  X2 1 -0.42672524816265555714  0.13643665802445156809 -3.1276399999999999757
         Pr(>|z|)    
  X1 1 2.6107e-06 ***
  X2 1  0.0017621 ** 
  ---
  Signif. codes:  
    0 '***' 0.001000000000000000020817 '**' 0.01000000000000000020817 '*'
    0.05000000000000000277556 '.' 0.1000000000000000055511 ' ' 1
  
  Error Structure:
                          Estimate              Std. Error               z value
  corr 1 2 0.854266728221043991631 0.062440889990424582046 13.681210000000000093
             Pr(>|z|)    
  corr 1 2 < 2.22e-16 ***
  ---
  Signif. codes:  
    0 '***' 0.001000000000000000020817 '**' 0.01000000000000000020817 '*'
    0.05000000000000000277556 '.' 0.1000000000000000055511 ' ' 1
  > # paste(format(res.summary$thresholds$Estimate), collapse = ",")
  > # paste(format(res.summary$coefficients$Estimate), collapse = ",")
  > # paste(format(res.summary$error.structure$Estimate), collapse = ",")
  > mvord:::check(all.equal(res.summary$thresholds$Estimate, c(-0.96257386663519672876,  1.03347036873223707687, -0.96257386663519672876,  1.03347036873223707687), tolerance = tolerance))
  > mvord:::check(all.equal(res.summary$coefficients$Estimate, c(0.63801035062404309883, -0.42672524816263474046), tolerance = tolerance))
  > mvord:::check(all.equal(res.summary$error.structure$Estimate, c(0.85426672822122684536), tolerance = tolerance))
  > mvord:::check(all.equal(res.summary$thresholds$`Std. Error`, c(0.16613952738605441972, 0.15004482537617935822, 0.16613952738605441972, 0.15004482537617935822), tolerance = tolerance))
  > mvord:::check(all.equal(res.summary$coefficients$`Std. Error`, c(0.13576747301357894315, 0.13643665802446261481), tolerance = tolerance))
  > mvord:::check(all.equal(res.summary$error.structure$`Std. Error`, c(0.062440889990360744222), tolerance = tolerance))
  > mvord:::check(all.equal(logLik(res)[[1]], -134.90867383086322207, tolerance = tolerance))
  > mvord:::check(all.equal(AIC(res), 280.3436634512001433, tolerance = tolerance))
  > mvord:::check(all.equal(BIC(res), 294.05508548271637892, tolerance = tolerance))
  Error in mvord:::check(all.equal(BIC(res), 294.055085482716, tolerance = tolerance)) : 
    ..1 is not TRUE
  Calls: <Anonymous> -> stopifnot
  Execution halted