Dear INLA community,
I am trying to use the function of INLA inla.posterior.sample and inla.posterior.sample.eval as I am interested to simulate the answers of the model.
I am having trouble adding the spde random effects, I have already read the vignette that INLA has for this topics and other answers in this group but it still unclear for me how to do it. Here is an example with artificial data replicating what I have been trying to do
Asume the mesh and the other processes are already completed
formula <- y ~ -1 + iIntercept + x1 + x2 + f(s, model = spde)
#s is this inla.spde.make.index("s", spde$n.spde)
res <- inla(formula, family = "lognormal",
data = inla.stack.data(stk.full),
control.predictor = list(A = inla.stack.A(stk.full), compute = TRUE),
control.compute = list(cpo = TRUE, dic = TRUE, waic = TRUE,
return.marginals.predictor = TRUE,
config = TRUE),
control.fixed=list(mean = 0,prec = 0.01,
mean.intercept = 0,prec.intercept = 0.01),
control.family = list(hyper=list(theta1 = list(
prior = "normal",
param = c(0.8, 0.3)))))
samples <- inla.posterior.sample(100, res)
#here is where I am starting to have problems as I am not sure how to introduce the #random effect term I defined previously in fun2
fun2 <- function() return (b0 + ind*grid_huelva$Industria + mar*grid_huelva$Marsh + agric*grid_huelva$Agric + refi*grid_huelva$Refineria + urban*grid_huelva$Urbano + phospho*grid_huelva$Phospho )
inla.posterior.sample.eval(fun2, samples)
Does anyone have any idea how can I do this? To have the posterior predictive distribution take on account f(s, model = spde)