# NOT RUN {
# }
# NOT RUN {
if (bru_safe_inla()) {
# Load the Gorilla data
data(gorillas, package = "inlabru")
# Plot the Gorilla nests, the mesh and the survey boundary
ggplot() +
gg(gorillas$mesh) +
gg(gorillas$nests) +
gg(gorillas$boundary) +
coord_fixed()
# Define SPDE prior
matern <- INLA::inla.spde2.pcmatern(gorillas$mesh,
prior.sigma = c(0.1, 0.01),
prior.range = c(0.01, 0.01)
)
# Define domain of the LGCP as well as the model components (spatial SPDE
# effect and Intercept)
cmp <- coordinates ~ mySmooth(map = coordinates, model = matern) + Intercept
# Fit the model (with int.strategy="eb" to make the example take less time)
fit <- lgcp(cmp, gorillas$nests,
samplers = gorillas$boundary,
domain = list(coordinates = gorillas$mesh),
options = list(control.inla = list(int.strategy = "eb"))
)
# Predict the spatial intensity surface
lambda <- predict(fit, pixels(gorillas$mesh), ~ exp(mySmooth + Intercept))
# Plot the intensity
ggplot() +
gg(lambda) +
gg(gorillas$mesh) +
gg(gorillas$nests) +
gg(gorillas$boundary) +
coord_fixed()
}
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab