Running examples in 'spGARCH-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: qml.SARspARCH
> ### Title: Maximum-likelihood estimation of a spatial autoregressive model
> ###   with spatial ARCH residuals
> ### Aliases: qml.SARspARCH
> ### Keywords: Spatial Autoregressive Model with spARCH Residuals QML
> ###   SARspARCH
> 
> ### ** Examples
> 
> require("spdep")
Loading required package: spdep
Loading required package: sp
Loading required package: spData
To access larger datasets in this package, install the spDataLarge
package with: `install.packages('spDataLarge',
repos='https://nowosad.github.io/drat/', type='source')`
Loading required package: sf
Linking to GEOS 3.8.0, GDAL 3.0.3, PROJ 6.3.0
> rho <- 0.5
> alpha <- 1
> lambda <- 0.5
> d <- 5
> n <- d^2
> nblist <- cell2nb(d, d, type = "queen")
> W <- nb2mat(nblist)
> B <- W
> 
> X <- cbind(rep(1, n), rnorm(n))
> beta <- c(5, 2)
> 
> y <- solve(diag(n) - lambda * B) %*%
+     (sim.spARCH(n = n, rho = rho, alpha = alpha, W = W, type = "log-spARCH") + X %*% beta)
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
spGARCH
 --- call from context --- 
sim.spARCH(n = n, rho = rho, alpha = alpha, W = W, type = "log-spARCH")
 --- call from argument --- 
if (class(W) != "dgCMatrix") {
    W <- .asdgCMatrix(rho * as.matrix(W))
} else {
    W <- rho * W
}
 --- R stacktrace ---
where 1: sim.spARCH(n = n, rho = rho, alpha = alpha, W = W, type = "log-spARCH")

 --- value of length: 2 type: logical ---
[1] TRUE TRUE
 --- function from context --- 
function (n = dim(W)[1], rho, alpha, W, b = 2, type = "spARCH", 
    control = list()) 
{
    if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE)) {
        runif(1)
    }
    con <- list(seed = runif(1) * 10^9, silent = FALSE, triangular = FALSE)
    nmsC <- names(con)
    con[(namc <- names(control))] <- control
    if (length(noNms <- namc[!namc %in% nmsC])) {
        warning("unknown names in control: ", paste(noNms, collapse = ", "))
    }
    R.seed <- get(".Random.seed", envir = .GlobalEnv)
    on.exit(assign(".Random.seed", R.seed, envir = .GlobalEnv))
    if (length(n) > 1) {
        n <- length(n)
    }
    if (!is.numeric(n)) {
        stop("non-numeric argument n. \n")
    }
    if (n < 1) {
        stop("n must be greater than 1 \n")
    }
    if (dim(W)[1] != dim(W)[2]) {
        stop("Spatial weight matrix W must be quadratic \n")
    }
    if (n != dim(W)[1]) {
        stop("Spatial weight matrix W must have dimension n x n \n")
    }
    if (class(W) != "dgCMatrix") {
        W <- .asdgCMatrix(rho * as.matrix(W))
    }
    else {
        W <- rho * W
    }
    set.seed(con$seed)
    if (type == "spARCH") {
        if (!con$triangular) {
            eigen_values <- eigen(W, only.values = TRUE)$values
            if (any(eigen_values != 0)) {
                a <- 1/sqrt(sqrt(norm(W %*% W, "1")))
                eps <- rtruncnorm(n, a = -a, b = a)
            }
            else {
                eps <- rnorm(n)
            }
        }
        else {
            eps <- rnorm(n)
        }
    }
    else {
        eps <- rnorm(n)
    }
    if (con$silent == FALSE) {
        cat("Current random seed: ", con$seed, " (To reproduce the results, add argument 'seed = ", 
            con$seed, "' to control argument) \n", sep = "")
    }
    if (type == "log-spARCH") {
        return(.Simulation_CPP_E(eps, W, alpha, b))
    }
    else {
        h <- .Simulation_CPP(eps, W, alpha)
    }
    if (type == "spARCH") {
        return(as.numeric(sqrt(h) * eps))
    }
    if (type == "log-spARCH") {
        return(as.numeric(exp(h) * eps))
    }
    if (type == "complex-spARCH") {
        return(as.complex(sqrt(as.complex(h)) * eps))
    }
    stop("invalid type: ", type)
}
<bytecode: 0xa1f23a8>
<environment: namespace:spGARCH>
 --- function search by body ---
Function sim.spARCH in namespace spGARCH has this body.
 ----------- END OF FAILURE REPORT -------------- 
Error in if (class(W) != "dgCMatrix") { : the condition has length > 1
Calls: sim.spARCH
Execution halted