Preparations before fitting with inla()

  • create a stack with the data for estimation and prediction
# stack for estimation stk.e
stk.e <- inla.stack(
  tag = "est",
  data = list(y = d$value),
  A = list(1, A),
  effects = list(
    data.frame(
      b0 = rep(1, nrow(A)),
      covtemp = d$covtemp,
      covprec = d$covprec
    ),
    s = indexs
  )
)
# stack for prediction stk.p
stk.p <- inla.stack(
  tag = "pred",
  data = list(y = NA),
  A = list(1, Ap),
  effects = list(
    data.frame(
      b0 = rep(1, nrow(Ap)),
      covtemp = dp$covtemp,
      covprec = dp$covprec
    ),
    s = indexs
  )
)
# stk.full has stk.e and stk.p
stk.full <- inla.stack(stk.e, stk.p)