loggingstdoutverboser-inla

How can I capture the verbose output of an INLA model in R?


Hopefully, this example illustrates what I'm trying to do.

I run a comparison of the same simple example toggling verbose TRUE and FALSE.

library("INLA")
test <- capture.output(
{
inla(speed ~ dist, data = datasets::cars, verbose = F)

    }
    )

I try and capture the verbose output. It appears in my console but is not captured. test and test2 appear identical.

library("INLA")
test2 <- capture.output(
{
inla(speed ~ dist, data = datasets::cars, verbose = T)

    }
    )

Some system info

                                 sysname 
                                 "Linux" 
                                 release 
                 "4.19.0-16-cloud-amd64" 
                                 version 
 "#1 SMP Debian 4.19.181-1 (2021-03-19)" 

Some R version info

platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          3                           
minor          6.3                         
year           2020                        
month          02                          
day            29                          
svn rev        77875                       
language       R                           
version.string R version 3.6.3 (2020-02-29)
nickname       Holding the Windsock  

Solution

  • I've had the answer to this from help@r-inla.org. If you set verbose = F, default, then the log is stored in a file.

    > r=inla(y~1,data=data.frame(y=0))
    > head(r$logfile)
    [1] "        Read ntt 4 1 with max.threads 8"                          
    [2] "        Found num.threads = 4:1 max_threads = 4"                  
    [3] "        file: src/inla.c  4f8384f383a924449b14072dec7e4f9ce74ca121
    - Wed Feb 16 14:16:16 2022 +0300"            
    [4] "Report bugs to <help@r-inla.org>"                                 
    [5] "Set reordering to id=[0] and name=[default]"                      
    [6] "Process file[/tmp/Rtmpv5S9QO/file1c6414e8a909a/Model.ini]
    threads[4] max.threads[8] blas_threads[1] nested[4:1]"
    

    Got to say since the logfile element isn't mentioned in the inla class documentation or in the verbose parameter to the function. I don't feel too bad about not spotting this.