Running ‘KleinI.R’ [9s/16s]
  Comparing ‘KleinI.Rout’ to ‘KleinI.Rout.save’ ... OK
  Running ‘KleinI_noMat.R’ [4s/6s]
  Running ‘test_2sls.R’ [4s/6s]
  Running ‘test_3sls.R’ [4s/7s]
  Running ‘test_hausman.R’ [4s/6s]
  Running ‘test_ols.R’ [4s/7s]
  Running ‘test_panel.R’ [4s/6s]
  Running ‘test_sur.R’ [4s/6s]
  Running ‘test_w2sls.R’ [4s/6s]
  Running ‘test_wls.R’ [4s/5s]
Running the tests in ‘tests/KleinI_noMat.R’ failed.
Complete output:
  > library( "systemfit" )
  Loading required package: Matrix
  Loading required package: car
  Loading required package: carData
  Loading required package: lmtest
  Loading required package: zoo
  
  Attaching package: 'zoo'
  
  The following objects are masked from 'package:base':
  
      as.Date, as.Date.numeric
  
  
  Please cite the 'systemfit' package as:
  Arne Henningsen and Jeff D. Hamann (2007). systemfit: A Package for Estimating Systems of Simultaneous Equations in R. Journal of Statistical Software 23(4), 1-40. http://www.jstatsoft.org/v23/i04/.
  
  If you have questions, suggestions, or comments regarding the 'systemfit' package, please use a forum or 'tracker' at systemfit's R-Forge site:
  https://r-forge.r-project.org/projects/systemfit/
  > options( warn = 1 )
  > options( digits = 3 )
  > 
  > data( "KleinI" )
  > eqConsump  <- consump ~ corpProf + corpProfLag + wages
  > eqInvest   <- invest ~ corpProf + corpProfLag + capitalLag
  > eqPrivWage <- privWage ~ gnp + gnpLag + trend
  > inst <- ~ govExp + taxes + govWage + trend + capitalLag + corpProfLag + gnpLag
  > system <- list( Consumption = eqConsump, Investment = eqInvest,
  +    PrivateWages = eqPrivWage )
  > restrict <- c( "Consumption_corpProf + Investment_capitalLag = 0" )
  > restrict2 <- c( restrict, "Consumption_corpProfLag - PrivateWages_trend = 0" )
  > 
  > for( dataNo in 1:5 ) {
  +    # set some values of some variables to NA
  +    if( dataNo == 2 ) {
  +       KleinI$gnpLag[ 7 ] <- NA
  +    } else if( dataNo == 3 ) {
  +       KleinI$wages[ 10 ] <- NA
  +    } else if( dataNo == 4 ) {
  +       KleinI$corpProf[ 13 ] <- NA
  +    } else if( dataNo == 5 ) {
  +       KleinI$invest[ 16 ] <- NA
  +    }
  + 
  +    # single-equation OLS
  +    lmConsump  <- lm( eqConsump, data = KleinI )
  +    lmInvest   <- lm( eqInvest, data = KleinI )
  +    lmPrivWage <- lm( eqPrivWage, data = KleinI )
  +    
  + for( methodNo in 1:5 ) {
  +    method <- c( "OLS", "2SLS", "SUR", "3SLS", "3SLS" )[ methodNo ]
  +    maxit <- ifelse( methodNo == 5, 500, 1 )
  + 
  +    cat( "> \n> # ", ifelse( maxit == 1, "", "I" ), method, "\n", sep = "" )
  +    if( method %in% c( "OLS", "WLS", "SUR" ) ) {
  +       kleinModel <- systemfit( system, method = method, data = KleinI,
  +          methodResidCov = ifelse( method == "OLS", "geomean", "noDfCor" ),
  +          maxit = maxit, useMatrix = FALSE )
  +    } else {
  +       kleinModel <- systemfit( system, method = method, data = KleinI,
  +          inst = inst, methodResidCov = "noDfCor", maxit = maxit,
  +          useMatrix = FALSE )
  +    }
  +    cat( "> summary\n" )
  +    print( summary( kleinModel ) )
  +    if( method == "OLS" ) {
  +       cat( "compare coef with single-equation OLS\n" )
  +       print( all.equal( coef( kleinModel ),
  +          c( coef( lmConsump ), coef( lmInvest ), coef( lmPrivWage ) ),
  +          check.attributes = FALSE ) )
  +    }
  +    cat( "> residuals\n" )
  +    print( residuals( kleinModel ) )
  +    cat( "> fitted\n" )
  +    print( fitted( kleinModel ) )
  +    cat( "> predict\n" )
  +    print( predict( kleinModel, se.fit = TRUE,
  +       interval = ifelse( methodNo %in% c( 1, 4 ), "prediction",  "confidence" ),
  +       useDfSys = methodNo %in% c( 1, 3, 5 ) ) )
  +    cat( "> model.frame\n" )
  +    if( methodNo == 1 ) {
  +       mfOls <- model.frame( kleinModel )
  +       print( mfOls )
  +    } else if( methodNo == 2 ) {
  +       mf2sls <- model.frame( kleinModel )
  +       print( mf2sls )
  +    } else if( methodNo == 3 ) {
  +       print( all.equal( mfOls, model.frame( kleinModel ) ) )
  +    } else {
  +       print( all.equal( mf2sls, model.frame( kleinModel ) ) )
  +    }
  +    cat( "> model.matrix\n" )
  +    if( methodNo == 1 ) {
  +       mmOls <- model.matrix( kleinModel )
  +       print( mmOls )
  +    } else {
  +       print( all.equal( mmOls, model.matrix( kleinModel ) ) )
  +    }
  +    cat( "> nobs\n" )
  +    print( nobs( kleinModel ) )
  +    cat( "> linearHypothesis\n" )
  +    print( linearHypothesis( kleinModel, restrict ) )
  +    print( linearHypothesis( kleinModel, restrict, test = "F" ) )
  +    print( linearHypothesis( kleinModel, restrict, test = "Chisq" ) )
  +    print( linearHypothesis( kleinModel, restrict2 ) )
  +    print( linearHypothesis( kleinModel, restrict2, test = "F" ) )
  +    print( linearHypothesis( kleinModel, restrict2, test = "Chisq" ) )
  +    cat( "> logLik\n" )
  +    print( logLik( kleinModel ) )
  +    print( logLik( kleinModel, residCovDiag = TRUE ) )
  +    if( method == "OLS" ) {
  +       cat( "compare log likelihood value with single-equation OLS\n" )
  +       print( all.equal( logLik( kleinModel, residCovDiag = TRUE ),
  +          logLik( lmConsump ) + logLik( lmInvest ) + logLik( lmPrivWage ),
  +          check.attributes = FALSE ) )
  +    }
  + }
  + }
  > 
  > # OLS
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  systemfit
   --- call from context --- 
  .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      diag = TRUE, centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
   --- call from argument --- 
  if (class(resids) == "data.frame") {
      resids <- as.matrix(resids)
      validObsEq <- !is.na(resids)
      eqNames <- names(resids)
  } else if (!is.null(validObsEq)) {
      residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
      for (i in 1:ncol(validObsEq)) {
          residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
              0:(i - 1)])):(sum(validObsEq[, 1:i]))]
      }
      resids <- residMat
      rm(residMat)
  } else {
      stop("internal error in .calcResidCov: if argument 'validObsEq'", 
          " is not provided, argument 'resids' must be a data.frame'")
  }
   --- R stacktrace ---
  where 1: .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      diag = TRUE, centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
  where 2: systemfit(system, method = method, data = KleinI, methodResidCov = ifelse(method == 
      "OLS", "geomean", "noDfCor"), maxit = maxit, useMatrix = FALSE)
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (resids, methodResidCov, validObsEq = NULL, nCoefEq = NULL, 
      xEq = NULL, diag = FALSE, centered = FALSE, useMatrix = FALSE, 
      solvetol = .Machine$double.eps) 
  {
      eqNames <- NULL
      if (class(resids) == "data.frame") {
          resids <- as.matrix(resids)
          validObsEq <- !is.na(resids)
          eqNames <- names(resids)
      }
      else if (!is.null(validObsEq)) {
          residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
          for (i in 1:ncol(validObsEq)) {
              residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
                  0:(i - 1)])):(sum(validObsEq[, 1:i]))]
          }
          resids <- residMat
          rm(residMat)
      }
      else {
          stop("internal error in .calcResidCov: if argument 'validObsEq'", 
              " is not provided, argument 'resids' must be a data.frame'")
      }
      nEq <- ncol(validObsEq)
      result <- matrix(0, nEq, nEq)
      if (centered) {
          for (i in 1:nEq) {
              resids[, i] <- resids[, i] - mean(resids[validObsEq[, 
                  i], i])
          }
      }
      validObsAll <- rowSums(!validObsEq) == 0
      for (i in 1:nEq) {
          for (j in ifelse(diag, i, 1):ifelse(diag, i, nEq)) {
              if (methodResidCov == "noDfCor") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sum(validObsAll)
              }
              else if (methodResidCov == "geomean") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sqrt((sum(validObsAll) - 
                    nCoefEq[i]) * (sum(validObsAll) - nCoefEq[j]))
              }
              else if (methodResidCov == "Theil") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    nCoefEq[i] - nCoefEq[j] + sum(diag(solve(crossprod(xEq[[i]]), 
                    tol = solvetol) %*% crossprod(xEq[[i]], xEq[[j]]) %*% 
                    solve(crossprod(xEq[[j]]), tol = solvetol) %*% 
                    crossprod(xEq[[j]], xEq[[i]]))))
              }
              else if (methodResidCov == "max") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    max(nCoefEq[i], nCoefEq[j]))
              }
              else {
                  stop(paste("Argument 'methodResidCov' must be either 'noDfCor',", 
                    "'geomean', 'max', or 'Theil'."))
              }
          }
      }
      if (!is.null(eqNames)) {
          rownames(result) <- eqNames
          colnames(result) <- eqNames
      }
      if (useMatrix) {
          result <- as(result, "dspMatrix")
      }
      return(result)
  }
  <bytecode: 0x5603a43420c0>
  <environment: namespace:systemfit>
   --- function search by body ---
  Function .calcResidCov in namespace systemfit has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1
Running the tests in ‘tests/test_2sls.R’ failed.
Complete output:
  > library( systemfit )
  Loading required package: Matrix
  Loading required package: car
  Loading required package: carData
  Loading required package: lmtest
  Loading required package: zoo
  
  Attaching package: 'zoo'
  
  The following objects are masked from 'package:base':
  
      as.Date, as.Date.numeric
  
  
  Please cite the 'systemfit' package as:
  Arne Henningsen and Jeff D. Hamann (2007). systemfit: A Package for Estimating Systems of Simultaneous Equations in R. Journal of Statistical Software 23(4), 1-40. http://www.jstatsoft.org/v23/i04/.
  
  If you have questions, suggestions, or comments regarding the 'systemfit' package, please use a forum or 'tracker' at systemfit's R-Forge site:
  https://r-forge.r-project.org/projects/systemfit/
  > options( digits = 3 )
  > 
  > data( "Kmenta" )
  > useMatrix <- FALSE
  > 
  > demand <- consump ~ price + income
  > supply <- consump ~ price + farmPrice + trend
  > inst <- ~ income + farmPrice + trend
  > inst1  <- ~ income + farmPrice
  > instlist <- list( inst1, inst )
  > system <- list( demand = demand, supply = supply )
  > restrm <- matrix(0,1,7)  # restriction matrix "R"
  > restrm[1,3] <-  1
  > restrm[1,7] <- -1
  > restrict <- "demand_income - supply_trend = 0"
  > restr2m <- matrix(0,2,7)  # restriction matrix "R" 2
  > restr2m[1,3] <-  1
  > restr2m[1,7] <- -1
  > restr2m[2,2] <- -1
  > restr2m[2,5] <-  1
  > restr2q <- c( 0, 0.5 )  # restriction vector "q" 2
  > restrict2 <- c( "demand_income - supply_trend = 0",
  +    "- demand_price + supply_price = 0.5" )
  > tc <- matrix(0,7,6)
  > tc[1,1] <- 1
  > tc[2,2] <- 1
  > tc[3,3] <- 1
  > tc[4,4] <- 1
  > tc[5,5] <- 1
  > tc[6,6] <- 1
  > tc[7,3] <- 1
  > restr3m <- matrix(0,1,6)  # restriction matrix "R" 2
  > restr3m[1,2] <- -1
  > restr3m[1,5] <-  1
  > restr3q <- c( 0.5 )  # restriction vector "q" 2
  > restrict3 <- "- C2 + C5 = 0.5"
  > 
  > # It is not possible to estimate 2SLS with systemfit exactly
  > # as EViews does, because EViews uses
  > # methodResidCov == "geomean" for the coefficient covariance matrix and
  > # methodResidCov == "noDfCor" for the residual covariance matrix.
  > # systemfit uses always the same formulas for both calculations.
  > 
  > ## *************** 2SLS estimation ************************
  > ## ************ 2SLS estimation (default)*********************
  > fit2sls1 <- systemfit( system, "2SLS", data = Kmenta, inst = inst,
  +    x = TRUE, useMatrix = useMatrix )
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  systemfit
   --- call from context --- 
  .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      diag = TRUE, centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
   --- call from argument --- 
  if (class(resids) == "data.frame") {
      resids <- as.matrix(resids)
      validObsEq <- !is.na(resids)
      eqNames <- names(resids)
  } else if (!is.null(validObsEq)) {
      residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
      for (i in 1:ncol(validObsEq)) {
          residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
              0:(i - 1)])):(sum(validObsEq[, 1:i]))]
      }
      resids <- residMat
      rm(residMat)
  } else {
      stop("internal error in .calcResidCov: if argument 'validObsEq'", 
          " is not provided, argument 'resids' must be a data.frame'")
  }
   --- R stacktrace ---
  where 1: .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      diag = TRUE, centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
  where 2: systemfit(system, "2SLS", data = Kmenta, inst = inst, x = TRUE, 
      useMatrix = useMatrix)
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (resids, methodResidCov, validObsEq = NULL, nCoefEq = NULL, 
      xEq = NULL, diag = FALSE, centered = FALSE, useMatrix = FALSE, 
      solvetol = .Machine$double.eps) 
  {
      eqNames <- NULL
      if (class(resids) == "data.frame") {
          resids <- as.matrix(resids)
          validObsEq <- !is.na(resids)
          eqNames <- names(resids)
      }
      else if (!is.null(validObsEq)) {
          residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
          for (i in 1:ncol(validObsEq)) {
              residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
                  0:(i - 1)])):(sum(validObsEq[, 1:i]))]
          }
          resids <- residMat
          rm(residMat)
      }
      else {
          stop("internal error in .calcResidCov: if argument 'validObsEq'", 
              " is not provided, argument 'resids' must be a data.frame'")
      }
      nEq <- ncol(validObsEq)
      result <- matrix(0, nEq, nEq)
      if (centered) {
          for (i in 1:nEq) {
              resids[, i] <- resids[, i] - mean(resids[validObsEq[, 
                  i], i])
          }
      }
      validObsAll <- rowSums(!validObsEq) == 0
      for (i in 1:nEq) {
          for (j in ifelse(diag, i, 1):ifelse(diag, i, nEq)) {
              if (methodResidCov == "noDfCor") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sum(validObsAll)
              }
              else if (methodResidCov == "geomean") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sqrt((sum(validObsAll) - 
                    nCoefEq[i]) * (sum(validObsAll) - nCoefEq[j]))
              }
              else if (methodResidCov == "Theil") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    nCoefEq[i] - nCoefEq[j] + sum(diag(solve(crossprod(xEq[[i]]), 
                    tol = solvetol) %*% crossprod(xEq[[i]], xEq[[j]]) %*% 
                    solve(crossprod(xEq[[j]]), tol = solvetol) %*% 
                    crossprod(xEq[[j]], xEq[[i]]))))
              }
              else if (methodResidCov == "max") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    max(nCoefEq[i], nCoefEq[j]))
              }
              else {
                  stop(paste("Argument 'methodResidCov' must be either 'noDfCor',", 
                    "'geomean', 'max', or 'Theil'."))
              }
          }
      }
      if (!is.null(eqNames)) {
          rownames(result) <- eqNames
          colnames(result) <- eqNames
      }
      if (useMatrix) {
          result <- as(result, "dspMatrix")
      }
      return(result)
  }
  <bytecode: 0x561cf78465e0>
  <environment: namespace:systemfit>
   --- function search by body ---
  Function .calcResidCov in namespace systemfit has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1
