- using R Under development (unstable) (2019-12-11 r77556)
- using platform: x86_64-pc-linux-gnu (64-bit)
- using session charset: ISO8859-15
- checking for file 'geostatsp/DESCRIPTION' ... OK
- checking extension type ... Package
- this is package 'geostatsp' version '1.7.8'
- checking package namespace information ... OK
- checking package dependencies ... NOTE
Package which this enhances but not available for checking: 'INLA'
- checking if this is a source package ... OK
- checking if there is a namespace ... OK
- checking for executable files ... OK
- checking for hidden files and directories ... OK
- checking for portable file names ... OK
- checking for sufficient/correct file permissions ... OK
- checking serialization versions ... OK
- checking whether package 'geostatsp' can be installed ... OK
- checking package directory ... OK
- checking for future file timestamps ... OK
- checking 'build' directory ... OK
- checking DESCRIPTION meta-information ... OK
- checking top-level files ... OK
- checking for left-over files ... OK
- checking index information ... OK
- checking package subdirectories ... OK
- checking R files for non-ASCII characters ... OK
- checking R files for syntax errors ... OK
- checking whether the package can be loaded ... OK
- checking whether the package can be loaded with stated dependencies ... OK
- checking whether the package can be unloaded cleanly ... OK
- checking whether the namespace can be loaded with stated dependencies ... OK
- checking whether the namespace can be unloaded cleanly ... OK
- checking loading without being on the library search path ... OK
- checking use of S3 registration ... OK
- checking dependencies in R code ... OK
- checking S3 generic/method consistency ... OK
- checking replacement functions ... OK
- checking foreign function calls ... OK
- checking R code for possible problems ... [38s/41s] OK
- checking Rd files ... OK
- checking Rd metadata ... OK
- checking Rd line widths ... OK
- checking Rd cross-references ... OK
- checking for missing documentation entries ... OK
- checking for code/documentation mismatches ... OK
- checking Rd \usage sections ... OK
- checking Rd contents ... OK
- checking for unstated dependencies in examples ... OK
- checking contents of 'data' directory ... OK
- checking data for non-ASCII characters ... OK
- checking data for ASCII and uncompressed saves ... OK
- checking line endings in C/C++/Fortran sources/headers ... OK
- checking line endings in Makefiles ... OK
- checking compilation flags in Makevars ... OK
- checking for GNU extensions in Makefiles ... OK
- checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK
- checking use of PKG_*FLAGS in Makefiles ... OK
- checking use of SHLIB_OPENMP_*FLAGS in Makefiles ... OK
- checking include directives in Makefiles ... OK
- checking pragmas in C/C++ headers and code ... OK
- checking compilation flags used ... OK
- checking compiled code ... OK
- checking sizes of PDF files under 'inst/doc' ... OK
- checking installed files from 'inst/doc' ... OK
- checking files in 'vignettes' ... OK
- checking examples ... [24s/25s] OK
Examples with CPU (user + system) or elapsed time > 5s
user system elapsed
RFsimulate 4.85 0.219 5.402
- checking for unstated dependencies in 'tests' ... OK
- checking tests ... [248s/205s] ERROR
Running 'RFsimulate.R' [11s/11s]
Running 'krige.R' [8s/9s]
Running 'lgcp.R' [8s/9s]
Running 'lgm.R' [11s/12s]
Running 'lgmRaster.R' [159s/107s]
Running 'likfitLgm.R' [10s/11s]
Running 'matern.R' [6s/7s]
Running 'maternGmrfPrec.R' [9s/11s]
Running 'profLlgm.R' [14s/13s]
Running 'simLgcp.R' [7s/8s]
Running 'stackRasterList.R' [6s/6s]
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: 0x1122c2c8>
<environment: namespace:geostatsp>
--- function search by body ---
Function informationLgm in namespace geostatsp has this body.
----------- END OF FAILURE REPORT --------------
Error in if (class(infmat) == "try-error") { :
the condition has length > 1
Calls: lgm ... callGeneric -> eval -> eval -> lgm -> lgm -> informationLgm
Execution halted
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] "Thu Dec 12 23:20:00 2019"
> x=profLlgm(swissFit, mc.cores=Ncores,
+ range=seq(15000, 55000 , len=12)
+ )
> date()
[1] "Thu Dec 12 23:20:03 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: 0x12574bf0>
<environment: namespace:geostatsp>
--- function search by body ---
Function informationLgm in namespace geostatsp has this body.
----------- END OF FAILURE REPORT --------------
Error in if (class(infmat) == "try-error") { :
the condition has length > 1
Calls: informationLgm
Execution halted
- checking for unstated dependencies in vignettes ... OK
- checking package vignettes in 'inst/doc' ... OK
- checking re-building of vignette outputs ... [21s/24s] OK
- checking PDF version of manual ... OK
- checking for non-standard things in the check directory ... OK
- DONE
Status: 1 ERROR, 1 NOTE