CRAN Package Check Results for Package bayesDccGarch

Last updated on 2020-02-19 10:48:46 CET.

Flavor Version Tinstall Tcheck Ttotal Status Flags
r-devel-linux-x86_64-debian-clang 2.0 8.25 26.20 34.45 ERROR
r-devel-linux-x86_64-debian-gcc 2.0 3.38 20.36 23.74 ERROR
r-devel-linux-x86_64-fedora-clang 2.0 42.48 ERROR
r-devel-linux-x86_64-fedora-gcc 2.0 37.72 ERROR
r-devel-windows-ix86+x86_64 2.0 11.00 61.00 72.00 NOTE
r-devel-windows-ix86+x86_64-gcc8 2.0 20.00 77.00 97.00 NOTE
r-patched-linux-x86_64 2.0 4.12 28.91 33.03 NOTE
r-patched-solaris-x86 2.0 64.70 NOTE
r-release-linux-x86_64 2.0 3.92 28.82 32.74 NOTE
r-release-windows-ix86+x86_64 2.0 13.00 61.00 74.00 NOTE
r-release-osx-x86_64 2.0 NOTE
r-oldrel-windows-ix86+x86_64 2.0 10.00 61.00 71.00 NOTE
r-oldrel-osx-x86_64 2.0 NOTE

Check Details

Version: 2.0
Check: DESCRIPTION meta-information
Result: NOTE
    BugReports field is not a suitable URL but contains an email address:
     use the Contact field instead
Flavors: r-devel-linux-x86_64-debian-clang, r-devel-linux-x86_64-debian-gcc, r-devel-linux-x86_64-fedora-clang, r-devel-linux-x86_64-fedora-gcc, r-devel-windows-ix86+x86_64, r-devel-windows-ix86+x86_64-gcc8, r-patched-linux-x86_64, r-patched-solaris-x86, r-release-linux-x86_64, r-release-windows-ix86+x86_64

