Hi,
I've encountered a problem trying to fit covariates as random walks that I can't really interpret. I've managed to reproduce it with the gorilla's dataset.
rm(list = ls())
library(inlabru)
library(spatstat)
library(terra)
library(INLA)
# get gorillas data
data(gorillas_sf, package = "inlabru")
mesh <- gorillas_sf$mesh
boundary <- gorillas_sf$boundary
nests <- gorillas_sf$nests
# get covariates
data("gorillas")
elevation <- rast(gorillas.extra$elevation)
crs(elevation) <- "epsg:32632"
elevation <- project(elevation, crs(nests))
# set up 1 covariate for RW2
mesh1D_elev <- inla.mesh.1d(seq(min(elevation[], na.rm = T)-1,
max(elevation[], na.rm = T)+1,
length.out = 20),
degree = 2)
mapper_elev <- bru_mapper(mesh1D_elev, indexed = FALSE)
# set up spatial random field
matern <- INLA::inla.spde2.pcmatern(
mesh,
prior.sigma = c(0.1, 0.01),
prior.range = c(0.1, 0.01))
# fit model
cmp <- geometry ~ Intercept(1) +
Eff.elevation(elevation, model = "rw2", mapper = mapper_elev) +
field(geometry, model = matern)
fit <- lgcp(cmp, nests,
samplers = boundary,
domain = list(geometry = mesh))
This produces the following error that doesn't appear when fitting the covariate as linear
Warning in input_eval.bru_input(component[[part]]$input, data, env = component$env, :
Model input 'elevation' for 'Eff.elevation' returned some NA values.
Attempting to fill in spatially by nearest available value.
To avoid this basic covariate imputation, supply complete data.
Error in .subscript.2ary(x, , j, drop = drop) :
logical subscript too long
I'm aware of the warning for the covariate imputation, that doesn't bother me at this point, my issue is with the cryptic error. Any ideas?
Many thanks!