Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

SPDE model to predict air pollutant

31 views
Skip to first unread message

Felipe Barletta

unread,
May 6, 2025, 8:48:46 AMMay 6
to r-inla-disc...@googlegroups.com
Dear friends of INLA,

I'm currently working on a spatial model using INLA and I’m having some trouble interpreting the posterior mean values from my model's predictions. Specifically, I’m not sure why the predicted values (posterior means) behave the way they do, as they seem inconsistent with the observed data and the spatial pattern I expected.

I fitted a SPDE model to predict an air pollutant (NO2) in Portugal. I have monthly measures from some stations between 2010 and 2018.
The model is:
############
formula <- y ~ 1 + f(spatial.field, model = spde)

result <- inla(
    formula,
    data = inla.stack.data(stack.full),
    family = "gaussian",
    control.predictor = list(A = inla.stack.A(stack.full), compute = TRUE),
    control.compute = list(dic = TRUE, cpo = TRUE),
    verbose = FALSE
)


And the summary of my response variable is:
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
   2.50   10.47   17.95   20.68   23.18   68.80

But the summary of predicted values of posterior mean is:
summary(df_pred$mean)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  20.68   20.68   20.68   20.68   20.68   20.68
> var(df_pred$mean)
[1] 2.873496e-09
> sd(df_pred$mean)
[1] 5.3605e-05

I attached the data and a reproducible code.

If anyone could help clarify what might be influencing these results or suggest steps to better understand the model output, I’d really appreciate it.

Thank you






reprod.R
df_month.RData

Elias T. Krainski

unread,
May 7, 2025, 3:41:03 AMMay 7
to r-inla-disc...@googlegroups.com
I didn't followed some bits of your code and tried to "fix" it (to my own understanding) and found no issues as I have
summary(result$summary.fitted.values$mean[1:n])

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  10.94   16.23   20.69   20.68   24.29   32.24
and got the attached picture.

Regards,
Elias

--
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, visit https://groups.google.com/d/msgid/r-inla-discussion-group/CAJz4ZjFn%3DQ_qbm_1zs%2BGvSv_e7jQJ93nvsmU6Q-dZPpPLEhZ5A%40mail.gmail.com.
Screenshot From 2025-05-07 10-39-54.png

Elias T. Krainski

unread,
May 7, 2025, 3:41:29 AMMay 7
to r-inla-disc...@googlegroups.com
the "fixed" code ;)
reprod.R

Felipe Barletta

unread,
May 7, 2025, 9:27:36 AMMay 7
to Elias T. Krainski, r-inla-disc...@googlegroups.com
Muito Obrigado Elias.
It's perfect.

I still have difficulty understanding how to define the mesh.

By the way, I compared these results with those obtained using the geoR package.

image.png

image.png








Reply all
Reply to author
Forward
0 new messages