Running the tests in ‘tests/test_3sls.R’ failed.
Complete output:
  > library( systemfit )
  Loading required package: Matrix
  Loading required package: car
  Loading required package: carData
  Loading required package: lmtest
  Loading required package: zoo
  
  Attaching package: 'zoo'
  
  The following objects are masked from 'package:base':
  
      as.Date, as.Date.numeric
  
  
  Please cite the 'systemfit' package as:
  Arne Henningsen and Jeff D. Hamann (2007). systemfit: A Package for Estimating Systems of Simultaneous Equations in R. Journal of Statistical Software 23(4), 1-40. http://www.jstatsoft.org/v23/i04/.
  
  If you have questions, suggestions, or comments regarding the 'systemfit' package, please use a forum or 'tracker' at systemfit's R-Forge site:
  https://r-forge.r-project.org/projects/systemfit/
  > options( digits = 3 )
  > 
  > data( "Kmenta" )
  > useMatrix <- FALSE
  > 
  > demand <- consump ~ price + income
  > supply <- consump ~ price + farmPrice + trend
  > inst <- ~ income + farmPrice + trend
  > inst1  <- ~ income + farmPrice
  > instlist <- list( inst1, inst )
  > system <- list( demand = demand, supply = supply )
  > restrm <- matrix(0,1,7)  # restriction matrix "R"
  > restrm[1,3] <-  1
  > restrm[1,7] <- -1
  > restrict <- "demand_income - supply_trend = 0"
  > restr2m <- matrix(0,2,7)  # restriction matrix "R" 2
  > restr2m[1,3] <-  1
  > restr2m[1,7] <- -1
  > restr2m[2,2] <- -1
  > restr2m[2,5] <-  1
  > restr2q <- c( 0, 0.5 )  # restriction vector "q" 2
  > restrict2 <- c( "demand_income - supply_trend = 0",
  +    "- demand_price + supply_price = 0.5" )
  > tc <- matrix(0,7,6)
  > tc[1,1] <- 1
  > tc[2,2] <- 1
  > tc[3,3] <- 1
  > tc[4,4] <- 1
  > tc[5,5] <- 1
  > tc[6,6] <- 1
  > tc[7,3] <- 1
  > restr3m <- matrix(0,1,6)  # restriction matrix "R" 2
  > restr3m[1,2] <- -1
  > restr3m[1,5] <-  1
  > restr3q <- c( 0.5 )  # restriction vector "q" 2
  > restrict3 <- "- C2 + C5 = 0.5"
  > 
  > 
  > ## *************** 3SLS estimation ************************
  > fit3sls <- list()
  > formulas <- c( "GLS", "IV", "Schmidt", "GMM", "EViews" )
  > for( i in seq( along = formulas ) ) {
  +    fit3sls[[ i ]] <- list()
  + 
  +    print( "***************************************************" )
  +    print( paste( "3SLS formula:", formulas[ i ] ) )
  +    print( "************* 3SLS *********************************" )
  +    fit3sls[[ i ]]$e1 <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, method3sls = formulas[ i ], useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e1 ) )
  + 
  +    print( "********************* 3SLS EViews-like *****************" )
  +    fit3sls[[ i ]]$e1e <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, methodResidCov = "noDfCor", method3sls = formulas[ i ],
  +       useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e1e, useDfSys = TRUE ) )
  + 
  +    print( "********************* 3SLS with methodResidCov = Theil *****************" )
  +    fit3sls[[ i ]]$e1c <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, methodResidCov = "Theil", method3sls = formulas[ i ],
  +       x = TRUE, useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e1c, useDfSys = TRUE ) )
  + 
  +    print( "*************** W3SLS with methodResidCov = Theil *****************" )
  +    fit3sls[[ i ]]$e1wc <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, methodResidCov = "Theil", method3sls = formulas[ i ],
  +       residCovWeighted = TRUE, useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e1wc, useDfSys = TRUE ) )
  + 
  + 
  +    print( "*************** 3SLS with restriction *****************" )
  +    fit3sls[[ i ]]$e2 <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, restrict.matrix = restrm, method3sls = formulas[ i ],
  +       x = TRUE, useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e2 ) )
  +    # the same with symbolically specified restrictions
  +    fit3sls[[ i ]]$e2Sym <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, restrict.matrix = restrict, method3sls = formulas[ i ],
  +       x = TRUE, useMatrix = useMatrix )
  +    print( all.equal( fit3sls[[ i ]]$e2, fit3sls[[ i ]]$e2Sym ) )
  + 
  +    print( "************** 3SLS with restriction (EViews-like) *****************" )
  +    fit3sls[[ i ]]$e2e <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, methodResidCov = "noDfCor", restrict.matrix = restrm,
  +       method3sls = formulas[ i ], useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e2e, useDfSys = TRUE ) )
  +    print( nobs( fit3sls[[i]]$e2e ))
  + 
  +    print( "*************** W3SLS with restriction *****************" )
  +    fit3sls[[ i ]]$e2w <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, restrict.matrix = restrm, method3sls = formulas[ i ],
  +       residCovWeighted = TRUE, useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e2w ) )
  + 
  + 
  +    print( "*************** 3SLS with restriction via restrict.regMat ********************" )
  +    fit3sls[[ i ]]$e3 <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, restrict.regMat = tc, method3sls = formulas[ i ],
  +       useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e3 ) )
  + 
  +    print( "*************** 3SLS with restriction via restrict.regMat (EViews-like) *******" )
  +    fit3sls[[ i ]]$e3e <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, methodResidCov = "noDfCor", restrict.regMat = tc,
  +       method3sls = formulas[ i ], x = TRUE,
  +       useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e3e, useDfSys = TRUE ) )
  + 
  +    print( "**** W3SLS with restriction via restrict.regMat (EViews-like) ****" )
  +    fit3sls[[ i ]]$e3we <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, methodResidCov = "noDfCor", restrict.regMat = tc,
  +       method3sls = formulas[ i ], residCovWeighted = TRUE,
  +       useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e3we, useDfSys = TRUE ) )
  + 
  + 
  +    print( "*************** 3SLS with 2 restrictions **********************" )
  +    fit3sls[[ i ]]$e4 <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, restrict.matrix = restr2m, restrict.rhs = restr2q,
  +       method3sls = formulas[ i ], x = TRUE,
  +       useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e4 ) )
  +    # the same with symbolically specified restrictions
  +    fit3sls[[ i ]]$e4Sym <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, restrict.matrix = restrict2, method3sls = formulas[ i ],
  +       x = TRUE, useMatrix = useMatrix )
  +    print( all.equal( fit3sls[[ i ]]$e4, fit3sls[[ i ]]$e4Sym ) )
  + 
  +    print( "*************** 3SLS with 2 restrictions (EViews-like) ************" )
  +    fit3sls[[ i ]]$e4e <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, methodResidCov = "noDfCor", restrict.matrix = restr2m,
  +       restrict.rhs = restr2q, method3sls = formulas[ i ],
  +       useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e4e, useDfSys = TRUE ) )
  + 
  +    print( "********** W3SLS with 2 (symbolic) restrictions ***************" )
  +    fit3sls[[ i ]]$e4wSym <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, restrict.matrix = restrict2, method3sls = formulas[ i ],
  +       residCovWeighted = TRUE, useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e4wSym ) )
  + 
  + 
  +    print( "*************** 3SLS with 2 restrictions via R and restrict.regMat **********" )
  +    fit3sls[[ i ]]$e5 <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, restrict.regMat = tc, restrict.matrix = restr3m,
  +       restrict.rhs = restr3q, method3sls = formulas[ i ],
  +       useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e5 ) )
  +    # the same with symbolically specified restrictions
  +    fit3sls[[ i ]]$e5Sym <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, restrict.regMat = tc, restrict.matrix = restrict3,
  +       method3sls = formulas[ i ], useMatrix = useMatrix )
  +    print( all.equal( fit3sls[[ i ]]$e5, fit3sls[[ i ]]$e5Sym ) )
  + 
  +    print( "******** 3SLS with 2 restrictions via R and restrict.regMat (EViews-like)*****" )
  +    fit3sls[[ i ]]$e5e <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, restrict.regMat = tc, methodResidCov = "noDfCor",
  +       restrict.matrix = restr3m, restrict.rhs = restr3q,
  +       method3sls = formulas[ i ], x = TRUE,
  +       useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e5e, useDfSys = TRUE ) )
  + 
  +    print( "*** W3SLS with 2 restrictions via R and restrict.regMat (EViews-like) ***" )
  +    fit3sls[[ i ]]$e5we <- systemfit( system, "3SLS", data = Kmenta,
  +       inst = inst, restrict.regMat = tc, methodResidCov = "noDfCor",
  +       restrict.matrix = restr3m, restrict.rhs = restr3q, method3sls = formulas[ i ],
  +       residCovWeighted = TRUE, useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$e5we, useDfSys = TRUE ) )
  + 
  +    ## *********** estimations with a single regressor ************
  +    fit3sls[[ i ]]$S1 <- systemfit(
  +       list( farmPrice ~ consump - 1, price ~ consump + trend ), "3SLS",
  +       data = Kmenta, inst = ~ trend + income, useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$S1 ) )
  +    fit3sls[[ i ]]$S2 <- systemfit(
  +       list( consump ~ farmPrice - 1, consump ~ trend - 1 ), "3SLS",
  +       data = Kmenta, inst = ~ price + income, useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$S2 ) )
  +    fit3sls[[ i ]]$S3 <- systemfit(
  +       list( consump ~ trend - 1, farmPrice ~ trend - 1 ), "3SLS",
  +       data = Kmenta, inst = instlist, useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$S3 ) )
  +    fit3sls[[ i ]]$S4 <- systemfit(
  +       list( consump ~ farmPrice - 1, price ~ trend - 1 ), "3SLS",
  +       data = Kmenta, inst = ~ farmPrice + trend + income,
  +       restrict.matrix = matrix( c( 1, -1 ), nrow = 1 ), useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$S4 ) )
  +    fit3sls[[ i ]]$S5 <- systemfit(
  +       list( consump ~ 1, price ~ 1 ), "3SLS",
  +       data = Kmenta, inst = ~ income, useMatrix = useMatrix )
  +    print( summary( fit3sls[[ i ]]$S5 ) )
  + }
  [1] "***************************************************"
  [1] "3SLS formula: GLS"
  [1] "************* 3SLS *********************************"
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  systemfit
   --- call from context --- 
  .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
   --- call from argument --- 
  if (class(resids) == "data.frame") {
      resids <- as.matrix(resids)
      validObsEq <- !is.na(resids)
      eqNames <- names(resids)
  } else if (!is.null(validObsEq)) {
      residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
      for (i in 1:ncol(validObsEq)) {
          residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
              0:(i - 1)])):(sum(validObsEq[, 1:i]))]
      }
      resids <- residMat
      rm(residMat)
  } else {
      stop("internal error in .calcResidCov: if argument 'validObsEq'", 
          " is not provided, argument 'resids' must be a data.frame'")
  }
   --- R stacktrace ---
  where 1: .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
  where 2: systemfit(system, "3SLS", data = Kmenta, inst = inst, method3sls = formulas[i], 
      useMatrix = useMatrix)
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (resids, methodResidCov, validObsEq = NULL, nCoefEq = NULL, 
      xEq = NULL, diag = FALSE, centered = FALSE, useMatrix = FALSE, 
      solvetol = .Machine$double.eps) 
  {
      eqNames <- NULL
      if (class(resids) == "data.frame") {
          resids <- as.matrix(resids)
          validObsEq <- !is.na(resids)
          eqNames <- names(resids)
      }
      else if (!is.null(validObsEq)) {
          residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
          for (i in 1:ncol(validObsEq)) {
              residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
                  0:(i - 1)])):(sum(validObsEq[, 1:i]))]
          }
          resids <- residMat
          rm(residMat)
      }
      else {
          stop("internal error in .calcResidCov: if argument 'validObsEq'", 
              " is not provided, argument 'resids' must be a data.frame'")
      }
      nEq <- ncol(validObsEq)
      result <- matrix(0, nEq, nEq)
      if (centered) {
          for (i in 1:nEq) {
              resids[, i] <- resids[, i] - mean(resids[validObsEq[, 
                  i], i])
          }
      }
      validObsAll <- rowSums(!validObsEq) == 0
      for (i in 1:nEq) {
          for (j in ifelse(diag, i, 1):ifelse(diag, i, nEq)) {
              if (methodResidCov == "noDfCor") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sum(validObsAll)
              }
              else if (methodResidCov == "geomean") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sqrt((sum(validObsAll) - 
                    nCoefEq[i]) * (sum(validObsAll) - nCoefEq[j]))
              }
              else if (methodResidCov == "Theil") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    nCoefEq[i] - nCoefEq[j] + sum(diag(solve(crossprod(xEq[[i]]), 
                    tol = solvetol) %*% crossprod(xEq[[i]], xEq[[j]]) %*% 
                    solve(crossprod(xEq[[j]]), tol = solvetol) %*% 
                    crossprod(xEq[[j]], xEq[[i]]))))
              }
              else if (methodResidCov == "max") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    max(nCoefEq[i], nCoefEq[j]))
              }
              else {
                  stop(paste("Argument 'methodResidCov' must be either 'noDfCor',", 
                    "'geomean', 'max', or 'Theil'."))
              }
          }
      }
      if (!is.null(eqNames)) {
          rownames(result) <- eqNames
          colnames(result) <- eqNames
      }
      if (useMatrix) {
          result <- as(result, "dspMatrix")
      }
      return(result)
  }
  <bytecode: 0x55b1320b9a08>
  <environment: namespace:systemfit>
   --- function search by body ---
  Function .calcResidCov in namespace systemfit has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1
Running the tests in ‘tests/test_hausman.R’ failed.
Complete output:
  > library( "systemfit" )
  Loading required package: Matrix
  Loading required package: car
  Loading required package: carData
  Loading required package: lmtest
  Loading required package: zoo
  
  Attaching package: 'zoo'
  
  The following objects are masked from 'package:base':
  
      as.Date, as.Date.numeric
  
  
  Please cite the 'systemfit' package as:
  Arne Henningsen and Jeff D. Hamann (2007). systemfit: A Package for Estimating Systems of Simultaneous Equations in R. Journal of Statistical Software 23(4), 1-40. http://www.jstatsoft.org/v23/i04/.
  
  If you have questions, suggestions, or comments regarding the 'systemfit' package, please use a forum or 'tracker' at systemfit's R-Forge site:
  https://r-forge.r-project.org/projects/systemfit/
  > options( digits = 5 )
  > 
  > data( "Kmenta" )
  > useMatrix <- FALSE
  > 
  > eqDemand <- consump ~ price + income
  > eqSupply <- consump ~ price + farmPrice + trend
  > inst <- ~ income + farmPrice + trend
  > eqSystem <- list( demand = eqDemand, supply = eqSupply )
  > restrm <- matrix(0,1,7)  # restriction matrix "R"
  > restrm[1,3] <-  1
  > restrm[1,7] <- -1
  > restr2m <- matrix(0,2,7)  # restriction matrix "R" 2
  > restr2m[1,3] <-  1
  > restr2m[1,7] <- -1
  > restr2m[2,2] <- -1
  > restr2m[2,5] <-  1
  > restr2q <- c( 0, 0.5 )  # restriction vector "q" 2
  > tc <- matrix(0,7,6)
  > tc[1,1] <- 1
  > tc[2,2] <- 1
  > tc[3,3] <- 1
  > tc[4,4] <- 1
  > tc[5,5] <- 1
  > tc[6,6] <- 1
  > tc[7,3] <- 1
  > restr3m <- matrix(0,1,6)  # restriction matrix "R" 2
  > restr3m[1,2] <- -1
  > restr3m[1,5] <-  1
  > restr3q <- c( 0.5 )  # restriction vector "q" 2
  > 
  > 
  > ## ******************* unrestricted estimation *****************
  > ## ******************** default estimation *********************
  > fit2sls1 <- systemfit( eqSystem, "2SLS", data = Kmenta, inst = inst,
  +    useMatrix = useMatrix )
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  systemfit
   --- call from context --- 
  .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      diag = TRUE, centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
   --- call from argument --- 
  if (class(resids) == "data.frame") {
      resids <- as.matrix(resids)
      validObsEq <- !is.na(resids)
      eqNames <- names(resids)
  } else if (!is.null(validObsEq)) {
      residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
      for (i in 1:ncol(validObsEq)) {
          residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
              0:(i - 1)])):(sum(validObsEq[, 1:i]))]
      }
      resids <- residMat
      rm(residMat)
  } else {
      stop("internal error in .calcResidCov: if argument 'validObsEq'", 
          " is not provided, argument 'resids' must be a data.frame'")
  }
   --- R stacktrace ---
  where 1: .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      diag = TRUE, centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
  where 2: systemfit(eqSystem, "2SLS", data = Kmenta, inst = inst, useMatrix = useMatrix)
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (resids, methodResidCov, validObsEq = NULL, nCoefEq = NULL, 
      xEq = NULL, diag = FALSE, centered = FALSE, useMatrix = FALSE, 
      solvetol = .Machine$double.eps) 
  {
      eqNames <- NULL
      if (class(resids) == "data.frame") {
          resids <- as.matrix(resids)
          validObsEq <- !is.na(resids)
          eqNames <- names(resids)
      }
      else if (!is.null(validObsEq)) {
          residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
          for (i in 1:ncol(validObsEq)) {
              residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
                  0:(i - 1)])):(sum(validObsEq[, 1:i]))]
          }
          resids <- residMat
          rm(residMat)
      }
      else {
          stop("internal error in .calcResidCov: if argument 'validObsEq'", 
              " is not provided, argument 'resids' must be a data.frame'")
      }
      nEq <- ncol(validObsEq)
      result <- matrix(0, nEq, nEq)
      if (centered) {
          for (i in 1:nEq) {
              resids[, i] <- resids[, i] - mean(resids[validObsEq[, 
                  i], i])
          }
      }
      validObsAll <- rowSums(!validObsEq) == 0
      for (i in 1:nEq) {
          for (j in ifelse(diag, i, 1):ifelse(diag, i, nEq)) {
              if (methodResidCov == "noDfCor") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sum(validObsAll)
              }
              else if (methodResidCov == "geomean") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sqrt((sum(validObsAll) - 
                    nCoefEq[i]) * (sum(validObsAll) - nCoefEq[j]))
              }
              else if (methodResidCov == "Theil") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    nCoefEq[i] - nCoefEq[j] + sum(diag(solve(crossprod(xEq[[i]]), 
                    tol = solvetol) %*% crossprod(xEq[[i]], xEq[[j]]) %*% 
                    solve(crossprod(xEq[[j]]), tol = solvetol) %*% 
                    crossprod(xEq[[j]], xEq[[i]]))))
              }
              else if (methodResidCov == "max") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    max(nCoefEq[i], nCoefEq[j]))
              }
              else {
                  stop(paste("Argument 'methodResidCov' must be either 'noDfCor',", 
                    "'geomean', 'max', or 'Theil'."))
              }
          }
      }
      if (!is.null(eqNames)) {
          rownames(result) <- eqNames
          colnames(result) <- eqNames
      }
      if (useMatrix) {
          result <- as(result, "dspMatrix")
      }
      return(result)
  }
  <bytecode: 0x560a2f018ed0>
  <environment: namespace:systemfit>
   --- function search by body ---
  Function .calcResidCov in namespace systemfit has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1
