inla.mesh.project error

799 views
Skip to first unread message

Paul Lantos

unread,
Jan 23, 2017, 11:26:16 AM1/23/17
to R-inla discussion group
I'm trying to project a model output and keep getting this error. The command usually works for me:

> g.mean <- inla.mesh.project(gproj, model1$summary.fitted.values$mean)
Error in projector$proj$A %*% as.vector(field) : 
  Cholmod error 'out of memory' at file ../Core/cholmod_memory.c, line 147

Finn Lindgren

unread,
Jan 23, 2017, 12:07:24 PM1/23/17
to Paul Lantos, R-inla discussion group
Is this part of a long interactive session?
R memory management in combination with inla sometimes leads to odd issues.
What's the output of str(gproj$proj) ?
What's str(model1$summary.fitted.values$mean) ?

You can try saving the workspace and restarting the R session, loading the old workspace again.

Finn
--
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 post to this group, send email to r-inla-disc...@googlegroups.com.
Visit this group at https://groups.google.com/group/r-inla-discussion-group.
For more options, visit https://groups.google.com/d/optout.

Paul Lantos

unread,
Jan 24, 2017, 11:24:48 AM1/24/17
to R-inla discussion group, paul....@gmail.com
It's happened even after restarting the computer -- here's the latest. The model otherwise seems to be working fine.

> g.mean <- inla.mesh.project(gproj, model1$summary.fitted.values$mean)
Error in projector$proj$A %*% as.vector(field) : 
  Cholmod error 'problem too large' at file ../Core/cholmod_dense.c, line 105

> str(gproj$proj) List of 4 $ t : int [1:90000, 1] NA NA NA NA NA NA NA NA NA NA ... $ bary: num [1:90000, 1:3] 0 0 0 0 0 0 0 0 0 0 ... $ A :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots .. ..@ i : int [1:201264] 50145 50146 50147 50148 50445 50446 50447 50448 50747 45651 ... .. ..@ p : int [1:15031] 0 9 19 30 45 54 66 73 87 105 ... .. ..@ Dim : int [1:2] 90000 15030 .. ..@ Dimnames:List of 2 .. .. ..$ : NULL .. .. ..$ : NULL .. ..@ x : num [1:201264] 0.106 0.312 0.519 0.303 0.151 ... .. ..@ factors : list() $ ok : logi [1:90000] FALSE FALSE FALSE FALSE FALSE FALSE ...

> str(model1$summary.fitted.values$mean) num [1:41292] 0.472 0.598 0.598 0.583 0.674 ...


On Monday, January 23, 2017 at 12:07:24 PM UTC-5, Finn Lindgren wrote:
Is this part of a long interactive session?
R memory management in combination with inla sometimes leads to odd issues.
What's the output of str(gproj$proj) ?
What's str(model1$summary.fitted.values$mean) ?

You can try saving the workspace and restarting the R session, loading the old workspace again.

Finn

On 23 Jan 2017, at 16:26, Paul Lantos <paul....@gmail.com> wrote:

I'm trying to project a model output and keep getting this error. The command usually works for me:

> g.mean <- inla.mesh.project(gproj, model1$summary.fitted.values$mean)
Error in projector$proj$A %*% as.vector(field) : 
  Cholmod error 'out of memory' at file ../Core/cholmod_memory.c, line 147

--
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-group+unsub...@googlegroups.com.

Finn Lindgren

unread,
Jan 24, 2017, 12:30:15 PM1/24/17
to Paul Lantos, R-inla discussion group
The matrix dimension doesn't match the vector length.
Check your gproj construction. You may also need some indexing into the linear predictor to get the needed values?

Finn
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.

Paul Lantos

unread,
Jan 26, 2017, 10:27:21 PM1/26/17
to R-inla discussion group, paul....@gmail.com
I keep getting similar errors -- here is the latest example. What do you mean by indexing into the linear predictor?

> slproj <- inla.mesh.projector(sl.mesh, dims=c(300,300))
> sl.mean <- inla.mesh.project(slproj, sl.model1$summary.fitted.values$mean)
Error in projector$proj$A %*% as.vector(field) : 
  Cholmod error 'X and/or Y have wrong dimensions' at file ../MatrixOps/cholmod_sdmult.c, line 90

> str(slproj$proj)
List of 4
 $ t   : int [1:90000, 1] NA NA NA NA NA NA NA NA NA NA ...
 $ bary: num [1:90000, 1:3] 0 0 0 0 0 0 0 0 0 0 ...
 $ A   :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. ..@ i       : int [1:199995] 54048 54049 54346 54347 54348 54349 54644 54645 54646 54647 ...
  .. ..@ p       : int [1:1427] 0 59 208 385 508 681 747 873 1082 1250 ...
  .. ..@ Dim     : int [1:2] 90000 1426
  .. ..@ Dimnames:List of 2
  .. .. ..$ : NULL
  .. .. ..$ : NULL
  .. ..@ x       : num [1:199995] 0.0844 0.0925 0.0445 0.2136 0.3827 ...
  .. ..@ factors : list()
 $ ok  : logi [1:90000] FALSE FALSE FALSE FALSE FALSE FALSE ...

>

Finn Lindgren

unread,
Jan 27, 2017, 1:44:05 AM1/27/17
to Paul Lantos, R-inla discussion group
Look through the previous emails.
You most likely should have something like

pred.ind <- inla.stack.index(stk.full, tag = "pred")$data
ypost <- p.res$marginals.fitted.values[pred.ind]


Finn
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.

