Running ‘RFsimulate.R’ [8s/11s]
  Running ‘krige.R’ [6s/8s]
  Running ‘lgcp.R’ [6s/10s]
  Running ‘lgm.R’ [8s/11s]
  Running ‘lgmRaster.R’ [118s/113s]
  Running ‘likfitLgm.R’ [7s/10s]
  Running ‘matern.R’ [5s/8s]
  Running ‘maternGmrfPrec.R’ [7s/11s]
  Running ‘profLlgm.R’ [10s/12s]
  Running ‘simLgcp.R’ [5s/7s]
  Running ‘stackRasterList.R’ [5s/8s]
Running the tests in ‘tests/lgm.R’ failed.
Complete output:
  > library("geostatsp")
  Loading required package: Matrix
  Loading required package: raster
  Loading required package: sp
  > data("swissRain")
  > 
  > bob = function(x) {
  + 	thepar = x$param
  + 	pdf(tempfile("lgm", tmpdir=".", fileext=".pdf"))
  + 	plot(x$predict[["predict"]], main=
  + 					paste(
  + 							paste(names(thepar), thepar, sep="="),
  + 							collapse=", "),cex.main=0.3
  + 	)
  + 	dev.off()
  + }
  > 
  > 
  > 
  > # specify formula name of raster layer
  > swissFit = lgm(data=swissRain[1:60,], formula=rain~ CHE_alt,
  + 		grid=80, covariates=swissAltitude,
  + 		shape=2,  fixShape=TRUE, 
  + 		boxcox=0.5, fixBoxcox=TRUE, 
  + 		aniso=TRUE)	
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  geostatsp
   --- call from context --- 
  informationLgm(res)
   --- call from argument --- 
  if (class(infmat) == "try-error") {
      return(list(summary = fit$summary, information = NULL, error = infmat))
  }
   --- R stacktrace ---
  where 1: informationLgm(res)
  where 2: lgm(formula = formula, data = data, grid = grid, covariates = covariates, 
      shape = shape, boxcox = boxcox, aniso = aniso, fixShape = fixShape, 
      fixBoxcox = fixBoxcox)
  where 3: lgm(formula = formula, data = data, grid = grid, covariates = covariates, 
      shape = shape, boxcox = boxcox, aniso = aniso, fixShape = fixShape, 
      fixBoxcox = fixBoxcox)
  where 4: eval(call, parent.frame())
  where 5: eval(call, parent.frame())
  where 6: callGeneric()
  where 7: lgm(formula = formula, data = data, grid = grid, covariates = covariates, 
      shape = shape, boxcox = boxcox, aniso = aniso, fixShape = fixShape, 
      fixBoxcox = fixBoxcox)
  where 8: lgm(formula = formula, data = data, grid = grid, covariates = covariates, 
      shape = shape, boxcox = boxcox, aniso = aniso, fixShape = fixShape, 
      fixBoxcox = fixBoxcox)
  where 9: eval(call, parent.frame())
  where 10: eval(call, parent.frame())
  where 11: callGeneric()
  where 12: lgm(data = swissRain[1:60, ], formula = rain ~ CHE_alt, grid = 80, 
      covariates = swissAltitude, shape = 2, fixShape = TRUE, boxcox = 0.5, 
      fixBoxcox = TRUE, aniso = TRUE)
  where 13: lgm(data = swissRain[1:60, ], formula = rain ~ CHE_alt, grid = 80, 
      covariates = swissAltitude, shape = 2, fixShape = TRUE, boxcox = 0.5, 
      fixBoxcox = TRUE, aniso = TRUE)
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (fit, ...) 
  {
      nonLinearParams = c("boxcox", "shape", "nugget", "variance", 
          "anisoAngleRadians", "anisoRatio", "range")
      reEstimate = rownames(fit$summary)[fit$summary[, "Estimated"]]
      reEstimate = gsub("sdNugget", "nugget", reEstimate)
      reEstimate = gsub("sdSpatial", "variance", reEstimate)
      reEstimate = gsub("range([[:space:]]?\\(km\\)|/1000)", "range", 
          reEstimate)
      reEstimate = intersect(reEstimate, nonLinearParams)
      baseParam = fit$parameters[reEstimate]
      moreParams = fit$parameters[!names(fit$parameters) %in% reEstimate & 
          names(fit$parameters) %in% nonLinearParams]
      parToLog = c("nugget", "variance", "anisoRatio", "range")
      parToLog = intersect(reEstimate, parToLog)
      if (!all(baseParam[parToLog] > 0)) 
          return(list(summary = fit$summary, information = NULL))
      fit$data = na.omit(fit$data)
      aniso = length(grep("^aniso", reEstimate)) | any(abs(moreParams["anisoRatio"] - 
          1) > 1e-05, na.rm = TRUE)
      if (!aniso) {
          coordinates = as(spDists(fit$data), "dsyMatrix")
      }
      else {
          coordinates = fit$data
      }
      oneL = function(param) {
          param[parToLog] = exp(param[parToLog])
          loglikLgm(param, data = fit$data, formula = fit$model$formula, 
              coordinates = coordinates, reml = fit$model$reml, 
              moreParams = moreParams, minustwotimes = FALSE)
      }
      baseParam[parToLog] = log(baseParam[parToLog])
      hess = numDeriv::hessian(oneL, baseParam, ...)
      whichLogged = which(names(baseParam) %in% parToLog)
      names(baseParam)[whichLogged] = paste("log(", names(baseParam)[whichLogged], 
          ")", sep = "")
      dimnames(hess) = list(names(baseParam), names(baseParam))
      infmat = -hess
      infmat = try(solve(infmat), silent = TRUE)
      if (class(infmat) == "try-error") {
          return(list(summary = fit$summary, information = NULL, 
              error = infmat))
      }
      if (length(grep("anisoAngleRadians", colnames(infmat)))) {
          anisoAngleDegrees = (360/(2 * pi)) * infmat[, "anisoAngleRadians"]
          infmat = rbind(infmat, anisoAngleDegrees = anisoAngleDegrees)
          anisoAngleDegrees = c(anisoAngleDegrees, anisoAngleDegrees = (360/(2 * 
              pi)) * as.numeric(anisoAngleDegrees["anisoAngleRadians"]))
          infmat = cbind(infmat, anisoAngleDegrees = anisoAngleDegrees)
      }
      pvec = grep("^ci([[:digit:]]|\\.)+$", colnames(fit$summary), 
          value = TRUE)
      pvec = as.numeric(gsub("^ci", "", pvec))
      qvec = qnorm(pvec)
      names(qvec) = paste("ci", pvec, sep = "")
      stdErr = diag(infmat)
      if (any(is.na(stdErr))) 
          return(list(summary = fit$summary, information = infmat))
      if (!all(stdErr > 0)) 
          return(list(summary = fit$summary, information = infmat))
      stdErr = sqrt(stdErr)
      toAdd = outer(stdErr, qvec, FUN = "*")
      forSummary = baseParam[rownames(toAdd)] + toAdd
      expAdd = exp(forSummary[grep("^log\\(", rownames(forSummary)), 
          ])
      rownames(expAdd) = gsub("^log\\(|\\)$", "", rownames(expAdd))
      forSummary = rbind(forSummary, expAdd)
      summary = fit$summary
      if (any(rownames(forSummary) == "nugget")) 
          forSummary = rbind(forSummary, sdNugget = sqrt(pmax(0, 
              forSummary["nugget", ])))
      if (any(rownames(forSummary) == "variance")) 
          forSummary = rbind(forSummary, sdSpatial = sqrt(pmax(0, 
              forSummary["variance", ])))
      if (any(rownames(forSummary) == "anisoAngleRadians")) 
          forSummary = rbind(forSummary, anisoAngleDegrees = forSummary["anisoAngleRadians", 
              ] * 360/(2 * pi))
      inBoth = intersect(rownames(summary), rownames(forSummary))
      summary[inBoth, colnames(forSummary)] = forSummary[inBoth, 
          ]
      list(summary = summary, information = infmat)
  }
  <bytecode: 0x55f68f7661a0>
  <environment: namespace:geostatsp>
   --- function search by body ---
  Function informationLgm in namespace geostatsp has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1