Running the tests in ‘tests/test_ols.R’ failed.
Complete output:
  > library( systemfit )
  Loading required package: Matrix
  Loading required package: car
  Loading required package: carData
  Loading required package: lmtest
  Loading required package: zoo
  
  Attaching package: 'zoo'
  
  The following objects are masked from 'package:base':
  
      as.Date, as.Date.numeric
  
  
  Please cite the 'systemfit' package as:
  Arne Henningsen and Jeff D. Hamann (2007). systemfit: A Package for Estimating Systems of Simultaneous Equations in R. Journal of Statistical Software 23(4), 1-40. http://www.jstatsoft.org/v23/i04/.
  
  If you have questions, suggestions, or comments regarding the 'systemfit' package, please use a forum or 'tracker' at systemfit's R-Forge site:
  https://r-forge.r-project.org/projects/systemfit/
  > options( digits = 3 )
  > 
  > data( "Kmenta" )
  > useMatrix <- FALSE
  > 
  > demand <- consump ~ price + income
  > supply <- consump ~ price + farmPrice + trend
  > system <- list( demand = demand, supply = supply )
  > restrm <- matrix(0,1,7)  # restriction matrix "R"
  > restrm[1,3] <-  1
  > restrm[1,7] <- -1
  > restrict <- "demand_income - supply_trend = 0"
  > restr2m <- matrix(0,2,7)  # restriction matrix "R" 2
  > restr2m[1,3] <-  1
  > restr2m[1,7] <- -1
  > restr2m[2,2] <- -1
  > restr2m[2,5] <-  1
  > restr2q <- c( 0, 0.5 )    # restriction vector "q" 2
  > restrict2 <- c( "demand_income - supply_trend = 0",
  +    "- demand_price + supply_price = 0.5" )
  > tc <- matrix(0,7,6)
  > tc[1,1] <- 1
  > tc[2,2] <- 1
  > tc[3,3] <- 1
  > tc[4,4] <- 1
  > tc[5,5] <- 1
  > tc[6,6] <- 1
  > tc[7,3] <- 1
  > restr3m <- matrix(0,1,6)  # restriction matrix "R" 2
  > restr3m[1,2] <- -1
  > restr3m[1,5] <-  1
  > restr3q <- c( 0.5 )       # restriction vector "q" 2
  > restrict3 <- "- C2 + C5 = 0.5"
  > 
  > # It is not possible to estimate OLS with systemfit
  > # exactly as EViews does, because EViews uses
  > # methodResidCov == "geomean" for the coefficient covariance matrix and
  > # methodResidCov == "noDfCor" for the residual covariance matrix, while
  > # systemfit uses always the same formulas for both calculations.
  > 
  > ## *******  single-equation OLS estimations  *********************
  > lmDemand <- lm( demand, data = Kmenta )
  > lmSupply <- lm( supply, data = Kmenta )
  > 
  > ## *************** OLS estimation ************************
  > ## ********** OLS estimation (default) ********************
  > fitols1 <- systemfit( system, "OLS", data = Kmenta, useMatrix = useMatrix )
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  systemfit
   --- call from context --- 
  .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      diag = TRUE, centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
   --- call from argument --- 
  if (class(resids) == "data.frame") {
      resids <- as.matrix(resids)
      validObsEq <- !is.na(resids)
      eqNames <- names(resids)
  } else if (!is.null(validObsEq)) {
      residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
      for (i in 1:ncol(validObsEq)) {
          residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
              0:(i - 1)])):(sum(validObsEq[, 1:i]))]
      }
      resids <- residMat
      rm(residMat)
  } else {
      stop("internal error in .calcResidCov: if argument 'validObsEq'", 
          " is not provided, argument 'resids' must be a data.frame'")
  }
   --- R stacktrace ---
  where 1: .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      diag = TRUE, centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
  where 2: systemfit(system, "OLS", data = Kmenta, useMatrix = useMatrix)
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (resids, methodResidCov, validObsEq = NULL, nCoefEq = NULL, 
      xEq = NULL, diag = FALSE, centered = FALSE, useMatrix = FALSE, 
      solvetol = .Machine$double.eps) 
  {
      eqNames <- NULL
      if (class(resids) == "data.frame") {
          resids <- as.matrix(resids)
          validObsEq <- !is.na(resids)
          eqNames <- names(resids)
      }
      else if (!is.null(validObsEq)) {
          residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
          for (i in 1:ncol(validObsEq)) {
              residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
                  0:(i - 1)])):(sum(validObsEq[, 1:i]))]
          }
          resids <- residMat
          rm(residMat)
      }
      else {
          stop("internal error in .calcResidCov: if argument 'validObsEq'", 
              " is not provided, argument 'resids' must be a data.frame'")
      }
      nEq <- ncol(validObsEq)
      result <- matrix(0, nEq, nEq)
      if (centered) {
          for (i in 1:nEq) {
              resids[, i] <- resids[, i] - mean(resids[validObsEq[, 
                  i], i])
          }
      }
      validObsAll <- rowSums(!validObsEq) == 0
      for (i in 1:nEq) {
          for (j in ifelse(diag, i, 1):ifelse(diag, i, nEq)) {
              if (methodResidCov == "noDfCor") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sum(validObsAll)
              }
              else if (methodResidCov == "geomean") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sqrt((sum(validObsAll) - 
                    nCoefEq[i]) * (sum(validObsAll) - nCoefEq[j]))
              }
              else if (methodResidCov == "Theil") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    nCoefEq[i] - nCoefEq[j] + sum(diag(solve(crossprod(xEq[[i]]), 
                    tol = solvetol) %*% crossprod(xEq[[i]], xEq[[j]]) %*% 
                    solve(crossprod(xEq[[j]]), tol = solvetol) %*% 
                    crossprod(xEq[[j]], xEq[[i]]))))
              }
              else if (methodResidCov == "max") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    max(nCoefEq[i], nCoefEq[j]))
              }
              else {
                  stop(paste("Argument 'methodResidCov' must be either 'noDfCor',", 
                    "'geomean', 'max', or 'Theil'."))
              }
          }
      }
      if (!is.null(eqNames)) {
          rownames(result) <- eqNames
          colnames(result) <- eqNames
      }
      if (useMatrix) {
          result <- as(result, "dspMatrix")
      }
      return(result)
  }
  <bytecode: 0x55bac2eda520>
  <environment: namespace:systemfit>
   --- function search by body ---
  Function .calcResidCov in namespace systemfit has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1
