residuals and standardized residuals in INLA

234 views
Skip to first unread message

Natoya j

unread,
Nov 2, 2022, 3:31:16 AM11/2/22
to R-inla discussion group
Hi,

I would like to calculate the (standardized) residuals from a model  in INLA (random and spatial effects). My response has some NA values. I've tried a couple of functions, but because of the NAs and model complexity, I've  encountered problems. I have given the functions I've used to calculate the residuals, and  a short snippet of my model output. Would you kindly help with this? Thank you!

1. residuals(object, type = c("pearson", "deviance", "working", "response", "partial"), ...) (from https://inlatools.netlify.app/reference/residuals.html). This gives error: Error in object$.args$data[, response, drop = TRUE] :incorrect number of dimensions


2. ggplot_inla_residuals2(inla.model, observed, CI = FALSE, se = TRUE, method = "auto")   (https://www.rdocumentation.org/packages/INLAutils/versions/0.0.5/topics/ggplot_inla_residuals2). 

This gives problems with NAs when calculating the stand. dev. Removing NA's gives  a large range of standardized residuals (e.g., 10 to -20), instead of within  between -3 to 3., although most of  


3. ri  =  ei / s(ei)  (where  ei: The ith residual); by removing the NAs when calculating 


A snippet of inla results:

Time used:
    Pre = 10.1, Running = 4844, Post = 2.51, Total = 4856
Fixed effects:
                                        mean    sd      0.025quant   0.5quant 0.975quant   mode   kld
road_coverAb:AADT1   4.349   0.128      4.097         4.349      4.601              NA      0
road_coverAgb:AADT1  4.671  0.112      4.452          4.671      4.890              NA     0
road_coverSka:AADT1   2.017   0.074      1.872         2.017      2.162               NA   0
AADT1:rut_depth2          0.353     0.018    0.317          0.353       0.389             NA   0
AADT1:width2                -0.078     0.012     -0.103        -0.078     -0.054            NA   0
AADT1:slope2                 -0.042    0.060     -0.160       -0.042      0.076              NA   0

Random effects:
  Name      Model
    year IID model
   spatial.field.group SPDE2 model
   spatial.field.2011 SPDE2 model
   spatial.field.2012 SPDE2 model
   spatial.field.2013 SPDE2 model
   spatial.field.2014 SPDE2 model
   spatial.field.2015 SPDE2 model
   spatial.field.2016 SPDE2 model
   spatial.field.2017 SPDE2 model
   spatial.field.2018 SPDE2 model
   spatial.field.2019 SPDE2 model
   spatial.field.2020 SPDE2 model

Model hyperparameters:
                                            mean                     sd 0.025quant 0.5quant 0.975quant mode
Precision for the Gaussian observations    0.527    0.003      0.520    0.527   5.34e-01   NA
Precision for year                                            3.918    1.050      2.058    3.847   6.14e+00   NA
Range for spatial.field.group               229.518  15.820    200.233  228.847   2.63e+02   NA
Stdev for spatial.field.group                         0.490    0.020      0.452    0.490   5.29e-01   NA
Range for spatial.field.2011                     96.043    7.242     82.583   95.764   1.11e+02   NA
Stdev for spatial.field.2011                           1.605    0.048      1.513    1.604   1.70e+00   NA
Range for spatial.field.2012         1552.903  283.419   1079.323 1523.861   2.19e+03   NA
Stdev for spatial.field.2012               1.101    0.108      0.904    1.095   1.33e+00   NA


Natoya

Helpdesk (Haavard Rue)

unread,
Nov 2, 2022, 6:19:38 AM11/2/22
to Natoya j, R-inla discussion group


'inlatools'and 'INLAutils' are external packages we do not control and
you could contact the authors of those with these issues.

there is currently no option to provide residuals in INLA, whatever
'residuals' means in the Bayesian context.

let me check options of what can be done...

> --
> 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/bc50461a-a0eb-4475-8e49-e463edbaeedbn%40googlegroups.com
> .

--
Håvard Rue
he...@r-inla.org

Reply all
Reply to author
Forward
0 new messages