Running ‘fail.R’ [2s/3s]
  Running ‘frontier41.R’ [1s/2s]
  Running ‘frontierTest.R’ [2s/3s]
  Running ‘nestedModels.R’ [2s/3s]
  Running ‘translogRay.R’ [2s/4s]
  Running ‘translogRayMult.R’ [3s/4s]
  Running ‘wrongSkewness.R’ [2s/3s]
Running the tests in ‘tests/fail.R’ failed.
Complete output:
  > library( "frontier" )
  Loading required package: micEcon
  
  If you have questions, suggestions, or comments regarding one of the 'micEcon' packages, please use a forum or 'tracker' at micEcon's R-Forge site:
  https://r-forge.r-project.org/projects/micecon/
  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 'frontier' package as:
  Tim Coelli and Arne Henningsen (2013). frontier: Stochastic Frontier Analysis. R package version 1.1. http://CRAN.R-Project.org/package=frontier.
  
  If you have questions, suggestions, or comments regarding the 'frontier' package, please use a forum or 'tracker' at frontier's R-Forge site:
  https://r-forge.r-project.org/projects/frontier/
  > library( "plm" )
  > options( digits = 5 )
  > 
  > ## example data included in FRONTIER 4.1 (cross-section data)
  > data( front41Data )
  > front41Data$firmNo <- c( 1:nrow( front41Data ) )
  > 
  > ## non-existing variable
  > try( sfa( log( output ) ~ log( capital7 ) + log( labour ),
  +    data = front41Data ) )
  Error in eval(predvars, data, env) : object 'capital7' not found
  > 
  > ## nParamTotal > nObs
  > try( sfa( log( output ) ~ log( capital ) + log( labour ),
  +    data = front41Data[ 1:4, ] ) )
  Error in sfa(log(output) ~ log(capital) + log(labour), data = front41Data[1:4,  : 
    the model cannot be estimated, because the number of parameters (5) is larger than the number of observations (4)
  > 
  > ## nParamTotal >> nObs
  > try( sfa( log( output ) ~ log( capital ) + log( labour ),
  +    data = front41Data[ 1:2, ] ) )
  Error in sfa(log(output) ~ log(capital) + log(labour), data = front41Data[1:2,  : 
    the model cannot be estimated, because the number of parameters (5) is larger than the number of observations (2)
  > 
  > ## nParamTotal > number of valid observations
  > try( sfa( log( output ) ~ log( capital ) + log( labour ) + log( firmNo - 56 ),
  +    data = front41Data ) )
  Error in sfa(log(output) ~ log(capital) + log(labour) + log(firmNo - 56),  : 
    the model cannot be estimated, because the number of parameters (6) is larger than the number of valid observations (4)
  In addition: Warning message:
  In log(firmNo - 56) : NaNs produced
  > 
  > ## the dependent variable has only infinite values
  > try( sfa( log( 0 * output ) ~ log( capital ) + log( labour ),
  +    data = front41Data ) )
  Error in sfa(log(0 * output) ~ log(capital) + log(labour), data = front41Data) : 
    the dependent variable has no valid observations
  > 
  > ## the dependent variable has only NA values
  > try( sfa( log( -output ) ~ log( capital ) + log( labour ),
  +    data = front41Data ) )
  Error in sfa(log(-output) ~ log(capital) + log(labour), data = front41Data) : 
    the dependent variable has no valid observations
  In addition: Warning message:
  In log(-output) : NaNs produced
  > 
  > ## one of the regressors has only infinite values
  > try( sfa( log( output ) ~ log( 0 * capital ) + log( labour ),
  +    data = front41Data ) )
  Error in sfa(log(output) ~ log(0 * capital) + log(labour), data = front41Data) : 
    regressor 'log(0 * capital)' has no valid observations
  > 
  > ## one of the regressors has only NA values
  > try( sfa( log( output ) ~ log( capital ) + log( -labour ),
  +    data = front41Data ) )
  Error in sfa(log(output) ~ log(capital) + log(-labour), data = front41Data) : 
    regressor 'log(-labour)' has no valid observations
  In addition: Warning message:
  In log(-labour) : NaNs produced
  > 
  > ## one of the regressors of the inefficiency term has only infinite values
  > try( sfa( log( output ) ~ log( capital ) + log( labour ) | log( 0 * firmNo ),
  +    data = front41Data ) )
  Error in sfa(log(output) ~ log(capital) + log(labour) | log(0 * firmNo),  : 
    the regressor for the inefficiency term 'log(0 * firmNo)' has no valid observations
  > 
  > ## one of the regressors of the inefficiency term has only NA values
  > try( sfa( log( output ) ~ log( capital ) + log( labour ) | log(-firmNo ),
  +    data = front41Data ) )
  Error in sfa(log(output) ~ log(capital) + log(labour) | log(-firmNo),  : 
    the regressor for the inefficiency term 'log(-firmNo)' has no valid observations
  In addition: Warning message:
  In log(-firmNo) : NaNs produced
  > 
  > ## no convergence
  > a1 <- sfa( log( output ) ~ log( capital ) + log( labour ),
  +    data = front41Data, maxit = 2 )
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  frontier
   --- call from context --- 
  sfa(log(output) ~ log(capital) + log(labour), data = front41Data, 
      maxit = 2)
   --- call from argument --- 
  if (class(testSingularCov) == "try-error") {
      if (grepl("singular", testSingularCov[1])) {
          warning("the covariance matrix of the maximum likelihood estimates", 
              " is singular")
      }
      else {
          warning("the covariance matrix of the maximum likelihood estimates", 
              " is not invertible")
      }
  }
   --- R stacktrace ---
  where 1: sfa(log(output) ~ log(capital) + log(labour), data = front41Data, 
      maxit = 2)
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (formula, data = sys.frame(sys.parent()), ineffDecrease = TRUE, 
      truncNorm = FALSE, timeEffect = FALSE, startVal = NULL, tol = 1e-05, 
      maxit = 1000, muBound = 2, bignum = 1e+16, searchStep = 1e-05, 
      searchTol = 0.001, searchScale = NA, gridSize = 0.1, gridDouble = TRUE, 
      restartMax = 10, restartFactor = 0.999, printIter = 0) 
  {
      formula <- as.Formula(formula)
      if (length(formula)[2] == 1) {
          modelType <- 1
          effFormula <- NULL
      }
      else if (length(formula)[2] == 2) {
          modelType <- 2
          effFormula <- formula(formula, lhs = 0, rhs = 2)
      }
      else {
          stop("argument 'formula' has an inappropriate number of RHS parts")
      }
      formula <- formula(formula, lhs = 1, rhs = 1)
      if (class(formula) != "formula") {
          stop("argument 'formula' must be a formula")
      }
      else if (length(formula) != 3) {
          stop("argument 'formula' must be a 2-sided formula")
      }
      if (!is.logical(ineffDecrease) || length(ineffDecrease) != 
          1) {
          stop("argument 'ineffDecrease' must be a single logical value")
      }
      if (!is.logical(truncNorm)) {
          stop("argument 'truncNorm' must be logical")
      }
      if (truncNorm && modelType == 2) {
          warning("argument 'truncNorm' is ignored in", " Efficiency Effects Frontiers (EEF)")
      }
      if (!is.logical(timeEffect)) {
          stop("argument 'timeEffect' must be logical")
      }
      if (timeEffect && !(inherits(data, "pdata.frame") || inherits(data, 
          "plm.dim"))) {
          warning("argument 'timeEffect' is ignored in case of", 
              " cross-sectional data")
      }
      if (!is.numeric(printIter)) {
          stop("argument 'printIter' must be numeric")
      }
      else if (printIter != round(printIter)) {
          stop("argument 'printIter' must be an iteger")
      }
      else if (printIter < 0) {
          stop("argument 'printIter' must be non-negative")
      }
      printIter <- as.integer(printIter)
      if (length(searchScale) != 1) {
          stop("argument 'searchScale' must be a single logical value or NA")
      }
      else if (is.na(searchScale)) {
          indic <- as.integer(1)
      }
      else if (is.logical(searchScale)) {
          indic <- as.integer(2 - 2 * searchScale)
      }
      else {
          stop("argument 'searchScale' must be a logical value or NA")
      }
      if (!is.numeric(tol)) {
          stop("argument 'tol' must be numeric")
      }
      else if (tol < 0) {
          stop("argument 'tol' must be non-negative")
      }
      if (!is.numeric(searchTol)) {
          stop("argument 'searchTol' must be numeric")
      }
      else if (searchTol < 0) {
          stop("argument 'searchTol' must be non-negative")
      }
      if (!is.numeric(muBound) || length(muBound) != 1) {
          stop("argument 'muBound' must be a numeric scalar")
      }
      else if (is.infinite(muBound)) {
          muBound <- 0
      }
      if (!is.numeric(bignum)) {
          stop("argument 'bignum' must be numeric")
      }
      else if (bignum <= 0) {
          stop("argument 'bignum' must be positive")
      }
      if (!is.numeric(searchStep)) {
          stop("argument 'searchStep' must be numeric")
      }
      else if (searchStep <= 0) {
          stop("argument 'searchStep' must be positive")
      }
      if (!is.logical(gridDouble) || length(gridDouble) != 1) {
          stop("argument 'gridDouble' must be a single logical value")
      }
      if (!is.numeric(gridSize)) {
          stop("argument 'gridSize' must be numeric")
      }
      else if (gridSize <= 0) {
          stop("argument 'gridSize' must be positive")
      }
      if (!is.numeric(maxit) || length(maxit) != 1) {
          stop("argument 'maxit' must be a single numeric scalar")
      }
      else if (maxit != round(maxit)) {
          stop("argument 'maxit' must be an integer")
      }
      else if (maxit < 0) {
          stop("argument 'maxit' must not be negative")
      }
      maxit <- as.integer(maxit)
      if (!is.numeric(restartMax) || length(restartMax) != 1) {
          stop("argument 'restartMax' must be a single numeric scalar")
      }
      else if (restartMax != round(restartMax)) {
          stop("argument 'restartMax' must be an integer")
      }
      else if (restartMax < 0) {
          stop("argument 'restartMax' must not be negative")
      }
      restartMax <- as.integer(restartMax)
      if (!is.numeric(restartFactor) || length(restartFactor) != 
          1) {
          stop("argument 'restartFactor' must be a numeric scalar")
      }
      else if (is.infinite(restartFactor)) {
          stop("argument 'restartFactor' must be finite")
      }
      mc <- match.call(expand.dots = FALSE)
      tmp <- frontierDataTable(formula = formula, effFormula = effFormula, 
          data = data, mc = mc)
      if (is.character(tmp)) {
          stop(tmp)
      }
      validObs <- tmp$validObs
      dataTable <- cbind(tmp$idVec, tmp$timeVec, tmp$yVec, tmp$xMat, 
          tmp$zMat)
      rownames(dataTable) <- names(validObs)[validObs]
      colnames(dataTable)[1:3] <- c("id", "t", tmp$yName)
      firmId <- tmp$firmId
      timeId <- tmp$timeId
      nb <- ncol(tmp$xMat)
      nob <- sum(validObs)
      nn <- max(tmp$idVec)
      nt <- max(tmp$timeVec)
      zIntercept <- tmp$zIntercept
      nZvars <- ncol(tmp$zMat)
      if (modelType == 1) {
          mu <- truncNorm
      }
      else {
          mu <- zIntercept
      }
      if (modelType == 1) {
          eta <- timeEffect
      }
      else {
          eta <- nZvars
      }
      nParamTotal <- nb + 2 + mu + eta
      if (nParamTotal > nob) {
          stop("the model cannot be estimated,", " because the number of parameters (", 
              nParamTotal, ") is larger than the number of", ifelse(sum(!validObs) > 
                  0, " valid", ""), " observations (", nob, ")")
      }
      if (is.null(startVal)) {
          startVal <- 0
      }
      else {
          if (nParamTotal != length(startVal)) {
              stop("wrong number of starting values (you provided ", 
                  length(startVal), " starting values but the model has ", 
                  nParamTotal, " parameters)")
          }
      }
      if (nb > 0) {
          ols <- lm(tmp$yVec ~ tmp$xMat - 1)
      }
      else if (nb == 0) {
          ols <- lm(tmp$yVec ~ -1)
      }
      if (any(is.na(coef(ols)))) {
          stop("at least one coefficient estimated by OLS is NA: ", 
              paste(colnames(tmp$xMat)[is.na(coef(ols))], collapse = ", "), 
              ". This may have been caused by (nearly) perfect multicollinearity")
      }
      olsParam <- c(coef(ols), summary(ols)$sigma^2)
      olsStdEr <- sqrt(diag(vcov(ols)))
      olsLogl <- logLik(ols)[1]
      if (nb > 0) {
          gridAdj <- coef(lm(rep(1, nrow(dataTable)) ~ dataTable[, 
              4:(3 + nb)] - 1))
      }
      else {
          gridAdj <- numeric(0)
      }
      if (length(gridAdj) != nb) {
          stop("internal error: the length of 'gridAdj' is not equal to 'nb'.", 
              " Please contact the maintainer of the frontier package")
      }
      returnObj <- .Fortran(C_front41, modelType = as.integer(modelType), 
          ineffDecrease = as.integer((!ineffDecrease) + 1), icept = as.integer(0), 
          nn = as.integer(nn), nt = as.integer(nt), nob = as.integer(nob), 
          nb = as.integer(nb), mu = as.integer(mu), eta = as.integer(eta), 
          printIter = as.integer(printIter), indic = as.integer(indic), 
          tol = as.double(tol), searchTol = as.double(searchTol), 
          bignum = as.double(bignum), searchStep = as.double(searchStep), 
          gridDouble = as.integer(gridDouble), gridSize = as.double(gridSize), 
          maxit = as.integer(maxit), muBound = as.double(muBound), 
          restartMax = as.integer(restartMax), restartFactor = as.double(restartFactor), 
          nRestart = as.integer(0), nStartVal = as.integer(length(startVal)), 
          startVal = as.double(startVal), nRowData = as.integer(nrow(dataTable)), 
          nColData = as.integer(ncol(dataTable)), dataTable = matrix(as.double(dataTable), 
              nrow(dataTable), ncol(dataTable), dimnames = dimnames(dataTable)), 
          nParamTotal = as.integer(nParamTotal), olsParam = as.double(c(olsParam, 
              rep(0, 1 + mu + eta))), gridAdj = as.double(gridAdj), 
          gridParam = as.double(rep(0, nParamTotal)), startLogl = as.double(0), 
          mleParam = as.double(rep(0, nParamTotal)), mleCov = matrix(as.double(0), 
              nParamTotal, nParamTotal), mleLogl = as.double(0), 
          nIter = as.integer(0), code = as.integer(0), nFuncEval = as.integer(0))
      if (returnObj$code == 101) {
          stop("the total number of observations exceeds the product of", 
              " the number of firms by the number of years")
      }
      else if (returnObj$code == 102) {
          stop("internal error: calculated variable 'n'", " is not equal to argument 'nParamTotal'.", 
              " Please contact the maintainer of the 'frontier' package", 
              " (arne.henningsen@gmail.com)")
      }
      else if (returnObj$code == 103) {
          stop("wrong number of starting values")
      }
      else if (returnObj$code == 104) {
          stop("a firm number is < 1")
      }
      else if (returnObj$code == 105) {
          stop("a firm number is > number of firms")
      }
      else if (returnObj$code == 106) {
          stop("a period number is < 1")
      }
      else if (returnObj$code == 107) {
          stop("a period number is > number of periods")
      }
      else if (returnObj$code == 108) {
          stop("there are no observations on at least one firm")
      }
      else if (returnObj$code == 109) {
          stop("internal error: 2 + nr - nmu * (im-1)", " is not equal to argument 'nColData'.", 
              " Please contact the maintainer of the 'frontier' package", 
              " (arne.henningsen@gmail.com)")
      }
      else if (returnObj$code > 100) {
          stop("unknown error.", " Please contact the maintainer of the 'frontier' package", 
              " (arne.henningsen@gmail.com)")
      }
      returnObj$nStartVal <- NULL
      returnObj$nRowData <- NULL
      returnObj$nColData <- NULL
      returnObj$nParamTotal <- NULL
      returnObj$ineffDecrease <- as.logical(2 - returnObj$ineffDecrease)
      returnObj$gridDouble <- as.logical(returnObj$gridDouble)
      returnObj$olsParam <- olsParam
      returnObj$olsStdEr <- olsStdEr
      returnObj$olsLogl <- olsLogl
      if (nb == 0) {
          fitVal <- rep(0, sum(validObs))
      }
      else {
          fitVal <- drop(dataTable[, 4:(3 + nb), drop = FALSE] %*% 
              returnObj$mleParam[1:nb])
      }
      returnObj$fitted <- matrix(NA, nrow = nn, ncol = nt)
      if (length(fitVal) != nrow(dataTable)) {
          stop("internal error: length of the fitted values is not equal to", 
              " the number of rows of the data table (valid observations)")
      }
      for (i in 1:length(fitVal)) {
          returnObj$fitted[dataTable[i, 1], dataTable[i, 2]] <- fitVal[i]
      }
      resid <- drop(dataTable[, 3] - fitVal)
      returnObj$resid <- matrix(NA, nrow = nn, ncol = nt)
      if (length(resid) != nrow(dataTable)) {
          stop("internal error: length of residuals is not equal to", 
              " the number of rows of the data table (valid observations)")
      }
      for (i in 1:length(resid)) {
          returnObj$resid[dataTable[i, 1], dataTable[i, 2]] <- resid[i]
      }
      returnObj$olsResid <- residuals(ols)
      returnObj$olsSkewness <- skewness(returnObj$olsResid)
      returnObj$olsSkewnessOkay <- returnObj$olsSkewness * (-1)^ineffDecrease >= 
          0
      warnMaxit <- maxit <= returnObj$nIter && maxit > 0
      if (!returnObj$olsSkewnessOkay && returnObj$mleLogl < returnObj$olsLogl) {
          warning("the residuals of the OLS estimates are ", ifelse(ineffDecrease, 
              "right", "left"), "-skewed", " and the likelihood value of the ML estimation is less", 
              " than that obtained using OLS;", " this usually indicates that there is no inefficiency", 
              " or that the model is misspecified")
      }
      else if (!returnObj$olsSkewnessOkay) {
          warning("the residuals of the OLS estimates are ", ifelse(ineffDecrease, 
              "right", "left"), "-skewed;", " this might indicate that there is no inefficiency", 
              " or that the model is misspecified")
      }
      else if (returnObj$mleLogl < returnObj$olsLogl && warnMaxit) {
          warning("the maximum number of iterations has been reached and", 
              " the likelihood value of the ML estimation is less", 
              " than that obtained using OLS;", " please try again using different starting values and/or", 
              " increase the maximum number of iterations")
          warnMaxit <- FALSE
      }
      else if (returnObj$mleLogl < returnObj$olsLogl && maxit > 
          0) {
          warning("the likelihood value of the ML estimation is less", 
              " than that obtained using OLS;", " this indicates that the likelihood maximization did not", 
              " converge to the global maximum or", " that there is no inefficiency", 
              " (you could try again using different starting values)")
      }
      if (warnMaxit) {
          warning("the maximum number of iterations has been reached;", 
              " please try again using different starting values and/or", 
              " increase the maximum number of iterations")
      }
      if (modelType == 1) {
          returnObj$truncNorm <- as.logical(returnObj$mu)
          returnObj$zIntercept <- zIntercept
          returnObj$mu <- NULL
      }
      else {
          returnObj$truncNorm <- truncNorm
          returnObj$zIntercept <- as.logical(returnObj$mu)
          returnObj$mu <- NULL
      }
      if (modelType == 1) {
          returnObj$timeEffect <- as.logical(returnObj$eta)
      }
      else {
          returnObj$timeEffect <- timeEffect
      }
      returnObj$eta <- NULL
      if (returnObj$indic == 2) {
          returnObj$searchScale <- FALSE
      }
      else if (returnObj$indic == 1) {
          returnObj$searchScale <- NA
      }
      else {
          returnObj$searchScale <- TRUE
      }
      returnObj$indic <- NULL
      if (length(startVal) == 1) {
          if (modelType == 1) {
              idx <- 1:(nb + 2)
          }
          else {
              if (nb == 0) {
                  idx <- NULL
              }
              else {
                  idx <- 1:nb
              }
              idx <- c(idx, (nParamTotal - 1):nParamTotal)
          }
          if (any(returnObj$gridParam[(1:nParamTotal)[-idx]] != 
              0)) {
              warning("internal error: some unused grid-search parameters are", 
                  " non-zero: ", paste(returnObj$gridParam, collapse = " "), 
                  " please contact the maintainer of the 'frontier' package")
          }
          returnObj$gridParam <- returnObj$gridParam[idx]
          names(returnObj)[names(returnObj) == "startLogl"] <- "gridLogl"
      }
      else {
          returnObj$gridParam <- NULL
      }
      if (inherits(data, "pdata.frame") || inherits(data, "plm.dim")) {
          rownames(returnObj$resid) <- levels(index(data)[[1]])[firmId]
          colnames(returnObj$resid) <- levels(index(data)[[2]])[timeId]
      }
      else {
          rownames(returnObj$resid) <- names(validObs)[validObs]
          colnames(returnObj$resid) <- "residuals"
      }
      paramNames <- colnames(tmp$xMat)
      if (modelType == 2) {
          if (zIntercept) {
              paramNames <- c(paramNames, "Z_(Intercept)")
          }
          if (nZvars > 0) {
              paramNames <- c(paramNames, paste("Z", colnames(tmp$zMat), 
                  sep = "_"))
          }
      }
      if (length(startVal) == 1) {
          returnObj$startVal <- NULL
      }
      paramNames <- c(paramNames, "sigmaSq", "gamma")
      if (modelType == 1) {
          if (truncNorm) {
              paramNames <- c(paramNames, "mu")
          }
          if (timeEffect) {
              paramNames <- c(paramNames, "time")
          }
      }
      if (nb >= 1) {
          betaNames <- paramNames[1:nb]
      }
      else {
          betaNames <- NULL
      }
      names(returnObj$olsParam) <- c(betaNames, "sigmaSq")
      names(returnObj$olsStdEr) <- betaNames
      if (!is.null(returnObj$gridParam)) {
          names(returnObj$gridParam) <- c(betaNames, "sigmaSq", 
              "gamma")
      }
      names(returnObj$mleParam) <- paramNames
      rownames(returnObj$mleCov) <- paramNames
      colnames(returnObj$mleCov) <- paramNames
      if (!is.null(returnObj$startVal)) {
          names(returnObj$startVal) <- paramNames
      }
      returnObj$call <- match.call()
      returnObj$validObs <- validObs
      if (maxit > 0) {
          if ((returnObj$mleParam["gamma"] < 0.01 || returnObj$mleParam["gamma"] > 
              0.99)) {
              warning("the parameter 'gamma' is close to the boundary", 
                  " of the parameter space [0,1]:", " this can cause convergence problems and", 
                  " can negatively affect the validity and reliability", 
                  " of statistical tests", " and might be caused by model misspecification")
          }
          if (!semidefiniteness(returnObj$mleCov)) {
              warning("the covariance matrix of the maximum likelihood estimates", 
                  " is not positive semidefinite")
          }
          else {
              testSingularCov <- try(solve(returnObj$mleCov), silent = TRUE)
              if (class(testSingularCov) == "try-error") {
                  if (grepl("singular", testSingularCov[1])) {
                    warning("the covariance matrix of the maximum likelihood estimates", 
                      " is singular")
                  }
                  else {
                    warning("the covariance matrix of the maximum likelihood estimates", 
                      " is not invertible")
                  }
              }
          }
      }
      class(returnObj) <- "frontier"
      return(returnObj)
  }
  <bytecode: 0x55de9ebdfb80>
  <environment: namespace:frontier>
   --- function search by body ---
  Function sfa in namespace frontier has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1
Running the tests in ‘tests/frontierTest.R’ failed.
Complete output:
  > library( "frontier" )
  Loading required package: micEcon
  
  If you have questions, suggestions, or comments regarding one of the 'micEcon' packages, please use a forum or 'tracker' at micEcon's R-Forge site:
  https://r-forge.r-project.org/projects/micecon/
  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 'frontier' package as:
  Tim Coelli and Arne Henningsen (2013). frontier: Stochastic Frontier Analysis. R package version 1.1. http://CRAN.R-Project.org/package=frontier.
  
  If you have questions, suggestions, or comments regarding the 'frontier' package, please use a forum or 'tracker' at frontier's R-Forge site:
  https://r-forge.r-project.org/projects/frontier/
  > library( "plm" )
  > options( digits = 5 )
  > 
  > printAll <- function( x ) {
  +    for( n in names( x ) ) {
  +       cat( "$", n, "\n", sep = "" )
  +       if( n %in% c( "olsParam", "gridAdj", "gridParam", "mleParam", "olsStdEr", 
  +             "mleCov", "resid", "fitted", "olsResid" ) ) {
  +          print( round( x[[ n ]], 2 ) )
  +       } else {
  +          print( x[[ n ]] )
  +       }
  +       cat( "\n" )
  +    }
  +    cat( "class\n" )
  +    print( class( x ) )
  + }
  > 
  > printME <- function( x ) {
  +    me <- attr( x, "margEff" )
  +    attr( x, "margEff" ) <- NULL
  +    print( round( x, 2 ) )
  +    if( !is.null( me ) ) {
  +       cat( "margEff\n" )
  +       print( round( me, 2 ) )
  +    }
  + }
  > 
  > ## example data included in FRONTIER 4.1 (cross-section data)
  > data( front41Data )
  > row.names( front41Data ) <- paste( "F", row.names( front41Data ), sep = "_" )
  > front41Data$logOutput  <- log( front41Data$output )
  > front41Data$logCapital <- log( front41Data$capital )
  > front41Data$logLabour  <- log( front41Data$labour )
  > front41Data$firmNo     <- c( 1:nrow( front41Data ) )
  > front41Data$ones       <- 1
  >    
  > ## cross-section data, error components frontier
  > sa1 <- sfa( logOutput ~ logCapital + logLabour, data = front41Data )
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  frontier
   --- call from context --- 
  sfa(logOutput ~ logCapital + logLabour, data = front41Data)
   --- call from argument --- 
  if (class(testSingularCov) == "try-error") {
      if (grepl("singular", testSingularCov[1])) {
          warning("the covariance matrix of the maximum likelihood estimates", 
              " is singular")
      }
      else {
          warning("the covariance matrix of the maximum likelihood estimates", 
              " is not invertible")
      }
  }
   --- R stacktrace ---
  where 1: sfa(logOutput ~ logCapital + logLabour, data = front41Data)
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (formula, data = sys.frame(sys.parent()), ineffDecrease = TRUE, 
      truncNorm = FALSE, timeEffect = FALSE, startVal = NULL, tol = 1e-05, 
      maxit = 1000, muBound = 2, bignum = 1e+16, searchStep = 1e-05, 
      searchTol = 0.001, searchScale = NA, gridSize = 0.1, gridDouble = TRUE, 
      restartMax = 10, restartFactor = 0.999, printIter = 0) 
  {
      formula <- as.Formula(formula)
      if (length(formula)[2] == 1) {
          modelType <- 1
          effFormula <- NULL
      }
      else if (length(formula)[2] == 2) {
          modelType <- 2
          effFormula <- formula(formula, lhs = 0, rhs = 2)
      }
      else {
          stop("argument 'formula' has an inappropriate number of RHS parts")
      }
      formula <- formula(formula, lhs = 1, rhs = 1)
      if (class(formula) != "formula") {
          stop("argument 'formula' must be a formula")
      }
      else if (length(formula) != 3) {
          stop("argument 'formula' must be a 2-sided formula")
      }
      if (!is.logical(ineffDecrease) || length(ineffDecrease) != 
          1) {
          stop("argument 'ineffDecrease' must be a single logical value")
      }
      if (!is.logical(truncNorm)) {
          stop("argument 'truncNorm' must be logical")
      }
      if (truncNorm && modelType == 2) {
          warning("argument 'truncNorm' is ignored in", " Efficiency Effects Frontiers (EEF)")
      }
      if (!is.logical(timeEffect)) {
          stop("argument 'timeEffect' must be logical")
      }
      if (timeEffect && !(inherits(data, "pdata.frame") || inherits(data, 
          "plm.dim"))) {
          warning("argument 'timeEffect' is ignored in case of", 
              " cross-sectional data")
      }
      if (!is.numeric(printIter)) {
          stop("argument 'printIter' must be numeric")
      }
      else if (printIter != round(printIter)) {
          stop("argument 'printIter' must be an iteger")
      }
      else if (printIter < 0) {
          stop("argument 'printIter' must be non-negative")
      }
      printIter <- as.integer(printIter)
      if (length(searchScale) != 1) {
          stop("argument 'searchScale' must be a single logical value or NA")
      }
      else if (is.na(searchScale)) {
          indic <- as.integer(1)
      }
      else if (is.logical(searchScale)) {
          indic <- as.integer(2 - 2 * searchScale)
      }
      else {
          stop("argument 'searchScale' must be a logical value or NA")
      }
      if (!is.numeric(tol)) {
          stop("argument 'tol' must be numeric")
      }
      else if (tol < 0) {
          stop("argument 'tol' must be non-negative")
      }
      if (!is.numeric(searchTol)) {
          stop("argument 'searchTol' must be numeric")
      }
      else if (searchTol < 0) {
          stop("argument 'searchTol' must be non-negative")
      }
      if (!is.numeric(muBound) || length(muBound) != 1) {
          stop("argument 'muBound' must be a numeric scalar")
      }
      else if (is.infinite(muBound)) {
          muBound <- 0
      }
      if (!is.numeric(bignum)) {
          stop("argument 'bignum' must be numeric")
      }
      else if (bignum <= 0) {
          stop("argument 'bignum' must be positive")
      }
      if (!is.numeric(searchStep)) {
          stop("argument 'searchStep' must be numeric")
      }
      else if (searchStep <= 0) {
          stop("argument 'searchStep' must be positive")
      }
      if (!is.logical(gridDouble) || length(gridDouble) != 1) {
          stop("argument 'gridDouble' must be a single logical value")
      }
      if (!is.numeric(gridSize)) {
          stop("argument 'gridSize' must be numeric")
      }
      else if (gridSize <= 0) {
          stop("argument 'gridSize' must be positive")
      }
      if (!is.numeric(maxit) || length(maxit) != 1) {
          stop("argument 'maxit' must be a single numeric scalar")
      }
      else if (maxit != round(maxit)) {
          stop("argument 'maxit' must be an integer")
      }
      else if (maxit < 0) {
          stop("argument 'maxit' must not be negative")
      }
      maxit <- as.integer(maxit)
      if (!is.numeric(restartMax) || length(restartMax) != 1) {
          stop("argument 'restartMax' must be a single numeric scalar")
      }
      else if (restartMax != round(restartMax)) {
          stop("argument 'restartMax' must be an integer")
      }
      else if (restartMax < 0) {
          stop("argument 'restartMax' must not be negative")
      }
      restartMax <- as.integer(restartMax)
      if (!is.numeric(restartFactor) || length(restartFactor) != 
          1) {
          stop("argument 'restartFactor' must be a numeric scalar")
      }
      else if (is.infinite(restartFactor)) {
          stop("argument 'restartFactor' must be finite")
      }
      mc <- match.call(expand.dots = FALSE)
      tmp <- frontierDataTable(formula = formula, effFormula = effFormula, 
          data = data, mc = mc)
      if (is.character(tmp)) {
          stop(tmp)
      }
      validObs <- tmp$validObs
      dataTable <- cbind(tmp$idVec, tmp$timeVec, tmp$yVec, tmp$xMat, 
          tmp$zMat)
      rownames(dataTable) <- names(validObs)[validObs]
      colnames(dataTable)[1:3] <- c("id", "t", tmp$yName)
      firmId <- tmp$firmId
      timeId <- tmp$timeId
      nb <- ncol(tmp$xMat)
      nob <- sum(validObs)
      nn <- max(tmp$idVec)
      nt <- max(tmp$timeVec)
      zIntercept <- tmp$zIntercept
      nZvars <- ncol(tmp$zMat)
      if (modelType == 1) {
          mu <- truncNorm
      }
      else {
          mu <- zIntercept
      }
      if (modelType == 1) {
          eta <- timeEffect
      }
      else {
          eta <- nZvars
      }
      nParamTotal <- nb + 2 + mu + eta
      if (nParamTotal > nob) {
          stop("the model cannot be estimated,", " because the number of parameters (", 
              nParamTotal, ") is larger than the number of", ifelse(sum(!validObs) > 
                  0, " valid", ""), " observations (", nob, ")")
      }
      if (is.null(startVal)) {
          startVal <- 0
      }
      else {
          if (nParamTotal != length(startVal)) {
              stop("wrong number of starting values (you provided ", 
                  length(startVal), " starting values but the model has ", 
                  nParamTotal, " parameters)")
          }
      }
      if (nb > 0) {
          ols <- lm(tmp$yVec ~ tmp$xMat - 1)
      }
      else if (nb == 0) {
          ols <- lm(tmp$yVec ~ -1)
      }
      if (any(is.na(coef(ols)))) {
          stop("at least one coefficient estimated by OLS is NA: ", 
              paste(colnames(tmp$xMat)[is.na(coef(ols))], collapse = ", "), 
              ". This may have been caused by (nearly) perfect multicollinearity")
      }
      olsParam <- c(coef(ols), summary(ols)$sigma^2)
      olsStdEr <- sqrt(diag(vcov(ols)))
      olsLogl <- logLik(ols)[1]
      if (nb > 0) {
          gridAdj <- coef(lm(rep(1, nrow(dataTable)) ~ dataTable[, 
              4:(3 + nb)] - 1))
      }
      else {
          gridAdj <- numeric(0)
      }
      if (length(gridAdj) != nb) {
          stop("internal error: the length of 'gridAdj' is not equal to 'nb'.", 
              " Please contact the maintainer of the frontier package")
      }
      returnObj <- .Fortran(C_front41, modelType = as.integer(modelType), 
          ineffDecrease = as.integer((!ineffDecrease) + 1), icept = as.integer(0), 
          nn = as.integer(nn), nt = as.integer(nt), nob = as.integer(nob), 
          nb = as.integer(nb), mu = as.integer(mu), eta = as.integer(eta), 
          printIter = as.integer(printIter), indic = as.integer(indic), 
          tol = as.double(tol), searchTol = as.double(searchTol), 
          bignum = as.double(bignum), searchStep = as.double(searchStep), 
          gridDouble = as.integer(gridDouble), gridSize = as.double(gridSize), 
          maxit = as.integer(maxit), muBound = as.double(muBound), 
          restartMax = as.integer(restartMax), restartFactor = as.double(restartFactor), 
          nRestart = as.integer(0), nStartVal = as.integer(length(startVal)), 
          startVal = as.double(startVal), nRowData = as.integer(nrow(dataTable)), 
          nColData = as.integer(ncol(dataTable)), dataTable = matrix(as.double(dataTable), 
              nrow(dataTable), ncol(dataTable), dimnames = dimnames(dataTable)), 
          nParamTotal = as.integer(nParamTotal), olsParam = as.double(c(olsParam, 
              rep(0, 1 + mu + eta))), gridAdj = as.double(gridAdj), 
          gridParam = as.double(rep(0, nParamTotal)), startLogl = as.double(0), 
          mleParam = as.double(rep(0, nParamTotal)), mleCov = matrix(as.double(0), 
              nParamTotal, nParamTotal), mleLogl = as.double(0), 
          nIter = as.integer(0), code = as.integer(0), nFuncEval = as.integer(0))
      if (returnObj$code == 101) {
          stop("the total number of observations exceeds the product of", 
              " the number of firms by the number of years")
      }
      else if (returnObj$code == 102) {
          stop("internal error: calculated variable 'n'", " is not equal to argument 'nParamTotal'.", 
              " Please contact the maintainer of the 'frontier' package", 
              " (arne.henningsen@gmail.com)")
      }
      else if (returnObj$code == 103) {
          stop("wrong number of starting values")
      }
      else if (returnObj$code == 104) {
          stop("a firm number is < 1")
      }
      else if (returnObj$code == 105) {
          stop("a firm number is > number of firms")
      }
      else if (returnObj$code == 106) {
          stop("a period number is < 1")
      }
      else if (returnObj$code == 107) {
          stop("a period number is > number of periods")
      }
      else if (returnObj$code == 108) {
          stop("there are no observations on at least one firm")
      }
      else if (returnObj$code == 109) {
          stop("internal error: 2 + nr - nmu * (im-1)", " is not equal to argument 'nColData'.", 
              " Please contact the maintainer of the 'frontier' package", 
              " (arne.henningsen@gmail.com)")
      }
      else if (returnObj$code > 100) {
          stop("unknown error.", " Please contact the maintainer of the 'frontier' package", 
              " (arne.henningsen@gmail.com)")
      }
      returnObj$nStartVal <- NULL
      returnObj$nRowData <- NULL
      returnObj$nColData <- NULL
      returnObj$nParamTotal <- NULL
      returnObj$ineffDecrease <- as.logical(2 - returnObj$ineffDecrease)
      returnObj$gridDouble <- as.logical(returnObj$gridDouble)
      returnObj$olsParam <- olsParam
      returnObj$olsStdEr <- olsStdEr
      returnObj$olsLogl <- olsLogl
      if (nb == 0) {
          fitVal <- rep(0, sum(validObs))
      }
      else {
          fitVal <- drop(dataTable[, 4:(3 + nb), drop = FALSE] %*% 
              returnObj$mleParam[1:nb])
      }
      returnObj$fitted <- matrix(NA, nrow = nn, ncol = nt)
      if (length(fitVal) != nrow(dataTable)) {
          stop("internal error: length of the fitted values is not equal to", 
              " the number of rows of the data table (valid observations)")
      }
      for (i in 1:length(fitVal)) {
          returnObj$fitted[dataTable[i, 1], dataTable[i, 2]] <- fitVal[i]
      }
      resid <- drop(dataTable[, 3] - fitVal)
      returnObj$resid <- matrix(NA, nrow = nn, ncol = nt)
      if (length(resid) != nrow(dataTable)) {
          stop("internal error: length of residuals is not equal to", 
              " the number of rows of the data table (valid observations)")
      }
      for (i in 1:length(resid)) {
          returnObj$resid[dataTable[i, 1], dataTable[i, 2]] <- resid[i]
      }
      returnObj$olsResid <- residuals(ols)
      returnObj$olsSkewness <- skewness(returnObj$olsResid)
      returnObj$olsSkewnessOkay <- returnObj$olsSkewness * (-1)^ineffDecrease >= 
          0
      warnMaxit <- maxit <= returnObj$nIter && maxit > 0
      if (!returnObj$olsSkewnessOkay && returnObj$mleLogl < returnObj$olsLogl) {
          warning("the residuals of the OLS estimates are ", ifelse(ineffDecrease, 
              "right", "left"), "-skewed", " and the likelihood value of the ML estimation is less", 
              " than that obtained using OLS;", " this usually indicates that there is no inefficiency", 
              " or that the model is misspecified")
      }
      else if (!returnObj$olsSkewnessOkay) {
          warning("the residuals of the OLS estimates are ", ifelse(ineffDecrease, 
              "right", "left"), "-skewed;", " this might indicate that there is no inefficiency", 
              " or that the model is misspecified")
      }
      else if (returnObj$mleLogl < returnObj$olsLogl && warnMaxit) {
          warning("the maximum number of iterations has been reached and", 
              " the likelihood value of the ML estimation is less", 
              " than that obtained using OLS;", " please try again using different starting values and/or", 
              " increase the maximum number of iterations")
          warnMaxit <- FALSE
      }
      else if (returnObj$mleLogl < returnObj$olsLogl && maxit > 
          0) {
          warning("the likelihood value of the ML estimation is less", 
              " than that obtained using OLS;", " this indicates that the likelihood maximization did not", 
              " converge to the global maximum or", " that there is no inefficiency", 
              " (you could try again using different starting values)")
      }
      if (warnMaxit) {
          warning("the maximum number of iterations has been reached;", 
              " please try again using different starting values and/or", 
              " increase the maximum number of iterations")
      }
      if (modelType == 1) {
          returnObj$truncNorm <- as.logical(returnObj$mu)
          returnObj$zIntercept <- zIntercept
          returnObj$mu <- NULL
      }
      else {
          returnObj$truncNorm <- truncNorm
          returnObj$zIntercept <- as.logical(returnObj$mu)
          returnObj$mu <- NULL
      }
      if (modelType == 1) {
          returnObj$timeEffect <- as.logical(returnObj$eta)
      }
      else {
          returnObj$timeEffect <- timeEffect
      }
      returnObj$eta <- NULL
      if (returnObj$indic == 2) {
          returnObj$searchScale <- FALSE
      }
      else if (returnObj$indic == 1) {
          returnObj$searchScale <- NA
      }
      else {
          returnObj$searchScale <- TRUE
      }
      returnObj$indic <- NULL
      if (length(startVal) == 1) {
          if (modelType == 1) {
              idx <- 1:(nb + 2)
          }
          else {
              if (nb == 0) {
                  idx <- NULL
              }
              else {
                  idx <- 1:nb
              }
              idx <- c(idx, (nParamTotal - 1):nParamTotal)
          }
          if (any(returnObj$gridParam[(1:nParamTotal)[-idx]] != 
              0)) {
              warning("internal error: some unused grid-search parameters are", 
                  " non-zero: ", paste(returnObj$gridParam, collapse = " "), 
                  " please contact the maintainer of the 'frontier' package")
          }
          returnObj$gridParam <- returnObj$gridParam[idx]
          names(returnObj)[names(returnObj) == "startLogl"] <- "gridLogl"
      }
      else {
          returnObj$gridParam <- NULL
      }
      if (inherits(data, "pdata.frame") || inherits(data, "plm.dim")) {
          rownames(returnObj$resid) <- levels(index(data)[[1]])[firmId]
          colnames(returnObj$resid) <- levels(index(data)[[2]])[timeId]
      }
      else {
          rownames(returnObj$resid) <- names(validObs)[validObs]
          colnames(returnObj$resid) <- "residuals"
      }
      paramNames <- colnames(tmp$xMat)
      if (modelType == 2) {
          if (zIntercept) {
              paramNames <- c(paramNames, "Z_(Intercept)")
          }
          if (nZvars > 0) {
              paramNames <- c(paramNames, paste("Z", colnames(tmp$zMat), 
                  sep = "_"))
          }
      }
      if (length(startVal) == 1) {
          returnObj$startVal <- NULL
      }
      paramNames <- c(paramNames, "sigmaSq", "gamma")
      if (modelType == 1) {
          if (truncNorm) {
              paramNames <- c(paramNames, "mu")
          }
          if (timeEffect) {
              paramNames <- c(paramNames, "time")
          }
      }
      if (nb >= 1) {
          betaNames <- paramNames[1:nb]
      }
      else {
          betaNames <- NULL
      }
      names(returnObj$olsParam) <- c(betaNames, "sigmaSq")
      names(returnObj$olsStdEr) <- betaNames
      if (!is.null(returnObj$gridParam)) {
          names(returnObj$gridParam) <- c(betaNames, "sigmaSq", 
              "gamma")
      }
      names(returnObj$mleParam) <- paramNames
      rownames(returnObj$mleCov) <- paramNames
      colnames(returnObj$mleCov) <- paramNames
      if (!is.null(returnObj$startVal)) {
          names(returnObj$startVal) <- paramNames
      }
      returnObj$call <- match.call()
      returnObj$validObs <- validObs
      if (maxit > 0) {
          if ((returnObj$mleParam["gamma"] < 0.01 || returnObj$mleParam["gamma"] > 
              0.99)) {
              warning("the parameter 'gamma' is close to the boundary", 
                  " of the parameter space [0,1]:", " this can cause convergence problems and", 
                  " can negatively affect the validity and reliability", 
                  " of statistical tests", " and might be caused by model misspecification")
          }
          if (!semidefiniteness(returnObj$mleCov)) {
              warning("the covariance matrix of the maximum likelihood estimates", 
                  " is not positive semidefinite")
          }
          else {
              testSingularCov <- try(solve(returnObj$mleCov), silent = TRUE)
              if (class(testSingularCov) == "try-error") {
                  if (grepl("singular", testSingularCov[1])) {
                    warning("the covariance matrix of the maximum likelihood estimates", 
                      " is singular")
                  }
                  else {
                    warning("the covariance matrix of the maximum likelihood estimates", 
                      " is not invertible")
                  }
              }
          }
      }
      class(returnObj) <- "frontier"
      return(returnObj)
  }
  <bytecode: 0x559f8ad34640>
  <environment: namespace:frontier>
   --- function search by body ---
  Function sfa in namespace frontier has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1
Running the tests in ‘tests/nestedModels.R’ failed.
Complete output:
  > library( "frontier" )
  Loading required package: micEcon
  
  If you have questions, suggestions, or comments regarding one of the 'micEcon' packages, please use a forum or 'tracker' at micEcon's R-Forge site:
  https://r-forge.r-project.org/projects/micecon/
  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 'frontier' package as:
  Tim Coelli and Arne Henningsen (2013). frontier: Stochastic Frontier Analysis. R package version 1.1. http://CRAN.R-Project.org/package=frontier.
  
  If you have questions, suggestions, or comments regarding the 'frontier' package, please use a forum or 'tracker' at frontier's R-Forge site:
  https://r-forge.r-project.org/projects/frontier/
  > library( "plm" )
  > options( digits = 5 )
  > 
  > ## data set of rice producers in the Philippines
  > data( riceProdPhil )
  > riceProdPhil$lPROD  <- log( riceProdPhil$PROD )
  > riceProdPhil$lAREA  <- log( riceProdPhil$AREA )
  > riceProdPhil$lLABOR <- log( riceProdPhil$LABOR )
  > riceProdPhil$lNPK   <- log( riceProdPhil$NPK )
  > riceProdPhil$farm <-
  +    paste( "F_", ifelse( riceProdPhil$FMERCODE > 9, "", "0" ),
  +    riceProdPhil$FMERCODE, sep = "" )
  > riceProdPhil$year <- riceProdPhil$YEARDUM + 1998
  > riceProdPhil <- pdata.frame( riceProdPhil, c( "farm", "year" ), 
  +    row.names = FALSE )
  > 
  > 
  > ########## cross-section data #############
  > 
  > ## without mu / zIntercept
  > # Error Components Frontier (ECF)
  > sbb5ecf <- sfa( lPROD ~ lAREA + lLABOR + lNPK,
  +    data = as.data.frame( riceProdPhil ) )
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  frontier
   --- call from context --- 
  sfa(lPROD ~ lAREA + lLABOR + lNPK, data = as.data.frame(riceProdPhil))
   --- call from argument --- 
  if (class(testSingularCov) == "try-error") {
      if (grepl("singular", testSingularCov[1])) {
          warning("the covariance matrix of the maximum likelihood estimates", 
              " is singular")
      }
      else {
          warning("the covariance matrix of the maximum likelihood estimates", 
              " is not invertible")
      }
  }
   --- R stacktrace ---
  where 1: sfa(lPROD ~ lAREA + lLABOR + lNPK, data = as.data.frame(riceProdPhil))
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (formula, data = sys.frame(sys.parent()), ineffDecrease = TRUE, 
      truncNorm = FALSE, timeEffect = FALSE, startVal = NULL, tol = 1e-05, 
      maxit = 1000, muBound = 2, bignum = 1e+16, searchStep = 1e-05, 
      searchTol = 0.001, searchScale = NA, gridSize = 0.1, gridDouble = TRUE, 
      restartMax = 10, restartFactor = 0.999, printIter = 0) 
  {
      formula <- as.Formula(formula)
      if (length(formula)[2] == 1) {
          modelType <- 1
          effFormula <- NULL
      }
      else if (length(formula)[2] == 2) {
          modelType <- 2
          effFormula <- formula(formula, lhs = 0, rhs = 2)
      }
      else {
          stop("argument 'formula' has an inappropriate number of RHS parts")
      }
      formula <- formula(formula, lhs = 1, rhs = 1)
      if (class(formula) != "formula") {
          stop("argument 'formula' must be a formula")
      }
      else if (length(formula) != 3) {
          stop("argument 'formula' must be a 2-sided formula")
      }
      if (!is.logical(ineffDecrease) || length(ineffDecrease) != 
          1) {
          stop("argument 'ineffDecrease' must be a single logical value")
      }
      if (!is.logical(truncNorm)) {
          stop("argument 'truncNorm' must be logical")
      }
      if (truncNorm && modelType == 2) {
          warning("argument 'truncNorm' is ignored in", " Efficiency Effects Frontiers (EEF)")
      }
      if (!is.logical(timeEffect)) {
          stop("argument 'timeEffect' must be logical")
      }
      if (timeEffect && !(inherits(data, "pdata.frame") || inherits(data, 
          "plm.dim"))) {
          warning("argument 'timeEffect' is ignored in case of", 
              " cross-sectional data")
      }
      if (!is.numeric(printIter)) {
          stop("argument 'printIter' must be numeric")
      }
      else if (printIter != round(printIter)) {
          stop("argument 'printIter' must be an iteger")
      }
      else if (printIter < 0) {
          stop("argument 'printIter' must be non-negative")
      }
      printIter <- as.integer(printIter)
      if (length(searchScale) != 1) {
          stop("argument 'searchScale' must be a single logical value or NA")
      }
      else if (is.na(searchScale)) {
          indic <- as.integer(1)
      }
      else if (is.logical(searchScale)) {
          indic <- as.integer(2 - 2 * searchScale)
      }
      else {
          stop("argument 'searchScale' must be a logical value or NA")
      }
      if (!is.numeric(tol)) {
          stop("argument 'tol' must be numeric")
      }
      else if (tol < 0) {
          stop("argument 'tol' must be non-negative")
      }
      if (!is.numeric(searchTol)) {
          stop("argument 'searchTol' must be numeric")
      }
      else if (searchTol < 0) {
          stop("argument 'searchTol' must be non-negative")
      }
      if (!is.numeric(muBound) || length(muBound) != 1) {
          stop("argument 'muBound' must be a numeric scalar")
      }
      else if (is.infinite(muBound)) {
          muBound <- 0
      }
      if (!is.numeric(bignum)) {
          stop("argument 'bignum' must be numeric")
      }
      else if (bignum <= 0) {
          stop("argument 'bignum' must be positive")
      }
      if (!is.numeric(searchStep)) {
          stop("argument 'searchStep' must be numeric")
      }
      else if (searchStep <= 0) {
          stop("argument 'searchStep' must be positive")
      }
      if (!is.logical(gridDouble) || length(gridDouble) != 1) {
          stop("argument 'gridDouble' must be a single logical value")
      }
      if (!is.numeric(gridSize)) {
          stop("argument 'gridSize' must be numeric")
      }
      else if (gridSize <= 0) {
          stop("argument 'gridSize' must be positive")
      }
      if (!is.numeric(maxit) || length(maxit) != 1) {
          stop("argument 'maxit' must be a single numeric scalar")
      }
      else if (maxit != round(maxit)) {
          stop("argument 'maxit' must be an integer")
      }
      else if (maxit < 0) {
          stop("argument 'maxit' must not be negative")
      }
      maxit <- as.integer(maxit)
      if (!is.numeric(restartMax) || length(restartMax) != 1) {
          stop("argument 'restartMax' must be a single numeric scalar")
      }
      else if (restartMax != round(restartMax)) {
          stop("argument 'restartMax' must be an integer")
      }
      else if (restartMax < 0) {
          stop("argument 'restartMax' must not be negative")
      }
      restartMax <- as.integer(restartMax)
      if (!is.numeric(restartFactor) || length(restartFactor) != 
          1) {
          stop("argument 'restartFactor' must be a numeric scalar")
      }
      else if (is.infinite(restartFactor)) {
          stop("argument 'restartFactor' must be finite")
      }
      mc <- match.call(expand.dots = FALSE)
      tmp <- frontierDataTable(formula = formula, effFormula = effFormula, 
          data = data, mc = mc)
      if (is.character(tmp)) {
          stop(tmp)
      }
      validObs <- tmp$validObs
      dataTable <- cbind(tmp$idVec, tmp$timeVec, tmp$yVec, tmp$xMat, 
          tmp$zMat)
      rownames(dataTable) <- names(validObs)[validObs]
      colnames(dataTable)[1:3] <- c("id", "t", tmp$yName)
      firmId <- tmp$firmId
      timeId <- tmp$timeId
      nb <- ncol(tmp$xMat)
      nob <- sum(validObs)
      nn <- max(tmp$idVec)
      nt <- max(tmp$timeVec)
      zIntercept <- tmp$zIntercept
      nZvars <- ncol(tmp$zMat)
      if (modelType == 1) {
          mu <- truncNorm
      }
      else {
          mu <- zIntercept
      }
      if (modelType == 1) {
          eta <- timeEffect
      }
      else {
          eta <- nZvars
      }
      nParamTotal <- nb + 2 + mu + eta
      if (nParamTotal > nob) {
          stop("the model cannot be estimated,", " because the number of parameters (", 
              nParamTotal, ") is larger than the number of", ifelse(sum(!validObs) > 
                  0, " valid", ""), " observations (", nob, ")")
      }
      if (is.null(startVal)) {
          startVal <- 0
      }
      else {
          if (nParamTotal != length(startVal)) {
              stop("wrong number of starting values (you provided ", 
                  length(startVal), " starting values but the model has ", 
                  nParamTotal, " parameters)")
          }
      }
      if (nb > 0) {
          ols <- lm(tmp$yVec ~ tmp$xMat - 1)
      }
      else if (nb == 0) {
          ols <- lm(tmp$yVec ~ -1)
      }
      if (any(is.na(coef(ols)))) {
          stop("at least one coefficient estimated by OLS is NA: ", 
              paste(colnames(tmp$xMat)[is.na(coef(ols))], collapse = ", "), 
              ". This may have been caused by (nearly) perfect multicollinearity")
      }
      olsParam <- c(coef(ols), summary(ols)$sigma^2)
      olsStdEr <- sqrt(diag(vcov(ols)))
      olsLogl <- logLik(ols)[1]
      if (nb > 0) {
          gridAdj <- coef(lm(rep(1, nrow(dataTable)) ~ dataTable[, 
              4:(3 + nb)] - 1))
      }
      else {
          gridAdj <- numeric(0)
      }
      if (length(gridAdj) != nb) {
          stop("internal error: the length of 'gridAdj' is not equal to 'nb'.", 
              " Please contact the maintainer of the frontier package")
      }
      returnObj <- .Fortran(C_front41, modelType = as.integer(modelType), 
          ineffDecrease = as.integer((!ineffDecrease) + 1), icept = as.integer(0), 
          nn = as.integer(nn), nt = as.integer(nt), nob = as.integer(nob), 
          nb = as.integer(nb), mu = as.integer(mu), eta = as.integer(eta), 
          printIter = as.integer(printIter), indic = as.integer(indic), 
          tol = as.double(tol), searchTol = as.double(searchTol), 
          bignum = as.double(bignum), searchStep = as.double(searchStep), 
          gridDouble = as.integer(gridDouble), gridSize = as.double(gridSize), 
          maxit = as.integer(maxit), muBound = as.double(muBound), 
          restartMax = as.integer(restartMax), restartFactor = as.double(restartFactor), 
          nRestart = as.integer(0), nStartVal = as.integer(length(startVal)), 
          startVal = as.double(startVal), nRowData = as.integer(nrow(dataTable)), 
          nColData = as.integer(ncol(dataTable)), dataTable = matrix(as.double(dataTable), 
              nrow(dataTable), ncol(dataTable), dimnames = dimnames(dataTable)), 
          nParamTotal = as.integer(nParamTotal), olsParam = as.double(c(olsParam, 
              rep(0, 1 + mu + eta))), gridAdj = as.double(gridAdj), 
          gridParam = as.double(rep(0, nParamTotal)), startLogl = as.double(0), 
          mleParam = as.double(rep(0, nParamTotal)), mleCov = matrix(as.double(0), 
              nParamTotal, nParamTotal), mleLogl = as.double(0), 
          nIter = as.integer(0), code = as.integer(0), nFuncEval = as.integer(0))
      if (returnObj$code == 101) {
          stop("the total number of observations exceeds the product of", 
              " the number of firms by the number of years")
      }
      else if (returnObj$code == 102) {
          stop("internal error: calculated variable 'n'", " is not equal to argument 'nParamTotal'.", 
              " Please contact the maintainer of the 'frontier' package", 
              " (arne.henningsen@gmail.com)")
      }
      else if (returnObj$code == 103) {
          stop("wrong number of starting values")
      }
      else if (returnObj$code == 104) {
          stop("a firm number is < 1")
      }
      else if (returnObj$code == 105) {
          stop("a firm number is > number of firms")
      }
      else if (returnObj$code == 106) {
          stop("a period number is < 1")
      }
      else if (returnObj$code == 107) {
          stop("a period number is > number of periods")
      }
      else if (returnObj$code == 108) {
          stop("there are no observations on at least one firm")
      }
      else if (returnObj$code == 109) {
          stop("internal error: 2 + nr - nmu * (im-1)", " is not equal to argument 'nColData'.", 
              " Please contact the maintainer of the 'frontier' package", 
              " (arne.henningsen@gmail.com)")
      }
      else if (returnObj$code > 100) {
          stop("unknown error.", " Please contact the maintainer of the 'frontier' package", 
              " (arne.henningsen@gmail.com)")
      }
      returnObj$nStartVal <- NULL
      returnObj$nRowData <- NULL
      returnObj$nColData <- NULL
      returnObj$nParamTotal <- NULL
      returnObj$ineffDecrease <- as.logical(2 - returnObj$ineffDecrease)
      returnObj$gridDouble <- as.logical(returnObj$gridDouble)
      returnObj$olsParam <- olsParam
      returnObj$olsStdEr <- olsStdEr
      returnObj$olsLogl <- olsLogl
      if (nb == 0) {
          fitVal <- rep(0, sum(validObs))
      }
      else {
          fitVal <- drop(dataTable[, 4:(3 + nb), drop = FALSE] %*% 
              returnObj$mleParam[1:nb])
      }
      returnObj$fitted <- matrix(NA, nrow = nn, ncol = nt)
      if (length(fitVal) != nrow(dataTable)) {
          stop("internal error: length of the fitted values is not equal to", 
              " the number of rows of the data table (valid observations)")
      }
      for (i in 1:length(fitVal)) {
          returnObj$fitted[dataTable[i, 1], dataTable[i, 2]] <- fitVal[i]
      }
      resid <- drop(dataTable[, 3] - fitVal)
      returnObj$resid <- matrix(NA, nrow = nn, ncol = nt)
      if (length(resid) != nrow(dataTable)) {
          stop("internal error: length of residuals is not equal to", 
              " the number of rows of the data table (valid observations)")
      }
      for (i in 1:length(resid)) {
          returnObj$resid[dataTable[i, 1], dataTable[i, 2]] <- resid[i]
      }
      returnObj$olsResid <- residuals(ols)
      returnObj$olsSkewness <- skewness(returnObj$olsResid)
      returnObj$olsSkewnessOkay <- returnObj$olsSkewness * (-1)^ineffDecrease >= 
          0
      warnMaxit <- maxit <= returnObj$nIter && maxit > 0
      if (!returnObj$olsSkewnessOkay && returnObj$mleLogl < returnObj$olsLogl) {
          warning("the residuals of the OLS estimates are ", ifelse(ineffDecrease, 
              "right", "left"), "-skewed", " and the likelihood value of the ML estimation is less", 
              " than that obtained using OLS;", " this usually indicates that there is no inefficiency", 
              " or that the model is misspecified")
      }
      else if (!returnObj$olsSkewnessOkay) {
          warning("the residuals of the OLS estimates are ", ifelse(ineffDecrease, 
              "right", "left"), "-skewed;", " this might indicate that there is no inefficiency", 
              " or that the model is misspecified")
      }
      else if (returnObj$mleLogl < returnObj$olsLogl && warnMaxit) {
          warning("the maximum number of iterations has been reached and", 
              " the likelihood value of the ML estimation is less", 
              " than that obtained using OLS;", " please try again using different starting values and/or", 
              " increase the maximum number of iterations")
          warnMaxit <- FALSE
      }
      else if (returnObj$mleLogl < returnObj$olsLogl && maxit > 
          0) {
          warning("the likelihood value of the ML estimation is less", 
              " than that obtained using OLS;", " this indicates that the likelihood maximization did not", 
              " converge to the global maximum or", " that there is no inefficiency", 
              " (you could try again using different starting values)")
      }
      if (warnMaxit) {
          warning("the maximum number of iterations has been reached;", 
              " please try again using different starting values and/or", 
              " increase the maximum number of iterations")
      }
      if (modelType == 1) {
          returnObj$truncNorm <- as.logical(returnObj$mu)
          returnObj$zIntercept <- zIntercept
          returnObj$mu <- NULL
      }
      else {
          returnObj$truncNorm <- truncNorm
          returnObj$zIntercept <- as.logical(returnObj$mu)
          returnObj$mu <- NULL
      }
      if (modelType == 1) {
          returnObj$timeEffect <- as.logical(returnObj$eta)
      }
      else {
          returnObj$timeEffect <- timeEffect
      }
      returnObj$eta <- NULL
      if (returnObj$indic == 2) {
          returnObj$searchScale <- FALSE
      }
      else if (returnObj$indic == 1) {
          returnObj$searchScale <- NA
      }
      else {
          returnObj$searchScale <- TRUE
      }
      returnObj$indic <- NULL
      if (length(startVal) == 1) {
          if (modelType == 1) {
              idx <- 1:(nb + 2)
          }
          else {
              if (nb == 0) {
                  idx <- NULL
              }
              else {
                  idx <- 1:nb
              }
              idx <- c(idx, (nParamTotal - 1):nParamTotal)
          }
          if (any(returnObj$gridParam[(1:nParamTotal)[-idx]] != 
              0)) {
              warning("internal error: some unused grid-search parameters are", 
                  " non-zero: ", paste(returnObj$gridParam, collapse = " "), 
                  " please contact the maintainer of the 'frontier' package")
          }
          returnObj$gridParam <- returnObj$gridParam[idx]
          names(returnObj)[names(returnObj) == "startLogl"] <- "gridLogl"
      }
      else {
          returnObj$gridParam <- NULL
      }
      if (inherits(data, "pdata.frame") || inherits(data, "plm.dim")) {
          rownames(returnObj$resid) <- levels(index(data)[[1]])[firmId]
          colnames(returnObj$resid) <- levels(index(data)[[2]])[timeId]
      }
      else {
          rownames(returnObj$resid) <- names(validObs)[validObs]
          colnames(returnObj$resid) <- "residuals"
      }
      paramNames <- colnames(tmp$xMat)
      if (modelType == 2) {
          if (zIntercept) {
              paramNames <- c(paramNames, "Z_(Intercept)")
          }
          if (nZvars > 0) {
              paramNames <- c(paramNames, paste("Z", colnames(tmp$zMat), 
                  sep = "_"))
          }
      }
      if (length(startVal) == 1) {
          returnObj$startVal <- NULL
      }
      paramNames <- c(paramNames, "sigmaSq", "gamma")
      if (modelType == 1) {
          if (truncNorm) {
              paramNames <- c(paramNames, "mu")
          }
          if (timeEffect) {
              paramNames <- c(paramNames, "time")
          }
      }
      if (nb >= 1) {
          betaNames <- paramNames[1:nb]
      }
      else {
          betaNames <- NULL
      }
      names(returnObj$olsParam) <- c(betaNames, "sigmaSq")
      names(returnObj$olsStdEr) <- betaNames
      if (!is.null(returnObj$gridParam)) {
          names(returnObj$gridParam) <- c(betaNames, "sigmaSq", 
              "gamma")
      }
      names(returnObj$mleParam) <- paramNames
      rownames(returnObj$mleCov) <- paramNames
      colnames(returnObj$mleCov) <- paramNames
      if (!is.null(returnObj$startVal)) {
          names(returnObj$startVal) <- paramNames
      }
      returnObj$call <- match.call()
      returnObj$validObs <- validObs
      if (maxit > 0) {
          if ((returnObj$mleParam["gamma"] < 0.01 || returnObj$mleParam["gamma"] > 
              0.99)) {
              warning("the parameter 'gamma' is close to the boundary", 
                  " of the parameter space [0,1]:", " this can cause convergence problems and", 
                  " can negatively affect the validity and reliability", 
                  " of statistical tests", " and might be caused by model misspecification")
          }
          if (!semidefiniteness(returnObj$mleCov)) {
              warning("the covariance matrix of the maximum likelihood estimates", 
                  " is not positive semidefinite")
          }
          else {
              testSingularCov <- try(solve(returnObj$mleCov), silent = TRUE)
              if (class(testSingularCov) == "try-error") {
                  if (grepl("singular", testSingularCov[1])) {
                    warning("the covariance matrix of the maximum likelihood estimates", 
                      " is singular")
                  }
                  else {
                    warning("the covariance matrix of the maximum likelihood estimates", 
                      " is not invertible")
                  }
              }
          }
      }
      class(returnObj) <- "frontier"
      return(returnObj)
  }
  <bytecode: 0x556feeedd908>
  <environment: namespace:frontier>
   --- function search by body ---
  Function sfa in namespace frontier has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1
Running the tests in ‘tests/translogRay.R’ failed.
Complete output:
  > library( frontier )
  Loading required package: micEcon
  
  If you have questions, suggestions, or comments regarding one of the 'micEcon' packages, please use a forum or 'tracker' at micEcon's R-Forge site:
  https://r-forge.r-project.org/projects/micecon/
  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 'frontier' package as:
  Tim Coelli and Arne Henningsen (2013). frontier: Stochastic Frontier Analysis. R package version 1.1. http://CRAN.R-Project.org/package=frontier.
  
  If you have questions, suggestions, or comments regarding the 'frontier' package, please use a forum or 'tracker' at frontier's R-Forge site:
  https://r-forge.r-project.org/projects/frontier/
  > options( digits = 5 )
  > 
  > printAll <- function( x ) {
  +    for( n in names( x ) ) {
  +       cat( "$", n, "\n", sep = "" )
  +       if( n %in% c( "olsParam", "gridParam", "mleParam", "olsStdEr", "mleCov" ) ) {
  +          print( round( x[[ n ]], 2 ) )
  +       } else if( n %in% c( "fitted", "resid", "olsResid" ) ) {
  +          print( round( x[[ n ]], 3 ) )
  +       } else {
  +          print( x[[ n ]] )
  +       }
  +       cat( "\n" )
  +    }
  +    cat( "class\n" )
  +    print( class( x ) )
  + }
  > 
  > ## preparing data
  > data( germanFarms )
  > # quantity of crop outputs
  > germanFarms$qCrop <- germanFarms$vCrop / germanFarms$pOutput
  > # quantity of animal outputs
  > germanFarms$qAnimal <- germanFarms$vAnimal / germanFarms$pOutput
  > # quantity of variable inputs
  > germanFarms$qVarInput <- germanFarms$vVarInput / germanFarms$pVarInput
  > # a time trend to account for technical progress:
  > germanFarms$time <- c(1:20)
  > 
  > # estimate a translog ray production function
  > estResultRay <- frontierTranslogRay( yNames = c( "qCrop", "qAnimal" ),
  +    xNames = c( "qLabor", "land", "qVarInput" ),
  +    data = germanFarms )
  restarting with starting values multiplied by
  [1] 0.999
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  frontier
   --- call from context --- 
  sfa(formula = sfaFormula, data = data, ...)
   --- call from argument --- 
  if (class(testSingularCov) == "try-error") {
      if (grepl("singular", testSingularCov[1])) {
          warning("the covariance matrix of the maximum likelihood estimates", 
              " is singular")
      }
      else {
          warning("the covariance matrix of the maximum likelihood estimates", 
              " is not invertible")
      }
  }
   --- R stacktrace ---
  where 1: sfa(formula = sfaFormula, data = data, ...)
  where 2: frontier(yName = "y", xNames = xNamesAll, zNames = zNamesNew, 
      data = dataQuad, ...)
  where 3: frontierQuad(yName = "distance", xNames = c(xNames, paste("theta", 
      1:(nOutput - 1), sep = "_")), shifterNames = shifterNames, 
      zNames = zNames, data = logData, ...)
  where 4: frontierTranslogRay(yNames = c("qCrop", "qAnimal"), xNames = c("qLabor", 
      "land", "qVarInput"), data = germanFarms)
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (formula, data = sys.frame(sys.parent()), ineffDecrease = TRUE, 
      truncNorm = FALSE, timeEffect = FALSE, startVal = NULL, tol = 1e-05, 
      maxit = 1000, muBound = 2, bignum = 1e+16, searchStep = 1e-05, 
      searchTol = 0.001, searchScale = NA, gridSize = 0.1, gridDouble = TRUE, 
      restartMax = 10, restartFactor = 0.999, printIter = 0) 
  {
      formula <- as.Formula(formula)
      if (length(formula)[2] == 1) {
          modelType <- 1
          effFormula <- NULL
      }
      else if (length(formula)[2] == 2) {
          modelType <- 2
          effFormula <- formula(formula, lhs = 0, rhs = 2)
      }
      else {
          stop("argument 'formula' has an inappropriate number of RHS parts")
      }
      formula <- formula(formula, lhs = 1, rhs = 1)
      if (class(formula) != "formula") {
          stop("argument 'formula' must be a formula")
      }
      else if (length(formula) != 3) {
          stop("argument 'formula' must be a 2-sided formula")
      }
      if (!is.logical(ineffDecrease) || length(ineffDecrease) != 
          1) {
          stop("argument 'ineffDecrease' must be a single logical value")
      }
      if (!is.logical(truncNorm)) {
          stop("argument 'truncNorm' must be logical")
      }
      if (truncNorm && modelType == 2) {
          warning("argument 'truncNorm' is ignored in", " Efficiency Effects Frontiers (EEF)")
      }
      if (!is.logical(timeEffect)) {
          stop("argument 'timeEffect' must be logical")
      }
      if (timeEffect && !(inherits(data, "pdata.frame") || inherits(data, 
          "plm.dim"))) {
          warning("argument 'timeEffect' is ignored in case of", 
              " cross-sectional data")
      }
      if (!is.numeric(printIter)) {
          stop("argument 'printIter' must be numeric")
      }
      else if (printIter != round(printIter)) {
          stop("argument 'printIter' must be an iteger")
      }
      else if (printIter < 0) {
          stop("argument 'printIter' must be non-negative")
      }
      printIter <- as.integer(printIter)
      if (length(searchScale) != 1) {
          stop("argument 'searchScale' must be a single logical value or NA")
      }
      else if (is.na(searchScale)) {
          indic <- as.integer(1)
      }
      else if (is.logical(searchScale)) {
          indic <- as.integer(2 - 2 * searchScale)
      }
      else {
          stop("argument 'searchScale' must be a logical value or NA")
      }
      if (!is.numeric(tol)) {
          stop("argument 'tol' must be numeric")
      }
      else if (tol < 0) {
          stop("argument 'tol' must be non-negative")
      }
      if (!is.numeric(searchTol)) {
          stop("argument 'searchTol' must be numeric")
      }
      else if (searchTol < 0) {
          stop("argument 'searchTol' must be non-negative")
      }
      if (!is.numeric(muBound) || length(muBound) != 1) {
          stop("argument 'muBound' must be a numeric scalar")
      }
      else if (is.infinite(muBound)) {
          muBound <- 0
      }
      if (!is.numeric(bignum)) {
          stop("argument 'bignum' must be numeric")
      }
      else if (bignum <= 0) {
          stop("argument 'bignum' must be positive")
      }
      if (!is.numeric(searchStep)) {
          stop("argument 'searchStep' must be numeric")
      }
      else if (searchStep <= 0) {
          stop("argument 'searchStep' must be positive")
      }
      if (!is.logical(gridDouble) || length(gridDouble) != 1) {
          stop("argument 'gridDouble' must be a single logical value")
      }
      if (!is.numeric(gridSize)) {
          stop("argument 'gridSize' must be numeric")
      }
      else if (gridSize <= 0) {
          stop("argument 'gridSize' must be positive")
      }
      if (!is.numeric(maxit) || length(maxit) != 1) {
          stop("argument 'maxit' must be a single numeric scalar")
      }
      else if (maxit != round(maxit)) {
          stop("argument 'maxit' must be an integer")
      }
      else if (maxit < 0) {
          stop("argument 'maxit' must not be negative")
      }
      maxit <- as.integer(maxit)
      if (!is.numeric(restartMax) || length(restartMax) != 1) {
          stop("argument 'restartMax' must be a single numeric scalar")
      }
      else if (restartMax != round(restartMax)) {
          stop("argument 'restartMax' must be an integer")
      }
      else if (restartMax < 0) {
          stop("argument 'restartMax' must not be negative")
      }
      restartMax <- as.integer(restartMax)
      if (!is.numeric(restartFactor) || length(restartFactor) != 
          1) {
          stop("argument 'restartFactor' must be a numeric scalar")
      }
      else if (is.infinite(restartFactor)) {
          stop("argument 'restartFactor' must be finite")
      }
      mc <- match.call(expand.dots = FALSE)
      tmp <- frontierDataTable(formula = formula, effFormula = effFormula, 
          data = data, mc = mc)
      if (is.character(tmp)) {
          stop(tmp)
      }
      validObs <- tmp$validObs
      dataTable <- cbind(tmp$idVec, tmp$timeVec, tmp$yVec, tmp$xMat, 
          tmp$zMat)
      rownames(dataTable) <- names(validObs)[validObs]
      colnames(dataTable)[1:3] <- c("id", "t", tmp$yName)
      firmId <- tmp$firmId
      timeId <- tmp$timeId
      nb <- ncol(tmp$xMat)
      nob <- sum(validObs)
      nn <- max(tmp$idVec)
      nt <- max(tmp$timeVec)
      zIntercept <- tmp$zIntercept
      nZvars <- ncol(tmp$zMat)
      if (modelType == 1) {
          mu <- truncNorm
      }
      else {
          mu <- zIntercept
      }
      if (modelType == 1) {
          eta <- timeEffect
      }
      else {
          eta <- nZvars
      }
      nParamTotal <- nb + 2 + mu + eta
      if (nParamTotal > nob) {
          stop("the model cannot be estimated,", " because the number of parameters (", 
              nParamTotal, ") is larger than the number of", ifelse(sum(!validObs) > 
                  0, " valid", ""), " observations (", nob, ")")
      }
      if (is.null(startVal)) {
          startVal <- 0
      }
      else {
          if (nParamTotal != length(startVal)) {
              stop("wrong number of starting values (you provided ", 
                  length(startVal), " starting values but the model has ", 
                  nParamTotal, " parameters)")
          }
      }
      if (nb > 0) {
          ols <- lm(tmp$yVec ~ tmp$xMat - 1)
      }
      else if (nb == 0) {
          ols <- lm(tmp$yVec ~ -1)
      }
      if (any(is.na(coef(ols)))) {
          stop("at least one coefficient estimated by OLS is NA: ", 
              paste(colnames(tmp$xMat)[is.na(coef(ols))], collapse = ", "), 
              ". This may have been caused by (nearly) perfect multicollinearity")
      }
      olsParam <- c(coef(ols), summary(ols)$sigma^2)
      olsStdEr <- sqrt(diag(vcov(ols)))
      olsLogl <- logLik(ols)[1]
      if (nb > 0) {
          gridAdj <- coef(lm(rep(1, nrow(dataTable)) ~ dataTable[, 
              4:(3 + nb)] - 1))
      }
      else {
          gridAdj <- numeric(0)
      }
      if (length(gridAdj) != nb) {
          stop("internal error: the length of 'gridAdj' is not equal to 'nb'.", 
              " Please contact the maintainer of the frontier package")
      }
      returnObj <- .Fortran(C_front41, modelType = as.integer(modelType), 
          ineffDecrease = as.integer((!ineffDecrease) + 1), icept = as.integer(0), 
          nn = as.integer(nn), nt = as.integer(nt), nob = as.integer(nob), 
          nb = as.integer(nb), mu = as.integer(mu), eta = as.integer(eta), 
          printIter = as.integer(printIter), indic = as.integer(indic), 
          tol = as.double(tol), searchTol = as.double(searchTol), 
          bignum = as.double(bignum), searchStep = as.double(searchStep), 
          gridDouble = as.integer(gridDouble), gridSize = as.double(gridSize), 
          maxit = as.integer(maxit), muBound = as.double(muBound), 
          restartMax = as.integer(restartMax), restartFactor = as.double(restartFactor), 
          nRestart = as.integer(0), nStartVal = as.integer(length(startVal)), 
          startVal = as.double(startVal), nRowData = as.integer(nrow(dataTable)), 
          nColData = as.integer(ncol(dataTable)), dataTable = matrix(as.double(dataTable), 
              nrow(dataTable), ncol(dataTable), dimnames = dimnames(dataTable)), 
          nParamTotal = as.integer(nParamTotal), olsParam = as.double(c(olsParam, 
              rep(0, 1 + mu + eta))), gridAdj = as.double(gridAdj), 
          gridParam = as.double(rep(0, nParamTotal)), startLogl = as.double(0), 
          mleParam = as.double(rep(0, nParamTotal)), mleCov = matrix(as.double(0), 
              nParamTotal, nParamTotal), mleLogl = as.double(0), 
          nIter = as.integer(0), code = as.integer(0), nFuncEval = as.integer(0))
      if (returnObj$code == 101) {
          stop("the total number of observations exceeds the product of", 
              " the number of firms by the number of years")
      }
      else if (returnObj$code == 102) {
          stop("internal error: calculated variable 'n'", " is not equal to argument 'nParamTotal'.", 
              " Please contact the maintainer of the 'frontier' package", 
              " (arne.henningsen@gmail.com)")
      }
      else if (returnObj$code == 103) {
          stop("wrong number of starting values")
      }
      else if (returnObj$code == 104) {
          stop("a firm number is < 1")
      }
      else if (returnObj$code == 105) {
          stop("a firm number is > number of firms")
      }
      else if (returnObj$code == 106) {
          stop("a period number is < 1")
      }
      else if (returnObj$code == 107) {
          stop("a period number is > number of periods")
      }
      else if (returnObj$code == 108) {
          stop("there are no observations on at least one firm")
      }
      else if (returnObj$code == 109) {
          stop("internal error: 2 + nr - nmu * (im-1)", " is not equal to argument 'nColData'.", 
              " Please contact the maintainer of the 'frontier' package", 
              " (arne.henningsen@gmail.com)")
      }
      else if (returnObj$code > 100) {
          stop("unknown error.", " Please contact the maintainer of the 'frontier' package", 
              " (arne.henningsen@gmail.com)")
      }
      returnObj$nStartVal <- NULL
      returnObj$nRowData <- NULL
      returnObj$nColData <- NULL
      returnObj$nParamTotal <- NULL
      returnObj$ineffDecrease <- as.logical(2 - returnObj$ineffDecrease)
      returnObj$gridDouble <- as.logical(returnObj$gridDouble)
      returnObj$olsParam <- olsParam
      returnObj$olsStdEr <- olsStdEr
      returnObj$olsLogl <- olsLogl
      if (nb == 0) {
          fitVal <- rep(0, sum(validObs))
      }
      else {
          fitVal <- drop(dataTable[, 4:(3 + nb), drop = FALSE] %*% 
              returnObj$mleParam[1:nb])
      }
      returnObj$fitted <- matrix(NA, nrow = nn, ncol = nt)
      if (length(fitVal) != nrow(dataTable)) {
          stop("internal error: length of the fitted values is not equal to", 
              " the number of rows of the data table (valid observations)")
      }
      for (i in 1:length(fitVal)) {
          returnObj$fitted[dataTable[i, 1], dataTable[i, 2]] <- fitVal[i]
      }
      resid <- drop(dataTable[, 3] - fitVal)
      returnObj$resid <- matrix(NA, nrow = nn, ncol = nt)
      if (length(resid) != nrow(dataTable)) {
          stop("internal error: length of residuals is not equal to", 
              " the number of rows of the data table (valid observations)")
      }
      for (i in 1:length(resid)) {
          returnObj$resid[dataTable[i, 1], dataTable[i, 2]] <- resid[i]
      }
      returnObj$olsResid <- residuals(ols)
      returnObj$olsSkewness <- skewness(returnObj$olsResid)
      returnObj$olsSkewnessOkay <- returnObj$olsSkewness * (-1)^ineffDecrease >= 
          0
      warnMaxit <- maxit <= returnObj$nIter && maxit > 0
      if (!returnObj$olsSkewnessOkay && returnObj$mleLogl < returnObj$olsLogl) {
          warning("the residuals of the OLS estimates are ", ifelse(ineffDecrease, 
              "right", "left"), "-skewed", " and the likelihood value of the ML estimation is less", 
              " than that obtained using OLS;", " this usually indicates that there is no inefficiency", 
              " or that the model is misspecified")
      }
      else if (!returnObj$olsSkewnessOkay) {
          warning("the residuals of the OLS estimates are ", ifelse(ineffDecrease, 
              "right", "left"), "-skewed;", " this might indicate that there is no inefficiency", 
              " or that the model is misspecified")
      }
      else if (returnObj$mleLogl < returnObj$olsLogl && warnMaxit) {
          warning("the maximum number of iterations has been reached and", 
              " the likelihood value of the ML estimation is less", 
              " than that obtained using OLS;", " please try again using different starting values and/or", 
              " increase the maximum number of iterations")
          warnMaxit <- FALSE
      }
      else if (returnObj$mleLogl < returnObj$olsLogl && maxit > 
          0) {
          warning("the likelihood value of the ML estimation is less", 
              " than that obtained using OLS;", " this indicates that the likelihood maximization did not", 
              " converge to the global maximum or", " that there is no inefficiency", 
              " (you could try again using different starting values)")
      }
      if (warnMaxit) {
          warning("the maximum number of iterations has been reached;", 
              " please try again using different starting values and/or", 
              " increase the maximum number of iterations")
      }
      if (modelType == 1) {
          returnObj$truncNorm <- as.logical(returnObj$mu)
          returnObj$zIntercept <- zIntercept
          returnObj$mu <- NULL
      }
      else {
          returnObj$truncNorm <- truncNorm
          returnObj$zIntercept <- as.logical(returnObj$mu)
          returnObj$mu <- NULL
      }
      if (modelType == 1) {
          returnObj$timeEffect <- as.logical(returnObj$eta)
      }
      else {
          returnObj$timeEffect <- timeEffect
      }
      returnObj$eta <- NULL
      if (returnObj$indic == 2) {
          returnObj$searchScale <- FALSE
      }
      else if (returnObj$indic == 1) {
          returnObj$searchScale <- NA
      }
      else {
          returnObj$searchScale <- TRUE
      }
      returnObj$indic <- NULL
      if (length(startVal) == 1) {
          if (modelType == 1) {
              idx <- 1:(nb + 2)
          }
          else {
              if (nb == 0) {
                  idx <- NULL
              }
              else {
                  idx <- 1:nb
              }
              idx <- c(idx, (nParamTotal - 1):nParamTotal)
          }
          if (any(returnObj$gridParam[(1:nParamTotal)[-idx]] != 
              0)) {
              warning("internal error: some unused grid-search parameters are", 
                  " non-zero: ", paste(returnObj$gridParam, collapse = " "), 
                  " please contact the maintainer of the 'frontier' package")
          }
          returnObj$gridParam <- returnObj$gridParam[idx]
          names(returnObj)[names(returnObj) == "startLogl"] <- "gridLogl"
      }
      else {
          returnObj$gridParam <- NULL
      }
      if (inherits(data, "pdata.frame") || inherits(data, "plm.dim")) {
          rownames(returnObj$resid) <- levels(index(data)[[1]])[firmId]
          colnames(returnObj$resid) <- levels(index(data)[[2]])[timeId]
      }
      else {
          rownames(returnObj$resid) <- names(validObs)[validObs]
          colnames(returnObj$resid) <- "residuals"
      }
      paramNames <- colnames(tmp$xMat)
      if (modelType == 2) {
          if (zIntercept) {
              paramNames <- c(paramNames, "Z_(Intercept)")
          }
          if (nZvars > 0) {
              paramNames <- c(paramNames, paste("Z", colnames(tmp$zMat), 
                  sep = "_"))
          }
      }
      if (length(startVal) == 1) {
          returnObj$startVal <- NULL
      }
      paramNames <- c(paramNames, "sigmaSq", "gamma")
      if (modelType == 1) {
          if (truncNorm) {
              paramNames <- c(paramNames, "mu")
          }
          if (timeEffect) {
              paramNames <- c(paramNames, "time")
          }
      }
      if (nb >= 1) {
          betaNames <- paramNames[1:nb]
      }
      else {
          betaNames <- NULL
      }
      names(returnObj$olsParam) <- c(betaNames, "sigmaSq")
      names(returnObj$olsStdEr) <- betaNames
      if (!is.null(returnObj$gridParam)) {
          names(returnObj$gridParam) <- c(betaNames, "sigmaSq", 
              "gamma")
      }
      names(returnObj$mleParam) <- paramNames
      rownames(returnObj$mleCov) <- paramNames
      colnames(returnObj$mleCov) <- paramNames
      if (!is.null(returnObj$startVal)) {
          names(returnObj$startVal) <- paramNames
      }
      returnObj$call <- match.call()
      returnObj$validObs <- validObs
      if (maxit > 0) {
          if ((returnObj$mleParam["gamma"] < 0.01 || returnObj$mleParam["gamma"] > 
              0.99)) {
              warning("the parameter 'gamma' is close to the boundary", 
                  " of the parameter space [0,1]:", " this can cause convergence problems and", 
                  " can negatively affect the validity and reliability", 
                  " of statistical tests", " and might be caused by model misspecification")
          }
          if (!semidefiniteness(returnObj$mleCov)) {
              warning("the covariance matrix of the maximum likelihood estimates", 
                  " is not positive semidefinite")
          }
          else {
              testSingularCov <- try(solve(returnObj$mleCov), silent = TRUE)
              if (class(testSingularCov) == "try-error") {
                  if (grepl("singular", testSingularCov[1])) {
                    warning("the covariance matrix of the maximum likelihood estimates", 
                      " is singular")
                  }
                  else {
                    warning("the covariance matrix of the maximum likelihood estimates", 
                      " is not invertible")
                  }
              }
          }
      }
      class(returnObj) <- "frontier"
      return(returnObj)
  }
  <bytecode: 0x55d536231150>
  <environment: namespace:frontier>
   --- function search by body ---
  Function sfa in namespace frontier has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1
Running the tests in ‘tests/wrongSkewness.R’ failed.
Complete output:
  > library( frontier )
  Loading required package: micEcon
  
  If you have questions, suggestions, or comments regarding one of the 'micEcon' packages, please use a forum or 'tracker' at micEcon's R-Forge site:
  https://r-forge.r-project.org/projects/micecon/
  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 'frontier' package as:
  Tim Coelli and Arne Henningsen (2013). frontier: Stochastic Frontier Analysis. R package version 1.1. http://CRAN.R-Project.org/package=frontier.
  
  If you have questions, suggestions, or comments regarding the 'frontier' package, please use a forum or 'tracker' at frontier's R-Forge site:
  https://r-forge.r-project.org/projects/frontier/
  > options( digits = 5 )
  > 
  > ## example data included in FRONTIER 4.1 (cross-section data)
  > data( front41Data )
  > data( riceProdPhil )
  > riceProdPhil$cost <- riceProdPhil$LABOR * riceProdPhil$LABORP +
  +    riceProdPhil$NPK * riceProdPhil$NPKP
  > 
  > ###### left-skewed residuals but ineffDecrease = FALSE
  > ## front41Data
  > a1 <- sfa( log( output ) ~ log( capital ) + log( labour ),
  +    ineffDecrease = FALSE, data = front41Data )
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  frontier
   --- call from context --- 
  sfa(log(output) ~ log(capital) + log(labour), ineffDecrease = FALSE, 
      data = front41Data)
   --- call from argument --- 
  if (class(testSingularCov) == "try-error") {
      if (grepl("singular", testSingularCov[1])) {
          warning("the covariance matrix of the maximum likelihood estimates", 
              " is singular")
      }
      else {
          warning("the covariance matrix of the maximum likelihood estimates", 
              " is not invertible")
      }
  }
   --- R stacktrace ---
  where 1: sfa(log(output) ~ log(capital) + log(labour), ineffDecrease = FALSE, 
      data = front41Data)
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (formula, data = sys.frame(sys.parent()), ineffDecrease = TRUE, 
      truncNorm = FALSE, timeEffect = FALSE, startVal = NULL, tol = 1e-05, 
      maxit = 1000, muBound = 2, bignum = 1e+16, searchStep = 1e-05, 
      searchTol = 0.001, searchScale = NA, gridSize = 0.1, gridDouble = TRUE, 
      restartMax = 10, restartFactor = 0.999, printIter = 0) 
  {
      formula <- as.Formula(formula)
      if (length(formula)[2] == 1) {
          modelType <- 1
          effFormula <- NULL
      }
      else if (length(formula)[2] == 2) {
          modelType <- 2
          effFormula <- formula(formula, lhs = 0, rhs = 2)
      }
      else {
          stop("argument 'formula' has an inappropriate number of RHS parts")
      }
      formula <- formula(formula, lhs = 1, rhs = 1)
      if (class(formula) != "formula") {
          stop("argument 'formula' must be a formula")
      }
      else if (length(formula) != 3) {
          stop("argument 'formula' must be a 2-sided formula")
      }
      if (!is.logical(ineffDecrease) || length(ineffDecrease) != 
          1) {
          stop("argument 'ineffDecrease' must be a single logical value")
      }
      if (!is.logical(truncNorm)) {
          stop("argument 'truncNorm' must be logical")
      }
      if (truncNorm && modelType == 2) {
          warning("argument 'truncNorm' is ignored in", " Efficiency Effects Frontiers (EEF)")
      }
      if (!is.logical(timeEffect)) {
          stop("argument 'timeEffect' must be logical")
      }
      if (timeEffect && !(inherits(data, "pdata.frame") || inherits(data, 
          "plm.dim"))) {
          warning("argument 'timeEffect' is ignored in case of", 
              " cross-sectional data")
      }
      if (!is.numeric(printIter)) {
          stop("argument 'printIter' must be numeric")
      }
      else if (printIter != round(printIter)) {
          stop("argument 'printIter' must be an iteger")
      }
      else if (printIter < 0) {
          stop("argument 'printIter' must be non-negative")
      }
      printIter <- as.integer(printIter)
      if (length(searchScale) != 1) {
          stop("argument 'searchScale' must be a single logical value or NA")
      }
      else if (is.na(searchScale)) {
          indic <- as.integer(1)
      }
      else if (is.logical(searchScale)) {
          indic <- as.integer(2 - 2 * searchScale)
      }
      else {
          stop("argument 'searchScale' must be a logical value or NA")
      }
      if (!is.numeric(tol)) {
          stop("argument 'tol' must be numeric")
      }
      else if (tol < 0) {
          stop("argument 'tol' must be non-negative")
      }
      if (!is.numeric(searchTol)) {
          stop("argument 'searchTol' must be numeric")
      }
      else if (searchTol < 0) {
          stop("argument 'searchTol' must be non-negative")
      }
      if (!is.numeric(muBound) || length(muBound) != 1) {
          stop("argument 'muBound' must be a numeric scalar")
      }
      else if (is.infinite(muBound)) {
          muBound <- 0
      }
      if (!is.numeric(bignum)) {
          stop("argument 'bignum' must be numeric")
      }
      else if (bignum <= 0) {
          stop("argument 'bignum' must be positive")
      }
      if (!is.numeric(searchStep)) {
          stop("argument 'searchStep' must be numeric")
      }
      else if (searchStep <= 0) {
          stop("argument 'searchStep' must be positive")
      }
      if (!is.logical(gridDouble) || length(gridDouble) != 1) {
          stop("argument 'gridDouble' must be a single logical value")
      }
      if (!is.numeric(gridSize)) {
          stop("argument 'gridSize' must be numeric")
      }
      else if (gridSize <= 0) {
          stop("argument 'gridSize' must be positive")
      }
      if (!is.numeric(maxit) || length(maxit) != 1) {
          stop("argument 'maxit' must be a single numeric scalar")
      }
      else if (maxit != round(maxit)) {
          stop("argument 'maxit' must be an integer")
      }
      else if (maxit < 0) {
          stop("argument 'maxit' must not be negative")
      }
      maxit <- as.integer(maxit)
      if (!is.numeric(restartMax) || length(restartMax) != 1) {
          stop("argument 'restartMax' must be a single numeric scalar")
      }
      else if (restartMax != round(restartMax)) {
          stop("argument 'restartMax' must be an integer")
      }
      else if (restartMax < 0) {
          stop("argument 'restartMax' must not be negative")
      }
      restartMax <- as.integer(restartMax)
      if (!is.numeric(restartFactor) || length(restartFactor) != 
          1) {
          stop("argument 'restartFactor' must be a numeric scalar")
      }
      else if (is.infinite(restartFactor)) {
          stop("argument 'restartFactor' must be finite")
      }
      mc <- match.call(expand.dots = FALSE)
      tmp <- frontierDataTable(formula = formula, effFormula = effFormula, 
          data = data, mc = mc)
      if (is.character(tmp)) {
          stop(tmp)
      }
      validObs <- tmp$validObs
      dataTable <- cbind(tmp$idVec, tmp$timeVec, tmp$yVec, tmp$xMat, 
          tmp$zMat)
      rownames(dataTable) <- names(validObs)[validObs]
      colnames(dataTable)[1:3] <- c("id", "t", tmp$yName)
      firmId <- tmp$firmId
      timeId <- tmp$timeId
      nb <- ncol(tmp$xMat)
      nob <- sum(validObs)
      nn <- max(tmp$idVec)
      nt <- max(tmp$timeVec)
      zIntercept <- tmp$zIntercept
      nZvars <- ncol(tmp$zMat)
      if (modelType == 1) {
          mu <- truncNorm
      }
      else {
          mu <- zIntercept
      }
      if (modelType == 1) {
          eta <- timeEffect
      }
      else {
          eta <- nZvars
      }
      nParamTotal <- nb + 2 + mu + eta
      if (nParamTotal > nob) {
          stop("the model cannot be estimated,", " because the number of parameters (", 
              nParamTotal, ") is larger than the number of", ifelse(sum(!validObs) > 
                  0, " valid", ""), " observations (", nob, ")")
      }
      if (is.null(startVal)) {
          startVal <- 0
      }
      else {
          if (nParamTotal != length(startVal)) {
              stop("wrong number of starting values (you provided ", 
                  length(startVal), " starting values but the model has ", 
                  nParamTotal, " parameters)")
          }
      }
      if (nb > 0) {
          ols <- lm(tmp$yVec ~ tmp$xMat - 1)
      }
      else if (nb == 0) {
          ols <- lm(tmp$yVec ~ -1)
      }
      if (any(is.na(coef(ols)))) {
          stop("at least one coefficient estimated by OLS is NA: ", 
              paste(colnames(tmp$xMat)[is.na(coef(ols))], collapse = ", "), 
              ". This may have been caused by (nearly) perfect multicollinearity")
      }
      olsParam <- c(coef(ols), summary(ols)$sigma^2)
      olsStdEr <- sqrt(diag(vcov(ols)))
      olsLogl <- logLik(ols)[1]
      if (nb > 0) {
          gridAdj <- coef(lm(rep(1, nrow(dataTable)) ~ dataTable[, 
              4:(3 + nb)] - 1))
      }
      else {
          gridAdj <- numeric(0)
      }
      if (length(gridAdj) != nb) {
          stop("internal error: the length of 'gridAdj' is not equal to 'nb'.", 
              " Please contact the maintainer of the frontier package")
      }
      returnObj <- .Fortran(C_front41, modelType = as.integer(modelType), 
          ineffDecrease = as.integer((!ineffDecrease) + 1), icept = as.integer(0), 
          nn = as.integer(nn), nt = as.integer(nt), nob = as.integer(nob), 
          nb = as.integer(nb), mu = as.integer(mu), eta = as.integer(eta), 
          printIter = as.integer(printIter), indic = as.integer(indic), 
          tol = as.double(tol), searchTol = as.double(searchTol), 
          bignum = as.double(bignum), searchStep = as.double(searchStep), 
          gridDouble = as.integer(gridDouble), gridSize = as.double(gridSize), 
          maxit = as.integer(maxit), muBound = as.double(muBound), 
          restartMax = as.integer(restartMax), restartFactor = as.double(restartFactor), 
          nRestart = as.integer(0), nStartVal = as.integer(length(startVal)), 
          startVal = as.double(startVal), nRowData = as.integer(nrow(dataTable)), 
          nColData = as.integer(ncol(dataTable)), dataTable = matrix(as.double(dataTable), 
              nrow(dataTable), ncol(dataTable), dimnames = dimnames(dataTable)), 
          nParamTotal = as.integer(nParamTotal), olsParam = as.double(c(olsParam, 
              rep(0, 1 + mu + eta))), gridAdj = as.double(gridAdj), 
          gridParam = as.double(rep(0, nParamTotal)), startLogl = as.double(0), 
          mleParam = as.double(rep(0, nParamTotal)), mleCov = matrix(as.double(0), 
              nParamTotal, nParamTotal), mleLogl = as.double(0), 
          nIter = as.integer(0), code = as.integer(0), nFuncEval = as.integer(0))
      if (returnObj$code == 101) {
          stop("the total number of observations exceeds the product of", 
              " the number of firms by the number of years")
      }
      else if (returnObj$code == 102) {
          stop("internal error: calculated variable 'n'", " is not equal to argument 'nParamTotal'.", 
              " Please contact the maintainer of the 'frontier' package", 
              " (arne.henningsen@gmail.com)")
      }
      else if (returnObj$code == 103) {
          stop("wrong number of starting values")
      }
      else if (returnObj$code == 104) {
          stop("a firm number is < 1")
      }
      else if (returnObj$code == 105) {
          stop("a firm number is > number of firms")
      }
      else if (returnObj$code == 106) {
          stop("a period number is < 1")
      }
      else if (returnObj$code == 107) {
          stop("a period number is > number of periods")
      }
      else if (returnObj$code == 108) {
          stop("there are no observations on at least one firm")
      }
      else if (returnObj$code == 109) {
          stop("internal error: 2 + nr - nmu * (im-1)", " is not equal to argument 'nColData'.", 
              " Please contact the maintainer of the 'frontier' package", 
              " (arne.henningsen@gmail.com)")
      }
      else if (returnObj$code > 100) {
          stop("unknown error.", " Please contact the maintainer of the 'frontier' package", 
              " (arne.henningsen@gmail.com)")
      }
      returnObj$nStartVal <- NULL
      returnObj$nRowData <- NULL
      returnObj$nColData <- NULL
      returnObj$nParamTotal <- NULL
      returnObj$ineffDecrease <- as.logical(2 - returnObj$ineffDecrease)
      returnObj$gridDouble <- as.logical(returnObj$gridDouble)
      returnObj$olsParam <- olsParam
      returnObj$olsStdEr <- olsStdEr
      returnObj$olsLogl <- olsLogl
      if (nb == 0) {
          fitVal <- rep(0, sum(validObs))
      }
      else {
          fitVal <- drop(dataTable[, 4:(3 + nb), drop = FALSE] %*% 
              returnObj$mleParam[1:nb])
      }
      returnObj$fitted <- matrix(NA, nrow = nn, ncol = nt)
      if (length(fitVal) != nrow(dataTable)) {
          stop("internal error: length of the fitted values is not equal to", 
              " the number of rows of the data table (valid observations)")
      }
      for (i in 1:length(fitVal)) {
          returnObj$fitted[dataTable[i, 1], dataTable[i, 2]] <- fitVal[i]
      }
      resid <- drop(dataTable[, 3] - fitVal)
      returnObj$resid <- matrix(NA, nrow = nn, ncol = nt)
      if (length(resid) != nrow(dataTable)) {
          stop("internal error: length of residuals is not equal to", 
              " the number of rows of the data table (valid observations)")
      }
      for (i in 1:length(resid)) {
          returnObj$resid[dataTable[i, 1], dataTable[i, 2]] <- resid[i]
      }
      returnObj$olsResid <- residuals(ols)
      returnObj$olsSkewness <- skewness(returnObj$olsResid)
      returnObj$olsSkewnessOkay <- returnObj$olsSkewness * (-1)^ineffDecrease >= 
          0
      warnMaxit <- maxit <= returnObj$nIter && maxit > 0
      if (!returnObj$olsSkewnessOkay && returnObj$mleLogl < returnObj$olsLogl) {
          warning("the residuals of the OLS estimates are ", ifelse(ineffDecrease, 
              "right", "left"), "-skewed", " and the likelihood value of the ML estimation is less", 
              " than that obtained using OLS;", " this usually indicates that there is no inefficiency", 
              " or that the model is misspecified")
      }
      else if (!returnObj$olsSkewnessOkay) {
          warning("the residuals of the OLS estimates are ", ifelse(ineffDecrease, 
              "right", "left"), "-skewed;", " this might indicate that there is no inefficiency", 
              " or that the model is misspecified")
      }
      else if (returnObj$mleLogl < returnObj$olsLogl && warnMaxit) {
          warning("the maximum number of iterations has been reached and", 
              " the likelihood value of the ML estimation is less", 
              " than that obtained using OLS;", " please try again using different starting values and/or", 
              " increase the maximum number of iterations")
          warnMaxit <- FALSE
      }
      else if (returnObj$mleLogl < returnObj$olsLogl && maxit > 
          0) {
          warning("the likelihood value of the ML estimation is less", 
              " than that obtained using OLS;", " this indicates that the likelihood maximization did not", 
              " converge to the global maximum or", " that there is no inefficiency", 
              " (you could try again using different starting values)")
      }
      if (warnMaxit) {
          warning("the maximum number of iterations has been reached;", 
              " please try again using different starting values and/or", 
              " increase the maximum number of iterations")
      }
      if (modelType == 1) {
          returnObj$truncNorm <- as.logical(returnObj$mu)
          returnObj$zIntercept <- zIntercept
          returnObj$mu <- NULL
      }
      else {
          returnObj$truncNorm <- truncNorm
          returnObj$zIntercept <- as.logical(returnObj$mu)
          returnObj$mu <- NULL
      }
      if (modelType == 1) {
          returnObj$timeEffect <- as.logical(returnObj$eta)
      }
      else {
          returnObj$timeEffect <- timeEffect
      }
      returnObj$eta <- NULL
      if (returnObj$indic == 2) {
          returnObj$searchScale <- FALSE
      }
      else if (returnObj$indic == 1) {
          returnObj$searchScale <- NA
      }
      else {
          returnObj$searchScale <- TRUE
      }
      returnObj$indic <- NULL
      if (length(startVal) == 1) {
          if (modelType == 1) {
              idx <- 1:(nb + 2)
          }
          else {
              if (nb == 0) {
                  idx <- NULL
              }
              else {
                  idx <- 1:nb
              }
              idx <- c(idx, (nParamTotal - 1):nParamTotal)
          }
          if (any(returnObj$gridParam[(1:nParamTotal)[-idx]] != 
              0)) {
              warning("internal error: some unused grid-search parameters are", 
                  " non-zero: ", paste(returnObj$gridParam, collapse = " "), 
                  " please contact the maintainer of the 'frontier' package")
          }
          returnObj$gridParam <- returnObj$gridParam[idx]
          names(returnObj)[names(returnObj) == "startLogl"] <- "gridLogl"
      }
      else {
          returnObj$gridParam <- NULL
      }
      if (inherits(data, "pdata.frame") || inherits(data, "plm.dim")) {
          rownames(returnObj$resid) <- levels(index(data)[[1]])[firmId]
          colnames(returnObj$resid) <- levels(index(data)[[2]])[timeId]
      }
      else {
          rownames(returnObj$resid) <- names(validObs)[validObs]
          colnames(returnObj$resid) <- "residuals"
      }
      paramNames <- colnames(tmp$xMat)
      if (modelType == 2) {
          if (zIntercept) {
              paramNames <- c(paramNames, "Z_(Intercept)")
          }
          if (nZvars > 0) {
              paramNames <- c(paramNames, paste("Z", colnames(tmp$zMat), 
                  sep = "_"))
          }
      }
      if (length(startVal) == 1) {
          returnObj$startVal <- NULL
      }
      paramNames <- c(paramNames, "sigmaSq", "gamma")
      if (modelType == 1) {
          if (truncNorm) {
              paramNames <- c(paramNames, "mu")
          }
          if (timeEffect) {
              paramNames <- c(paramNames, "time")
          }
      }
      if (nb >= 1) {
          betaNames <- paramNames[1:nb]
      }
      else {
          betaNames <- NULL
      }
      names(returnObj$olsParam) <- c(betaNames, "sigmaSq")
      names(returnObj$olsStdEr) <- betaNames
      if (!is.null(returnObj$gridParam)) {
          names(returnObj$gridParam) <- c(betaNames, "sigmaSq", 
              "gamma")
      }
      names(returnObj$mleParam) <- paramNames
      rownames(returnObj$mleCov) <- paramNames
      colnames(returnObj$mleCov) <- paramNames
      if (!is.null(returnObj$startVal)) {
          names(returnObj$startVal) <- paramNames
      }
      returnObj$call <- match.call()
      returnObj$validObs <- validObs
      if (maxit > 0) {
          if ((returnObj$mleParam["gamma"] < 0.01 || returnObj$mleParam["gamma"] > 
              0.99)) {
              warning("the parameter 'gamma' is close to the boundary", 
                  " of the parameter space [0,1]:", " this can cause convergence problems and", 
                  " can negatively affect the validity and reliability", 
                  " of statistical tests", " and might be caused by model misspecification")
          }
          if (!semidefiniteness(returnObj$mleCov)) {
              warning("the covariance matrix of the maximum likelihood estimates", 
                  " is not positive semidefinite")
          }
          else {
              testSingularCov <- try(solve(returnObj$mleCov), silent = TRUE)
              if (class(testSingularCov) == "try-error") {
                  if (grepl("singular", testSingularCov[1])) {
                    warning("the covariance matrix of the maximum likelihood estimates", 
                      " is singular")
                  }
                  else {
                    warning("the covariance matrix of the maximum likelihood estimates", 
                      " is not invertible")
                  }
              }
          }
      }
      class(returnObj) <- "frontier"
      return(returnObj)
  }
  <bytecode: 0x559518494a60>
  <environment: namespace:frontier>
   --- function search by body ---
  Function sfa in namespace frontier has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1