inlabru-org / inlabru

inlabru
https://inlabru-org.github.io/inlabru/
78 stars 21 forks source link

Improve the missing domain error message (was: Error caused by Domain definitions missing) #159

Closed coedekoven closed 1 year ago

coedekoven commented 1 year ago

Hi, I was trying to fit the models given as supplementary materials in Bachl et al. (2019, MEE). No matter which model I try to fit, I always get this error message:

Error in ipmaker(samplers = samplers, domain = domain, dnames = response, : Domain definitions missing for dimensions: coordinates

Any ideas how this could be fixed? Many thanks in advance. Cornelia

finnlindgren commented 1 year ago

That's likely due to the newer inlabru versions being more strict about the user specifying the model domain(s). I don't have the code in front of me, but there's probably something like

fit <- lgcp(components = coordinates ~ name(coordinates, model = spde),
            samplers = ...,
            data = ...)

and the older version guessed that the domain information should be inferred from the only spde object in the model. In newer versions, it doesn't assume that, and forces the user to say what domain to actually use (e.g. there might be more than one, so leaving it out is ambiguous). Then you need

fit <- lgcp(components = coordinates ~ name(coordinates, model = spde),
            samplers = ...,
            domain = list(coordinates = mesh),
            data = ...)

(assuming that the spde mesh is in mesh)

finnlindgren commented 1 year ago

We're currently working on this part of the interface, to support sf and more general models.

finnlindgren commented 1 year ago

If the above is the problem, I can try to improve the error message to point the user in the right direction of the solution.

coedekoven commented 1 year ago

Thank you very much for the quick response, Finn. That did the trick.

finnlindgren commented 1 year ago

The entire code surrounding integration has been rewritten, and most of it moved to the fmesher::fm_int() methods (from 2.9.0 that is about to be submitted to CRAN), making the internal logic for multi-domain integration work a bit differently. If the related error messages still need improvement, please open a new issue.