Running the tests in ‘tests/test_panel.R’ failed.
Complete output:
  > library( systemfit )
  Loading required package: Matrix
  Loading required package: car
  Loading required package: carData
  Loading required package: lmtest
  Loading required package: zoo
  
  Attaching package: 'zoo'
  
  The following objects are masked from 'package:base':
  
      as.Date, as.Date.numeric
  
  
  Please cite the 'systemfit' package as:
  Arne Henningsen and Jeff D. Hamann (2007). systemfit: A Package for Estimating Systems of Simultaneous Equations in R. Journal of Statistical Software 23(4), 1-40. http://www.jstatsoft.org/v23/i04/.
  
  If you have questions, suggestions, or comments regarding the 'systemfit' package, please use a forum or 'tracker' at systemfit's R-Forge site:
  https://r-forge.r-project.org/projects/systemfit/
  > library( plm )
  > options( digits = 3 )
  > useMatrix <- FALSE
  > 
  > ## Repeating the OLS and SUR estimations in Theil (1971, pp. 295, 300)
  > data( "GrunfeldGreene" )
  > GrunfeldTheil <- subset( GrunfeldGreene,
  +    firm %in% c( "General Electric", "Westinghouse" ) )
  > GrunfeldTheil <- pdata.frame( GrunfeldTheil, c( "firm", "year" ) )
  > formulaGrunfeld <- invest ~ value + capital
  > 
  > # OLS
  > theilOls <- systemfit( formulaGrunfeld, "OLS",
  +    data = GrunfeldTheil, useMatrix = useMatrix )
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  systemfit
   --- call from context --- 
  .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      diag = TRUE, centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
   --- call from argument --- 
  if (class(resids) == "data.frame") {
      resids <- as.matrix(resids)
      validObsEq <- !is.na(resids)
      eqNames <- names(resids)
  } else if (!is.null(validObsEq)) {
      residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
      for (i in 1:ncol(validObsEq)) {
          residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
              0:(i - 1)])):(sum(validObsEq[, 1:i]))]
      }
      resids <- residMat
      rm(residMat)
  } else {
      stop("internal error in .calcResidCov: if argument 'validObsEq'", 
          " is not provided, argument 'resids' must be a data.frame'")
  }
   --- R stacktrace ---
  where 1: .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      diag = TRUE, centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
  where 2: systemfit(formulaGrunfeld, "OLS", data = GrunfeldTheil, useMatrix = useMatrix)
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (resids, methodResidCov, validObsEq = NULL, nCoefEq = NULL, 
      xEq = NULL, diag = FALSE, centered = FALSE, useMatrix = FALSE, 
      solvetol = .Machine$double.eps) 
  {
      eqNames <- NULL
      if (class(resids) == "data.frame") {
          resids <- as.matrix(resids)
          validObsEq <- !is.na(resids)
          eqNames <- names(resids)
      }
      else if (!is.null(validObsEq)) {
          residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
          for (i in 1:ncol(validObsEq)) {
              residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
                  0:(i - 1)])):(sum(validObsEq[, 1:i]))]
          }
          resids <- residMat
          rm(residMat)
      }
      else {
          stop("internal error in .calcResidCov: if argument 'validObsEq'", 
              " is not provided, argument 'resids' must be a data.frame'")
      }
      nEq <- ncol(validObsEq)
      result <- matrix(0, nEq, nEq)
      if (centered) {
          for (i in 1:nEq) {
              resids[, i] <- resids[, i] - mean(resids[validObsEq[, 
                  i], i])
          }
      }
      validObsAll <- rowSums(!validObsEq) == 0
      for (i in 1:nEq) {
          for (j in ifelse(diag, i, 1):ifelse(diag, i, nEq)) {
              if (methodResidCov == "noDfCor") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sum(validObsAll)
              }
              else if (methodResidCov == "geomean") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sqrt((sum(validObsAll) - 
                    nCoefEq[i]) * (sum(validObsAll) - nCoefEq[j]))
              }
              else if (methodResidCov == "Theil") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    nCoefEq[i] - nCoefEq[j] + sum(diag(solve(crossprod(xEq[[i]]), 
                    tol = solvetol) %*% crossprod(xEq[[i]], xEq[[j]]) %*% 
                    solve(crossprod(xEq[[j]]), tol = solvetol) %*% 
                    crossprod(xEq[[j]], xEq[[i]]))))
              }
              else if (methodResidCov == "max") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    max(nCoefEq[i], nCoefEq[j]))
              }
              else {
                  stop(paste("Argument 'methodResidCov' must be either 'noDfCor',", 
                    "'geomean', 'max', or 'Theil'."))
              }
          }
      }
      if (!is.null(eqNames)) {
          rownames(result) <- eqNames
          colnames(result) <- eqNames
      }
      if (useMatrix) {
          result <- as(result, "dspMatrix")
      }
      return(result)
  }
  <bytecode: 0x55dae01d2a28>
  <environment: namespace:systemfit>
   --- function search by body ---
  Function .calcResidCov in namespace systemfit has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1
