Hello everyone, I am trying to estimate a Log Gaussian Cox Process Model in which the effort function changes every year.
The information on effort is contained in a list of dataframes defined as follows:
List of 24
$ eff_2000:'data.frame': 11589919 obs. of 4 variables:
..$ x : num [1:11589919] -1760 -1759 -1758 -1757 -1756 ...
..$ y : num [1:11589919] 5473 5473 5473 5473 5473 ...
..$ eff2000: num [1:11589919] 0 0 0 0 0 0 0 0 0 0 ...
..$ Year : int [1:11589919] 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 ...
$ eff_2001:'data.frame': 11589919 obs. of 4 variables:
..$ x : num [1:11589919] -1760 -1759 -1758 -1757 -1756 ...
..$ y : num [1:11589919] 5473 5473 5473 5473 5473 ...
..$ eff2001: num [1:11589919] 0 0 0 0 0 0 0 0 0 0 ...
..$ Year : int [1:11589919] 2001 2001 2001 2001 2001 2001 2001 2001 2001 2001 etc...Meanwhile, the effort function is defined like this:
log_detect_year = function(xy, t1, t2, Year1) {indx <- Year1
print(paste("Detection:", indx), sep = " ")
print(xy)
eff <- rast(df[,1:3], type = "xyz")
dens = eval_spatial(eff, xy)
pnorm(dens / qexppnorm(t1, rate = 0.5) +
t2,
log.p = TRUE)
}
My INLA model is defined as follows:
cmp = ~
intercept1(1, mean.linear = 0, prec.linear = 2) +
SPDE(geometry, model = barrier.model,
mapper = bru_mapper(mesh_medit),
replicate = Year1, nrep = 4) +
depth_s(depth.r$depth, mean.linear = 0.5, prec.linear = 2) +
temp(temp.mean.r$temp_fa, mean.linear = 0, prec.linear = 1.5) +
bpi(bpi.r$bpi, mean.linear = 0, prec.linear = 1.5) +
Year_cov(Year1, model = "linear", prec.linear = 0.01) +
effort_scale(1, prec.linear = 1) +
effort_shift(1, prec.linear = 10)
formula_t = geometry + Year1 ~
intercept1 +
SPDE +
depth_s +
temp +
bpi +
Year_cov +
log_detect_year(geometry, effort_scale, effort_shift, Year1)
lik_t <- like("cp",
formula = formula_t,
samplers = boundary_domain,
domain = list(geometry = mesh_medit,
Year1 = seq(21, 24,1)),
data = mk.sf)
fit <- bru(components = cmp,
lik_t,
options = list(
verbose = FALSE,
inla.mode = "experimental",
bru_max_iter = 35,
control.inla = list(int.strategy = "eb")
))
The model doesn’t run and returns this error:
Error in eff.r.ls[[indx]] : no such index at level 2
I’m definitely doing something wrong in the implementation.
Can you help me figure it out?