Paul Lantos

unread,
Jan 27, 2017, 2:52:18 PM1/27/17
to Finn Lindgren, R-inla discussion group
Hi Finn,
 I've done that, but where does ypost fit into the inla.mesh.project call? That's where I get the error.

Thanks,
Paul

To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion-group+unsubscr...@googlegroups.com.

To post to this group, send email to r-inla-disc...@googlegroups.com.
Visit this group at https://groups.google.com/group/r-inla-discussion-group.
For more options, visit https://groups.google.com/d/optout.

--
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-group+unsubscr...@googlegroups.com.

To post to this group, send email to r-inla-disc...@googlegroups.com.
Visit this group at https://groups.google.com/group/r-inla-discussion-group.
For more options, visit https://groups.google.com/d/optout.

--
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-group+unsub...@googlegroups.com.
To post to this group, send email to r-inla-discussion-group@googlegroups.com.

Mária Rúčeková

unread,
Mar 23, 2022, 7:50:41 AM3/23/22
to R-inla discussion group
Hey. Since this post seem to relate to what I am trying to solve, I dare to ask about exceedence probabilities. I have built same structure for the data as in this site https://www.paulamoraga.com/book-geospatial/sec-geostatisticaldataexamplespatial.html#mapping-exceedance-probabilities and everything works perfectly but then it all stops with  res$marginals.fitted.values[index] function. I havent had problem with   res$summary.fitted.values[index] but it marginals seem to be problem. Instead of geeting value from the code, the output is NULL. Could you please give me advice on this? Thank you for your time!



Dátum: piatok 27. januára 2017, čas: 20:52:18 UTC+1, odosielateľ: paul....@gmail.com

Finn Lindgren

unread,
Mar 23, 2022, 7:59:06 AM3/23/22
to R-inla discussion group
Probably need
control.predictor=list(compute = TRUE)

compute
A boolean variable; should the marginals for the linear predictor be computed? (Default FALSE.)

Finn

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/fa5e2b8d-7e24-4a19-bae0-8bbd2b54f4a9n%40googlegroups.com.


--
Finn Lindgren
email: finn.l...@gmail.com

Mária Rúčeková

unread,
Mar 23, 2022, 8:25:18 AM3/23/22
to R-inla discussion group
thanks, but it did not help unfortunately. If you would happen to have time I could send you dataset with the code. I could compensate you financially if you could help me. thanks for an effort. I deeply appreciate that

Dátum: streda 23. marca 2022, čas: 12:59:06 UTC+1, odosielateľ: finn.l...@gmail.com

Finn Lindgren

unread,
Mar 23, 2022, 9:00:20 AM3/23/22
to R-inla discussion group
I have too little time to debug your code, sorry.

To get help on the list you need to post more details, and check what the variables actually do contain; I'm sure Haavard recently mentioned adding an option (possibly not the one I replied with before) for turningon/off the marginals, so it may be as simple as finding that. Check that your index variable contains what it needs to contain. Etc.

Finn

Elias T. Krainski

unread,
Mar 23, 2022, 9:03:16 AM3/23/22
to R-inla discussion group
Dear Maria,
The problem is that the fitted mean length is different from the SPDE model length. The projection should be from something at the mesh nodes and this seems not to be the case. Please compare the cases in section 2.4.2 and 2.5.3 of the spde-book (https://becarioprecario.bitbucket.io/spde-gitbook/)
Elias

Mária Rúčeková

unread,
Mar 23, 2022, 11:06:38 AM3/23/22
to R-inla discussion group

Okay, I tried once again original dataset gambia from the site. Now this does not work either. Please do you think that there is some missing package that was not installed? I did exactly everything as was mentioned on the site. thanks

> index <- inla.stack.index(stack = stk.full, tag = "pred")$data
> marg <- res$marginals.fitted.values[index][[1]]
> 1 - inla.pmarginal(q = 0.20, marginal = marg)
Error in seq.default(xmin, xmax, len = n) :
  'from' must be a finite number
In addition: Warning messages:
  1: In max(marginal[["y"]]) :
  no non-missing arguments to max; returning -Inf
2: In min(x, na.rm = na.rm) :
  no non-missing arguments to min; returning Inf
3: In max(x, na.rm = na.rm) :
  no non-missing arguments to max; returning -Inf
4: In min(m[["x"]]) : no non-missing arguments to min; returning Inf
5: In max(m[["x"]]) : no non-missing arguments to max; returning -Inf

Dátum: streda 23. marca 2022, čas: 14:03:16 UTC+1, odosielateľ: eliask...@gmail.com

Elias T. Krainski

unread,
Mar 24, 2022, 2:17:30 AM3/24/22
to R-inla discussion group
Dear Maria,
Unfortunately your code is not reproducible and thus we can only guess why this error is happening. My guess, as Finn already mentioned, is that the posterior marginals for the linear predictor were not computed. You can ask inla() to compute it by adding by compute=TRUE in control.predictor along with return.marginals.predictor=TRUE in control.results. Thus, your code will look like this:
    inla(..., control.predictor=list(A=..., compute=TRUE), control.results(return.marginals.predictor=TRUE), ...)
Best regards,
Elias

Elias T. Krainski

unread,
Mar 24, 2022, 3:09:58 AM3/24/22
to R-inla discussion group
correction:
inla(...,
  control.predictor=list(A=..., compute=TRUE), ## to return summary
  control.compute=list(return.marginals.predictor=TRUE), ## to return marginals
...)

Reply all
Reply to author
Forward
0 new messages