Running the tests in ‘tests/profLlgm.R’ failed.
Complete output:
  > library('geostatsp')
  Loading required package: Matrix
  Loading required package: raster
  Loading required package: sp
  > data('swissRain')
  > 
  > Ncores = c(1,2)[1+(.Platform$OS.type=='unix')]
  > 
  > 
  > 
  > sr2 = swissRain
  > sr2$elev = raster::extract(swissAltitude, sr2)
  > swissFit = likfitLgm(
  +     data=sr2, 
  +     formula=rain~ elev,
  +     param=c(range=10000,shape=1,nugget=0,boxcox=0.5,anisoRatio=2,anisoAngleDegrees=45),
  +     paramToEstimate = c("range",'anisoAngleDegrees','anisoRatio'),
  +     reml=FALSE,
  +     verbose=FALSE
  + )
  > 
  > 
  > # calculate log-likelihood at the MLE's, but re-estimate variance
  > sl = loglikLgm(
  +     swissFit$param[c('range','shape','boxcox', 'anisoRatio', 'anisoAngleRadians')],
  +     data=sr2, 
  +     formula=rain~ elev,
  +     reml=swissFit$model$reml)  
  > 
  > 
  > # calculate log-likelihood without re-estimating variance
  > sigSqHat = attributes(sl)$totalVarHat
  > sl1 = loglikLgm(
  +     c(attributes(sl)$param[
  +             c('boxcox','anisoRatio','anisoAngleRadians','shape', 'range')], 
  +         variance=sigSqHat),
  +     data=sr2, 
  +     formula=rain~ elev,
  +     reml=swissFit$model$reml)  
  >  
  > 
  > # re=estimate the anisotropy parameters but not the range
  > sf2 = likfitLgm(
  +     data=swissFit$data, 
  +     formula=swissFit$model$formula,
  +     param= swissFit$param[c('range','nugget','shape','boxcox', 'anisoRatio', 'anisoAngleRadians')],
  +     paramToEstimate = c('variance','anisoAngleRadians','anisoRatio'),
  +     reml=swissFit$model$reml)  
  > 
  > # these should all be the same
  > as.numeric(sl1)
  [1] 646.9659
  > as.numeric(sl) 
  [1] 646.9659
  > swissFit$optim$logL
  m2logL.ml   logL.ml 
   646.9659 -323.4829 
  > sf2$optim$logL
  m2logL.ml   logL.ml 
   646.9659 -323.4829 
  > 
  > date()
  [1] "Tue Dec  3 20:59:08 2019"
  > x=profLlgm(swissFit, mc.cores=Ncores,
  +     range=seq(15000, 55000 , len=12)
  + )
  > date()
  [1] "Tue Dec  3 20:59:10 2019"
  > 
  >  
  > swissInf = informationLgm(swissFit)
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  geostatsp
   --- call from context --- 
  informationLgm(swissFit)
   --- call from argument --- 
  if (class(infmat) == "try-error") {
      return(list(summary = fit$summary, information = NULL, error = infmat))
  }
   --- R stacktrace ---
  where 1: informationLgm(swissFit)
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (fit, ...) 
  {
      nonLinearParams = c("boxcox", "shape", "nugget", "variance", 
          "anisoAngleRadians", "anisoRatio", "range")
      reEstimate = rownames(fit$summary)[fit$summary[, "Estimated"]]
      reEstimate = gsub("sdNugget", "nugget", reEstimate)
      reEstimate = gsub("sdSpatial", "variance", reEstimate)
      reEstimate = gsub("range([[:space:]]?\\(km\\)|/1000)", "range", 
          reEstimate)
      reEstimate = intersect(reEstimate, nonLinearParams)
      baseParam = fit$parameters[reEstimate]
      moreParams = fit$parameters[!names(fit$parameters) %in% reEstimate & 
          names(fit$parameters) %in% nonLinearParams]
      parToLog = c("nugget", "variance", "anisoRatio", "range")
      parToLog = intersect(reEstimate, parToLog)
      if (!all(baseParam[parToLog] > 0)) 
          return(list(summary = fit$summary, information = NULL))
      fit$data = na.omit(fit$data)
      aniso = length(grep("^aniso", reEstimate)) | any(abs(moreParams["anisoRatio"] - 
          1) > 1e-05, na.rm = TRUE)
      if (!aniso) {
          coordinates = as(spDists(fit$data), "dsyMatrix")
      }
      else {
          coordinates = fit$data
      }
      oneL = function(param) {
          param[parToLog] = exp(param[parToLog])
          loglikLgm(param, data = fit$data, formula = fit$model$formula, 
              coordinates = coordinates, reml = fit$model$reml, 
              moreParams = moreParams, minustwotimes = FALSE)
      }
      baseParam[parToLog] = log(baseParam[parToLog])
      hess = numDeriv::hessian(oneL, baseParam, ...)
      whichLogged = which(names(baseParam) %in% parToLog)
      names(baseParam)[whichLogged] = paste("log(", names(baseParam)[whichLogged], 
          ")", sep = "")
      dimnames(hess) = list(names(baseParam), names(baseParam))
      infmat = -hess
      infmat = try(solve(infmat), silent = TRUE)
      if (class(infmat) == "try-error") {
          return(list(summary = fit$summary, information = NULL, 
              error = infmat))
      }
      if (length(grep("anisoAngleRadians", colnames(infmat)))) {
          anisoAngleDegrees = (360/(2 * pi)) * infmat[, "anisoAngleRadians"]
          infmat = rbind(infmat, anisoAngleDegrees = anisoAngleDegrees)
          anisoAngleDegrees = c(anisoAngleDegrees, anisoAngleDegrees = (360/(2 * 
              pi)) * as.numeric(anisoAngleDegrees["anisoAngleRadians"]))
          infmat = cbind(infmat, anisoAngleDegrees = anisoAngleDegrees)
      }
      pvec = grep("^ci([[:digit:]]|\\.)+$", colnames(fit$summary), 
          value = TRUE)
      pvec = as.numeric(gsub("^ci", "", pvec))
      qvec = qnorm(pvec)
      names(qvec) = paste("ci", pvec, sep = "")
      stdErr = diag(infmat)
      if (any(is.na(stdErr))) 
          return(list(summary = fit$summary, information = infmat))
      if (!all(stdErr > 0)) 
          return(list(summary = fit$summary, information = infmat))
      stdErr = sqrt(stdErr)
      toAdd = outer(stdErr, qvec, FUN = "*")
      forSummary = baseParam[rownames(toAdd)] + toAdd
      expAdd = exp(forSummary[grep("^log\\(", rownames(forSummary)), 
          ])
      rownames(expAdd) = gsub("^log\\(|\\)$", "", rownames(expAdd))
      forSummary = rbind(forSummary, expAdd)
      summary = fit$summary
      if (any(rownames(forSummary) == "nugget")) 
          forSummary = rbind(forSummary, sdNugget = sqrt(pmax(0, 
              forSummary["nugget", ])))
      if (any(rownames(forSummary) == "variance")) 
          forSummary = rbind(forSummary, sdSpatial = sqrt(pmax(0, 
              forSummary["variance", ])))
      if (any(rownames(forSummary) == "anisoAngleRadians")) 
          forSummary = rbind(forSummary, anisoAngleDegrees = forSummary["anisoAngleRadians", 
              ] * 360/(2 * pi))
      inBoth = intersect(rownames(summary), rownames(forSummary))
      summary[inBoth, colnames(forSummary)] = forSummary[inBoth, 
          ]
      list(summary = summary, information = infmat)
  }
  <bytecode: 0x55d90cf65328>
  <environment: namespace:geostatsp>
   --- function search by body ---
  Function informationLgm in namespace geostatsp has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1