Closed agila5 closed 4 years ago
Hi,
Thanks for checking. The code should run fine on R 3.6.3 and the latest version of INLA. The error message that you provide is not very informative... Can you provide your sessionInfo()?
Best,
Virgilio
This is a copy-paste of the error message I obtain in interactive version of Rstudio:
Error in inla.inlaprogram.has.crashed() :
The inla-program exited with an error. Unless you interupted it yourself, please rerun with verbose=TRUE and check the output carefully.
If this does not help, please contact the developers at <help@r-inla.org>.
In addition: Warning message:
In inla.model.properties.generic(inla.trim.family(model), mm[names(mm) == :
Model 'rgeneric' in section 'latent' is marked as 'experimental'; changes may appear at any time.
Use this model with extra care!!! Further warnings are disabled.
and this is the sessionInfo:
I’ll try to reproduce the error and go back to you.
Best,
Virgilio
El 6 may 2020, a las 21:07, Andrea Gilardi notifications@github.com<mailto:notifications@github.com> escribió:
This is a copy-paste of the error message I obtain in interactive version of Rstudio:
Error in inla.inlaprogram.has.crashed() : The inla-program exited with an error. Unless you interupted it yourself, please rerun with verbose=TRUE and check the output carefully. If this does not help, please contact the developers at help@r-inla.org<mailto:help@r-inla.org>. In addition: Warning message: In inla.model.properties.generic(inla.trim.family(model), mm[names(mm) == : Model 'rgeneric' in section 'latent' is marked as 'experimental'; changes may appear at any time. Use this model with extra care!!! Further warnings are disabled.
and this is the sessionInfo:
Session info
devtools::session_info()
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/becarioprecario/INLAMSM/issues/1#issuecomment-624834145, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABYD6WVSP6RORD7CZWPKNSDRQGYO3ANCNFSM4M2SNFGQ.
I had an epiphany a few minutes ago and I think I get it know. The problem is that the second argument to the inla.rgeneric.define
function is an unnamed argument, i.e. list(k = k, W = W)
, which implies that it's passed to the debug
parameter:
# packages
options(width = 120)
library(INLA)
library(INLAMSM)
# The k and W parameters are never passed to the inla.rgeneric.indep.IMCAR.model
# but the are assigned to the debug parameter.
k <- 1
W <- diag(2)
inla.rgeneric.define(
inla.rgeneric.indep.IMCAR.model,
list(k = k, W = W)
)
#> $f
#> $f$model
#> [1] "rgeneric"
#>
#> $f$n
#> [1] 2
#>
#> $f$rgeneric
#> $definition
#> function (cmd = c("graph", "Q", "mu", "initial", "log.norm.const",
#> "log.prior", "quit"), theta = NULL)
#> {
#> interpret.theta = function() {
#> param <- sapply(theta[as.integer(1:k)], function(x) {
#> exp(x)
#> })
#> PREC <- diag(param, k)
#> return(list(param = param, PREC = PREC))
#> }
#> graph = function() {
#> PREC <- diag(1, k)
#> G <- kronecker(PREC, Matrix::Diagonal(nrow(W), 1) + W)
#> return(G)
#> }
#> Q = function() {
#> param <- interpret.theta()
#> Q <- kronecker(param$PREC, Matrix::Diagonal(nrow(W),
#> apply(W, 1, sum)) - W)
#> return(Q)
#> }
#> mu = function() {
#> return(numeric(0))
#> }
#> log.norm.const = function() {
#> val <- numeric(0)
#> return(val)
#> }
#> log.prior = function() {
#> param = interpret.theta()
#> val <- -sum(theta)/2 - k * log(2)
#> return(val)
#> }
#> initial = function() {
#> return(c(rep(log(1), k)))
#> }
#> quit = function() {
#> return(invisible())
#> }
#> val = do.call(match.arg(cmd), args = list())
#> return(val)
#> }
#> <environment: 0x000000001cbfa888>
#>
#> $debug
#> $debug$k
#> [1] 1
#>
#> $debug$W
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 0 1
#>
#>
#> attr(,"class")
#> [1] "inla.rgeneric"
#>
#>
#> attr(,"class")
#> [1] "inla.rgeneric"
# debug = FALSE as it should be
inla.rgeneric.define(
inla.rgeneric.indep.IMCAR.model,
k = k,
W = W
)
#> $f
#> $f$model
#> [1] "rgeneric"
#>
#> $f$n
#> [1] 2
#>
#> $f$rgeneric
#> $definition
#> function (cmd = c("graph", "Q", "mu", "initial", "log.norm.const",
#> "log.prior", "quit"), theta = NULL)
#> {
#> interpret.theta = function() {
#> param <- sapply(theta[as.integer(1:k)], function(x) {
#> exp(x)
#> })
#> PREC <- diag(param, k)
#> return(list(param = param, PREC = PREC))
#> }
#> graph = function() {
#> PREC <- diag(1, k)
#> G <- kronecker(PREC, Matrix::Diagonal(nrow(W), 1) + W)
#> return(G)
#> }
#> Q = function() {
#> param <- interpret.theta()
#> Q <- kronecker(param$PREC, Matrix::Diagonal(nrow(W),
#> apply(W, 1, sum)) - W)
#> return(Q)
#> }
#> mu = function() {
#> return(numeric(0))
#> }
#> log.norm.const = function() {
#> val <- numeric(0)
#> return(val)
#> }
#> log.prior = function() {
#> param = interpret.theta()
#> val <- -sum(theta)/2 - k * log(2)
#> return(val)
#> }
#> initial = function() {
#> return(c(rep(log(1), k)))
#> }
#> quit = function() {
#> return(invisible())
#> }
#> val = do.call(match.arg(cmd), args = list())
#> return(val)
#> }
#> <environment: 0x000000001d8b2610>
#>
#> $debug
#> [1] FALSE
#>
#> attr(,"class")
#> [1] "inla.rgeneric"
#>
#>
#> attr(,"class")
#> [1] "inla.rgeneric"
Created on 2020-05-06 by the reprex package (v0.3.0)
Hi,
I had an epiphany a few minutes ago and I think I get it know. The problem is that the second argument to the inla.rgeneric.define function is an unnamed argument, i.e. list(k = k, W = W), which implies that it's passed to the debug parameter:
Thanks for this. I believe that we changed this because one of the reviewers of the paper suggested that the arguments needed to be in a list. You can simply pass the values of k and W without the list and it should work.
Best,
Virgilio
Thanks for this. I believe that we changed this because one of the reviewers of the paper suggested that the arguments needed to be in a list. You can simply pass the values of k and W without the list and it should work.
Yes, it works. It was really a minor problem.
Kind regards Andrea
Hi,
Yes, it works. It was really a minor problem.
A minor problem that makes the R code not to run on some platforms. We’ll like into this to make sure that it can also run smoothly on all platforms.
Best,
Virgilio
We have changed the example in the paper so that arguments passed to define the structure of the latent GMRF are not in a list anymore. This should work. Thanks for reporting the error!
Virgilio
You're welcome!
Dear Prof. Gómez-Rubio, I found a minor error running the code in the JSS paper. I installed the INLAMSM package from github while the R code is the same as in the document that you sent me.
Created on 2020-05-06 by the reprex package (v0.3.0)
The same code runs without any issue if I specify
model.indimcar <- inla.INDIMCAR.model(k = k, W = W)
instead of theinla.rgeneric.define
code.