Error when running inla.barrier.pcmatern()

44 views
Skip to first unread message

JUAN MIGUEL REQUENA MULLOR

unread,
Apr 8, 2025, 12:34:53 PM4/8/25
to R-inla discussion group
Hello all,

I'm running INLA 25.3.24 and INLAspacetime 0.1.12 in R 4.4.3.
When running the following to code to simulate a barrier model I got the following error:

# load required packages
library("INLA")
library("raster")
library("INLAspacetime")
Loading required package: Matrix
This is INLA_25.03.24 built 2025-03-24 16:12:01 UTC.
 - See www.r-inla.org/contact-us for how to get help.
 - List available models/likelihoods/etc with inla.list.models()
 - Use inla.doc(<NAME>) to access documentation
Loading required package: sp
Loading required package: fmesher
see more on https://eliaskrainski.github.io/INLAspacetime

> set.seed(201805)

# load required spatial files for building the mesh
greenhouses <- shapefile("/home/jrequena/sampling_simulation/domain.shp")
points <- spsample(greenhouses, n = 40, type = "random")# extract a random sample of points outside greenhouses

> range <- 1000 # in meters
bound.outer = 200
max.edge <- (1/10) * range
# Build the mesh; lengths in meters
mesh = inla.mesh.2d(boundary = greenhouses,
                    loc=cbind(points$x, points$y),
                    max.edge = c(0.5,4)*max.edge,
                    cutoff = 2,
                    crs = CRS("+proj=utm +zone=30 +datum=WGS84 +units=m +no_defs"),
                    offset = c(max.edge, bound.outer))


> water.tri = inla.over_sp_mesh(greenhouses, y = mesh, type = "centroid", ignore.CRS = TRUE)
num.tri = length(mesh$graph$tv[, 1])
barrier.tri = setdiff(1:num.tri, water.tri[[1]])
poly.barrier = inla.barrier.polygon(mesh,
                                    barrier.triangles = barrier.tri)
crs(poly.barrier) <- CRS("+proj=utm +zone=30 +datum=WGS84 +units=m +no_defs")
> prec <- 1

barrier.model <- inla.barrier.pcmatern(mesh, prior.range = c(range,0.5), prior.sigma = c(prec,0.5),
                                       barrier.triangles = barrier.tri, range.fraction = 0.5, enable.INLAspacetime = FALSE)

Error in as.character(package) :
  cannot coerce type 'closure' to vector of type 'character'

In addition: Warning messages:
1: In inla.barrier.pcmatern(mesh, prior.range = c(range, 0.5), prior.sigma = c(prec,  :
  Please install the `INLAspacetime` package
 which contains an implementation that runs faster!
2: In inla.barrier.fem(mesh, barrier.triangles = barrier.triangles) :
  Using implementation from the `INLAspacetime` package
-----------------------------------------------------------------------------------------------------------------


I have tried a bunch of stuff with no success.
I appreciate any help.
Thank you in advance.
Regards!
Juanmi

Helpdesk (Haavard Rue)

unread,
Apr 8, 2025, 1:23:16 PM4/8/25
to JUAN MIGUEL REQUENA MULLOR, R-inla discussion group
could you please share

/home/jrequena/sampling_simulation/domain.shp

so we can rerun it here? (or another file with same error)

On Tue, 2025-04-08 at 09:34 -0700, 'JUAN MIGUEL REQUENA MULLOR' via R-inla
> --
> You received this message because you are subscribed to the Google Groups "R-
> inla discussion group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to r-inla-discussion...@googlegroups.com.
> To view this discussion, visit
> https://groups.google.com/d/msgid/r-inla-discussion-group/c1b4aa3b-3e63-43de-826d-106c6484d053n%40googlegroups.com
> .

--
Håvard Rue
he...@r-inla.org
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages