Meaning of the verbose output and NA in modes of model results

37 views
Skip to first unread message

Insang Song

unread,
May 9, 2022, 1:16:15 PMMay 9
to R-inla discussion group
Dear R-INLA community:

Hello,
I want to ask two questions, one of which might be very elementary question but I could not be successful to find descriptions, and the other is about the model results.

1. Meaning of messages when running inla(..., verbose=TRUE) 
I always set verbose as TRUE every time I try running INLA models. It helps me to determine when I need to stop the model runs that are oftentimes time-consuming. I used to read the numbers being printed while the model is running, for example:

maxld= -60198.849 fn= 96 theta= -0.043 0.051 4.058 2.038 5.156 0.238 -0.091 2.958 [8.2, 1.87]

maxld, fn, thetas seem straightforward. However, the last part wrapped in squared brackets has no label, which made me assume these two values are related to theta values. Could someone explain the meaning of these values? Sometimes I realize these values can be an indicator of how the model is going under the hood as well as how the model results will look like.

2. All-NAs in mode values in model results
I have been fitting spatiotemporal models with three to five random components. I found that the mode is printed as NA in the model results (i.e., running the summary function for an inla object). The thing that confused me even worse is that the mode status (i.e., inla_object$mode$mode.status) is always zero. I am not sure how all-NA values in modes result in a fair mode status.

I am using experimental features that are provided in the testing version (currently INLA 22.04.16) and my model code is as below:

latent_sp_main = "besagproper"
latent_t_main = "ar1"
latent_sp_random = "besag"
latent_t_random = "iid"

form = y ~ offset(log(pop)) +
                            f(GEOID_int1, model = latent_sp_main, graph = graph, constr = TRUE) +
                            f(year_int1, model = latent_t_main, constr = TRUE) +
                            f(GEOID_int2, model = latent_sp_main, graph = graph, group = year_int2, control.group = list(model = latent_t_main), constr = TRUE) +
                            f(GEOID_int3, x1, model = latent_sp_rand, graph = graph, constr=TRUE)+ f(year_int3, x1, model = latent_t_rand, constr = TRUE) +
                           x1 + x2 + x3 + x4 + x5 + x6 + x7

threads = "28:1"
inla_result = 
    inla(
        formula = form,
            data = data,
            family = "poisson", verbose = TRUE,
            lincomb = lcs,
            control.lincomb = list(verbose = FALSE),
            control.inla = control.inla(
                                        strategy = "simplified.laplace",
                                        int.strategy = 'eb',
                                        restart = 5,
                                        optimiser = 'default',
                                        stupid.search.factor = 1.25,
                                        npoints = 9,
                                        improved.simplified.laplace = TRUE,
                                        use.directions = FALSE),
            control.predictor = list(compute = TRUE, link = 1),
            control.compute = list(cpo = TRUE, waic = TRUE, dic = TRUE,
                                   return.marginals.predictor = TRUE,
                                   openmp.strategy = 'huge',
                                   smtp = 'default'),
            control.mode = list(restart = TRUE, fixed = FALSE,
                                theta = thetas),
            num.threads = threads,
            safe = TRUE)

Thank you very much in advance!
Best,
Insang

Insang Song

unread,
May 9, 2022, 1:18:49 PMMay 9
to R-inla discussion group
Let me clarify:

The all mode values in the summary results have NA values, both in fixed effects and model hyperparameters. For example:

Model hyperparameters:
                             mean       sd 0.025quant 0.5quant 0.975quant mode
Precision for GEOID_int1 5.95e-01 3.30e-02      0.536 5.93e-01   6.66e-01   NA
Diagonal for GEOID_int1  8.51e-01 1.82e-01      0.541 8.35e-01   1.25e+00   NA
Precision for year_int1  7.36e+01 3.62e+01     20.988 6.78e+01   1.59e+02   NA
Rho for year_int1        8.14e-01 9.60e-02      0.591 8.29e-01   9.56e-01   NA
Precision for GEOID_int3 1.49e+04 1.25e+04   1987.444 1.14e+04   4.86e+04   NA
Precision for GEOID_int2 5.33e+00 4.62e-01      4.431 5.33e+00   6.25e+00   NA
Diagonal for GEOID_int2  5.42e-01 1.20e-01      0.354 5.26e-01   8.25e-01   NA

