Test code does not run

170 views
Skip to first unread message

Claire Lay

unread,
Jul 30, 2024, 5:59:51 PM7/30/24
to R-inla discussion group
I've tried installing and re-installing RInla several times, but keep having trouble using it.
I'm working on a server I didn't build, and I'd like to avoid uninstalling and re-installing R itself.  I've re-installed R-INLA several times. I'm working on a server I didn't build, and I'd like to avoid uninstalling and re-installing R itself. I'm wondering if I am missing a dependency (perhaps one of the matrix products?) but without errors, it's tough to tell what it might be. Thanks for any help you can provide. 

See below for test code and issue. 

** Installation proceeds with no obvious issues, and the package loads: 

library(INLA) This is INLA_24.06.27 built 2024-06-27 02:36:04 UTC. - See www.r-inla.org/contact-us for how to get help. - List available models/likelihoods/etc with inla.list.models() - Use inla.doc(<NAME>) to access documentation

** However,  running test code from R-INLA Project - Download & Install fails as follows: 

result = inla(formula, family = "gaussian", data = data, verbose = T, debug = T) [1] "head(scale)" NULL [1] "head(weights)" NULL [1] "head(Ntrials)" NULL [1] "head(offset)" NULL [1] "head(E)" NULL [1] "head(strata)" NULL [1] "head(lp.scale)" NULL [1] "head(link.covariates)" NULL [1] "MPredictor 0" [1] "NPredictor 100" [1] "NData 100" [1] "y...fake has length 100" n.family 1 [1] "Entries with same length:" "z" "y...fake" *** inla.core.safe: The inla program failed, but will rerun in case better initial values may help. try=1/1 [1] "MPredictor 0" [1] "NPredictor 100" [1] "NData 100" [1] "y...fake has length 100" n.family 1 [1] "Entries with same length:" "z" "y...fake" Error in inla.core.safe(formula = formula, family = family, contrasts = contrasts, : invalid class “dsparseModelMatrix” object: superclass "dCsparseMatrix" not defined in the environment of the object's class The inla program failed and the maximum number of tries has been reached.


Session info below. Do I need anything different for "matrix products"
 
sessionInfo() R version 4.4.1 (2024-06-14) Platform: x86_64-pc-linux-gnu Running under: Ubuntu 22.04.4 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0 locale: [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 LC_PAPER=C.UTF-8 [8] LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C time zone: Etc/UTC tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] INLA_24.06.27 sp_2.1-4 Matrix_1.6-5 loaded via a namespace (and not attached): [1] dplyr_1.1.4 compiler_4.4.1 tidyselect_1.2.1 Rcpp_1.0.12 stringr_1.5.1 MatrixModels_0.5-0 parallel_4.4.1 snakecase_0.11.1 splines_4.4.1 [10] boot_1.3-30 lattice_0.22-5 R6_2.5.1 generics_0.1.3 classInt_0.4-3 sf_1.0-6 knitr_1.48 MASS_7.3-61 tibble_3.2.1 [19] nloptr_2.0.0 fmesher_0.1.7 janitor_2.2.0 units_0.8-0 lubridate_1.9.3 minqa_1.2.7 DBI_1.2.3 pillar_1.9.0 rlang_1.1.4 [28] utf8_1.2.4 stringi_1.8.4 xfun_0.45 timechange_0.3.0 cli_3.6.3 withr_3.0.0 magrittr_2.0.3 class_7.3-22 grid_4.4.1 [37] rstudioapi_0.16.0 lme4_1.1-35.5 lifecycle_1.0.4 nlme_3.1-165 vctrs_0.6.5 KernSmooth_2.23-24 proxy_0.4-27 glue_1.7.0 fansi_1.0.6 [46] e1071_1.7-14 pkgconfig_2.0.3 tools_4.4.1

Havard Rue

unread,
Jul 30, 2024, 6:05:23 PM7/30/24
to R-inla discussion group, Claire Lay
Can u upgrade all packages you have installed, especially Matrix package 

-- 
Håvard Rue 
--
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/9c82d88a-cef5-48c5-ba69-423d31853657n%40googlegroups.com.

André Luís Luza

unread,
Oct 31, 2024, 11:24:13 AM10/31/24
to R-inla discussion group
Hello,

I'm new here (and also a new R-INLA user). I'm interesting in occupancy models, and I'm trying to reproduce the simulations and the promising model shown in Belmont et al (2024) (here and here). However, I found the same issues as Claire Lay. I must say that the issues persisted after updating the packages (note in my session info that I'm using the last Matrix package version 1.7-1). 
Digging a bit more on the issue I found this documentation that, as far I can understand, show that the conversion from different classes of sparse matrices should be somehow straightforward (e.g. from 'dgCMatrix' to 'dCsparseMatrix', which is required for R-INLA) using the Matrix package. However, when searching for the classes of sparse matrices available in the Matrix package (by typing getClass("dgCMatrix") in R), I didn't find any corresponding to 'dCsparseMatrix' (see the list below). So I'll ask two silly questions:

Should this mismatch be the source of the original issue? And how to fix it?
My R code is attached in any case.

Best regards,

Andre

> getClass("dgCMatrix") # ---------------------------------------------------------------------
Class "dgCMatrix" [package "Matrix"]

Slots:
                                                           
Name:         i        p      Dim Dimnames        x  factors
Class:  integer  integer  integer     list  numeric     list

Extends:
Class "CsparseMatrix", directly
Class "dsparseMatrix", directly
Class "generalMatrix", directly
Class "dMatrix", by class "dsparseMatrix", distance 2
Class "sparseMatrix", by class "dsparseMatrix", distance 2
Class "Matrix", by class "generalMatrix", distance 2
Class "xMatrix", by class "dMatrix", distance 3
Class "mMatrix", by class "Matrix", distance 4
Class "replValueSp", by class "Matrix", distance 4
Class "Mnumeric", by class "Matrix", distance 4


# my session info ----------------------------------------------------------------------------

sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=fr_FR.UTF-8      
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=en_US.UTF-8  
 [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C      

time zone: Europe/Paris

tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    

other attached packages:
 [1] terra_1.7-83          spatstat_2.3-0        spatstat.linnet_2.3-1 spatstat.core_2.3-2  
 [5] rpart_4.1.23          nlme_3.1-165          spatstat.geom_2.3-2   spatstat.data_2.1-2  
 [9] sf_1.0-18             dplyr_1.1.4           here_1.0.1            fmesher_0.1.7        
[13] INLA_24.10.13         sp_2.1-4              Matrix_1.7-1        

loaded via a namespace (and not attached):
 [1] utf8_1.2.4            generics_0.1.3        class_7.3-22          KernSmooth_2.23-24  
 [5] tensor_1.5            lattice_0.22-5        magrittr_2.0.3        spatstat.utils_2.3-0
 [9] grid_4.4.1            rprojroot_2.0.2       spatstat.sparse_2.1-0 e1071_1.7-16        
[13] DBI_1.2.3             mgcv_1.9-1            fansi_1.0.6           codetools_0.2-19    
[17] abind_1.4-5           cli_3.6.3             rlang_1.1.4           units_0.8-5          
[21] polyclip_1.10-0       splines_4.4.1         withr_3.0.2           tools_4.4.1          
[25] deldir_1.0-6          vctrs_0.6.5           R6_2.5.1              proxy_0.4-27        
[29] lifecycle_1.0.4       classInt_0.4-10       pkgconfig_2.0.3       pillar_1.9.0        
[33] glue_1.8.0            Rcpp_1.0.13           tibble_3.2.1          tidyselect_1.2.1    
[37] rstudioapi_0.17.1     goftest_1.2-3         compiler_4.4.1   
4.7.Simulations_R-INLA.R
spde-book-functions.R

Helpdesk (Haavard Rue)

unread,
Nov 1, 2024, 12:10:50 PM11/1/24
to André Luís Luza, R-inla discussion group
your example runs without any issues with me.

you can use

inla.as.sparse(A)

to convert a sparse matrix into the format used by R-INLA.



my packages are as follows.

> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-redhat-linux-gnu
Running under: Fedora Linux 41 (Workstation Edition)

Matrix products: default
BLAS/LAPACK: FlexiBLAS MKL; LAPACK version 3.12.0

locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

time zone: Asia/Riyadh
tzcode source: system (glibc)

attached base packages:
[1] datasets compiler grDevices graphics utils stats methods
[8] base

other attached packages:
[1] INLA_24.10.29 sp_2.1-4 Matrix_1.7-1 flexiblas_3.4.0
[5] dplyr_1.1.4

loaded via a namespace (and not attached):
[1] vctrs_0.6.5 cli_3.6.3 rlang_1.1.4 KernSmooth_2.23-24
[5] DBI_1.2.3 generics_0.1.3 sf_1.0-18 glue_1.8.0
[9] e1071_1.7-16 fansi_1.0.6 grid_4.4.1 classInt_0.4-10
[13] tibble_3.2.1 lifecycle_1.0.4 fmesher_0.1.7.9010 Rcpp_1.0.13
[17] pkgconfig_2.0.3 lattice_0.22-6 R6_2.5.1 class_7.3-22
[21] tidyselect_1.2.1 utf8_1.2.4 parallel_4.4.1 pillar_1.9.0
[25] splines_4.4.1 magrittr_2.0.3 withr_3.0.2 tools_4.4.1
[29] proxy_0.4-27 units_0.8-5
> To view this discussion, visit
> https://groups.google.com/d/msgid/r-inla-discussion-group/3e5f3bac-7d8b-4513-8de4-d5d9d75df27en%40googlegroups.com
> .

--
Håvard Rue
he...@r-inla.org
Reply all
Reply to author
Forward
0 new messages