Hi,
You do not always need constr = TRUE. It is not needed for 'iid' model, or any other model with proper joint distribution. But sometimes you want it, for example for the case of having a long range correlation that interacts with some other model component. You only need constraint in intrinsic models if another model component includes its null space.
Please take a look at the example below, where I illustrate the fact that you do not always need to add a constraint while working with intrinsic models.
library(INLA)
n <- 30
x <- scale(cumsum(rnorm(n)))
plot(x)
y <- rpois(n, exp(2 + x))
fit1 <- inla(
y ~ f(i, model = 'rw1'),
data = list(i = 1:n, y = y),
family = 'poisson'
)
## The intercept captures the overall mean
fit1$summary.fix
## posterior mean for the constrained random effect is around zero
summary(fit1$summary.random$i$mean)
## Now, take the intercept ou of the linear predictor
## Then, the constraint in the random effect is no longer needed
fit2 <- inla(
y ~ 0 + f(i, model = 'rw1', constr = FALSE),
data = list(i = 1:n, y = y),
family = 'poisson'
)
## unconstrained random effect is around the intercept (not fitted separately)
summary(fit2$summary.random$i$mean)
## However, the fitted values are similar (not exactly the same as the priors are different and there are some small numerical differences while doing the computations)
summary(fit1$summary.fitted.values$mean)
summary(fit2$summary.fitted.values$mean)
regards,
Elias