2022년 5월 9일 월요일 오전 10시 16분 15초 UTC-7에 Insang Song님이 작성:

Helpdesk

unread,
May 9, 2022, 2:53:04 PMMay 9
to Insang Song, R-inla discussion group
-----Original Message-----
1. Meaning of messages when running inla(..., verbose=TRUE) 
I always set verbose as TRUE every time I try running INLA models. It
helps me to determine when I need to stop the model runs that are
oftentimes time-consuming. I used to read the numbers being printed
while the model is running, for example:

maxld= -60198.849 fn= 96 theta= -0.043 0.051 4.058 2.038 5.156 0.238 -
0.091 2.958 [8.2, 1.87]


*** the number in the brackets are [a, b], where 'a' is
max(abs(latent.field)) and 'b' is the cpu-time in seconds for on
function evaluation.



2. All-NAs in mode values in model results
I have been fitting spatiotemporal models with three to five random
components. I found that the mode is printed as NA in the model results
(i.e., running the summary function for an inla object). The thing that
confused me even worse is that the mode status (i.e.,
inla_object$mode$mode.status) is always zero. I am not sure how all-NA
values in modes result in a fair mode status.


*** I know, I changed this as I didn't find (at the time of rewriting) a
good and quick way of computing the mode, especially with a
transformation (like exp()). I decided to add that later on as it needs
more work (and since this is potentially done many time, its important
to do well)



--
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/81530d27-c911-4c7e-b4e9-f4f475da25c5n%40googlegroups.com.

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

Helpdesk

unread,
May 9, 2022, 2:53:41 PMMay 9
to Insang Song, R-inla discussion group

its currently a feature, it will come back, needs more work
--
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/31149bac-3c6b-4175-818b-c20ebf05bdf2n%40googlegroups.com.

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

Insang Song

unread,
May 9, 2022, 5:10:38 PMMay 9
to R-inla discussion group
Dear Dr. Rue:

Thank you very much for the prompt response.
I hope the mode.status and non-NA mode values will come back. It is good to know the meaning of the numbers in brackets!

Best,
Insang

2022년 5월 9일 월요일 오전 11시 53분 41초 UTC-7에 he...@r-inla.org님이 작성:

Elias T. Krainski

unread,
May 10, 2022, 1:57:52 AMMay 10
to R-inla discussion group
Just a small detail. If you use verbose=FALSE, you can still have this log into
result$logfile which is, sometimes, useful. E.g.:

```
 result <- inla(y ~ 1, data=list(y=1:5))
 tail(result$logfile, 11)
 grep('config', result$logfile, value=TRUE)
 fnc <- grep('fn=', result$logfile, value=TRUE)
 d <- t(sapply(str_extract_all(fnc, '-?[0-9]+\\.[0-9]+'), as.numeric))
 plot(d[,2:1], xlab='theta', ylab='fn')
 nd <- nrow(d)
 arrows(d[1:(nd-1), 2], d[1:(nd-1), 1], d[2:nd, 2], d[2:nd, 1], length=0.1)
```

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.

Elias T. Krainski

unread,
May 10, 2022, 2:03:05 AMMay 10
to R-inla discussion group
In order to be able to run the previous code chunk, please run this before:
library(INLA)
library(stringr)

Insang Song

unread,
May 10, 2022, 1:04:05 PMMay 10
to R-inla discussion group
Dear Dr. Krainski:

Thank you very much for the information! I was totally unaware of the saved element for messages in inla objects. It is really great to know.

Best,
Insang

2022년 5월 9일 월요일 오후 11시 3분 5초 UTC-7에 eliask...@gmail.com님이 작성:
Reply all
Reply to author
Forward
0 new messages