Fits a discharge rating curve based on the power-law and the generalized power-law from data on paired water elevation and discharge measurements in a given river using a Bayesian hierarchical model as described in Hrafnkelsson et al. (2022)
Currently the model object output contains loads of information, including all MCMC draws for all parameters and the rating curve. For storing and using in light-weight web applications, it would be useful to have an option to get a smaller output object, one which would only contain the necessary information to plot the rating curve and data.
Use logsumexp-trick where possible in numerical calculations, for example when calculating $\widehat{\text{lppd}}_i$ in calc_waic() and when estimating the marginal likelihood with the harmonic mean estimator in evaluate_game(). The code for both these cases has been written by @RafaelVias and just needs to be incorporated. Other use-cases for the logsumexp-trick in the code should be explored.
When the tournament() function is used to create an object of class tournament, then, when the $ operator is used to access its contents and the pop-down window appears, if the mouse hovers over summary the following error message is printed:
Error in exists(cacheKey, where = .rs.CachedDataEnv, inherits = FALSE) :
invalid first argument
Error in if (maxRows != -1 && nrow(data) > maxRows) data <- head(data, :
missing value where TRUE/FALSE needed
Error in exists(cacheKey, where = .rs.CachedDataEnv, inherits = FALSE) :
invalid first argument
Error in if (maxRows != -1 && nrow(data) > maxRows) data <- head(data, :
missing value where TRUE/FALSE needed
Very nice algorithm, and though we'd want to test it more, I consider it among the best candidates for operational use.
To that end, one of the main requirements communicated to me was the algorithm should incorporate information about measurement uncertainty if it is available. That's probably an easy thing to add, but I have no time to contribute at the moment.
I'll also point out that discharge uncertainty is typically reported as +- X%. IMO, it would be fine to convert those to geometric errors (*/), since your model is fitting in log.