Running the tests in ‘tests/test_sur.R’ failed.
Complete output:
  > library( systemfit )
  Loading required package: Matrix
  Loading required package: car
  Loading required package: carData
  Loading required package: lmtest
  Loading required package: zoo
  
  Attaching package: 'zoo'
  
  The following objects are masked from 'package:base':
  
      as.Date, as.Date.numeric
  
  
  Please cite the 'systemfit' package as:
  Arne Henningsen and Jeff D. Hamann (2007). systemfit: A Package for Estimating Systems of Simultaneous Equations in R. Journal of Statistical Software 23(4), 1-40. http://www.jstatsoft.org/v23/i04/.
  
  If you have questions, suggestions, or comments regarding the 'systemfit' package, please use a forum or 'tracker' at systemfit's R-Forge site:
  https://r-forge.r-project.org/projects/systemfit/
  > options( digits = 3 )
  > 
  > data( "Kmenta" )
  > useMatrix <- FALSE
  > 
  > demand <- consump ~ price + income
  > supply <- consump ~ price + farmPrice + trend
  > system <- list( demand = demand, supply = supply )
  > restrm <- matrix(0,1,7)  # restriction matrix "R"
  > restrm[1,3] <-  1
  > restrm[1,7] <- -1
  > restrict <- "demand_income - supply_trend = 0"
  > restr2m <- matrix(0,2,7)  # restriction matrix "R" 2
  > restr2m[1,3] <-  1
  > restr2m[1,7] <- -1
  > restr2m[2,2] <- -1
  > restr2m[2,5] <-  1
  > restr2q <- c( 0, 0.5 )  # restriction vector "q" 2
  > restrict2 <- c( "demand_income - supply_trend = 0",
  +    "- demand_price + supply_price = 0.5" )
  > restrict2i <- c( "demand_income - supply_trend = 0",
  +    "- demand_price + supply_income = 0.5" )
  > tc <- matrix(0,7,6)
  > tc[1,1] <- 1
  > tc[2,2] <- 1
  > tc[3,3] <- 1
  > tc[4,4] <- 1
  > tc[5,5] <- 1
  > tc[6,6] <- 1
  > tc[7,3] <- 1
  > restr3m <- matrix(0,1,6)  # restriction matrix "R" 2
  > restr3m[1,2] <- -1
  > restr3m[1,5] <-  1
  > restr3q <- c( 0.5 )  # restriction vector "q" 2
  > restrict3 <- "- C2 + C5 = 0.5"
  > 
  > # the standard equations do not converge and lead to a singular weighting matrix
  > # both in R and in EViews, since both equations have the same endogenous variable
  > supply2 <- price ~ income + farmPrice + trend
  > system2 <- list( demand = demand, supply = supply2 )
  > 
  > 
  > ## *************** SUR estimation ************************
  > fitsur1 <- systemfit( system, "SUR", data = Kmenta, useMatrix = useMatrix )
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  systemfit
   --- call from context --- 
  .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
   --- call from argument --- 
  if (class(resids) == "data.frame") {
      resids <- as.matrix(resids)
      validObsEq <- !is.na(resids)
      eqNames <- names(resids)
  } else if (!is.null(validObsEq)) {
      residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
      for (i in 1:ncol(validObsEq)) {
          residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
              0:(i - 1)])):(sum(validObsEq[, 1:i]))]
      }
      resids <- residMat
      rm(residMat)
  } else {
      stop("internal error in .calcResidCov: if argument 'validObsEq'", 
          " is not provided, argument 'resids' must be a data.frame'")
  }
   --- R stacktrace ---
  where 1: .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
  where 2: systemfit(system, "SUR", data = Kmenta, useMatrix = useMatrix)
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (resids, methodResidCov, validObsEq = NULL, nCoefEq = NULL, 
      xEq = NULL, diag = FALSE, centered = FALSE, useMatrix = FALSE, 
      solvetol = .Machine$double.eps) 
  {
      eqNames <- NULL
      if (class(resids) == "data.frame") {
          resids <- as.matrix(resids)
          validObsEq <- !is.na(resids)
          eqNames <- names(resids)
      }
      else if (!is.null(validObsEq)) {
          residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
          for (i in 1:ncol(validObsEq)) {
              residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
                  0:(i - 1)])):(sum(validObsEq[, 1:i]))]
          }
          resids <- residMat
          rm(residMat)
      }
      else {
          stop("internal error in .calcResidCov: if argument 'validObsEq'", 
              " is not provided, argument 'resids' must be a data.frame'")
      }
      nEq <- ncol(validObsEq)
      result <- matrix(0, nEq, nEq)
      if (centered) {
          for (i in 1:nEq) {
              resids[, i] <- resids[, i] - mean(resids[validObsEq[, 
                  i], i])
          }
      }
      validObsAll <- rowSums(!validObsEq) == 0
      for (i in 1:nEq) {
          for (j in ifelse(diag, i, 1):ifelse(diag, i, nEq)) {
              if (methodResidCov == "noDfCor") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sum(validObsAll)
              }
              else if (methodResidCov == "geomean") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sqrt((sum(validObsAll) - 
                    nCoefEq[i]) * (sum(validObsAll) - nCoefEq[j]))
              }
              else if (methodResidCov == "Theil") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    nCoefEq[i] - nCoefEq[j] + sum(diag(solve(crossprod(xEq[[i]]), 
                    tol = solvetol) %*% crossprod(xEq[[i]], xEq[[j]]) %*% 
                    solve(crossprod(xEq[[j]]), tol = solvetol) %*% 
                    crossprod(xEq[[j]], xEq[[i]]))))
              }
              else if (methodResidCov == "max") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    max(nCoefEq[i], nCoefEq[j]))
              }
              else {
                  stop(paste("Argument 'methodResidCov' must be either 'noDfCor',", 
                    "'geomean', 'max', or 'Theil'."))
              }
          }
      }
      if (!is.null(eqNames)) {
          rownames(result) <- eqNames
          colnames(result) <- eqNames
      }
      if (useMatrix) {
          result <- as(result, "dspMatrix")
      }
      return(result)
  }
  <bytecode: 0x5634804b3ec8>
  <environment: namespace:systemfit>
   --- function search by body ---
  Function .calcResidCov in namespace systemfit has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1
Running the tests in ‘tests/test_w2sls.R’ failed.
Complete output:
  > library( systemfit )
  Loading required package: Matrix
  Loading required package: car
  Loading required package: carData
  Loading required package: lmtest
  Loading required package: zoo
  
  Attaching package: 'zoo'
  
  The following objects are masked from 'package:base':
  
      as.Date, as.Date.numeric
  
  
  Please cite the 'systemfit' package as:
  Arne Henningsen and Jeff D. Hamann (2007). systemfit: A Package for Estimating Systems of Simultaneous Equations in R. Journal of Statistical Software 23(4), 1-40. http://www.jstatsoft.org/v23/i04/.
  
  If you have questions, suggestions, or comments regarding the 'systemfit' package, please use a forum or 'tracker' at systemfit's R-Forge site:
  https://r-forge.r-project.org/projects/systemfit/
  > options( digits = 3 )
  > 
  > data( "Kmenta" )
  > useMatrix <- FALSE
  > 
  > demand <- consump ~ price + income
  > supply <- consump ~ price + farmPrice + trend
  > inst <- ~ income + farmPrice + trend
  > inst1  <- ~ income + farmPrice
  > instlist <- list( inst1, inst )
  > system <- list( demand = demand, supply = supply )
  > restrm <- matrix(0,1,7)  # restriction matrix "R"
  > restrm[1,3] <-  1
  > restrm[1,7] <- -1
  > restrict <- "demand_income - supply_trend = 0"
  > restr2m <- matrix(0,2,7)  # restriction matrix "R" 2
  > restr2m[1,3] <-  1
  > restr2m[1,7] <- -1
  > restr2m[2,2] <- -1
  > restr2m[2,5] <-  1
  > restr2q <- c( 0, 0.5 )  # restriction vector "q" 2
  > restrict2 <- c( "demand_income - supply_trend = 0",
  +    "- demand_price + supply_price = 0.5" )
  > tc <- matrix(0,7,6)
  > tc[1,1] <- 1
  > tc[2,2] <- 1
  > tc[3,3] <- 1
  > tc[4,4] <- 1
  > tc[5,5] <- 1
  > tc[6,6] <- 1
  > tc[7,3] <- 1
  > restr3m <- matrix(0,1,6)  # restriction matrix "R" 2
  > restr3m[1,2] <- -1
  > restr3m[1,5] <-  1
  > restr3q <- c( 0.5 )  # restriction vector "q" 2
  > restrict3 <- "- C2 + C5 = 0.5"
  > 
  > 
  > ## ********************* W2SLS *****************
  > fitw2sls1 <- systemfit( system, "W2SLS", data = Kmenta, inst = inst,
  +    useMatrix = useMatrix )
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  systemfit
   --- call from context --- 
  .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      diag = TRUE, centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
   --- call from argument --- 
  if (class(resids) == "data.frame") {
      resids <- as.matrix(resids)
      validObsEq <- !is.na(resids)
      eqNames <- names(resids)
  } else if (!is.null(validObsEq)) {
      residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
      for (i in 1:ncol(validObsEq)) {
          residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
              0:(i - 1)])):(sum(validObsEq[, 1:i]))]
      }
      resids <- residMat
      rm(residMat)
  } else {
      stop("internal error in .calcResidCov: if argument 'validObsEq'", 
          " is not provided, argument 'resids' must be a data.frame'")
  }
   --- R stacktrace ---
  where 1: .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      diag = TRUE, centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
  where 2: systemfit(system, "W2SLS", data = Kmenta, inst = inst, useMatrix = useMatrix)
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (resids, methodResidCov, validObsEq = NULL, nCoefEq = NULL, 
      xEq = NULL, diag = FALSE, centered = FALSE, useMatrix = FALSE, 
      solvetol = .Machine$double.eps) 
  {
      eqNames <- NULL
      if (class(resids) == "data.frame") {
          resids <- as.matrix(resids)
          validObsEq <- !is.na(resids)
          eqNames <- names(resids)
      }
      else if (!is.null(validObsEq)) {
          residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
          for (i in 1:ncol(validObsEq)) {
              residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
                  0:(i - 1)])):(sum(validObsEq[, 1:i]))]
          }
          resids <- residMat
          rm(residMat)
      }
      else {
          stop("internal error in .calcResidCov: if argument 'validObsEq'", 
              " is not provided, argument 'resids' must be a data.frame'")
      }
      nEq <- ncol(validObsEq)
      result <- matrix(0, nEq, nEq)
      if (centered) {
          for (i in 1:nEq) {
              resids[, i] <- resids[, i] - mean(resids[validObsEq[, 
                  i], i])
          }
      }
      validObsAll <- rowSums(!validObsEq) == 0
      for (i in 1:nEq) {
          for (j in ifelse(diag, i, 1):ifelse(diag, i, nEq)) {
              if (methodResidCov == "noDfCor") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sum(validObsAll)
              }
              else if (methodResidCov == "geomean") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sqrt((sum(validObsAll) - 
                    nCoefEq[i]) * (sum(validObsAll) - nCoefEq[j]))
              }
              else if (methodResidCov == "Theil") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    nCoefEq[i] - nCoefEq[j] + sum(diag(solve(crossprod(xEq[[i]]), 
                    tol = solvetol) %*% crossprod(xEq[[i]], xEq[[j]]) %*% 
                    solve(crossprod(xEq[[j]]), tol = solvetol) %*% 
                    crossprod(xEq[[j]], xEq[[i]]))))
              }
              else if (methodResidCov == "max") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    max(nCoefEq[i], nCoefEq[j]))
              }
              else {
                  stop(paste("Argument 'methodResidCov' must be either 'noDfCor',", 
                    "'geomean', 'max', or 'Theil'."))
              }
          }
      }
      if (!is.null(eqNames)) {
          rownames(result) <- eqNames
          colnames(result) <- eqNames
      }
      if (useMatrix) {
          result <- as(result, "dspMatrix")
      }
      return(result)
  }
  <bytecode: 0x55ac485a8998>
  <environment: namespace:systemfit>
   --- function search by body ---
  Function .calcResidCov in namespace systemfit has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1
