I'm wondering whether INLA treats factors incorrectly or am I missing something. In this toy example there is a variable with 6 factor levels, which I put into a stack and feed to INLA, which returns estimates for 7 levels!? However, if I give the data directly to INLA I get 5 as should:
data(InsectSprays)
n = nrow(InsectSprays)
loc = matrix(runif(n),n,2)
mesh = inla.mesh.create.helper(points.domain=loc, max.edge=c(0.1,0.5))
spde = inla.spde2.matern(mesh)
index = inla.spde.make.index("spatial", mesh$n)
A = inla.spde.make.A(mesh, loc, index=1:n)
stack = inla.stack(data=list(count=InsectSprays$count), A=list(A, 1),
effects=list(c(index, list(intercept=1)), list(spray=InsectSprays$spray)))
summary(inla(count ~ -1 + intercept + spray, data=inla.stack.data(stack), control.predictor=list(A=inla.stack.A(stack))))
summary(inla(count ~ spray, data=InsectSprays))