Learn R Programming

bdrc - Bayesian Discharge Rating Curves

The bdrc package provides tools for fitting discharge rating curves using Bayesian hierarchical models. It implements both the classical power-law and the novel generalized power-law models, offering flexibility in handling various hydrological scenarios.

This package implements four models as described in Hrafnkelsson et al. (2022):

  • plm0() - Power-law model with constant log-error variance.

  • plm() - Power-law model with stage-dependent log-error variance.

  • gplm0() - Generalized power-law model with constant log-error variance.

  • gplm() - Generalized power-law model with stage-dependent log-error variance.

Installation

# Install release version from CRAN
install.packages("bdrc")
# Install development version from GitHub
devtools::install_github("sor16/bdrc")

Usage

Fitting a discharge rating curve with bdrc is straightforward:

library(bdrc)
data(krokfors)
gplm.fit <- gplm(Q ~ W, krokfors)
summary(gplm.fit)
plot(gplm.fit)

Key-features

  • Easy-to-use interface for fitting Bayesian discharge rating curves
  • Features the novel Generalized power-law rating curve model (Hrafnkelsson et al., 2022)
  • Multiple model options to suit different hydrological scenarios
  • Built-in visualization tools for model results and diagnostics
  • Integrates R and C++ for efficient MCMC sampling with parallel processing

Getting started

For a deeper dive into the package’s functionality, visualization options, and the underlying theory of the models, please check out our vignettes:

References

Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, A. Ö., Vias, R. D., and Gardarsson, S. M. (2022). Generalization of the power-law rating curve using hydrodynamic theory and Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711

Copy Link

Version

Install

install.packages('bdrc')

Monthly Downloads

242

Version

2.0.0

License

MIT + file LICENSE

Maintainer

Rafael Vias

Last Published

February 14th, 2026

Functions in bdrc (2.0.0)

gplm

Generalized power-law model with variance that varies with stage.
plot.tournament

Plot method for a discharge rating curve tournament
norn

Norn gauging station in Sweden
plm0

Power-law model with a constant variance
plot.plm0

Plot method for discharge rating curves
plm

Power-law model with variance that varies with stage.
print.tournament

Print method for discharge rating curve tournament
predict.plm0

Predict method for discharge rating curves
summary.tournament

Summary method for a discharge rating curve tournament
kallstorp

Kallstorp gauging station in Sweden
krokfors

Krokfors gauging station in Sweden
plot_fun

Plot bdrc model objects
melby

Melby gauging station in Sweden
nordura

Nordura gauging station in Iceland
skjalf

Skjalfandafljot gauging station in Iceland
skogsliden

Skogsliden gauging station in Sweden
summary.plm0

Summary method for discharge rating curves
spread_draws

Spread MCMC chain draws to data.frame on a wide format
spanga

Spanga gauging station in Sweden
tournament_summary_output

Internal function to generate a summary output for a discharge rating curve tournament
tournament

Tournament - Model comparison
print.plm0

Print method for discharge rating curves
theme_bdrc

Custom bdrc theme
autoplot.plm0

Autoplot method for discharge rating curves
autoplot.tournament

Autoplot method for discharge rating curve tournament
get_report_pages

Report pages for a discharge rating curve or tournament
jokdal

Jokulsa a Dal gauging station in Iceland
gather_draws

Gather MCMC chain draws to data.frame on a long format
get_report

Report for a discharge rating curve or tournament
gplm0

Generalized power-law model with a constant variance
evaluate_comparison

Compare two models using a specified model-selection criteria
jokfjoll

Jokulsa a Fjollum gauging station in Iceland