Running the tests in ‘tests/test_wls.R’ failed.
Complete output:
  > library( systemfit )
  Loading required package: Matrix
  Loading required package: car
  Loading required package: carData
  Loading required package: lmtest
  Loading required package: zoo
  
  Attaching package: 'zoo'
  
  The following objects are masked from 'package:base':
  
      as.Date, as.Date.numeric
  
  
  Please cite the 'systemfit' package as:
  Arne Henningsen and Jeff D. Hamann (2007). systemfit: A Package for Estimating Systems of Simultaneous Equations in R. Journal of Statistical Software 23(4), 1-40. http://www.jstatsoft.org/v23/i04/.
  
  If you have questions, suggestions, or comments regarding the 'systemfit' package, please use a forum or 'tracker' at systemfit's R-Forge site:
  https://r-forge.r-project.org/projects/systemfit/
  > options( digits = 3 )
  > 
  > data( "Kmenta" )
  > useMatrix <- FALSE
  > 
  > demand <- consump ~ price + income
  > supply <- consump ~ price + farmPrice + trend
  > system <- list( demand = demand, supply = supply )
  > restrm <- matrix(0,1,7)  # restriction matrix "R"
  > restrm[1,3] <-  1
  > restrm[1,7] <- -1
  > restrict <- "demand_income - supply_trend = 0"
  > restr2m <- matrix(0,2,7)  # restriction matrix "R" 2
  > restr2m[1,3] <-  1
  > restr2m[1,7] <- -1
  > restr2m[2,2] <- -1
  > restr2m[2,5] <-  1
  > restr2q <- c( 0, 0.5 )  # restriction vector "q" 2
  > restrict2 <- c( "demand_income - supply_trend = 0",
  +    "- demand_price + supply_price = 0.5" )
  > tc <- matrix(0,7,6)
  > tc[1,1] <- 1
  > tc[2,2] <- 1
  > tc[3,3] <- 1
  > tc[4,4] <- 1
  > tc[5,5] <- 1
  > tc[6,6] <- 1
  > tc[7,3] <- 1
  > restr3m <- matrix(0,1,6)  # restriction matrix "R" 2
  > restr3m[1,2] <- -1
  > restr3m[1,5] <-  1
  > restr3q <- c( 0.5 )  # restriction vector "q" 2
  > restrict3 <- "- C2 + C5 = 0.5"
  > 
  > 
  > ## *******  single-equation OLS estimations  *********************
  > lmDemand <- lm( demand, data = Kmenta )
  > lmSupply <- lm( supply, data = Kmenta )
  > 
  > ## *************** WLS estimation ************************
  > fitwls1 <- systemfit( system, "WLS", data = Kmenta, useMatrix = useMatrix )
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  systemfit
   --- call from context --- 
  .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      diag = TRUE, centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
   --- call from argument --- 
  if (class(resids) == "data.frame") {
      resids <- as.matrix(resids)
      validObsEq <- !is.na(resids)
      eqNames <- names(resids)
  } else if (!is.null(validObsEq)) {
      residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
      for (i in 1:ncol(validObsEq)) {
          residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
              0:(i - 1)])):(sum(validObsEq[, 1:i]))]
      }
      resids <- residMat
      rm(residMat)
  } else {
      stop("internal error in .calcResidCov: if argument 'validObsEq'", 
          " is not provided, argument 'resids' must be a data.frame'")
  }
   --- R stacktrace ---
  where 1: .calcResidCov(resids, methodResidCov = control$methodResidCov, 
      validObsEq = validObsEq, nCoefEq = nCoefLiEq, xEq = xMatEq, 
      diag = TRUE, centered = control$centerResiduals, useMatrix = control$useMatrix, 
      solvetol = control$solvetol)
  where 2: systemfit(system, "WLS", data = Kmenta, useMatrix = useMatrix)
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (resids, methodResidCov, validObsEq = NULL, nCoefEq = NULL, 
      xEq = NULL, diag = FALSE, centered = FALSE, useMatrix = FALSE, 
      solvetol = .Machine$double.eps) 
  {
      eqNames <- NULL
      if (class(resids) == "data.frame") {
          resids <- as.matrix(resids)
          validObsEq <- !is.na(resids)
          eqNames <- names(resids)
      }
      else if (!is.null(validObsEq)) {
          residMat <- matrix(NA, nrow = nrow(validObsEq), ncol = ncol(validObsEq))
          for (i in 1:ncol(validObsEq)) {
              residMat[validObsEq[, i], i] <- resids[(1 + sum(validObsEq[, 
                  0:(i - 1)])):(sum(validObsEq[, 1:i]))]
          }
          resids <- residMat
          rm(residMat)
      }
      else {
          stop("internal error in .calcResidCov: if argument 'validObsEq'", 
              " is not provided, argument 'resids' must be a data.frame'")
      }
      nEq <- ncol(validObsEq)
      result <- matrix(0, nEq, nEq)
      if (centered) {
          for (i in 1:nEq) {
              resids[, i] <- resids[, i] - mean(resids[validObsEq[, 
                  i], i])
          }
      }
      validObsAll <- rowSums(!validObsEq) == 0
      for (i in 1:nEq) {
          for (j in ifelse(diag, i, 1):ifelse(diag, i, nEq)) {
              if (methodResidCov == "noDfCor") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sum(validObsAll)
              }
              else if (methodResidCov == "geomean") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/sqrt((sum(validObsAll) - 
                    nCoefEq[i]) * (sum(validObsAll) - nCoefEq[j]))
              }
              else if (methodResidCov == "Theil") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    nCoefEq[i] - nCoefEq[j] + sum(diag(solve(crossprod(xEq[[i]]), 
                    tol = solvetol) %*% crossprod(xEq[[i]], xEq[[j]]) %*% 
                    solve(crossprod(xEq[[j]]), tol = solvetol) %*% 
                    crossprod(xEq[[j]], xEq[[i]]))))
              }
              else if (methodResidCov == "max") {
                  result[i, j] <- sum(resids[validObsAll, i] * 
                    resids[validObsAll, j])/(sum(validObsAll) - 
                    max(nCoefEq[i], nCoefEq[j]))
              }
              else {
                  stop(paste("Argument 'methodResidCov' must be either 'noDfCor',", 
                    "'geomean', 'max', or 'Theil'."))
              }
          }
      }
      if (!is.null(eqNames)) {
          rownames(result) <- eqNames
          colnames(result) <- eqNames
      }
      if (useMatrix) {
          result <- as(result, "dspMatrix")
      }
      return(result)
  }
  <bytecode: 0x55e37734db08>
  <environment: namespace:systemfit>
   --- function search by body ---
  Function .calcResidCov in namespace systemfit has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1