Open ThierryO opened 5 years ago
I have an email thread with another user from a few weeks back that looked at this in some detail, including providing some solutions. I’ll try to extract the relevant bits and put here, awaiting a full solution in the package.
Even if inlabru would recognise control.fixed and pass it on to inla(), this would not have the desired effect. The reason is that internally, fixed effect terms are re-interpreted as f(..., model="linear") terms before the inla() call, and control.fixed doesn't apply to such model components.
Until we come up with a way to automate it by using the information in control.fixed in the re-interpretation step, the following workaround can be used: Replace
Y ~ X + logArea
by
Y ~ X(map=X, model="linear", mean.linear=0, prec.linear=0.001) +
logArea(map=logArea, model="linear", mean.linear=1, prec.linear=1e20)
Full example attached: code46.zip
Note that this also applies to the intercept term, so to control the prior for that you need to include it explicitly, with
+ Intercept(map=Inter, model="linear", prec.linear=...)
and have Inter=1 in the data data.frame.
Dev notes: The sensible thing seems to be if we can parse control.fixed, but I'm not sure if the point in the processing where the inla formula is constructed is too early for that to work. (If it is, then it needs to be adjusted in the code before calling inla)
The workaround works fine.
I would suggest to update the documentation that mentions control.fixed
(?bru
and ?bru.options
) rather than putting a lot of effort in the parsing.
This issue can be closed.
Ah, I didn’t realise that’s in the documentation! Will fix it!
I've updated the documentation in commit 82764e7 and 48cd2cb, which also enables only partially overriding control.* parameters. I'll keep this open as a wishlist enhancement item.
Updated code (removing no longer needed control.fixed from the correct bru()
call, and more precise comment on the output): code46.zip
Create some example data
Model it with INLA. First using the defaults, then fixed the parameter of logArea to 1 by setting the prior to mean = 1 and var = 0.
bru()
seems to ignore the options when passed as a list. Passing the output ofbru.options()
yields an error.Error in (function (data, model, stackmaker, n = 10, result = NULL, family, : INLA returned message: unused argument (inla.options = list(list(TRUE, TRUE, TRUE), list("auto"), list(list(1, 0), list(1e+20, 0.001)))) In addition: Warning message: In (function (formula, family = "gaussian", contrasts = NULL, data, :
Error in (function (data, model, stackmaker, n = 10, result = NULL, family, : INLA returned message: unused argument (inla.options = list(list(TRUE, TRUE, TRUE), list("auto"), list(list(1, 0), list(1e+20, 0.001))))
SessionInfo