Closed courtiol closed 11 months ago
Here is another example leading to the same message:
> GNIPDataDEagg <- prepsources(data = GNIPDataDE)
> GermanFit <- isofit(data = GNIPDataDEagg,
+ mean_model_fix = list(elev = TRUE, lat_abs = TRUE))
> CalibAlien <- calibfit(data = CalibDataAlien, isofit = GermanFit)
[1] "predicting the isoscape value in each calibration site..."
Warning in .calc_logdisp_cov(object, dvdloglamMat = dvdloglamMat, dvdlogphiMat = dvdlogphiMat, :
Numerical precision issue in computation of the information matrix for dispersion parameters:
the prediction variance may be inaccurate.
I prefer having confused users asking questions rather than having hidden persistent problems in the code.
To indicate what to do when the warning occurs, one needs to find the cause as it can have different causes calling for different actions. This is not straightforward in general; the next version of spaMM will (likely) include some improvements. In the present case the warning only results from a very low variance for one random effect (ca. 1e-10) meaning that there is no need to consider it, so one may ask whether we should keep this random effect in the prediction variance computations.
Perhaps I should intercept expected warnings and only cancel those. I could use a wrapper for that, such as:
wrapper <- function(x) {
withCallingHandlers(x, warning = function(w) {
if(!w[[1]] == "bla") warning(w[[1]], call. = FALSE)
invokeRestart("muffleWarning")
})
}
foo <- function(x, warn) {
warning(warn)
x
}
wrapper(foo(1, "bla"))
wrapper(foo(2, "bli"))
I would need to check what happens when multiple warnings occur...
Perhaps some of the spaMM warnings should be removed as they confuse users, otherwise we need to indicate what they could do to avoid the situation creating the warnings.
Here is a first example: