inlabru-org / inlabru

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

Allow custom quantiles in inlabru summary and plot functions #127

Open Martin-Jung opened 2 years ago

Martin-Jung commented 2 years ago

By default inlabru calculates a 0.025, 0.5 and 0.975 quantile and uses these measurements in summary functions and plots. However for a specific application I prefer to use other quantiles in the estimation. If I pass on the quantiles to be calculated as an explicit option in inlabru, these are taken into account in the resulting inla call. E.g., via: inlabru::bru_options_set(quantiles = c(0.05, 0.5, 0.95)) # Set quantiles to be computed

However many of the inlabru functions still have the default quantiles hardcoded in. For instance here or here. Any model fitted via the custom bru options specified above subsequently results in errors. Calling for instance inlabru:::plot.prediction on a model object with other specified quantiles returns this

Error in exp(spderesult$summary.log.range.nominal[["0.975quant"]]) : 
  non-numeric argument to mathematical function

A solution would be to add grep on the posterior names to get those columns with quant in its name.

finnlindgren commented 2 years ago

Some words seem to be missing (markdown issue?), but I get the main points, and the predict() output suffers from this issue as well; there's currently no option to safely alter the quantiles (although one can do it via manual processing of generate() output).

  1. The predict method should allow user-defined quantiles
  2. The automated plotting methods should detect the quantiles computed by inla and predict
  3. The predict summary output should be standardised (and an optional broom style tidy() output option/postprocessing method added, even though the naming scheme from https://www.tidymodels.org/learn/develop/broom/#glossary has some terminology issues for Bayesian outputs)
finnlindgren commented 2 years ago

Part 1. has now been fixed; predict() now takes a probs argument for specifying quantile probabilities.