Running examples in ‘gmm-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: KTest
> ### Title: Compute the K statistics of Kleibergen
> ### Aliases: KTest print.gmmTests
> 
> ### ** Examples
> 
> 
> library(mvtnorm)
> sig <- matrix(c(1,.5,.5,1),2,2)
> n <- 400
> e <- rmvnorm(n,sigma=sig)
> x4 <- rnorm(n)
> w <- exp(-x4^2) + e[,1]
> y <- 0.1*w + e[,2]
> h <- cbind(x4, x4^2, x4^3, x4^6)
> g3 <- y~w
> res <- gmm(g3,h)
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
gmm
 --- call from context --- 
FinRes.baseGmm.res(z, Model_info)
 --- call from argument --- 
if (class(z$vcov) == "try-error") {
    z$vcov <- matrix(Inf, length(z$coef), length(z$coef))
    warning("The covariance matrix of the coefficients is singular")
}
 --- R stacktrace ---
where 1: FinRes.baseGmm.res(z, Model_info)
where 2: FinRes(z, Model_info)
where 3: gmm(g3, h)

 --- value of length: 2 type: logical ---
[1] FALSE FALSE
 --- function from context --- 
function (z, object, ...) 
{
    P <- object
    x <- z$dat
    n <- ifelse(is.null(nrow(z$gt)), length(z$gt), nrow(z$gt))
    if (!is.null(attr(x, "eqConst")) & P$allArg$eqConstFullVcov) {
        eqConst <- attr(x, "eqConst")$eqConst
        coef <- rep(0, length(eqConst[, 1]) + length(z$coefficients))
        ncoef <- rep("", length(eqConst[, 1]) + length(z$coefficients))
        coef[-eqConst[, 1]] <- z$coefficients
        ncoef[-eqConst[, 1]] <- names(z$coefficients)
        coef[eqConst[, 1]] <- eqConst[, 2]
        ncoef[eqConst[, 1]] <- rownames(eqConst)
        names(coef) <- ncoef
        z$coefficients <- coef
        if (!is.null(z$initTheta)) {
            initTheta <- rep(0, length(z$coefficients))
            initTheta[eqConst[, 1]] <- eqConst[, 2]
            initTheta[-eqConst[, 1]] <- z$initTheta
            z$initTheta <- initTheta
        }
        z$k <- z$k + nrow(eqConst)
        z$k2 <- z$k2 + nrow(eqConst)
        attr(x, "eqConst") <- NULL
        z$specMod <- paste(z$specMod, "** Note: Covariance matrix computed for all coefficients based on restricted values \n   Tests non-valid**\n\n")
    }
    z$G <- z$gradv(z$coefficients, x)
    G <- z$G
    if (P$vcov == "TrueFixed") 
        v <- .weightFct(z$coefficient, x, "fixed")
    else v <- .weightFct(z$coefficient, x, P$vcov)
    z$v <- v
    if (P$vcov == "TrueFixed") {
        z$vcov = try(solve(crossprod(G, P$weightsMatrix) %*% 
            G)/n, silent = TRUE)
        if (class(z$vcov) == "try-error") {
            z$vcov <- matrix(Inf, length(z$coef), length(z$coef))
            warning("The covariance matrix of the coefficients is singular")
        }
    }
    else if ((is.null(P$weightsMatrix)) & (P$wmatrix != "ident")) {
        if (dim(G)[1] == dim(G)[2]) {
            T1 <- try(solve(G), silent = TRUE)
            z$vcov <- try(T1 %*% v %*% t(T1)/n, silent = TRUE)
        }
        else {
            z$vcov <- try(solve(crossprod(G, solve(v, G)))/n, 
                silent = TRUE)
        }
        if (class(z$vcov) == "try-error") {
            z$vcov <- matrix(Inf, length(z$coef), length(z$coef))
            warning("The covariance matrix of the coefficients is singular")
        }
    }
    else {
        if (is.null(P$weightsMatrix)) 
            w <- diag(ncol(z$gt))
        else w <- P$weightsMatrix
        if (dim(G)[1] == dim(G)[2]) {
            T1 <- try(solve(G), silent = TRUE)
        }
        else {
            T1 <- try(solve(t(G) %*% w %*% G, t(G) %*% w), silent = TRUE)
        }
        if (class(T1) == "try-error") {
            z$vcov <- matrix(Inf, length(z$coef), length(z$coef))
            warning("The covariance matrix of the coefficients is singular")
        }
        else {
            z$vcov <- T1 %*% v %*% t(T1)/n
        }
    }
    dimnames(z$vcov) <- list(names(z$coefficients), names(z$coefficients))
    z$call <- P$call
    if (is.null(P$weightsMatrix)) {
        if (P$wmatrix == "ident") {
            z$w <- diag(ncol(z$gt))
        }
        else {
            z$w <- try(solve(v), silent = TRUE)
            if (class(z$w) == "try-error") 
                warning("The covariance matrix of the moment function is singular")
        }
    }
    else {
        z$w <- P$weightsMatrix
    }
    z$weightsMatrix <- P$weightsMatrix
    z$infVcov <- P$vcov
    z$infWmatrix <- P$wmatrix
    z$allArg <- P$allArg
    if (P$wmatrix == "ident") 
        z$met <- "One step GMM with W = identity"
    else z$met <- P$type
    z$kernel <- P$kernel
    z$coefficients <- c(z$coefficients)
    class(z) <- "gmm"
    return(z)
}
<bytecode: 0x55c2ef5cea10>
<environment: namespace:gmm>
 --- function search by body ---
Function FinRes.baseGmm.res in namespace gmm has this body.
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1