Version: 2.0
Check: examples
Result: ERROR
    Running examples in 'bayesDccGarch-Ex.R' failed
    The error most likely occurred in:
    
    > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
    > ### Name: bayesDccGarch-package
    > ### Title: bayesDccGARCH: Methods and tools for Bayesian analysis of
    > ### DCC-GARCH(1,1) Model.
    > ### Aliases: bayesDccGarch-package
    > ### Keywords: package multivariate DCC-GARCH GARCH Bayes
    >
    > ### ** Examples
    >
    >
    > data(DaxCacNik)
    > Dax = DaxCacNik[,1]
    >
    > ### DCC-GARCH(1,1) ###
    > out = bayesDccGarch(DaxCacNik[1:10,], nSim=1000) # more data is necessary
    Maximizing the log-posterior density function.
    Done.
    One approximation for covariance matrix of parameters cannot be directly computed through the hessian matrix.
    Calibrating the standard deviations for simulation:
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.29 0.91 0.71 0.86 0.91 0.91 0.65 0.90 0.92 0.92 0.74
    phi_12 phi_13 phi_14 phi_15
     0.88 0.93 0.73 0.66
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.25 0.86 0.67 0.79 0.87 0.88 0.54 0.84 0.87 0.86 0.61
    phi_12 phi_13 phi_14 phi_15
     0.84 0.87 0.64 0.54
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.87 0.20 0.66 0.80 0.88 0.23 0.57 0.81 0.87 0.27 0.53
    phi_12 phi_13 phi_14 phi_15
     0.75 0.84 0.56 0.48
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.82 0.21 0.52 0.70 0.82 0.22 0.49 0.73 0.81 0.24 0.43
    phi_12 phi_13 phi_14 phi_15
     0.69 0.80 0.45 0.45
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.80 0.20 0.44 0.63 0.78 0.24 0.48 0.59 0.73 0.27 0.45
    phi_12 phi_13 phi_14 phi_15
     0.62 0.74 0.43 0.51
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.12 0.81 0.41 0.47 0.68 0.86 0.41 0.55 0.65 0.81 0.44
    phi_12 phi_13 phi_14 phi_15
     0.50 0.63 0.41 0.34
    Computing the covariance matrix of pilot sample.
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    bayesDccGarch
     --- call from context ---
    bayesDccGarch(DaxCacNik[1:10, ], nSim = 1000)
     --- call from argument ---
    if (class(control$cholCov) != "try-error") {
     writeLines("Done.")
     option = 1
    } else {
     control$cholCov = NULL
     writeLines("The approximately covariance matrix is not positive definitely.")
     option = 2
    }
     --- R stacktrace ---
    where 1: bayesDccGarch(DaxCacNik[1:10, ], nSim = 1000)
    
     --- value of length: 2 type: logical ---
    [1] TRUE TRUE
     --- function from context ---
    function (mY, nSim = 10000, tail_ini = 8, omega_ini = rep(0.03,
     ncol(mY)), alpha_ini = rep(0.03, ncol(mY)), beta_ini = rep(0.8,
     ncol(mY)), a_ini = 0.03, b_ini = 0.8, gamma_ini = rep(1,
     ncol(mY)), errorDist = 2, control = list())
    {
     ptm <- proc.time()
     if (missing(mY))
     stop("'mY' is missing")
     if (any(is.na(mY)))
     stop("'mY' contains 'NA' values")
     if (errorDist == 3 && tail_ini == 8) {
     tail_ini = 2
     }
     mY = as.matrix(mY)
     n = nrow(mY)
     k = ncol(mY)
     if (k == 1) {
     npar = 5
     }
     else {
     npar = 4 * k + 3
     }
     Lout = try(logLikDccGarch(mY, omega_ini, alpha_ini, beta_ini,
     a_ini, b_ini, gamma_ini, tail_ini, errorDist))
     if (class(Lout) == "try-error")
     stop("The likelihood function can not be computed for the initial values.")
     if (!is.list(control))
     stop("control must be an object of list class.")
     if (is.null(control$data)) {
     control$data = mY
     }
     if (is.null(control$errorDist)) {
     control$errorDist = errorDist
     }
     if (is.null(control$mu_a)) {
     control$mu_a = 0
     }
     else {
     if (length(control$mu_a) != 1) {
     stop("control$mu_a must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$mu_b)) {
     control$mu_b = 0
     }
     else {
     if (length(control$mu_b) != 1) {
     stop("control$mu_b must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$mu_omega)) {
     control$mu_omega = rep(0, k)
     }
     else {
     if (length(control$mu_omega) != k) {
     stop("control$mu_omega must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_alpha)) {
     control$mu_alpha = rep(0, k)
     }
     else {
     if (length(control$mu_alpha) != k) {
     stop("control$mu_alpha must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_beta)) {
     control$mu_beta = rep(0, k)
     }
     else {
     if (length(control$mu_beta) != k) {
     stop("control$mu_beta must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_gamma)) {
     control$mu_gamma = rep(0, k)
     }
     else {
     if (length(control$mu_gamma) != k) {
     stop("control$mu_gamma must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_tail)) {
     control$mu_tail = 0
     }
     else {
     if (length(control$mu_tail) != 1) {
     stop("control$mu_tail must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$sigma_a)) {
     control$sigma_a = 10
     }
     else {
     if (length(control$sigma_a) != 1) {
     stop("control$sigma_a must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$sigma_b)) {
     control$sigma_b = 10
     }
     else {
     if (length(control$sigma_b) != 1) {
     stop("control$sigma_b must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$sigma_omega)) {
     control$sigma_omega = rep(10, k)
     }
     else {
     if (length(control$sigma_omega) != k) {
     stop("control$sigma_omega must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_alpha)) {
     control$sigma_alpha = rep(10, k)
     }
     else {
     if (length(control$sigma_alpha) != k) {
     stop("control$sigma_alpha must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_beta)) {
     control$sigma_beta = rep(10, k)
     }
     else {
     if (length(control$sigma_beta) != k) {
     stop("control$sigma_beta must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_gamma)) {
     control$sigma_gamma = rep(10, k)
     }
     else {
     if (length(control$sigma_gamma) != k) {
     stop("control$sigma_gamma must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_tail)) {
     control$sigma_tail = 1.25
     }
     else {
     if (length(control$sigma_tail) != 1) {
     stop("control$sigma_tail must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$print)) {
     control$print = 1
     }
     else {
     if (!any(control$print == 0:1))
     control$print = 1
     }
     if (is.null(control$simAlg)) {
     control$simAlg = 3
     }
     else {
     if (!any(control$simAlg == 1:3))
     control$simAlg = 3
     }
     if (control$simAlg == 1) {
     option = 1
     if (is.null(control$cholCov)) {
     stop("control$cholCov was not found.")
     }
     else {
     if (!is.matrix(control$cholCov)) {
     stop("control$cholCov must be a positive definite matrix of dimension 5x5 if k=1 or (4k+3)x(4k+3) if k>1, where 'k=ncol(mY)'")
     }
     else {
     if (ncol(control$cholCov) != npar || nrow(control$cholCov) !=
     npar) {
     stop("control$cholCov must be a positive definite matrix of dimension 5x5 if k=1 or (4k+3)x(4k+3) if k>1, where 'k=ncol(mY)'")
     }
     }
     }
     }
     if (control$simAlg == 2 && !is.null(control$sdSim)) {
     option = 2
     if (length(control$sdSim) != npar)
     stop("control$sdSim must be a numeric positive vector with length 5 if k=1 or 4k+3 if k>1, where 'k=ncol(mY)'")
     }
     if (control$simAlg == 3) {
     if (k == 1) {
     control$sdSim = c(0.2, 0.2, 0.4, 0.4, 0.2)
     }
     else {
     control$sdSim = c(0.2, rep(c(0.2, 0.4, 0.4, 0.2),
     k), 1, 1.5)
     }
     }
     if (is.null(control$lambda)) {
     control$lambda = 0.5
     }
     if (is.null(control$nPilotSim)) {
     control$nPilotSim = 1000
     }
     phi_ini = .C("original_to_real_scale", phi = numeric(4 *
     k + 3), omega = as.double(omega_ini), alpha = as.double(alpha_ini),
     beta = as.double(beta_ini), a = as.double(a_ini), b = as.double(b_ini),
     gamma = as.double(gamma_ini), tail = as.double(tail_ini),
     k = as.integer(k), errorDist = as.integer(errorDist))$phi
     memoryAllocation(mY, errorDist, control$mu_omega, control$sigma_omega,
     control$mu_alpha, control$sigma_alpha, control$mu_beta,
     control$sigma_beta, control$mu_a, control$sigma_a, control$mu_b,
     control$sigma_b, control$mu_gamma, control$sigma_gamma,
     control$mu_tail, control$sigma_tail, control$print)
     if (control$simAlg == 3) {
     writeLines("Maximizing the log-posterior density function.")
     if (k == 1)
     phi_ini = phi_ini[1:5]
     opt = optim(par = phi_ini, fn = logPosterior_phi, hessian = TRUE,
     control = list(fnscale = -abs(Lout$value)))
     if (k == 1)
     phi_ini = c(phi_ini, -2, 1)
     if (opt$convergence == 0 || opt$convergence == 1) {
     writeLines("Done.")
     phi_ini = opt$par
     if (k == 1)
     phi_ini = c(phi_ini, -2, 1)
     control$cholCov = try(t(chol(solve(-opt$hessian))),
     silent = TRUE)
     if (class(control$cholCov) != "try-error") {
     option = 1
     }
     else {
     writeLines("One approximation for covariance matrix of parameters cannot be directly computed through the hessian matrix.")
     option = 2
     }
     }
     else {
     writeLines("The optim function convergence was not obtained.")
     option = 2
     }
     }
     repeat {
     if (option == 1 && control$simAlg != 2) {
     if (control$simAlg == 3) {
     writeLines("Calibrating the Lambda coefficient:")
     cont = 1
     proceed = TRUE
     while (proceed) {
     writeLines(paste("lambda:", control$lambda))
     MC_phi = MH_oneBlock(phi_ini, k, n_sim = control$nPilotSim,
     control$lambda * control$cholCov)
     acceptRate = 1 - rejectionRate(MC_phi)[5]
     writeLines(paste("Accept Rate:", round(acceptRate,
     2)))
     if (acceptRate > 0.2 && acceptRate < 0.5 ||
     cont > 5) {
     proceed = FALSE
     }
     else {
     cont = cont + 1
     if (acceptRate < 0.2) {
     control$lambda = control$lambda * 0.8
     }
     if (acceptRate > 0.5) {
     control$lambda = control$lambda * 1.2
     }
     }
     }
     writeLines("Done.")
     }
     writeLines("Starting the simulation by one-block random walk Metropolis-Hasting algorithm.")
     MC_phi = MH_oneBlock(phi_ini, k, n_sim = nSim, control$lambda *
     control$cholCov)
     writeLines("Done.")
     break
     }
     if (option == 2 && control$simAlg != 1) {
     if (control$simAlg == 3) {
     writeLines("Calibrating the standard deviations for simulation:")
     proceed = TRUE
     cont = 1
     while (proceed) {
     MC_phi = MH_oneDimension(phi_ini, k = k, n_sim = control$nPilotSim,
     control$sdSim)
     acceptRate = 1 - rejectionRate(MC_phi)
     writeLines("Accept Rate:")
     print(round(acceptRate, 2))
     if (errorDist == 1) {
     acceptRate[1] = 0.3
     }
     lowerRate = which(acceptRate < 0.15)
     upperRate = which(acceptRate > 0.5)
     if (length(lowerRate) == 0 && length(upperRate) ==
     0 || cont > 5) {
     proceed = FALSE
     }
     else {
     cont = cont + 1
     control$sdSim[lowerRate] = control$sdSim[lowerRate] *
     0.6
     control$sdSim[upperRate] = control$sdSim[upperRate] *
     1.4
     }
     }
     if (errorDist == 1) {
     MC_phi[, 1] = rnorm(control$nPilotSim)
     }
     writeLines("Computing the covariance matrix of pilot sample.")
     control$cholCov = try(t(chol(cov(MC_phi))), silent = TRUE)
     if (class(control$cholCov) != "try-error") {
     writeLines("Done.")
     option = 1
     }
     else {
     control$cholCov = NULL
     writeLines("The approximately covariance matrix is not positive definitely.")
     option = 2
     }
     }
     if (option == 2) {
     writeLines("Starting the simulation by one-dimensional random walk Metropolis-Hasting algorithm.")
     MC_phi = MH_oneDimension(phi_ini, k = k, n_sim = nSim,
     sd_phi_sim = control$sdSim)
     writeLines("Done.")
     break
     }
     }
     }
     vMMeanH = .C("getMeanH", vMMeanH = numeric(n * k * k))$vMMeanH
     mMeanH = matrix(vMMeanH, nrow = n, ncol = k * k, byrow = TRUE)
     name = rep("NA", k * k)
     for (i in 1:k) {
     for (j in 1:k) {
     name[(i - 1) * k + j] = paste("H_", i, ",", j, sep = "")
     }
     }
     colnames(mMeanH) = name
     logLike_mean = .C("getLogLikelihood_mean", value = numeric(1))$value
     memoryDeallocation()
     name = rep("NA", npar)
     MC = matrix(NA, nrow = nSim, ncol = npar)
     if (errorDist == 1 || errorDist == 3) {
     MC[, 1] = exp(MC_phi[, 1])
     name[1] = "delta"
     }
     if (errorDist == 2) {
     MC[, 1] = exp(MC_phi[, 1]) + 2
     name[1] = "nu"
     }
     for (i in 1:k) {
     MC[, 4 * (i - 1) + 2:5] = cbind(exp(MC_phi[, 4 * (i -
     1) + 2:3]), exp(MC_phi[, 4 * (i - 1) + 4:5])/(1 +
     exp(MC_phi[, 4 * (i - 1) + 4:5])))
     name[4 * (i - 1) + 2:5] = paste(c("gamma", "omega", "alpha",
     "beta"), "_", i, sep = "")
     }
     if (k > 1) {
     MC[, 4 * k + 2:3] = exp(MC_phi[, 4 * k + 2:3])/(1 + exp(MC_phi[,
     4 * k + 2:3]))
     name[4 * k + 2:3] = c("a", "b")
     }
     colnames(MC) = name
     D_mean = -2 * logLike_mean
     par_est = apply(X = MC, MARGIN = 2, FUN = mean)
     tail_est = par_est[1]
     gamma_est = par_est[2 + 4 * (0:(k - 1))]
     omega_est = par_est[3 + 4 * (0:(k - 1))]
     alpha_est = par_est[4 + 4 * (0:(k - 1))]
     beta_est = par_est[5 + 4 * (0:(k - 1))]
     if (k > 1) {
     a_est = par_est[2 + 4 * k]
     b_est = par_est[3 + 4 * k]
     }
     else {
     a_est = 0.1
     b_est = 0.1
     }
     D_at_mean = -2 * logLikDccGarch(mY, omega_est, alpha_est,
     beta_est, a_est, b_est, gamma_est, tail_est, errorDist)$value
     if (errorDist == 1) {
     EAIC = D_mean + 2 * (npar - 1)
     EBIC = D_mean + (npar - 1) * log(n)
     }
     else {
     EAIC = D_mean + 2 * npar
     EBIC = D_mean + npar * log(n)
     }
     DIC = D_at_mean + 2 * (D_mean - D_at_mean)
     IC = matrix(c(EAIC, EBIC, DIC), nrow = 3, ncol = 1)
     rownames(IC) = c("EAIC", "EBIC", "DIC")
     colnames(IC) = c("Estimative")
     out = list()
     out$control = control
     out$MC = as.mcmc(MC)
     out$H = mMeanH
     out$IC = IC
     out$elapsedTime = proc.time() - ptm
     return(structure(out, class = "bayesDccGarch"))
    }
    <bytecode: 0x376add0>
    <environment: namespace:bayesDccGarch>
     --- function search by body ---
    Function bayesDccGarch in namespace bayesDccGarch has this body.
     ----------- END OF FAILURE REPORT --------------
    Error in if (class(control$cholCov) != "try-error") { :
     the condition has length > 1
    Calls: bayesDccGarch
    Execution halted
Flavor: r-devel-linux-x86_64-debian-clang

Version: 2.0
Check: examples
Result: ERROR
    Running examples in ‘bayesDccGarch-Ex.R’ failed
    The error most likely occurred in:
    
    > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
    > ### Name: bayesDccGarch-package
    > ### Title: bayesDccGARCH: Methods and tools for Bayesian analysis of
    > ### DCC-GARCH(1,1) Model.
    > ### Aliases: bayesDccGarch-package
    > ### Keywords: package multivariate DCC-GARCH GARCH Bayes
    >
    > ### ** Examples
    >
    >
    > data(DaxCacNik)
    > Dax = DaxCacNik[,1]
    >
    > ### DCC-GARCH(1,1) ###
    > out = bayesDccGarch(DaxCacNik[1:10,], nSim=1000) # more data is necessary
    Maximizing the log-posterior density function.
    Done.
    One approximation for covariance matrix of parameters cannot be directly computed through the hessian matrix.
    Calibrating the standard deviations for simulation:
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.29 0.91 0.71 0.86 0.91 0.91 0.65 0.90 0.92 0.92 0.74
    phi_12 phi_13 phi_14 phi_15
     0.88 0.93 0.73 0.66
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.25 0.86 0.67 0.79 0.87 0.88 0.54 0.84 0.87 0.86 0.61
    phi_12 phi_13 phi_14 phi_15
     0.84 0.87 0.64 0.54
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.87 0.20 0.66 0.80 0.88 0.23 0.57 0.81 0.87 0.27 0.53
    phi_12 phi_13 phi_14 phi_15
     0.75 0.84 0.56 0.48
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.82 0.21 0.52 0.70 0.82 0.22 0.49 0.73 0.81 0.24 0.43
    phi_12 phi_13 phi_14 phi_15
     0.69 0.80 0.45 0.45
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.80 0.20 0.44 0.63 0.78 0.24 0.48 0.59 0.73 0.27 0.45
    phi_12 phi_13 phi_14 phi_15
     0.62 0.74 0.43 0.51
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.12 0.81 0.41 0.47 0.68 0.86 0.41 0.55 0.65 0.81 0.44
    phi_12 phi_13 phi_14 phi_15
     0.50 0.63 0.41 0.34
    Computing the covariance matrix of pilot sample.
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    bayesDccGarch
     --- call from context ---
    bayesDccGarch(DaxCacNik[1:10, ], nSim = 1000)
     --- call from argument ---
    if (class(control$cholCov) != "try-error") {
     writeLines("Done.")
     option = 1
    } else {
     control$cholCov = NULL
     writeLines("The approximately covariance matrix is not positive definitely.")
     option = 2
    }
     --- R stacktrace ---
    where 1: bayesDccGarch(DaxCacNik[1:10, ], nSim = 1000)
    
     --- value of length: 2 type: logical ---
    [1] TRUE TRUE
     --- function from context ---
    function (mY, nSim = 10000, tail_ini = 8, omega_ini = rep(0.03,
     ncol(mY)), alpha_ini = rep(0.03, ncol(mY)), beta_ini = rep(0.8,
     ncol(mY)), a_ini = 0.03, b_ini = 0.8, gamma_ini = rep(1,
     ncol(mY)), errorDist = 2, control = list())
    {
     ptm <- proc.time()
     if (missing(mY))
     stop("'mY' is missing")
     if (any(is.na(mY)))
     stop("'mY' contains 'NA' values")
     if (errorDist == 3 && tail_ini == 8) {
     tail_ini = 2
     }
     mY = as.matrix(mY)
     n = nrow(mY)
     k = ncol(mY)
     if (k == 1) {
     npar = 5
     }
     else {
     npar = 4 * k + 3
     }
     Lout = try(logLikDccGarch(mY, omega_ini, alpha_ini, beta_ini,
     a_ini, b_ini, gamma_ini, tail_ini, errorDist))
     if (class(Lout) == "try-error")
     stop("The likelihood function can not be computed for the initial values.")
     if (!is.list(control))
     stop("control must be an object of list class.")
     if (is.null(control$data)) {
     control$data = mY
     }
     if (is.null(control$errorDist)) {
     control$errorDist = errorDist
     }
     if (is.null(control$mu_a)) {
     control$mu_a = 0
     }
     else {
     if (length(control$mu_a) != 1) {
     stop("control$mu_a must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$mu_b)) {
     control$mu_b = 0
     }
     else {
     if (length(control$mu_b) != 1) {
     stop("control$mu_b must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$mu_omega)) {
     control$mu_omega = rep(0, k)
     }
     else {
     if (length(control$mu_omega) != k) {
     stop("control$mu_omega must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_alpha)) {
     control$mu_alpha = rep(0, k)
     }
     else {
     if (length(control$mu_alpha) != k) {
     stop("control$mu_alpha must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_beta)) {
     control$mu_beta = rep(0, k)
     }
     else {
     if (length(control$mu_beta) != k) {
     stop("control$mu_beta must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_gamma)) {
     control$mu_gamma = rep(0, k)
     }
     else {
     if (length(control$mu_gamma) != k) {
     stop("control$mu_gamma must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_tail)) {
     control$mu_tail = 0
     }
     else {
     if (length(control$mu_tail) != 1) {
     stop("control$mu_tail must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$sigma_a)) {
     control$sigma_a = 10
     }
     else {
     if (length(control$sigma_a) != 1) {
     stop("control$sigma_a must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$sigma_b)) {
     control$sigma_b = 10
     }
     else {
     if (length(control$sigma_b) != 1) {
     stop("control$sigma_b must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$sigma_omega)) {
     control$sigma_omega = rep(10, k)
     }
     else {
     if (length(control$sigma_omega) != k) {
     stop("control$sigma_omega must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_alpha)) {
     control$sigma_alpha = rep(10, k)
     }
     else {
     if (length(control$sigma_alpha) != k) {
     stop("control$sigma_alpha must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_beta)) {
     control$sigma_beta = rep(10, k)
     }
     else {
     if (length(control$sigma_beta) != k) {
     stop("control$sigma_beta must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_gamma)) {
     control$sigma_gamma = rep(10, k)
     }
     else {
     if (length(control$sigma_gamma) != k) {
     stop("control$sigma_gamma must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_tail)) {
     control$sigma_tail = 1.25
     }
     else {
     if (length(control$sigma_tail) != 1) {
     stop("control$sigma_tail must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$print)) {
     control$print = 1
     }
     else {
     if (!any(control$print == 0:1))
     control$print = 1
     }
     if (is.null(control$simAlg)) {
     control$simAlg = 3
     }
     else {
     if (!any(control$simAlg == 1:3))
     control$simAlg = 3
     }
     if (control$simAlg == 1) {
     option = 1
     if (is.null(control$cholCov)) {
     stop("control$cholCov was not found.")
     }
     else {
     if (!is.matrix(control$cholCov)) {
     stop("control$cholCov must be a positive definite matrix of dimension 5x5 if k=1 or (4k+3)x(4k+3) if k>1, where 'k=ncol(mY)'")
     }
     else {
     if (ncol(control$cholCov) != npar || nrow(control$cholCov) !=
     npar) {
     stop("control$cholCov must be a positive definite matrix of dimension 5x5 if k=1 or (4k+3)x(4k+3) if k>1, where 'k=ncol(mY)'")
     }
     }
     }
     }
     if (control$simAlg == 2 && !is.null(control$sdSim)) {
     option = 2
     if (length(control$sdSim) != npar)
     stop("control$sdSim must be a numeric positive vector with length 5 if k=1 or 4k+3 if k>1, where 'k=ncol(mY)'")
     }
     if (control$simAlg == 3) {
     if (k == 1) {
     control$sdSim = c(0.2, 0.2, 0.4, 0.4, 0.2)
     }
     else {
     control$sdSim = c(0.2, rep(c(0.2, 0.4, 0.4, 0.2),
     k), 1, 1.5)
     }
     }
     if (is.null(control$lambda)) {
     control$lambda = 0.5
     }
     if (is.null(control$nPilotSim)) {
     control$nPilotSim = 1000
     }
     phi_ini = .C("original_to_real_scale", phi = numeric(4 *
     k + 3), omega = as.double(omega_ini), alpha = as.double(alpha_ini),
     beta = as.double(beta_ini), a = as.double(a_ini), b = as.double(b_ini),
     gamma = as.double(gamma_ini), tail = as.double(tail_ini),
     k = as.integer(k), errorDist = as.integer(errorDist))$phi
     memoryAllocation(mY, errorDist, control$mu_omega, control$sigma_omega,
     control$mu_alpha, control$sigma_alpha, control$mu_beta,
     control$sigma_beta, control$mu_a, control$sigma_a, control$mu_b,
     control$sigma_b, control$mu_gamma, control$sigma_gamma,
     control$mu_tail, control$sigma_tail, control$print)
     if (control$simAlg == 3) {
     writeLines("Maximizing the log-posterior density function.")
     if (k == 1)
     phi_ini = phi_ini[1:5]
     opt = optim(par = phi_ini, fn = logPosterior_phi, hessian = TRUE,
     control = list(fnscale = -abs(Lout$value)))
     if (k == 1)
     phi_ini = c(phi_ini, -2, 1)
     if (opt$convergence == 0 || opt$convergence == 1) {
     writeLines("Done.")
     phi_ini = opt$par
     if (k == 1)
     phi_ini = c(phi_ini, -2, 1)
     control$cholCov = try(t(chol(solve(-opt$hessian))),
     silent = TRUE)
     if (class(control$cholCov) != "try-error") {
     option = 1
     }
     else {
     writeLines("One approximation for covariance matrix of parameters cannot be directly computed through the hessian matrix.")
     option = 2
     }
     }
     else {
     writeLines("The optim function convergence was not obtained.")
     option = 2
     }
     }
     repeat {
     if (option == 1 && control$simAlg != 2) {
     if (control$simAlg == 3) {
     writeLines("Calibrating the Lambda coefficient:")
     cont = 1
     proceed = TRUE
     while (proceed) {
     writeLines(paste("lambda:", control$lambda))
     MC_phi = MH_oneBlock(phi_ini, k, n_sim = control$nPilotSim,
     control$lambda * control$cholCov)
     acceptRate = 1 - rejectionRate(MC_phi)[5]
     writeLines(paste("Accept Rate:", round(acceptRate,
     2)))
     if (acceptRate > 0.2 && acceptRate < 0.5 ||
     cont > 5) {
     proceed = FALSE
     }
     else {
     cont = cont + 1
     if (acceptRate < 0.2) {
     control$lambda = control$lambda * 0.8
     }
     if (acceptRate > 0.5) {
     control$lambda = control$lambda * 1.2
     }
     }
     }
     writeLines("Done.")
     }
     writeLines("Starting the simulation by one-block random walk Metropolis-Hasting algorithm.")
     MC_phi = MH_oneBlock(phi_ini, k, n_sim = nSim, control$lambda *
     control$cholCov)
     writeLines("Done.")
     break
     }
     if (option == 2 && control$simAlg != 1) {
     if (control$simAlg == 3) {
     writeLines("Calibrating the standard deviations for simulation:")
     proceed = TRUE
     cont = 1
     while (proceed) {
     MC_phi = MH_oneDimension(phi_ini, k = k, n_sim = control$nPilotSim,
     control$sdSim)
     acceptRate = 1 - rejectionRate(MC_phi)
     writeLines("Accept Rate:")
     print(round(acceptRate, 2))
     if (errorDist == 1) {
     acceptRate[1] = 0.3
     }
     lowerRate = which(acceptRate < 0.15)
     upperRate = which(acceptRate > 0.5)
     if (length(lowerRate) == 0 && length(upperRate) ==
     0 || cont > 5) {
     proceed = FALSE
     }
     else {
     cont = cont + 1
     control$sdSim[lowerRate] = control$sdSim[lowerRate] *
     0.6
     control$sdSim[upperRate] = control$sdSim[upperRate] *
     1.4
     }
     }
     if (errorDist == 1) {
     MC_phi[, 1] = rnorm(control$nPilotSim)
     }
     writeLines("Computing the covariance matrix of pilot sample.")
     control$cholCov = try(t(chol(cov(MC_phi))), silent = TRUE)
     if (class(control$cholCov) != "try-error") {
     writeLines("Done.")
     option = 1
     }
     else {
     control$cholCov = NULL
     writeLines("The approximately covariance matrix is not positive definitely.")
     option = 2
     }
     }
     if (option == 2) {
     writeLines("Starting the simulation by one-dimensional random walk Metropolis-Hasting algorithm.")
     MC_phi = MH_oneDimension(phi_ini, k = k, n_sim = nSim,
     sd_phi_sim = control$sdSim)
     writeLines("Done.")
     break
     }
     }
     }
     vMMeanH = .C("getMeanH", vMMeanH = numeric(n * k * k))$vMMeanH
     mMeanH = matrix(vMMeanH, nrow = n, ncol = k * k, byrow = TRUE)
     name = rep("NA", k * k)
     for (i in 1:k) {
     for (j in 1:k) {
     name[(i - 1) * k + j] = paste("H_", i, ",", j, sep = "")
     }
     }
     colnames(mMeanH) = name
     logLike_mean = .C("getLogLikelihood_mean", value = numeric(1))$value
     memoryDeallocation()
     name = rep("NA", npar)
     MC = matrix(NA, nrow = nSim, ncol = npar)
     if (errorDist == 1 || errorDist == 3) {
     MC[, 1] = exp(MC_phi[, 1])
     name[1] = "delta"
     }
     if (errorDist == 2) {
     MC[, 1] = exp(MC_phi[, 1]) + 2
     name[1] = "nu"
     }
     for (i in 1:k) {
     MC[, 4 * (i - 1) + 2:5] = cbind(exp(MC_phi[, 4 * (i -
     1) + 2:3]), exp(MC_phi[, 4 * (i - 1) + 4:5])/(1 +
     exp(MC_phi[, 4 * (i - 1) + 4:5])))
     name[4 * (i - 1) + 2:5] = paste(c("gamma", "omega", "alpha",
     "beta"), "_", i, sep = "")
     }
     if (k > 1) {
     MC[, 4 * k + 2:3] = exp(MC_phi[, 4 * k + 2:3])/(1 + exp(MC_phi[,
     4 * k + 2:3]))
     name[4 * k + 2:3] = c("a", "b")
     }
     colnames(MC) = name
     D_mean = -2 * logLike_mean
     par_est = apply(X = MC, MARGIN = 2, FUN = mean)
     tail_est = par_est[1]
     gamma_est = par_est[2 + 4 * (0:(k - 1))]
     omega_est = par_est[3 + 4 * (0:(k - 1))]
     alpha_est = par_est[4 + 4 * (0:(k - 1))]
     beta_est = par_est[5 + 4 * (0:(k - 1))]
     if (k > 1) {
     a_est = par_est[2 + 4 * k]
     b_est = par_est[3 + 4 * k]
     }
     else {
     a_est = 0.1
     b_est = 0.1
     }
     D_at_mean = -2 * logLikDccGarch(mY, omega_est, alpha_est,
     beta_est, a_est, b_est, gamma_est, tail_est, errorDist)$value
     if (errorDist == 1) {
     EAIC = D_mean + 2 * (npar - 1)
     EBIC = D_mean + (npar - 1) * log(n)
     }
     else {
     EAIC = D_mean + 2 * npar
     EBIC = D_mean + npar * log(n)
     }
     DIC = D_at_mean + 2 * (D_mean - D_at_mean)
     IC = matrix(c(EAIC, EBIC, DIC), nrow = 3, ncol = 1)
     rownames(IC) = c("EAIC", "EBIC", "DIC")
     colnames(IC) = c("Estimative")
     out = list()
     out$control = control
     out$MC = as.mcmc(MC)
     out$H = mMeanH
     out$IC = IC
     out$elapsedTime = proc.time() - ptm
     return(structure(out, class = "bayesDccGarch"))
    }
    <bytecode: 0x558a69d3f620>
    <environment: namespace:bayesDccGarch>
     --- function search by body ---
    Function bayesDccGarch in namespace bayesDccGarch has this body.
     ----------- END OF FAILURE REPORT --------------
    Error in if (class(control$cholCov) != "try-error") { :
     the condition has length > 1
    Calls: bayesDccGarch
    Execution halted
Flavor: r-devel-linux-x86_64-debian-gcc

Version: 2.0
Check: compiled code
Result: NOTE
    File ‘bayesDccGarch/libs/bayesDccGarch.so’:
     Found no calls to: ‘R_registerRoutines’, ‘R_useDynamicSymbols’
    
    It is good practice to register native routines and to disable symbol
    search.
    
    See ‘Writing portable packages’ in the ‘Writing R Extensions’ manual.
Flavors: r-devel-linux-x86_64-fedora-clang, r-devel-linux-x86_64-fedora-gcc

Version: 2.0
Check: examples
Result: ERROR
    Running examples in ‘bayesDccGarch-Ex.R’ failed
    The error most likely occurred in:
    
    > ### Name: bayesDccGarch-package
    > ### Title: bayesDccGARCH: Methods and tools for Bayesian analysis of
    > ### DCC-GARCH(1,1) Model.
    > ### Aliases: bayesDccGarch-package
    > ### Keywords: package multivariate DCC-GARCH GARCH Bayes
    >
    > ### ** Examples
    >
    >
    > data(DaxCacNik)
    > Dax = DaxCacNik[,1]
    >
    > ### DCC-GARCH(1,1) ###
    > out = bayesDccGarch(DaxCacNik[1:10,], nSim=1000) # more data is necessary
    Maximizing the log-posterior density function.
    Done.
    One approximation for covariance matrix of parameters cannot be directly computed through the hessian matrix.
    Calibrating the standard deviations for simulation:
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.29 0.91 0.71 0.86 0.91 0.91 0.65 0.90 0.92 0.92 0.74
    phi_12 phi_13 phi_14 phi_15
     0.88 0.93 0.73 0.66
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.25 0.86 0.67 0.79 0.87 0.88 0.54 0.84 0.87 0.86 0.61
    phi_12 phi_13 phi_14 phi_15
     0.84 0.87 0.64 0.54
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.87 0.20 0.66 0.80 0.88 0.23 0.57 0.81 0.87 0.27 0.53
    phi_12 phi_13 phi_14 phi_15
     0.75 0.84 0.56 0.48
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.82 0.21 0.52 0.70 0.82 0.22 0.49 0.73 0.81 0.24 0.43
    phi_12 phi_13 phi_14 phi_15
     0.69 0.80 0.45 0.45
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.80 0.20 0.44 0.63 0.78 0.24 0.48 0.59 0.73 0.27 0.45
    phi_12 phi_13 phi_14 phi_15
     0.62 0.74 0.43 0.51
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.12 0.81 0.41 0.47 0.68 0.86 0.41 0.55 0.65 0.81 0.44
    phi_12 phi_13 phi_14 phi_15
     0.50 0.63 0.41 0.34
    Computing the covariance matrix of pilot sample.
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    bayesDccGarch
     --- call from context ---
    bayesDccGarch(DaxCacNik[1:10, ], nSim = 1000)
     --- call from argument ---
    if (class(control$cholCov) != "try-error") {
     writeLines("Done.")
     option = 1
    } else {
     control$cholCov = NULL
     writeLines("The approximately covariance matrix is not positive definitely.")
     option = 2
    }
     --- R stacktrace ---
    where 1: bayesDccGarch(DaxCacNik[1:10, ], nSim = 1000)
    
     --- value of length: 2 type: logical ---
    [1] TRUE TRUE
     --- function from context ---
    function (mY, nSim = 10000, tail_ini = 8, omega_ini = rep(0.03,
     ncol(mY)), alpha_ini = rep(0.03, ncol(mY)), beta_ini = rep(0.8,
     ncol(mY)), a_ini = 0.03, b_ini = 0.8, gamma_ini = rep(1,
     ncol(mY)), errorDist = 2, control = list())
    {
     ptm <- proc.time()
     if (missing(mY))
     stop("'mY' is missing")
     if (any(is.na(mY)))
     stop("'mY' contains 'NA' values")
     if (errorDist == 3 && tail_ini == 8) {
     tail_ini = 2
     }
     mY = as.matrix(mY)
     n = nrow(mY)
     k = ncol(mY)
     if (k == 1) {
     npar = 5
     }
     else {
     npar = 4 * k + 3
     }
     Lout = try(logLikDccGarch(mY, omega_ini, alpha_ini, beta_ini,
     a_ini, b_ini, gamma_ini, tail_ini, errorDist))
     if (class(Lout) == "try-error")
     stop("The likelihood function can not be computed for the initial values.")
     if (!is.list(control))
     stop("control must be an object of list class.")
     if (is.null(control$data)) {
     control$data = mY
     }
     if (is.null(control$errorDist)) {
     control$errorDist = errorDist
     }
     if (is.null(control$mu_a)) {
     control$mu_a = 0
     }
     else {
     if (length(control$mu_a) != 1) {
     stop("control$mu_a must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$mu_b)) {
     control$mu_b = 0
     }
     else {
     if (length(control$mu_b) != 1) {
     stop("control$mu_b must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$mu_omega)) {
     control$mu_omega = rep(0, k)
     }
     else {
     if (length(control$mu_omega) != k) {
     stop("control$mu_omega must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_alpha)) {
     control$mu_alpha = rep(0, k)
     }
     else {
     if (length(control$mu_alpha) != k) {
     stop("control$mu_alpha must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_beta)) {
     control$mu_beta = rep(0, k)
     }
     else {
     if (length(control$mu_beta) != k) {
     stop("control$mu_beta must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_gamma)) {
     control$mu_gamma = rep(0, k)
     }
     else {
     if (length(control$mu_gamma) != k) {
     stop("control$mu_gamma must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_tail)) {
     control$mu_tail = 0
     }
     else {
     if (length(control$mu_tail) != 1) {
     stop("control$mu_tail must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$sigma_a)) {
     control$sigma_a = 10
     }
     else {
     if (length(control$sigma_a) != 1) {
     stop("control$sigma_a must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$sigma_b)) {
     control$sigma_b = 10
     }
     else {
     if (length(control$sigma_b) != 1) {
     stop("control$sigma_b must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$sigma_omega)) {
     control$sigma_omega = rep(10, k)
     }
     else {
     if (length(control$sigma_omega) != k) {
     stop("control$sigma_omega must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_alpha)) {
     control$sigma_alpha = rep(10, k)
     }
     else {
     if (length(control$sigma_alpha) != k) {
     stop("control$sigma_alpha must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_beta)) {
     control$sigma_beta = rep(10, k)
     }
     else {
     if (length(control$sigma_beta) != k) {
     stop("control$sigma_beta must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_gamma)) {
     control$sigma_gamma = rep(10, k)
     }
     else {
     if (length(control$sigma_gamma) != k) {
     stop("control$sigma_gamma must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_tail)) {
     control$sigma_tail = 1.25
     }
     else {
     if (length(control$sigma_tail) != 1) {
     stop("control$sigma_tail must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$print)) {
     control$print = 1
     }
     else {
     if (!any(control$print == 0:1))
     control$print = 1
     }
     if (is.null(control$simAlg)) {
     control$simAlg = 3
     }
     else {
     if (!any(control$simAlg == 1:3))
     control$simAlg = 3
     }
     if (control$simAlg == 1) {
     option = 1
     if (is.null(control$cholCov)) {
     stop("control$cholCov was not found.")
     }
     else {
     if (!is.matrix(control$cholCov)) {
     stop("control$cholCov must be a positive definite matrix of dimension 5x5 if k=1 or (4k+3)x(4k+3) if k>1, where 'k=ncol(mY)'")
     }
     else {
     if (ncol(control$cholCov) != npar || nrow(control$cholCov) !=
     npar) {
     stop("control$cholCov must be a positive definite matrix of dimension 5x5 if k=1 or (4k+3)x(4k+3) if k>1, where 'k=ncol(mY)'")
     }
     }
     }
     }
     if (control$simAlg == 2 && !is.null(control$sdSim)) {
     option = 2
     if (length(control$sdSim) != npar)
     stop("control$sdSim must be a numeric positive vector with length 5 if k=1 or 4k+3 if k>1, where 'k=ncol(mY)'")
     }
     if (control$simAlg == 3) {
     if (k == 1) {
     control$sdSim = c(0.2, 0.2, 0.4, 0.4, 0.2)
     }
     else {
     control$sdSim = c(0.2, rep(c(0.2, 0.4, 0.4, 0.2),
     k), 1, 1.5)
     }
     }
     if (is.null(control$lambda)) {
     control$lambda = 0.5
     }
     if (is.null(control$nPilotSim)) {
     control$nPilotSim = 1000
     }
     phi_ini = .C("original_to_real_scale", phi = numeric(4 *
     k + 3), omega = as.double(omega_ini), alpha = as.double(alpha_ini),
     beta = as.double(beta_ini), a = as.double(a_ini), b = as.double(b_ini),
     gamma = as.double(gamma_ini), tail = as.double(tail_ini),
     k = as.integer(k), errorDist = as.integer(errorDist))$phi
     memoryAllocation(mY, errorDist, control$mu_omega, control$sigma_omega,
     control$mu_alpha, control$sigma_alpha, control$mu_beta,
     control$sigma_beta, control$mu_a, control$sigma_a, control$mu_b,
     control$sigma_b, control$mu_gamma, control$sigma_gamma,
     control$mu_tail, control$sigma_tail, control$print)
     if (control$simAlg == 3) {
     writeLines("Maximizing the log-posterior density function.")
     if (k == 1)
     phi_ini = phi_ini[1:5]
     opt = optim(par = phi_ini, fn = logPosterior_phi, hessian = TRUE,
     control = list(fnscale = -abs(Lout$value)))
     if (k == 1)
     phi_ini = c(phi_ini, -2, 1)
     if (opt$convergence == 0 || opt$convergence == 1) {
     writeLines("Done.")
     phi_ini = opt$par
     if (k == 1)
     phi_ini = c(phi_ini, -2, 1)
     control$cholCov = try(t(chol(solve(-opt$hessian))),
     silent = TRUE)
     if (class(control$cholCov) != "try-error") {
     option = 1
     }
     else {
     writeLines("One approximation for covariance matrix of parameters cannot be directly computed through the hessian matrix.")
     option = 2
     }
     }
     else {
     writeLines("The optim function convergence was not obtained.")
     option = 2
     }
     }
     repeat {
     if (option == 1 && control$simAlg != 2) {
     if (control$simAlg == 3) {
     writeLines("Calibrating the Lambda coefficient:")
     cont = 1
     proceed = TRUE
     while (proceed) {
     writeLines(paste("lambda:", control$lambda))
     MC_phi = MH_oneBlock(phi_ini, k, n_sim = control$nPilotSim,
     control$lambda * control$cholCov)
     acceptRate = 1 - rejectionRate(MC_phi)[5]
     writeLines(paste("Accept Rate:", round(acceptRate,
     2)))
     if (acceptRate > 0.2 && acceptRate < 0.5 ||
     cont > 5) {
     proceed = FALSE
     }
     else {
     cont = cont + 1
     if (acceptRate < 0.2) {
     control$lambda = control$lambda * 0.8
     }
     if (acceptRate > 0.5) {
     control$lambda = control$lambda * 1.2
     }
     }
     }
     writeLines("Done.")
     }
     writeLines("Starting the simulation by one-block random walk Metropolis-Hasting algorithm.")
     MC_phi = MH_oneBlock(phi_ini, k, n_sim = nSim, control$lambda *
     control$cholCov)
     writeLines("Done.")
     break
     }
     if (option == 2 && control$simAlg != 1) {
     if (control$simAlg == 3) {
     writeLines("Calibrating the standard deviations for simulation:")
     proceed = TRUE
     cont = 1
     while (proceed) {
     MC_phi = MH_oneDimension(phi_ini, k = k, n_sim = control$nPilotSim,
     control$sdSim)
     acceptRate = 1 - rejectionRate(MC_phi)
     writeLines("Accept Rate:")
     print(round(acceptRate, 2))
     if (errorDist == 1) {
     acceptRate[1] = 0.3
     }
     lowerRate = which(acceptRate < 0.15)
     upperRate = which(acceptRate > 0.5)
     if (length(lowerRate) == 0 && length(upperRate) ==
     0 || cont > 5) {
     proceed = FALSE
     }
     else {
     cont = cont + 1
     control$sdSim[lowerRate] = control$sdSim[lowerRate] *
     0.6
     control$sdSim[upperRate] = control$sdSim[upperRate] *
     1.4
     }
     }
     if (errorDist == 1) {
     MC_phi[, 1] = rnorm(control$nPilotSim)
     }
     writeLines("Computing the covariance matrix of pilot sample.")
     control$cholCov = try(t(chol(cov(MC_phi))), silent = TRUE)
     if (class(control$cholCov) != "try-error") {
     writeLines("Done.")
     option = 1
     }
     else {
     control$cholCov = NULL
     writeLines("The approximately covariance matrix is not positive definitely.")
     option = 2
     }
     }
     if (option == 2) {
     writeLines("Starting the simulation by one-dimensional random walk Metropolis-Hasting algorithm.")
     MC_phi = MH_oneDimension(phi_ini, k = k, n_sim = nSim,
     sd_phi_sim = control$sdSim)
     writeLines("Done.")
     break
     }
     }
     }
     vMMeanH = .C("getMeanH", vMMeanH = numeric(n * k * k))$vMMeanH
     mMeanH = matrix(vMMeanH, nrow = n, ncol = k * k, byrow = TRUE)
     name = rep("NA", k * k)
     for (i in 1:k) {
     for (j in 1:k) {
     name[(i - 1) * k + j] = paste("H_", i, ",", j, sep = "")
     }
     }
     colnames(mMeanH) = name
     logLike_mean = .C("getLogLikelihood_mean", value = numeric(1))$value
     memoryDeallocation()
     name = rep("NA", npar)
     MC = matrix(NA, nrow = nSim, ncol = npar)
     if (errorDist == 1 || errorDist == 3) {
     MC[, 1] = exp(MC_phi[, 1])
     name[1] = "delta"
     }
     if (errorDist == 2) {
     MC[, 1] = exp(MC_phi[, 1]) + 2
     name[1] = "nu"
     }
     for (i in 1:k) {
     MC[, 4 * (i - 1) + 2:5] = cbind(exp(MC_phi[, 4 * (i -
     1) + 2:3]), exp(MC_phi[, 4 * (i - 1) + 4:5])/(1 +
     exp(MC_phi[, 4 * (i - 1) + 4:5])))
     name[4 * (i - 1) + 2:5] = paste(c("gamma", "omega", "alpha",
     "beta"), "_", i, sep = "")
     }
     if (k > 1) {
     MC[, 4 * k + 2:3] = exp(MC_phi[, 4 * k + 2:3])/(1 + exp(MC_phi[,
     4 * k + 2:3]))
     name[4 * k + 2:3] = c("a", "b")
     }
     colnames(MC) = name
     D_mean = -2 * logLike_mean
     par_est = apply(X = MC, MARGIN = 2, FUN = mean)
     tail_est = par_est[1]
     gamma_est = par_est[2 + 4 * (0:(k - 1))]
     omega_est = par_est[3 + 4 * (0:(k - 1))]
     alpha_est = par_est[4 + 4 * (0:(k - 1))]
     beta_est = par_est[5 + 4 * (0:(k - 1))]
     if (k > 1) {
     a_est = par_est[2 + 4 * k]
     b_est = par_est[3 + 4 * k]
     }
     else {
     a_est = 0.1
     b_est = 0.1
     }
     D_at_mean = -2 * logLikDccGarch(mY, omega_est, alpha_est,
     beta_est, a_est, b_est, gamma_est, tail_est, errorDist)$value
     if (errorDist == 1) {
     EAIC = D_mean + 2 * (npar - 1)
     EBIC = D_mean + (npar - 1) * log(n)
     }
     else {
     EAIC = D_mean + 2 * npar
     EBIC = D_mean + npar * log(n)
     }
     DIC = D_at_mean + 2 * (D_mean - D_at_mean)
     IC = matrix(c(EAIC, EBIC, DIC), nrow = 3, ncol = 1)
     rownames(IC) = c("EAIC", "EBIC", "DIC")
     colnames(IC) = c("Estimative")
     out = list()
     out$control = control
     out$MC = as.mcmc(MC)
     out$H = mMeanH
     out$IC = IC
     out$elapsedTime = proc.time() - ptm
     return(structure(out, class = "bayesDccGarch"))
    }
    <bytecode: 0x2e71ae8>
    <environment: namespace:bayesDccGarch>
     --- function search by body ---
    Function bayesDccGarch in namespace bayesDccGarch has this body.
     ----------- END OF FAILURE REPORT --------------
    Error in if (class(control$cholCov) != "try-error") { :
     the condition has length > 1
    Calls: bayesDccGarch
    Execution halted
Flavor: r-devel-linux-x86_64-fedora-clang

Version: 2.0
Check: examples
Result: ERROR
    Running examples in ‘bayesDccGarch-Ex.R’ failed
    The error most likely occurred in:
    
    > ### Name: bayesDccGarch-package
    > ### Title: bayesDccGARCH: Methods and tools for Bayesian analysis of
    > ### DCC-GARCH(1,1) Model.
    > ### Aliases: bayesDccGarch-package
    > ### Keywords: package multivariate DCC-GARCH GARCH Bayes
    >
    > ### ** Examples
    >
    >
    > data(DaxCacNik)
    > Dax = DaxCacNik[,1]
    >
    > ### DCC-GARCH(1,1) ###
    > out = bayesDccGarch(DaxCacNik[1:10,], nSim=1000) # more data is necessary
    Maximizing the log-posterior density function.
    Done.
    One approximation for covariance matrix of parameters cannot be directly computed through the hessian matrix.
    Calibrating the standard deviations for simulation:
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.29 0.91 0.71 0.86 0.91 0.91 0.65 0.90 0.92 0.92 0.74
    phi_12 phi_13 phi_14 phi_15
     0.88 0.93 0.73 0.66
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.25 0.86 0.67 0.79 0.87 0.88 0.54 0.84 0.87 0.86 0.61
    phi_12 phi_13 phi_14 phi_15
     0.84 0.87 0.64 0.54
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.87 0.20 0.66 0.80 0.88 0.23 0.57 0.81 0.87 0.27 0.53
    phi_12 phi_13 phi_14 phi_15
     0.75 0.84 0.56 0.48
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.82 0.21 0.52 0.70 0.82 0.22 0.49 0.73 0.81 0.24 0.43
    phi_12 phi_13 phi_14 phi_15
     0.69 0.80 0.45 0.45
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.80 0.20 0.44 0.63 0.78 0.24 0.48 0.59 0.73 0.27 0.45
    phi_12 phi_13 phi_14 phi_15
     0.62 0.74 0.43 0.51
    Simulation number = 100
    Simulation number = 200
    Simulation number = 300
    Simulation number = 400
    Simulation number = 500
    Simulation number = 600
    Simulation number = 700
    Simulation number = 800
    Simulation number = 900
    Simulation number = 1000
    Accept Rate:
     phi_1 phi_2 phi_3 phi_4 phi_5 phi_6 phi_7 phi_8 phi_9 phi_10 phi_11
     0.12 0.81 0.41 0.47 0.68 0.86 0.41 0.55 0.65 0.81 0.44
    phi_12 phi_13 phi_14 phi_15
     0.50 0.63 0.41 0.34
    Computing the covariance matrix of pilot sample.
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    bayesDccGarch
     --- call from context ---
    bayesDccGarch(DaxCacNik[1:10, ], nSim = 1000)
     --- call from argument ---
    if (class(control$cholCov) != "try-error") {
     writeLines("Done.")
     option = 1
    } else {
     control$cholCov = NULL
     writeLines("The approximately covariance matrix is not positive definitely.")
     option = 2
    }
     --- R stacktrace ---
    where 1: bayesDccGarch(DaxCacNik[1:10, ], nSim = 1000)
    
     --- value of length: 2 type: logical ---
    [1] TRUE TRUE
     --- function from context ---
    function (mY, nSim = 10000, tail_ini = 8, omega_ini = rep(0.03,
     ncol(mY)), alpha_ini = rep(0.03, ncol(mY)), beta_ini = rep(0.8,
     ncol(mY)), a_ini = 0.03, b_ini = 0.8, gamma_ini = rep(1,
     ncol(mY)), errorDist = 2, control = list())
    {
     ptm <- proc.time()
     if (missing(mY))
     stop("'mY' is missing")
     if (any(is.na(mY)))
     stop("'mY' contains 'NA' values")
     if (errorDist == 3 && tail_ini == 8) {
     tail_ini = 2
     }
     mY = as.matrix(mY)
     n = nrow(mY)
     k = ncol(mY)
     if (k == 1) {
     npar = 5
     }
     else {
     npar = 4 * k + 3
     }
     Lout = try(logLikDccGarch(mY, omega_ini, alpha_ini, beta_ini,
     a_ini, b_ini, gamma_ini, tail_ini, errorDist))
     if (class(Lout) == "try-error")
     stop("The likelihood function can not be computed for the initial values.")
     if (!is.list(control))
     stop("control must be an object of list class.")
     if (is.null(control$data)) {
     control$data = mY
     }
     if (is.null(control$errorDist)) {
     control$errorDist = errorDist
     }
     if (is.null(control$mu_a)) {
     control$mu_a = 0
     }
     else {
     if (length(control$mu_a) != 1) {
     stop("control$mu_a must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$mu_b)) {
     control$mu_b = 0
     }
     else {
     if (length(control$mu_b) != 1) {
     stop("control$mu_b must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$mu_omega)) {
     control$mu_omega = rep(0, k)
     }
     else {
     if (length(control$mu_omega) != k) {
     stop("control$mu_omega must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_alpha)) {
     control$mu_alpha = rep(0, k)
     }
     else {
     if (length(control$mu_alpha) != k) {
     stop("control$mu_alpha must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_beta)) {
     control$mu_beta = rep(0, k)
     }
     else {
     if (length(control$mu_beta) != k) {
     stop("control$mu_beta must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_gamma)) {
     control$mu_gamma = rep(0, k)
     }
     else {
     if (length(control$mu_gamma) != k) {
     stop("control$mu_gamma must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$mu_tail)) {
     control$mu_tail = 0
     }
     else {
     if (length(control$mu_tail) != 1) {
     stop("control$mu_tail must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$sigma_a)) {
     control$sigma_a = 10
     }
     else {
     if (length(control$sigma_a) != 1) {
     stop("control$sigma_a must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$sigma_b)) {
     control$sigma_b = 10
     }
     else {
     if (length(control$sigma_b) != 1) {
     stop("control$sigma_b must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$sigma_omega)) {
     control$sigma_omega = rep(10, k)
     }
     else {
     if (length(control$sigma_omega) != k) {
     stop("control$sigma_omega must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_alpha)) {
     control$sigma_alpha = rep(10, k)
     }
     else {
     if (length(control$sigma_alpha) != k) {
     stop("control$sigma_alpha must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_beta)) {
     control$sigma_beta = rep(10, k)
     }
     else {
     if (length(control$sigma_beta) != k) {
     stop("control$sigma_beta must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_gamma)) {
     control$sigma_gamma = rep(10, k)
     }
     else {
     if (length(control$sigma_gamma) != k) {
     stop("control$sigma_gamma must be a numeric vector with length equal to 'ncol(mY)'.")
     }
     }
     if (is.null(control$sigma_tail)) {
     control$sigma_tail = 1.25
     }
     else {
     if (length(control$sigma_tail) != 1) {
     stop("control$sigma_tail must be a numeric vector with length equal to 1.")
     }
     }
     if (is.null(control$print)) {
     control$print = 1
     }
     else {
     if (!any(control$print == 0:1))
     control$print = 1
     }
     if (is.null(control$simAlg)) {
     control$simAlg = 3
     }
     else {
     if (!any(control$simAlg == 1:3))
     control$simAlg = 3
     }
     if (control$simAlg == 1) {
     option = 1
     if (is.null(control$cholCov)) {
     stop("control$cholCov was not found.")
     }
     else {
     if (!is.matrix(control$cholCov)) {
     stop("control$cholCov must be a positive definite matrix of dimension 5x5 if k=1 or (4k+3)x(4k+3) if k>1, where 'k=ncol(mY)'")
     }
     else {
     if (ncol(control$cholCov) != npar || nrow(control$cholCov) !=
     npar) {
     stop("control$cholCov must be a positive definite matrix of dimension 5x5 if k=1 or (4k+3)x(4k+3) if k>1, where 'k=ncol(mY)'")
     }
     }
     }
     }
     if (control$simAlg == 2 && !is.null(control$sdSim)) {
     option = 2
     if (length(control$sdSim) != npar)
     stop("control$sdSim must be a numeric positive vector with length 5 if k=1 or 4k+3 if k>1, where 'k=ncol(mY)'")
     }
     if (control$simAlg == 3) {
     if (k == 1) {
     control$sdSim = c(0.2, 0.2, 0.4, 0.4, 0.2)
     }
     else {
     control$sdSim = c(0.2, rep(c(0.2, 0.4, 0.4, 0.2),
     k), 1, 1.5)
     }
     }
     if (is.null(control$lambda)) {
     control$lambda = 0.5
     }
     if (is.null(control$nPilotSim)) {
     control$nPilotSim = 1000
     }
     phi_ini = .C("original_to_real_scale", phi = numeric(4 *
     k + 3), omega = as.double(omega_ini), alpha = as.double(alpha_ini),
     beta = as.double(beta_ini), a = as.double(a_ini), b = as.double(b_ini),
     gamma = as.double(gamma_ini), tail = as.double(tail_ini),
     k = as.integer(k), errorDist = as.integer(errorDist))$phi
     memoryAllocation(mY, errorDist, control$mu_omega, control$sigma_omega,
     control$mu_alpha, control$sigma_alpha, control$mu_beta,
     control$sigma_beta, control$mu_a, control$sigma_a, control$mu_b,
     control$sigma_b, control$mu_gamma, control$sigma_gamma,
     control$mu_tail, control$sigma_tail, control$print)
     if (control$simAlg == 3) {
     writeLines("Maximizing the log-posterior density function.")
     if (k == 1)
     phi_ini = phi_ini[1:5]
     opt = optim(par = phi_ini, fn = logPosterior_phi, hessian = TRUE,
     control = list(fnscale = -abs(Lout$value)))
     if (k == 1)
     phi_ini = c(phi_ini, -2, 1)
     if (opt$convergence == 0 || opt$convergence == 1) {
     writeLines("Done.")
     phi_ini = opt$par
     if (k == 1)
     phi_ini = c(phi_ini, -2, 1)
     control$cholCov = try(t(chol(solve(-opt$hessian))),
     silent = TRUE)
     if (class(control$cholCov) != "try-error") {
     option = 1
     }
     else {
     writeLines("One approximation for covariance matrix of parameters cannot be directly computed through the hessian matrix.")
     option = 2
     }
     }
     else {
     writeLines("The optim function convergence was not obtained.")
     option = 2
     }
     }
     repeat {
     if (option == 1 && control$simAlg != 2) {
     if (control$simAlg == 3) {
     writeLines("Calibrating the Lambda coefficient:")
     cont = 1
     proceed = TRUE
     while (proceed) {
     writeLines(paste("lambda:", control$lambda))
     MC_phi = MH_oneBlock(phi_ini, k, n_sim = control$nPilotSim,
     control$lambda * control$cholCov)
     acceptRate = 1 - rejectionRate(MC_phi)[5]
     writeLines(paste("Accept Rate:", round(acceptRate,
     2)))
     if (acceptRate > 0.2 && acceptRate < 0.5 ||
     cont > 5) {
     proceed = FALSE
     }
     else {
     cont = cont + 1
     if (acceptRate < 0.2) {
     control$lambda = control$lambda * 0.8
     }
     if (acceptRate > 0.5) {
     control$lambda = control$lambda * 1.2
     }
     }
     }
     writeLines("Done.")
     }
     writeLines("Starting the simulation by one-block random walk Metropolis-Hasting algorithm.")
     MC_phi = MH_oneBlock(phi_ini, k, n_sim = nSim, control$lambda *
     control$cholCov)
     writeLines("Done.")
     break
     }
     if (option == 2 && control$simAlg != 1) {
     if (control$simAlg == 3) {
     writeLines("Calibrating the standard deviations for simulation:")
     proceed = TRUE
     cont = 1
     while (proceed) {
     MC_phi = MH_oneDimension(phi_ini, k = k, n_sim = control$nPilotSim,
     control$sdSim)
     acceptRate = 1 - rejectionRate(MC_phi)
     writeLines("Accept Rate:")
     print(round(acceptRate, 2))
     if (errorDist == 1) {
     acceptRate[1] = 0.3
     }
     lowerRate = which(acceptRate < 0.15)
     upperRate = which(acceptRate > 0.5)
     if (length(lowerRate) == 0 && length(upperRate) ==
     0 || cont > 5) {
     proceed = FALSE
     }
     else {
     cont = cont + 1
     control$sdSim[lowerRate] = control$sdSim[lowerRate] *
     0.6
     control$sdSim[upperRate] = control$sdSim[upperRate] *
     1.4
     }
     }
     if (errorDist == 1) {
     MC_phi[, 1] = rnorm(control$nPilotSim)
     }
     writeLines("Computing the covariance matrix of pilot sample.")
     control$cholCov = try(t(chol(cov(MC_phi))), silent = TRUE)
     if (class(control$cholCov) != "try-error") {
     writeLines("Done.")
     option = 1
     }
     else {
     control$cholCov = NULL
     writeLines("The approximately covariance matrix is not positive definitely.")
     option = 2
     }
     }
     if (option == 2) {
     writeLines("Starting the simulation by one-dimensional random walk Metropolis-Hasting algorithm.")
     MC_phi = MH_oneDimension(phi_ini, k = k, n_sim = nSim,
     sd_phi_sim = control$sdSim)
     writeLines("Done.")
     break
     }
     }
     }
     vMMeanH = .C("getMeanH", vMMeanH = numeric(n * k * k))$vMMeanH
     mMeanH = matrix(vMMeanH, nrow = n, ncol = k * k, byrow = TRUE)
     name = rep("NA", k * k)
     for (i in 1:k) {
     for (j in 1:k) {
     name[(i - 1) * k + j] = paste("H_", i, ",", j, sep = "")
     }
     }
     colnames(mMeanH) = name
     logLike_mean = .C("getLogLikelihood_mean", value = numeric(1))$value
     memoryDeallocation()
     name = rep("NA", npar)
     MC = matrix(NA, nrow = nSim, ncol = npar)
     if (errorDist == 1 || errorDist == 3) {
     MC[, 1] = exp(MC_phi[, 1])
     name[1] = "delta"
     }
     if (errorDist == 2) {
     MC[, 1] = exp(MC_phi[, 1]) + 2
     name[1] = "nu"
     }
     for (i in 1:k) {
     MC[, 4 * (i - 1) + 2:5] = cbind(exp(MC_phi[, 4 * (i -
     1) + 2:3]), exp(MC_phi[, 4 * (i - 1) + 4:5])/(1 +
     exp(MC_phi[, 4 * (i - 1) + 4:5])))
     name[4 * (i - 1) + 2:5] = paste(c("gamma", "omega", "alpha",
     "beta"), "_", i, sep = "")
     }
     if (k > 1) {
     MC[, 4 * k + 2:3] = exp(MC_phi[, 4 * k + 2:3])/(1 + exp(MC_phi[,
     4 * k + 2:3]))
     name[4 * k + 2:3] = c("a", "b")
     }
     colnames(MC) = name
     D_mean = -2 * logLike_mean
     par_est = apply(X = MC, MARGIN = 2, FUN = mean)
     tail_est = par_est[1]
     gamma_est = par_est[2 + 4 * (0:(k - 1))]
     omega_est = par_est[3 + 4 * (0:(k - 1))]
     alpha_est = par_est[4 + 4 * (0:(k - 1))]
     beta_est = par_est[5 + 4 * (0:(k - 1))]
     if (k > 1) {
     a_est = par_est[2 + 4 * k]
     b_est = par_est[3 + 4 * k]
     }
     else {
     a_est = 0.1
     b_est = 0.1
     }
     D_at_mean = -2 * logLikDccGarch(mY, omega_est, alpha_est,
     beta_est, a_est, b_est, gamma_est, tail_est, errorDist)$value
     if (errorDist == 1) {
     EAIC = D_mean + 2 * (npar - 1)
     EBIC = D_mean + (npar - 1) * log(n)
     }
     else {
     EAIC = D_mean + 2 * npar
     EBIC = D_mean + npar * log(n)
     }
     DIC = D_at_mean + 2 * (D_mean - D_at_mean)
     IC = matrix(c(EAIC, EBIC, DIC), nrow = 3, ncol = 1)
     rownames(IC) = c("EAIC", "EBIC", "DIC")
     colnames(IC) = c("Estimative")
     out = list()
     out$control = control
     out$MC = as.mcmc(MC)
     out$H = mMeanH
     out$IC = IC
     out$elapsedTime = proc.time() - ptm
     return(structure(out, class = "bayesDccGarch"))
    }
    <bytecode: 0x29e5b48>
    <environment: namespace:bayesDccGarch>
     --- function search by body ---
    Function bayesDccGarch in namespace bayesDccGarch has this body.
     ----------- END OF FAILURE REPORT --------------
    Error in if (class(control$cholCov) != "try-error") { :
     the condition has length > 1
    Calls: bayesDccGarch
    Execution halted
Flavor: r-devel-linux-x86_64-fedora-gcc

Version: 2.0
Check: DESCRIPTION meta-information
Result: NOTE
    BugReports field is not a suitable URL but contains an email address
     which will be used as from R 3.4.0
Flavors: r-release-osx-x86_64, r-oldrel-windows-ix86+x86_64, r-oldrel-osx-x86_64