Value of zero-centered, IID random effect in SPDE prediction stack

139 views
Skip to first unread message

Tim Meehan

unread,
Jun 29, 2022, 12:29:58 PM6/29/22
to R-inla discussion group
Hi all,

I have a space-time model with an svc and a simple, zero-centered iid term added. I want to make spatial predictions on a separate prediction stack and have created the prediction grid with x, y, group, covariate values, etc.; projector A matrices for spatial terms; index sets for spatial terms; and stacked it all successfully. I want to ignore the iid for the spatial predictions, so I put an NA in the prediction grid for that term. 

QUESTION: While I tried using an NA, I am not sure what to put in the prediction grid for the iid random effect. If it was an intercept, I'd put a 1. If it were a covariate, I'd put the covariate value of interest. But what do you put in for a zero-centered iid effect, both if you have a particular value you want to put in, but mostly if you want to ignore it because it is zero centered. Is it NA? Zero? The integer value for the level where the random effect is closest to zero?

Thanks,
Tim

# model
formula_iid <- y ~ 0 +
  f(eps, model = spde, constr=F) +
  f(alpha, model = spde, constr=F, group = alpha.group,
    control.group = list(model = "ar1", hyper = ar_prior)) +
  f(gamma_iid, model = "iid", constr=T, hyper = pc_prior)

# top of prediction grid
> head(pred_grd)
      y                 x                   group        log_field_hours    gamma_iid
[1,] -1469.231 1005.589     1               0                              NA
[2,] -1433.296 1005.589     1               0                              NA
[3,] -1397.361 1005.589     1               0                              NA
[4,] -1361.426 1005.589     1               0                              NA
[5,] -1325.491 1005.589     1               0                              NA
[6,] -1289.556 1005.589     1               0                              NA

# prediction stack
stk.p <- inla.stack(
  tag = "pred",
  data = list(y = rep(NA, nrow(pred_grd))), # use pred_grd
  A = list(A_alpha_p, 1, A_eps_p, A_gamma_p, 1), 
  effects = list(alpha = idx_alpha,
                 b0 = rep(1, nrow(pred_grd)),
                 eps = idx_eps,
                 gamma = idx_gamma,
                 gamma_iid = pred_grd[, 4]) # use pred_grd
)

Finn Lindgren

unread,
Jun 29, 2022, 1:15:31 PM6/29/22
to Tim Meehan, R-inla discussion group
To “ignore” the iid component by letting have zero effect for the predictions, use NA. Since the iid component uses indexed inputs to determine which node to include the effect of, you need NA to say “no node”, effectively.

However, while ignoring such a random effect when predicting the posterior mean is ok for linear expressions, it will lead to bias for nonlinear expressions, and too small variance in general, so be careful when interpreting the output.

Finn

On 29 Jun 2022, at 17:30, Tim Meehan <tme...@gmail.com> wrote:

Hi all,
--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/r-inla-discussion-group/bc343e1e-bea0-4f3c-b117-ab5cf1928f65n%40googlegroups.com.

Tim Meehan

unread,
Jun 29, 2022, 1:35:09 PM6/29/22
to R-inla discussion group
Thanks, Finn!

Tim Meehan

unread,
Jun 29, 2022, 1:50:12 PM6/29/22
to R-inla discussion group
Thanks for explaining about the consequences of ignoring the random effect in a non-linear setting (Poisson regression). Is it possible, as a hack, to fit the model, then find the index of the random effect with a near zero value, then put that index in the prediction grid? Would this reduce biased predictions and overly optimistic variances?

Finn Lindgren

unread,
Jun 29, 2022, 2:01:56 PM6/29/22
to Tim Meehan, R-inla discussion group
Not sure I follow the question precisely, but in case you’re wondering “how can I incorporate the effect of an iid component when doing new predictions”, there are a few options.

The simplest, which works well for a linear prediction, is to add the posterior expectation of the iid component variance parameter to the posterior variance.

For more complex predictions, including nonlinear transformations, the easiest approach is posterior sampling. Use inla.posterior.sample to sample from the posterior components, and then add rnorm values that use the simulated iid component precision parameter values.
In inlabru, there’s an option to allow this to be done automatically in the general()/predict() methods, so that if you use non-existing indices for the iid model in the prediction expression (with name_eval()) it will automatically do the appropriate rnorm simulation to create new values for the iid component). I think this is documented in the inlabru ?generate documentation, and I think it requires that the mapper for the iid component is a bru_mapper_index mapper.

In INLA, the same this can be done with the help of inla.posterior.sample.eval(), where you can call rnorm to generate new iid values for the component.

Finn

On 29 Jun 2022, at 18:50, Tim Meehan <tme...@gmail.com> wrote:

Thanks for explaining about the consequences of ignoring the random effect in a non-linear setting (Poisson regression). Is it possible, as a hack, to fit the model, then find the index of the random effect with a near zero value, then put that index in the prediction grid? Would this reduce biased predictions and overly optimistic variances?

Tim Meehan

unread,
Jun 29, 2022, 2:09:47 PM6/29/22
to R-inla discussion group
Thanks, again, Finn!
Reply all
Reply to author
Forward
0 new messages