From 635581208f0f656b01ddd704a79adb4112d7432b Mon Sep 17 00:00:00 2001 From: RafaelVias <78622738+RafaelVias@users.noreply.github.com> Date: Fri, 6 Sep 2024 12:55:13 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20sor16/bd?= =?UTF-8?q?rc@da6a0dd5f8517273ab83eef16b79dc3369a5a2a1=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- articles/background.html | 8 ++++---- pkgdown.yml | 2 +- search.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/articles/background.html b/articles/background.html index 3d4ad68..dd585b8 100644 --- a/articles/background.html +++ b/articles/background.html @@ -242,14 +242,14 @@

Referenceshttps://doi.org/10.1016/s0022-1694(99)00097-9

Clarke, R., Mendiondo, E., Brusa L. (2000). Uncertainties in mean discharges from two large South American rivers due to rating curve -variability. Hydrological Sciences 45(2). 221–236.

+variability. Hydrological Sciences 45(2). 221–236. doi: https://doi.org/10.1080/02626660009492321

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.

+hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711

Matérn, B. (1960). Spatial variation. Stochastic models and their application to some problems in forest surveys and other sampling investigations. Meddelanden från statens Skogsforskningsinstitut. @@ -257,7 +257,7 @@

Referenceshttps://doi.org/10.1080/02626667009493957

diff --git a/pkgdown.yml b/pkgdown.yml index a9456eb..2dfac1f 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -5,7 +5,7 @@ articles: background: background.html introduction: introduction.html tournament: tournament.html -last_built: 2024-09-06T12:31Z +last_built: 2024-09-06T12:48Z urls: reference: https://sor16.github.io/bdrc/reference article: https://sor16.github.io/bdrc/articles diff --git a/search.json b/search.json index e013a05..783bdcd 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://sor16.github.io/bdrc/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2021 Birgir Hrafnkelsson Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://sor16.github.io/bdrc/articles/background.html","id":"bayesian-generalized-power-law-rating-curves","dir":"Articles","previous_headings":"","what":"Bayesian Generalized Power-Law Rating Curves","title":"Background","text":"power-law model commonly assumed hydraulic practice fit rating curves, mention , form Q(h)=(h−c)bQ(h) = (h-c)^{b} (1) QQ, hh, aa, bb cc , see e.g., Venetis (1970), Clarke (1999) Clarke et al. (2000). second type rating curve generalized power-law rating curve. construction based hydraulics open channel flow given formulas Chézy Manning form Q=KRxAS1/2Q = KR^{x}^{1/2} (2) KK xx constants; AA area cross section; SS slope channel; RR hydraulic radius, given R=/PR = /P, PP wetted perimeter. According Chézy x=1/2x = 1/2, Manning claimed x=2/3x = 2/3 (Chow, 1959). form generalized power-law rating curve Q=(h−c)f(h)Q = (h − c)^{f(h)} (3) aa cc constants; f(h)f(h) function hh, referred power-law exponent. relationship (2) (3) can found equating two equations. particular, form f(h)f(h) can derived, namely, f(h)=(x+1){logA(h)−logA(1)}−x{logP(h)−logP(1)}loghf(h) = \\frac{(x+1)\\{ \\log (h) - \\log (1) \\} - x \\{ \\log P(h) - \\log P(1) \\}}{\\log h} (4) Thus, f(h)f(h) function constant xx, cross-sectional area AA, wetted perimeter PP. Bayesian approach proposed estimating parameters power-law model generalized power-law model. Bayesian inference requires specification prior densities unknown parameters unknown quantities, along full probabilistic specification observed data. goal Bayesian inference obtain posterior density model parameters, interrogate posterior calculating summary statistics, posterior mean 95% posterior intervals. Analytical formulas summary statistics intractable cases thus computed generating samples posterior density using Markov chain Monte Carlo simulation. Bayesian power-law model presented logarithmic scale , log(Qi)=log()+blog(hi−c)+ϵi,=1,...,n,\\log(Q_i) = \\log() + b \\log(h_i -c) + \\epsilon_i, \\quad = 1,...,n, (5) ϵi\\epsilon_i follows normal distribution mean zero variance σϵ2\\sigma_{\\epsilon}^2, nn number paired observations, aa, bb cc . Bayesian inference scheme implemented power-law model standard, however, efficient posterior simulation, first, samples obtained joint marginal posterior density (c,σϵ2)(c, \\sigma_{\\epsilon}^2), samples obtained conditional posterior density (log(),b)(\\log(), b) conditional (c,σϵ2)(c, \\sigma_{\\epsilon}^2). Bayesian generalized power-law model presented Bayesian hierarchical model. function f(h)f(h) modeled latent level bb plus mean zero continuous stochastic process β(h)\\beta(h), assumed twice mean-square differentiable. model presented logarithmic scale , log(Qi)=log()+(b+β(hi))log(hi−c)+εi,=1,...,n,\\log (Q_i) = \\log () + (b + \\beta(h_i)) \\log(h_i -c) + \\varepsilon_i, \\quad = 1,...,n, (6) ϵi\\epsilon_i follows normal distribution mean zero variance σϵ2(hi)\\sigma_{\\epsilon}^2(h_i) can vary water elevation. parameters aa, bb cc play similar role Bayesian power-law model. stochastic process β(h)\\beta(h) assumed priori Gaussian process governed Matérn covariance function smoothness parameter ν=2.5\\nu = 2.5, see Matérn (1960). model constrained setting b=1.835b=1.835. efficient posterior simulation achieved sampling joint posterior density hyperparameters model, sampling conditional density latent parameters given hyperparameters.","code":""},{"path":"https://sor16.github.io/bdrc/articles/background.html","id":"references","dir":"Articles","previous_headings":"","what":"References","title":"Background","text":"Chow, V. (1959). Open-Channel Hydraulics. McGraw-Hill. New York. Clarke, R. (1999). Uncertainty estimation mean annual flood due rating-curve indefinition. Journal Hydrology 222(1-4). 185–190. Clarke, R., Mendiondo, E., Brusa L. (2000). Uncertainties mean discharges two large South American rivers due rating curve variability. Hydrological Sciences 45(2). 221–236. Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. Matérn, B. (1960). Spatial variation. Stochastic models application problems forest surveys sampling investigations. Meddelanden från statens Skogsforskningsinstitut. 49(5). Venetis, C. (1970). note estimation parameters logarithmic stage-discharge relationships estimates error. International Association Scientific Hydrology. Bulletin XV 2(6). 105–111.","code":""},{"path":"https://sor16.github.io/bdrc/articles/introduction.html","id":"fitting-a-discharge-rating-curve","dir":"Articles","previous_headings":"","what":"Fitting a discharge rating curve","title":"Introduction","text":"Fitting discharge rating curve bdrc straightforward. two input arguments mandatory: formula data. formula form y ~ x, y discharge cubic meters per second (m³/s), x water elevation (stage) meters (m). crucial data correct units! data argument must data.frame including x y column names. case, Krokfors data discharge water elevation measurements stored columns named Q W, respectively. ready fit discharge rating curve using gplm function: function prints summary fitting process key MCMC diagnostics. include acceptance rate, chain mixing (assessed via Gelman-Rubin statistic, R̂\\hat{R}), effective sample sizes. checkmarks indicate algorithm met important criteria reliability. However, sometimes may encounter warnings. example: warning suggests certain parameters (case, sigma_eta) haven’t mixed well across chains, affect reliability results. cases, function provides advice: output helps assess whether discharge rating curve fitted successfully reliably using specified data. function can made run silently setting verbose=FALSE. Note parallel=TRUE default setting, utilizing available cores machine. can adjust number cores num_cores argument needed. gplm function returns object class gplm can summarize visualize using familiar functions next section, dive deeper visualizing gplm object.","code":"> gplm.fit <- gplm(Q ~ W, data = krokfors, parallel = TRUE, num_cores = 2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.33%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> ⚠ Warning: Some chains are not mixing well. Parameters with Rhat > 1.1: #> - sigma_eta: Rhat = 1.281 #> ℹ Try re-running the model after inspecting the trace plots, convergence diagnostics plots, and reviewing the data for potential issues. > summary(gplm.fit) #> #> Formula: #> Q ~ W #> Latent parameters: #> lower-2.5% median-50% upper-97.5% #> a 1.47 1.94 2.23 #> b 1.83 1.84 1.84 #> #> Hyperparameters: #> lower-2.5% median-50% upper-97.5% #> c 7.70955 7.8089 7.855 #> sigma_beta 0.42275 0.6942 1.258 #> phi_beta 0.54941 1.1775 2.861 #> sigma_eta 0.00298 0.0934 0.498 #> eta_1 -4.91521 -4.2508 -3.535 #> eta_2 -5.97953 -4.0555 -2.264 #> eta_3 -6.92387 -4.1874 -1.612 #> eta_4 -7.66667 -4.4852 -1.160 #> eta_5 -8.33270 -4.6095 -0.757 #> eta_6 -8.81259 -4.6718 -0.311 #> #> WAIC: -27.81763 > plot(gplm.fit)"},{"path":"https://sor16.github.io/bdrc/articles/introduction.html","id":"visualizing-posterior-distributions-of-different-parameters","dir":"Articles","previous_headings":"","what":"Visualizing posterior distributions of different parameters","title":"Introduction","text":"bdrc package provides several tools visualize results model objects can give insight physical properties river hand. instance, hyperparameter cc corresponds water elevation zero discharge. visualize posterior cc, can write Technically, instead inferring cc directly, hmin−ch_{min}-c inferred, hminh_{min} lowest water elevation value data. Since parameter hmin−ch_{min}-c strictly positive, transformation ζ=log(hmin−c)\\zeta=log(h_{min}-c) used Bayesian inference support real line. plot transformed posterior write param argument can also vector containing multiple parameter names. example, visualize posterior distributions parameters aa cc, can write shorthand visualize hyperparameters Similarly, writing \"latent_parameters\" plots latent parameters one plot. plot hyperparameters transformed scale Bayesian inference, write Finally, can visualize components model allowed (depending model) vary water elevation, , power-law exponent, f(h)f(h), standard deviation error terms response level, σε(h)\\sigma_{\\varepsilon}(h). gplm0 gplm generalize power-law exponent modeling sum constant term, bb, Gaussian process, β(h)\\beta(h), namely f(h)=b+β(h)f(h)=b+\\beta(h), β(h)\\beta(h) assumed twice differentiable mean zero. hand, plm plm0 model power-law exponent constant setting β(h)=0\\beta(h)=0, gives f(h)=bf(h)=b. can plot inferred power-law exponent plm gplm model standard deviation error terms response level, σε(h)\\sigma_{\\varepsilon}(h), function water elevation, using B-splines basis functions, plm0 gplm0 model standard deviation constant. can plot inferred standard deviation writing get visual summary model, \"panel\" option plot type useful:","code":"> plot(gplm.fit, type = 'histogram', param = 'c') > plot(gplm.fit, type = 'histogram', param = 'c', transformed = TRUE) > plot(gplm.fit, type = 'histogram', param = c('a', 'c')) > plot(gplm.fit, type = 'histogram', param = 'hyperparameters') > plot(gplm.fit, type = 'histogram', param = 'hyperparameters', transformed = TRUE) > plot(gplm.fit, type = 'f') > plot(gplm.fit, type = 'sigma_eps') > plot(gplm.fit, type = 'panel', transformed = TRUE)"},{"path":"https://sor16.github.io/bdrc/articles/introduction.html","id":"assessing-model-fit-and-convergence","dir":"Articles","previous_headings":"","what":"Assessing model fit and convergence","title":"Introduction","text":"package several functions convergence diagnostics bdrc model, notably residual plot, trace plots, autocorrelation plots, Gelman-Rubin diagnostic plots. log-residuals can plotted log-residuals calculated subtracting posterior estimate (median) log-discharge, log(Q̂)log(\\hat{Q}), observed log-discharge, log(Q)log(Q). Additionally, plot includes 95% predictive intervals log(Q)\\log(Q) (- -) 95% credible intervals expected value log(Q)\\log(Q) (—), latter reflecting rating curve uncertainty. plot trace plot transformed hyperparameters, write assess mixing convergence MCMC chains parameter, can visualize Gelman-Rubin statistic, R̂\\hat{R}, presented Gelman Rubin (1992) : finally, autocorrelation parameters can assessed ","code":"> plot(gplm.fit, type = 'residuals') > plot(gplm.fit, type = 'trace', param = 'c', transformed = TRUE) > plot(gplm.fit, type = 'trace', param = 'hyperparameters', transformed = TRUE) > plot(gplm.fit, type = 'r_hat') > plot(gplm.fit, type = 'autocorrelation')"},{"path":"https://sor16.github.io/bdrc/articles/introduction.html","id":"customizing-the-models","dir":"Articles","previous_headings":"","what":"Customizing the models","title":"Introduction","text":"ways customize gplm function. instances, parameter zero discharge, cc, known, might want fix model parameter known value. addition, might want extrapolate rating curve higher water elevation values adjusting maximum water elevation. Assume 7.65 m known value cc want calculate rating curve water elevation values 10 m, function call look like ","code":"> gplm.fit.known_c <- gplm(Q ~ W, krokfors, c_param = 7.65, h_max = 10, parallel = FALSE)"},{"path":"https://sor16.github.io/bdrc/articles/introduction.html","id":"prediction-for-an-equally-spaced-grid-of-water-elevations","dir":"Articles","previous_headings":"","what":"Prediction for an equally spaced grid of water elevations","title":"Introduction","text":"get rating curve predictions equally spaced grid water elevation values, can use predict function. Note values range cc h_max accepted, range Bayesian inference performed","code":"> h_grid <- seq(8, 8.2, by = 0.01) > rating_curve_h_grid <- predict(gplm.fit, newdata = h_grid) > print(rating_curve_h_grid) #> h lower median upper #> 1 8.00 0.06138853 0.08252241 0.1108601 #> 2 8.01 0.06708762 0.09009315 0.1207313 #> 3 8.02 0.07340524 0.09850833 0.1316830 #> 4 8.03 0.07972287 0.10692352 0.1426346 #> 5 8.04 0.08620981 0.11547827 0.1537808 #> 6 8.05 0.09363849 0.12480929 0.1660087 #> 7 8.06 0.10106716 0.13414031 0.1782366 #> 8 8.07 0.10861541 0.14364701 0.1906011 #> 9 8.08 0.11657272 0.15375469 0.2034327 #> 10 8.09 0.12453003 0.16386237 0.2162643 #> 11 8.10 0.13257127 0.17428375 0.2295414 #> 12 8.11 0.14080833 0.18543710 0.2438577 #> 13 8.12 0.14904540 0.19659045 0.2581741 #> 14 8.13 0.15728247 0.20774380 0.2724905 #> 15 8.14 0.16662200 0.21960922 0.2875367 #> 16 8.15 0.17662981 0.23190628 0.3030253 #> 17 8.16 0.18663761 0.24420333 0.3185138 #> 18 8.17 0.19681441 0.25692028 0.3351942 #> 19 8.18 0.20699699 0.26965158 0.3519154 #> 20 8.19 0.21718541 0.28270330 0.3691020 #> 21 8.20 0.22738677 0.29646391 0.3873183"},{"path":"https://sor16.github.io/bdrc/articles/introduction.html","id":"references","dir":"Articles","previous_headings":"","what":"References","title":"Introduction","text":"Gelman, ., & Rubin, D. B. (1992). Inference iterative simulation using multiple sequences, Statistical Science, 7(4), 457–472. doi: https://doi.org/10.1214/ss/1177011136 Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711","code":""},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"the-tournament-method","dir":"Articles","previous_headings":"","what":"The tournament method","title":"Tournament - Model comparison","text":"tournament method uses Widely Applicable Information Criterion (WAIC) (Watanabe, 2010) select appropriate model given dataset. WAIC balances two factors: Goodness--fit: well model fits observed data. Model complexity: penalty term accounting effective number parameters. lower WAIC indicates better balance model fit complexity, making preferred model. tournament process occurs two rounds: First round: gplm vs gplm0 plm vs plm0 Final round: Winners first round face comparison, calculate WAIC difference less complex model, ΔWAIC=WAICless−WAICmore\\Delta\\text{WAIC} = \\text{WAIC}_{\\text{less}} - \\text{WAIC}_{\\text{}}. positive ΔWAIC\\Delta\\text{WAIC} suggests complex model appropriate. However, advance next round, ΔWAIC\\Delta\\text{WAIC} must exceed pre-specified “winning criteria” (default value = 2). threshold helps ensure choose complex model offers substantial improvement. default winning criteria 2 based statistical guidelines model selection (Burnham & Anderson, 2002), balancing trade-model fit complexity. helps prevent overfitting requiring evidence justify complex model. following sections, ’ll provide code examples demonstrating conduct power-law tournament data using bdrc package.","code":""},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"introducing-the-tournament-function","dir":"Articles","previous_headings":"","what":"Introducing the Tournament Function","title":"Tournament - Model comparison","text":"demonstrate tournament function, ’ll use real-world dataset Krokfors stream gauging station Sweden, included bdrc package: Krokfors dataset contains 27 observations discharge measurements stream gauging station. observation consists two variables: W: Water level (stage) measured meters fixed reference point. Q: Discharge, measured cubic meters per second (m³/s). Krokfors data particularly suitable demonstrating tournament function provides real-world example type data typically used discharge rating curve analysis. dataset help illustrate different models perform across range observed water levels discharges.","code":"> library(bdrc) > data(krokfors) > head(krokfors) #> W Q #> 1 9.478000 10.8211700 #> 2 8.698000 1.5010000 #> 3 9.009000 3.3190000 #> 4 8.097000 0.1595700 #> 5 9.104000 4.5462500 #> 6 8.133774 0.2121178"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"running-a-tournament","dir":"Articles","previous_headings":"","what":"Running a tournament","title":"Tournament - Model comparison","text":"tournament function straightforward use, requiring two main arguments: formula: Specifies relationship discharge water elevation (e.g., Q ~ W). data: data.frame column names corresponding variables specified formula. important discharge represented cubic meters per second (m³/s) water elevation meters (m). Let’s run first tournament: output provides valuable information MCMC sampling process model: Shows overall progress tournament four models fitted sequentially. Indicates start Markov Chain Monte Carlo (MCMC) process model. Provides information sampling process distributed across computer’s CPU cores. example, see 4 chain sampling process distributed across 2 CPU cores (4 chains 2 jobs). Acceptance rate: proportion proposed parameter values accepted MCMC sampling scheme. Chain mixing: message reporting different MCMC chains mixed well. Effective sample size: message reporting enough independent samples drawn posterior distribution. parameters meet criteria chain mixing effective sample size (Gelman-rubin statistic (Rhat) < 1.1 mixing effective number samples (eff_n_samples) > 400 sample size), function print warning. helps identify potential issues MCMC sampling specific parameters. diagnostics help ensure reliability results. Good chain mixing sufficient effective sample sizes indicate MCMC sampling likely converged true posterior distribution. function can made run silently setting verbose = FALSE. Note: default, parallel=TRUE function automatically detects number available cores. Parallel processing used run multiple MCMC chains simultaneously, significantly reducing computation time complex models large datasets. see tournament winner: ’ve already fitted four models separately stored objects (e.g., plm0.fit, plm.fit, gplm0.fit, gplm.fit), can run tournament efficiently: tournament function creates tournament object contains four elements: summary, contestants, winner, info. components structured follows: summary: data frame detailed information results different comparisons power-law tournament. contents data frame depend method used (\"WAIC\", \"DIC\", \"PMP\") include: Common columns methods: round: Indicates tournament round (1 2). Round 1 compares generalized classical power-law models separately (gplm vs gplm0 plm vs plm0), whereas Round 2 compares winners Round 1. comparison: numeric identifier model comparison (1, 2, 3). two comparisons Round 1 one Round 2. complexity: Indicates whether model “” “less” complex model given comparison. “less” complex model given advantage defined winning_criteria. model: model type (plm0, plm, gplm0, gplm). winner: logical value (TRUE/FALSE) indicating whether model selected winner. Method-specific columns: WAIC (Widely Applicable Information Criterion): lppd: Log-pointwise predictive density, measuring well model predicts observed data eff_num_param: Effective number parameters, estimating model complexity WAIC: computed WAIC value, balancing model fit complexity SE_WAIC: Standard error WAIC estimate Delta_WAIC: Difference WAIC compared models SE_Delta_WAIC: Standard error difference WAIC DIC (Deviance Information Criterion): D_hat: Minus two times log-likelihood evaluated median posterior samples eff_num_param: Effective number parameters, estimating model complexity DIC: computed DIC value, balancing model fit complexity Delta_DIC: Difference DIC compared models PMP (Posterior Model Probability): log_marg_lik: Logarithm marginal likelihood, estimated using harmonic-mean estimator PMP: Posterior model probability computed Bayes factor, indicating probability model given data contestants: list containing fitted model objects compared tournament: plm0, plm, gplm0 gplm. winner: model object tournament winner, representing appropriate model given data. info: list containing specific information tournament: overall winner method used comparison (\"WAIC\", \"DIC\", \"PMP\") winning criteria applied structure allows users easily access final results (winner) detailed process (summary) model comparison, well full model objects analysis needed. method-specific columns provide insights model selection process: * WAIC, lower values indicate better models, Delta_WAIC showing magnitude difference models. * DIC, like WAIC, lower values preferred, Delta_DIC showing difference models. * PMP, higher probabilities indicate stronger evidence model, values closer 1 suggesting stronger support. metrics help users understand just model selected, also strength evidence selection relative performance compared models. comprehensive summary tournament results: first round tournament favors gplm0 gplm, plm0 plm, based respective ΔWAIC\\Delta\\text{WAIC} values. final round, gplm0 emerges overall winner, substantial positive ΔWAIC\\Delta\\text{WAIC} ~24 compared plm0. indicates gplm0 provides best balance model complexity fit data. standard error estimated WAIC difference, denoted SE_Delta_WAIC, rather large ~9. suggests uncertainty magnitude difference. However, ’s important note despite small sample size, SE_Delta_WAIC less half ΔWAIC\\Delta\\text{WAIC} estimate. provides confidence preference gplm0, difference WAIC two standard errors away zero. Lets investigate comparison.","code":"> set.seed(1) # set seed for reproducibility > t_obj <- tournament(Q ~ W, krokfors, parallel = TRUE, num_cores = 2) #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.33%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.14%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.66%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.04%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% > t_obj # or alternatively print(t_obj) #> Tournament winner: gplm0 > t_obj <- tournament(list(plm0.fit, plm.fit, gplm0.fit, gplm.fit)) > summary(t_obj) #> #> === Tournament Model Comparison Summary === #> #> Method: WAIC #> Winning Criteria: Delta_WAIC > 2 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm 20.7794 6.8706 -27.8176 11.8918 0.5570 0.2416 #> less gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more plm 5.5842 4.2574 -2.6536 6.6635 -0.4066 0.1904 #> less plm0 <--- 5.6284 4.0984 -3.0601 6.6931 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 24.2005 9.1834 #> less plm0 5.6284 4.0984 -3.0601 6.6931 #> #> === End of Summary ==="},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"visualizing-the-model-comparisons","dir":"Articles","previous_headings":"","what":"Visualizing the model comparisons","title":"Tournament - Model comparison","text":"gain deeper insights model comparison results, can use various visualization tools:","code":""},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"tournament-results-diagram","dir":"Articles","previous_headings":"Visualizing the model comparisons","what":"1. Tournament results diagram:","title":"Tournament - Model comparison","text":"diagram illustrates tournament progression initial four models final winner. shows model’s residual plot bottom, corresponding WAIC values . Green WAIC values indicate selected model comparison.","code":"> plot(t_obj) #default plot type is type='tournament_results'"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"log-likelihood-comparison","dir":"Articles","previous_headings":"Visualizing the model comparisons","what":"2. Log-likelihood comparison:","title":"Tournament - Model comparison","text":"boxplot compares posterior log-likelihood values model, corresponding WAIC values shown red diamonds. log-likelihood values presented deviance scale (-2 * log-likelihood) direct comparison WAIC. Lower values indicate better fit.","code":"> plot(t_obj, type = 'boxplot')"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"rating-curve-comparison","dir":"Articles","previous_headings":"Visualizing the model comparisons","what":"3. Rating curve comparison:","title":"Tournament - Model comparison","text":"plot compares estimated rating curves four models. shows water level (stage) vs. discharge, solid lines representing estimated curves dotted lines showing 95% prediction intervals. visualization helps assess model fit across different water levels. Optimal model fit indicated solid line following mean observations 95% observations falling within prediction interval.","code":"> plot(t_obj, type = 'rating_curve')"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"residual-plot-comparison","dir":"Articles","previous_headings":"Visualizing the model comparisons","what":"4. Residual plot comparison:","title":"Tournament - Model comparison","text":"residual plots also help assess well model fits data showing differences observed predicted values across water levels. can reveal patterns model performance highlight systematic - -predictions. Optimal model fit indicated rating curve mean (solid horizontal line) following mean observations, 95% observations falling within 95% prediction interval (dotted lines).","code":"> plot(t_obj, type = 'residuals')"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"model-component-comparisons","dir":"Articles","previous_headings":"Visualizing the model comparisons","what":"5. Model Component Comparisons:","title":"Tournament - Model comparison","text":"differences four models lie treatment power-law exponent, f(h)f(h), log-error standard deviation, σε2(h)\\sigma^2_{\\varepsilon}(h), either constants stage-dependent functions. Therefore, insightful examine posterior distributions elements across different models determine whether stage dependence exists assumption constancy appropriate.","code":""},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"power-law-exponent-comparison","dir":"Articles","previous_headings":"Visualizing the model comparisons > 5. Model Component Comparisons:","what":"Power-law exponent comparison:","title":"Tournament - Model comparison","text":"plots show exponent clearly constant water elevations. observation supports use generalized power-law models (gplm gplm0) classical power-law models (plm plm0), allow non-constant behavior power-law exponent.","code":"> plot(t_obj, type = 'f')"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"log-error-standard-deviation-comparison","dir":"Articles","previous_headings":"Visualizing the model comparisons > 5. Model Component Comparisons:","what":"Log-error standard deviation comparison:","title":"Tournament - Model comparison","text":"contrast exponent, log-error standard deviation show clear non-constant trend water elevations. observation suggests models constant error variance (plm0 gplm0) might sufficient dataset, aligning tournament results selected gplm0.","code":"> plot(t_obj, type = 'sigma_eps')"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"winning-model-panel","dir":"Articles","previous_headings":"Visualizing the model comparisons","what":"6. Winning model panel:","title":"Tournament - Model comparison","text":"Finally, panel option useful gain insight different model components winning model, case gplm0: panel plot provides comprehensive view winning model’s components, including rating curve, residuals, power-law exponent, log-error standard deviation. visualization particularly useful understanding different elements winning model work together relate observed data. transformed = TRUE argument transforms rating curve observations onto modeling scale (log-scale).","code":"> plot(t_obj, type = 'panel', transformed = TRUE)"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"customizing-tournaments","dir":"Articles","previous_headings":"","what":"Customizing tournaments","title":"Tournament - Model comparison","text":"several ways customize tournament :","code":""},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"fixing-the-c-parameters","dir":"Articles","previous_headings":"Customizing tournaments","what":"1. Fixing the c parameters:","title":"Tournament - Model comparison","text":"parameter zero discharge cc known, might want fix parameter known value model. Assume 7.657.65 m known value cc. can directly run tournament cc parameter fixed models:","code":"> t_obj_known_c <- tournament(formula = Q ~ W , data = krokfors, c_param = 7.65)"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"adjusting-the-winning-criteria","dir":"Articles","previous_headings":"Customizing tournaments","what":"2. Adjusting the winning criteria:","title":"Tournament - Model comparison","text":"can change winning criteria (default value = 2) sets threshold complex model model comparison must exceed. example, increasing value winning_criteria = 5 raises threshold, thus favoring model simplicity . re-evaluate previously run tournament using different winning criteria, can simply summary function: method \"WAIC\", can also specify complex winning criteria string expression: criteria requires difference WAIC greater 2 difference minus standard error greater 0, providing conservative approach model selection. Note: Delta_WAIC SE_Delta_WAIC allowed variables winning_criteria expressions.","code":"> summary(t_obj, winning_criteria = 5) #> #> === Tournament Model Comparison Summary === #> #> Method: WAIC #> Winning Criteria: Delta_WAIC > 5 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm 20.7794 6.8706 -27.8176 11.8918 0.5570 0.2416 #> less gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more plm 5.5842 4.2574 -2.6536 6.6635 -0.4066 0.1904 #> less plm0 <--- 5.6284 4.0984 -3.0601 6.6931 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 24.2005 9.1834 #> less plm0 5.6284 4.0984 -3.0601 6.6931 #> #> === End of Summary === > summary(t_obj, winning_criteria = \"Delta_WAIC > 2 & Delta_WAIC - SE_Delta_WAIC > 0\") #> #> === Tournament Model Comparison Summary === #> #> Method: WAIC #> Winning Criteria: Delta_WAIC > 2 & Delta_WAIC - SE_Delta_WAIC > 0 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm 20.7794 6.8706 -27.8176 11.8918 0.5570 0.2416 #> less gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more plm 5.5842 4.2574 -2.6536 6.6635 -0.4066 0.1904 #> less plm0 <--- 5.6284 4.0984 -3.0601 6.6931 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 24.2005 9.1834 #> less plm0 5.6284 4.0984 -3.0601 6.6931 #> #> === End of Summary ==="},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"changing-the-model-comparison-method","dir":"Articles","previous_headings":"Customizing tournaments","what":"3. Changing the model comparison method:","title":"Tournament - Model comparison","text":"default method \"WAIC\", can also use \"DIC\" \"PMP\": \"WAIC\" (default): WAIC (Watanabe, 2010) fully Bayesian method uses full set posterior draws calculate best possible estimate expected log pointwise predictive density. \"DIC\": DIC (Spiegelhalter, 2002) similar WAIC uses point estimate posterior distribution instead full set posterior draws. \"PMP\" (posterior model probabilities): posterior model probabilities computed Bayes factors (Jeffreys, 1961; Kass Raftery, 1995), assuming models equally likely priori. winning criteria method \"PMP\" 0 1, representing threshold posterior probability complex model. default 0.75, give similar results two methods respective default values 2. method \"PMP\" chosen default method Bayes factor calculations can quite unstable. Let’s now use method, raise winning criteria 0.75 0.9 Note using summary function change method winning criteria, tournament re-run new parameters using original contestant models. allows efficient comparison different methods criteria without refit models. examples demonstrate different methods winning criteria can applied model comparison. ’s valuable explore options, generally recommend using WAIC method, provides robust theoretically sound approach model selection. WAIC uses full posterior distribution particularly well-suited hierarchical models. case Krokfors dataset, see results tournament change despite customizations, winner third final comparison still gplm0. consistency across different methods criteria suggests gplm0 indeed appropriate model particular dataset.","code":"> summary(t_obj, method = \"DIC\") #> #> === Tournament Model Comparison Summary === #> #> Method: DIC #> Winning Criteria: Delta_DIC > 2 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------- #> complexity model winner D_hat eff_num_param DIC Delta_DIC #> more gplm -42.7732 6.0631 -30.6470 0.8498 #> less gplm0 <--- -42.4880 6.3454 -29.7972 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------- #> complexity model winner D_hat eff_num_param DIC Delta_DIC #> more plm -11.3400 2.9739 -5.3923 -0.3058 #> less plm0 <--- -11.4712 2.8865 -5.6982 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------- #> complexity model winner D_hat eff_num_param DIC Delta_DIC #> more gplm0 <--- -42.4880 6.3454 -29.7972 24.0991 #> less plm0 -11.4712 2.8865 -5.6982 #> #> === End of Summary === > summary(t_obj, method = \"PMP\", winning_criteria = 0.9) #> #> === Tournament Model Comparison Summary === #> #> Method: PMP #> Winning Criteria: PMP of more complex model > 0.9 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> ------------------------------------------------------- #> complexity model winner log_marg_lik PMP #> more gplm 10.1504 0.4538 #> less gplm0 <--- 10.3357 0.5462 #> #> Comparison 2 Results: #> ------------------------------------------------------- #> complexity model winner log_marg_lik PMP #> more plm <--- 0.9781 0.9260 #> less plm0 -1.5486 0.0740 #> #> Comparison 3 Results: #> ------------------------------------------------------- #> complexity model winner log_marg_lik PMP #> more gplm0 <--- 10.3357 0.9999 #> less plm 0.9781 0.0001 #> #> === End of Summary === #> #> ⚠ Warning: The Harmonic Mean Estimator (HME) is used to estimate the Bayes Factor for the posterior model probability (PMP), which is known to be unstable and potentially unreliable. We recommend using method \"WAIC\" (Widely Applicable Information Criterion) for model comparison instead."},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"references","dir":"Articles","previous_headings":"","what":"References","title":"Tournament - Model comparison","text":"Burnham, K. P. Anderson, D. R. (eds) (2002). Information Likelihood Theory: Basis Model Selection Inference. New York, NY: Springer New York. 49–97, doi: https://doi.org/10.1007/978-0-387-22456-5_2 Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711 Jeffreys, H. (1961). Theory Probability, Third Edition. Oxford University Press. Kass, R., . Raftery, . (1995). Bayes Factors. Journal American Statistical Association, 90, 773-795. doi: https://doi.org/10.1080/01621459.1995.10476572 Spiegelhalter, D., Best, N., Carlin, B., Van Der Linde, . (2002). Bayesian measures model complexity fit. Journal Royal Statistical Society: Series B (Statistical Methodology) 64(4), 583–639. doi: https://doi.org/10.1111/1467-9868.00353 Watanabe, S. (2010). Asymptotic equivalence Bayes cross validation widely applicable information criterion singular learning theory. Journal Machine Learning Research, 11, 3571–3594.","code":""},{"path":"https://sor16.github.io/bdrc/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Birgir Hrafnkelsson. Author, copyright holder. Solvi Rognvaldsson. Author. Rafael Daníel Vias. Author, maintainer. Axel Orn Jansson. Author.","code":""},{"path":"https://sor16.github.io/bdrc/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Hrafnkelsson B, Rognvaldsson S, Vias R, Jansson (2024). bdrc: Bayesian Discharge Rating Curves. R package version 2.0.0, https://sor16.github.io/bdrc.","code":"@Manual{, title = {bdrc: Bayesian Discharge Rating Curves}, author = {Birgir Hrafnkelsson and Solvi Rognvaldsson and Rafael Daníel Vias and Axel Orn Jansson}, year = {2024}, note = {R package version 2.0.0}, url = {https://sor16.github.io/bdrc}, }"},{"path":"https://sor16.github.io/bdrc/index.html","id":"bdrc---bayesian-discharge-rating-curves-","dir":"","previous_headings":"","what":"bdrc - Bayesian Discharge Rating Curves","title":"Fit Bayesian Discharge Rating Curves","text":"bdrc package provides tools fitting discharge rating curves using Bayesian hierarchical models. implements classical power-law novel generalized power-law models, offering flexibility handling various hydrological scenarios. package implements four models described Hrafnkelsson et al. (2022): plm0() - Power-law model constant log-error variance. plm() - Power-law model stage-dependent log-error variance. gplm0() - Generalized power-law model constant log-error variance. gplm() - Generalized power-law model stage-dependent log-error variance.","code":""},{"path":"https://sor16.github.io/bdrc/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Fit Bayesian Discharge Rating Curves","text":"","code":"# Install release version from CRAN install.packages(\"bdrc\") # Install development version from GitHub devtools::install_github(\"sor16/bdrc\")"},{"path":"https://sor16.github.io/bdrc/index.html","id":"usage","dir":"","previous_headings":"","what":"Usage","title":"Fit Bayesian Discharge Rating Curves","text":"Fitting discharge rating curve bdrc straightforward:","code":"library(bdrc) data(krokfors) gplm.fit <- gplm(Q ~ W, krokfors) summary(gplm.fit) plot(gplm.fit)"},{"path":"https://sor16.github.io/bdrc/index.html","id":"key-features","dir":"","previous_headings":"","what":"Key-features","title":"Fit Bayesian Discharge Rating Curves","text":"Easy--use interface fitting Bayesian discharge rating curves Features novel Generalized power-law rating curve model (Hrafnkelsson et al., 2022) Multiple model options suit different hydrological scenarios Built-visualization tools model results diagnostics Integrates R C++ efficient MCMC sampling parallel processing","code":""},{"path":"https://sor16.github.io/bdrc/index.html","id":"getting-started","dir":"","previous_headings":"","what":"Getting started","title":"Fit Bayesian Discharge Rating Curves","text":"deeper dive package’s functionality, visualization options, underlying theory models, please check vignettes: Background Introduction Power-law tournament (model selection)","code":""},{"path":"https://sor16.github.io/bdrc/index.html","id":"references","dir":"","previous_headings":"","what":"References","title":"Fit Bayesian Discharge Rating Curves","text":"Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711","code":""},{"path":"https://sor16.github.io/bdrc/reference/autoplot.plm0.html","id":null,"dir":"Reference","previous_headings":"","what":"Autoplot method for discharge rating curves — autoplot.plm0","title":"Autoplot method for discharge rating curves — autoplot.plm0","text":"Visualize discharge rating curve model objects","code":""},{"path":"https://sor16.github.io/bdrc/reference/autoplot.plm0.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Autoplot method for discharge rating curves — autoplot.plm0","text":"","code":"# S3 method for class 'plm0' autoplot( object, ..., type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL ) # S3 method for class 'plm' autoplot( object, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... ) # S3 method for class 'gplm0' autoplot( object, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... ) # S3 method for class 'gplm' autoplot( object, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... )"},{"path":"https://sor16.github.io/bdrc/reference/autoplot.plm0.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Autoplot method for discharge rating curves — autoplot.plm0","text":"object object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". ... used function type character denoting type plot drawn. Defaults \"rating_curve\". Possible types : rating_curve Plots rating curve. rating_curve_mean Plots posterior mean rating curve. f Plots power-law exponent. beta Plots random effect power-law exponent. sigma_eps Plots standard deviation data level. residuals Plots log residuals. trace Plots trace plots parameters given param. histogram Plots histograms parameters given param. param character vector parameters plot. Defaults NULL used type \"trace\" \"histogram\". Allowed values parameters given model summary x well \"hyperparameters\" \"latent_parameters\" specific groups parameters. transformed logical value indicating whether quantity plotted transformed scale used Bayesian inference. Defaults FALSE. title character denoting title plot. xlim numeric vector length 2, denoting limits x axis plot. Applicable types \"rating_curve\", \"rating_curve_mean\", \"f\", \"beta\", \"sigma_eps\", \"residuals\". ylim numeric vector length 2, denoting limits y axis plot. Applicable types \"rating_curve\", \"rating_curve_mean\", \"f\", \"beta\", \"sigma_eps\", \"residuals\".","code":""},{"path":"https://sor16.github.io/bdrc/reference/autoplot.plm0.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Autoplot method for discharge rating curves — autoplot.plm0","text":"Returns object class \"ggplot2\".","code":""},{"path":"https://sor16.github.io/bdrc/reference/autoplot.plm0.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Autoplot method for discharge rating curves — autoplot.plm0","text":"autoplot(plm0): Autoplot method plm0 autoplot(plm): Autoplot method plm autoplot(gplm0): Autoplot method gplm0 autoplot(gplm): Autoplot method gplm","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/autoplot.plm0.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Autoplot method for discharge rating curves — autoplot.plm0","text":"","code":"# \\donttest{ library(ggplot2) data(krokfors) set.seed(1) plm0.fit <- plm0(Q~W,krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.09%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). autoplot(plm0.fit) autoplot(plm0.fit,transformed=TRUE) autoplot(plm0.fit,type='histogram',param='c') autoplot(plm0.fit,type='histogram',param='c',transformed=TRUE) autoplot(plm0.fit,type='histogram',param='hyperparameters') autoplot(plm0.fit,type='histogram',param='latent_parameters') autoplot(plm0.fit,type='residuals') autoplot(plm0.fit,type='f') autoplot(plm0.fit,type='sigma_eps') # }"},{"path":"https://sor16.github.io/bdrc/reference/autoplot.tournament.html","id":null,"dir":"Reference","previous_headings":"","what":"Autoplot method for discharge rating curve tournament — autoplot.tournament","title":"Autoplot method for discharge rating curve tournament — autoplot.tournament","text":"Compare four discharge rating curves tournament object different ways","code":""},{"path":"https://sor16.github.io/bdrc/reference/autoplot.tournament.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Autoplot method for discharge rating curve tournament — autoplot.tournament","text":"","code":"# S3 method for class 'tournament' autoplot(object, type = \"boxplot\", ...)"},{"path":"https://sor16.github.io/bdrc/reference/autoplot.tournament.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Autoplot method for discharge rating curve tournament — autoplot.tournament","text":"object object class \"tournament\" type character denoting type plot drawn. Possible types ... used function boxplot Creates boxplot posterior log-likelihood values transformed deviance scale.","code":""},{"path":"https://sor16.github.io/bdrc/reference/autoplot.tournament.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Autoplot method for discharge rating curve tournament — autoplot.tournament","text":"Returns object class \"ggplot2\".","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/autoplot.tournament.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Autoplot method for discharge rating curve tournament — autoplot.tournament","text":"","code":"# \\donttest{ library(ggplot2) data(krokfors) set.seed(1) t_obj <- tournament(formula = Q ~ W, data = krokfors, num_cores = 2) #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.33%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.14%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.66%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.04%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% autoplot(t_obj) # }"},{"path":"https://sor16.github.io/bdrc/reference/evaluate_comparison.html","id":null,"dir":"Reference","previous_headings":"","what":"Compare two models using a specified model-selection criteria — evaluate_comparison","title":"Compare two models using a specified model-selection criteria — evaluate_comparison","text":"evaluate_comparison uses Widely Applicable Information Criterion (WAIC), Deviance Information Criterion (DIC), posterior model probabilities (PMP), calculated Bayes factor, determine whether one model appropriate given data hand.","code":""},{"path":"https://sor16.github.io/bdrc/reference/evaluate_comparison.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compare two models using a specified model-selection criteria — evaluate_comparison","text":"","code":"evaluate_comparison(m, method, winning_criteria)"},{"path":"https://sor16.github.io/bdrc/reference/evaluate_comparison.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compare two models using a specified model-selection criteria — evaluate_comparison","text":"m list two model objects fit dataset. allowed model objects \"gplm\", \"gplm0\", \"plm\" \"plm0\" method string specifying method used estimate predictive performance models. allowed methods \"WAIC\", \"DIC\" \"PMP\". winning_criteria \"WAIC\", can either numeric value string expression. \"DIC\", must numeric value. \"PMP\", must numeric value 0 1. sets threshold determining appropriate model. See Details information.","code":""},{"path":"https://sor16.github.io/bdrc/reference/evaluate_comparison.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compare two models using a specified model-selection criteria — evaluate_comparison","text":"data.frame summary results comparison, including: complexity: Indicates whether model \"\" \"less\" complex model comparison model: type model (gplm, gplm0, plm, plm0) Method-specific columns (see Details) winner: Logical value indicating model selected","code":""},{"path":"https://sor16.github.io/bdrc/reference/evaluate_comparison.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Compare two models using a specified model-selection criteria — evaluate_comparison","text":"\"WAIC\" method: winning_criteria numeric, complex model wins Delta_WAIC > winning_criteria winning_criteria string, must valid R expression using Delta_WAIC /SE_Delta_WAIC Returns columns: lppd, eff_num_param, WAIC, SE_WAIC, Delta_WAIC, SE_Delta_WAIC \"DIC\" method: winning_criteria must numeric complex model wins Delta_DIC > winning_criteria Returns columns: D_hat, eff_num_param, DIC, Delta_DIC \"PMP\" method: winning_criteria must numeric value 0 1 complex model wins PMP > winning_criteria Returns columns: log_marg_lik, PMP","code":""},{"path":"https://sor16.github.io/bdrc/reference/evaluate_comparison.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Compare two models using a specified model-selection criteria — evaluate_comparison","text":"Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/gather_draws.html","id":null,"dir":"Reference","previous_headings":"","what":"Gather MCMC chain draws to data.frame on a long format — gather_draws","title":"Gather MCMC chain draws to data.frame on a long format — gather_draws","text":"Useful convert MCMC chain draws particular parameters output model object long format data wrangling","code":""},{"path":"https://sor16.github.io/bdrc/reference/gather_draws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Gather MCMC chain draws to data.frame on a long format — gather_draws","text":"","code":"gather_draws(mod, ..., transformed = F)"},{"path":"https://sor16.github.io/bdrc/reference/gather_draws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Gather MCMC chain draws to data.frame on a long format — gather_draws","text":"mod object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". ... number character vectors containing valid names parameters model \"rating_curve\" \"rating_curve_mean\". Also accepts \"latent_parameters\" \"hyperparameters\". transformed boolean value determining whether parameter represented transformed scale used sampling MCMC chain original scale. Defaults FALSE.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gather_draws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Gather MCMC chain draws to data.frame on a long format — gather_draws","text":"data frame columns: chain chain number. iter iteration number. param parameter name. value parameter value.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gather_draws.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Gather MCMC chain draws to data.frame on a long format — gather_draws","text":"Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/gather_draws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Gather MCMC chain draws to data.frame on a long format — gather_draws","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.09%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). hyp_samples <- gather_draws(plm0.fit,'hyperparameters') head(hyp_samples) #> chain iter name value #> 1 1 1 c 7.693275 #> 2 1 2 c 7.708797 #> 3 1 3 c 7.704167 #> 4 1 4 c 7.666575 #> 5 1 5 c 7.658464 #> 6 1 6 c 7.709366 rating_curve_samples <- gather_draws(plm0.fit,'rating_curve','rating_curve_mean') head(rating_curve_samples) #> chain iter h name value #> 1 1 1 7.673811 rating_curve 0.000000e+00 #> 2 1 2 7.673811 rating_curve 0.000000e+00 #> 3 1 3 7.673811 rating_curve 0.000000e+00 #> 4 1 4 7.673811 rating_curve 1.094841e-06 #> 5 1 5 7.673811 rating_curve 6.537614e-06 #> 6 1 6 7.673811 rating_curve 0.000000e+00 # }"},{"path":"https://sor16.github.io/bdrc/reference/get_report.html","id":null,"dir":"Reference","previous_headings":"","what":"Report for a discharge rating curve or tournament — get_report","title":"Report for a discharge rating curve or tournament — get_report","text":"Save pdf file report discharge rating curve object tournament.","code":""},{"path":"https://sor16.github.io/bdrc/reference/get_report.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Report for a discharge rating curve or tournament — get_report","text":"","code":"get_report(x, path = NULL, type = 1, ...) # S3 method for class 'plm0' get_report(x, path = NULL, type = 1, ...) # S3 method for class 'plm' get_report(x, path = NULL, type = 1, ...) # S3 method for class 'gplm0' get_report(x, path = NULL, type = 1, ...) # S3 method for class 'gplm' get_report(x, path = NULL, type = 1, ...) # S3 method for class 'tournament' get_report(x, path = NULL, type = 1, ...)"},{"path":"https://sor16.github.io/bdrc/reference/get_report.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Report for a discharge rating curve or tournament — get_report","text":"x object class \"tournament\", \"plm0\", \"plm\", \"gplm0\" \"gplm\". path file path pdf file report saved. NULL, current working directory used. type integer denoting type report produced. Defaults type 1. type 1 permissible object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". Possible types : 1 Produces report displaying results model (winning model tournament provided). first page contains panel four plots summary posterior distributions parameters. second page tabular prediction discharge equally spaced grid stages displayed. prediction table can span multiple pages. 2 Produces ten page report permissible objects class \"tournament\". first four pages contain panel four plots summary posterior distributions parameters four models tournament, fifth page shows summary tournament model comparison, sixth page convergence diagnostics plots, final four pages shows histograms parameters four models. ... arguments passed methods (currently unused).","code":""},{"path":"https://sor16.github.io/bdrc/reference/get_report.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Report for a discharge rating curve or tournament — get_report","text":"return value, called side effects.","code":""},{"path":"https://sor16.github.io/bdrc/reference/get_report.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Report for a discharge rating curve or tournament — get_report","text":"function can used interactive R session asks permission user write file system.","code":""},{"path":"https://sor16.github.io/bdrc/reference/get_report.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Report for a discharge rating curve or tournament — get_report","text":"get_report(plm0): Get report plm0 model object get_report(plm): Get report plm model object get_report(gplm0): Get report gplm0 model object get_report(gplm): Get report gplm get_report(tournament): Get report discharge rating curve tournament","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/get_report.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Report for a discharge rating curve or tournament — get_report","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.09%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). # } if (FALSE) { # \\dontrun{ get_report(plm0.fit) } # }"},{"path":"https://sor16.github.io/bdrc/reference/get_report_pages.html","id":null,"dir":"Reference","previous_headings":"","what":"Report pages for a discharge rating curve or tournament — get_report_pages","title":"Report pages for a discharge rating curve or tournament — get_report_pages","text":"Get list pages report discharge rating curve model tournament","code":""},{"path":"https://sor16.github.io/bdrc/reference/get_report_pages.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Report pages for a discharge rating curve or tournament — get_report_pages","text":"","code":"get_report_pages(x, type = 1) # S3 method for class 'plm0' get_report_pages(x, type = 1) # S3 method for class 'plm' get_report_pages(x, type = 1) # S3 method for class 'gplm0' get_report_pages(x, type = 1) # S3 method for class 'gplm' get_report_pages(x, type = 1) # S3 method for class 'tournament' get_report_pages(x, type = 1)"},{"path":"https://sor16.github.io/bdrc/reference/get_report_pages.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Report pages for a discharge rating curve or tournament — get_report_pages","text":"x object class \"tournament\", \"plm0\", \"plm\", \"gplm0\" \"gplm\". type integer denoting type report produced. Defaults type 1. Possible types : 1 Produces report displaying results model (winning model tournament provided). first page contains panel four plots summary posterior distributions parameters. second page tabular prediction discharge equally spaced grid stages displayed. prediction table can span multiple pages. 2 Produces ten page report permissible objects class \"tournament\". first four pages contain panel four plots summary posterior distributions parameters four models tournament, fifth page shows summary tournament model comparison, sixth page convergence diagnostics plots, final four pages shows histograms parameters four models.","code":""},{"path":"https://sor16.github.io/bdrc/reference/get_report_pages.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Report pages for a discharge rating curve or tournament — get_report_pages","text":"list objects type \"grob\" correspond pages rating curve report.","code":""},{"path":"https://sor16.github.io/bdrc/reference/get_report_pages.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Report pages for a discharge rating curve or tournament — get_report_pages","text":"get_report_pages(plm0): Get report pages plm0 model object get_report_pages(plm): Get report pages plm model object get_report_pages(gplm0): Get report pages gplm0 model object get_report_pages(gplm): Get report pages gplm model object get_report_pages(tournament): Get report pages discharge rating curve tournament model object","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/get_report_pages.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Report pages for a discharge rating curve or tournament — get_report_pages","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.09%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). plm0_pages <- get_report_pages(plm0.fit) # }"},{"path":"https://sor16.github.io/bdrc/reference/gplm.html","id":null,"dir":"Reference","previous_headings":"","what":"Generalized power-law model with variance that varies with stage. — gplm","title":"Generalized power-law model with variance that varies with stage. — gplm","text":"gplm used fit discharge rating curve paired measurements stage discharge using generalized power-law model variance varies stage described Hrafnkelsson et al. (2022). See \"Details\" elaborate description model.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generalized power-law model with variance that varies with stage. — gplm","text":"","code":"gplm( formula, data, c_param = NULL, h_max = NULL, parallel = TRUE, num_cores = NULL, forcepoint = rep(FALSE, nrow(data)), verbose = TRUE )"},{"path":"https://sor16.github.io/bdrc/reference/gplm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generalized power-law model with variance that varies with stage. — gplm","text":"formula object class \"formula\", discharge column name response stage column name covariate, .e. form y~x y discharge m\\(^3/\\)s x stage m (important data correct units). data data.frame containing variables specified formula. c_param largest stage value zero discharge. NULL, treated unknown model inferred data. h_max maximum stage rating curve extrapolate . NULL, maximum stage value data selected upper bound. parallel logical value indicating whether run MCMC parallel . Defaults TRUE. num_cores integer 1 4 (number MCMC chains) indicating many cores use. used parallel=TRUE. NULL, number cores available device detected automatically. forcepoint logical vector length number rows data. element index \\(\\) TRUE indicates rating curve forced \\(\\)-th measurement. Use care, strongly influence resulting rating curve. verbose logical value indicating whether print progress diagnostic information. `TRUE`, function print messages runs. `FALSE`, function run silently. Default `TRUE`.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generalized power-law model with variance that varies with stage. — gplm","text":"gplm returns object class \"gplm\". object class \"gplm\" list containing following components: rating_curve data frame 2.5%, 50% 97.5% percentiles posterior predictive distribution rating curve. rating_curve_mean data frame 2.5%, 50% 97.5% percentiles posterior distribution mean rating curve. param_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution latent- hyperparameters. Additionally contains columns r_hat effective number samples parameter defined Gelman et al. (2013). f_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution \\(f(h)\\). beta_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution \\(\\beta(h)\\). sigma_eps_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution \\(\\sigma_\\varepsilon(h)\\). posterior_log_likelihood_summary data frame 2.5%, 50% 97.5% percentiles posterior log-likelihood values. rating_curve_posterior matrix containing full thinned posterior samples posterior predictive distribution rating curve excluding burn-samples. rating_curve_mean_posterior matrix containing full thinned posterior samples posterior distribution mean rating curve excluding burn-samples. a_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\) excluding burn-samples. b_posterior numeric vector containing full thinned posterior samples posterior distribution \\(b\\) excluding burn-samples. c_posterior numeric vector containing full thinned posterior samples posterior distribution \\(c\\) excluding burn-samples. sigma_beta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_\\beta\\) excluding burn-samples. phi_beta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\phi_\\beta\\) excluding burn-samples. sigma_eta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_\\eta\\) excluding burn-samples. eta_1_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_1\\) excluding burn-samples. eta_2_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_2\\) excluding burn-samples. eta_3_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_3\\) excluding burn-samples. eta_4_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_4\\) excluding burn-samples. eta_5_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_5\\) excluding burn-samples. eta_6_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_6\\) excluding burn-samples. f_posterior numeric vector containing full thinned posterior samples posterior distribution \\(f(h)\\) excluding burn-samples. beta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\beta(h)\\) excluding burn-samples. sigma_eps_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_\\varepsilon(h)\\) excluding burn-samples. posterior_log_likelihood numeric vector containing full thinned posterior log-likelihood values, excluding burn-samples. D_hat statistic defined -2 times log-likelihood evaluated median value parameters. effective_num_param_DIC effective number parameters, calculated median(-2*posterior_log_likelihood) minus D_hat. DIC Deviance Information Criterion model, calculated D_hat plus 2*effective_num_parameters_DIC. lppd log pointwise predictive density observed data model. WAIC Widely Applicable Information Criterion model, defined -2*( lppd - effective_num_param_WAIC ). WAIC_i pointwise WAIC values, WAIC := sum(WAIC_i). effective_num_param_WAIC effective number parameters, calculated summing posterior variance log predictive density data point. autocorrelation data frame autocorrelation parameter different lags. acceptance_rate proportion accepted samples thinned MCMC chain (excluding burn-). formula object type \"formula\" provided user. data data provided user, ordered stage. run_info information input arguments specific parameters used MCMC chain.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Generalized power-law model with variance that varies with stage. — gplm","text":"generalized power-law model form $$Q=(h-c)^{f(h)}$$ \\(Q\\) discharge, \\(h\\) stage, \\(\\) \\(c\\) unknown constants \\(f\\) function \\(h\\), referred generalized power-law exponent. generalized power-law model inferred using Bayesian hierarchical model. function \\(f\\) modeled latent level fixed constant \\(b\\) plus continuous stochastic process, \\(\\beta(h)\\), assumed twice differentiable. model logarithmic scale $$\\log(Q_i) = \\log() + (b + \\beta(h_i)) \\log(h_i - c) + \\varepsilon_i, = 1,...,n$$ \\(\\varepsilon_i\\) follows normal distribution mean zero variance \\(\\sigma_\\varepsilon(h_i)^2\\) varies stage. stochastic process \\(\\beta(h)\\) assumed priori Gaussian process governed Matern covariance function smoothness parameter \\(\\nu = 2.5\\). error variance, \\(\\sigma_\\varepsilon^2(h)\\), log-discharge data modeled exponential B-spline curve, , linear combination six B-spline basis functions defined range stage observations. efficient posterior simulation achieved sampling joint posterior density hyperparameters model, sampling density latent parameters conditional hyperparameters. Bayesian inference based posterior density summary statistics posterior mean 95% posterior intervals based posterior density. Analytical formulas summary statistics intractable cases thus computed generating samples posterior density using Markov chain Monte Carlo simulation.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Generalized power-law model with variance that varies with stage. — gplm","text":"Gelman, ., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, ., Rubin, D. B. (2013). Bayesian Data Analysis, Third Edition. Chapman & Hall/CRC Texts Statistical Science. Taylor & Francis. doi: https://doi.org/10.1201/b16018 Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711 Spiegelhalter, D., Best, N., Carlin, B., Van Der Linde, . (2002). Bayesian measures model complexity fit. Journal Royal Statistical Society: Series B (Statistical Methodology) 64(4), 583–639. doi: https://doi.org/10.1111/1467-9868.00353 Watanabe, S. (2010). Asymptotic equivalence Bayes cross validation widely applicable information criterion singular learning theory. J. Mach. Learn. Res. 11, 3571–3594.","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/gplm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generalized power-law model with variance that varies with stage. — gplm","text":"","code":"# \\donttest{ data(norn) set.seed(1) gplm.fit <- gplm(formula=Q~W,data=norn,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 22.81%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). summary(gplm.fit) #> #> Formula: #> Q ~ W #> Latent parameters: #> lower-2.5% median-50% upper-97.5% #> a 13.40 24.55 32.51 #> b 1.83 1.84 1.84 #> #> Hyperparameters: #> lower-2.5% median-50% upper-97.5% #> c 396.421 396.669 396.812 #> sigma_beta 0.165 0.338 0.806 #> phi_beta 1.343 2.987 6.894 #> sigma_eta 0.048 0.436 0.897 #> eta_1 -6.128 -5.395 -4.399 #> eta_2 -7.692 -5.974 -4.521 #> eta_3 -9.093 -7.048 -5.072 #> eta_4 -10.429 -8.051 -5.135 #> eta_5 -11.473 -8.717 -5.092 #> eta_6 -12.436 -9.279 -5.095 #> #> WAIC: -141.1422 # }"},{"path":"https://sor16.github.io/bdrc/reference/gplm0.html","id":null,"dir":"Reference","previous_headings":"","what":"Generalized power-law model with a constant variance — gplm0","title":"Generalized power-law model with a constant variance — gplm0","text":"gplm0 used fit discharge rating curve paired measurements stage discharge using generalized power-law model constant variance described Hrafnkelsson et al. (2022). See \"Details\" elaborate description model.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm0.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generalized power-law model with a constant variance — gplm0","text":"","code":"gplm0( formula, data, c_param = NULL, h_max = NULL, parallel = TRUE, num_cores = NULL, forcepoint = rep(FALSE, nrow(data)), verbose = TRUE )"},{"path":"https://sor16.github.io/bdrc/reference/gplm0.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generalized power-law model with a constant variance — gplm0","text":"formula object class \"formula\", discharge column name response stage column name covariate, .e. form y~x y discharge m\\(^3/\\)s x stage m (important data correct units). data data.frame containing variables specified formula. c_param largest stage value zero discharge. NULL, treated unknown model inferred data. h_max maximum stage rating curve extrapolate . NULL, maximum stage value data selected upper bound. parallel logical value indicating whether run MCMC parallel . Defaults TRUE. num_cores integer 1 4 (number MCMC chains) indicating many cores use. used parallel=TRUE. NULL, number cores available device detected automatically. forcepoint logical vector length number rows data. element index \\(\\) TRUE indicates rating curve forced \\(\\)-th measurement. Use care, strongly influence resulting rating curve. verbose logical value indicating whether print progress diagnostic information. `TRUE`, function print messages runs. `FALSE`, function run silently. Default `TRUE`.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm0.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generalized power-law model with a constant variance — gplm0","text":"gplm0 returns object class \"gplm0\". object class \"gplm0\" list containing following components: rating_curve data frame 2.5%, 50% 97.5% percentiles posterior predictive distribution rating curve. rating_curve_mean data frame 2.5%, 50% 97.5% percentiles posterior distribution mean rating curve. param_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution latent- hyperparameters. Additionally contains columns r_hat effective number samples parameter defined Gelman et al. (2013). beta_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution \\(\\beta\\). posterior_log_likelihood_summary data frame 2.5%, 50% 97.5% percentiles posterior log-likelihood values. rating_curve_posterior matrix containing full thinned posterior samples posterior predictive distribution rating curve (excluding burn-). rating_curve_mean_posterior matrix containing full thinned posterior samples posterior distribution mean rating curve (excluding burn-). a_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\). b_posterior numeric vector containing full thinned posterior samples posterior distribution \\(b\\). c_posterior numeric vector containing full thinned posterior samples posterior distribution \\(c\\). sigma_eps_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_{\\varepsilon}\\). sigma_beta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_{\\beta}\\). phi_beta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\phi_{\\beta}\\). sigma_eta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_{\\eta}\\). beta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\beta\\). posterior_log_likelihood numeric vector containing full thinned posterior log-likelihood values, excluding burn-samples. D_hat statistic defined -2 times log-likelihood evaluated median value parameters. effective_num_param_DIC effective number parameters, calculated median(-2*posterior_log_likelihood) minus D_hat. DIC Deviance Information Criterion model, calculated D_hat plus 2*effective_num_parameters_DIC. lppd log pointwise predictive density observed data model. WAIC Widely Applicable Information Criterion model, defined -2*( lppd - effective_num_param_WAIC ). WAIC_i pointwise WAIC values, WAIC := sum(WAIC_i). effective_num_param_WAIC effective number parameters, calculated summing posterior variance log predictive density data point. autocorrelation data frame autocorrelation parameter different lags. acceptance_rate proportion accepted samples thinned MCMC chain (excluding burn-). formula object type \"formula\" provided user. data data provided user, ordered stage. run_info information input arguments specific parameters used MCMC chain.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm0.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Generalized power-law model with a constant variance — gplm0","text":"generalized power-law model form $$Q=(h-c)^{f(h)}$$ \\(Q\\) discharge, \\(h\\) stage, \\(\\) \\(c\\) unknown constants \\(f\\) function \\(h\\) referred generalized power-law exponent. generalized power-law model inferred using Bayesian hierarchical model. function \\(f\\) modeled latent level fixed constant $b$ plus continuous stochastic process,\\(\\beta(h)\\), assumed twice differentiable. model logarithmic scale $$\\log(Q_i) = \\log() + (b + \\beta(h_i)) \\log(h_i - c) + \\varepsilon, = 1,...,n$$ \\(\\varepsilon\\) follows normal distribution mean zero variance \\(\\sigma_\\varepsilon^2\\), independent stage. stochastic process \\(\\beta(h)\\) assumed priori Gaussian process governed Matern covariance function smoothness parameter \\(\\nu = 2.5\\). efficient posterior simulation achieved sampling joint posterior density hyperparameters model, sampling density latent parameters conditional hyperparameters. Bayesian inference based posterior density summary statistics posterior mean 95% posterior intervals based posterior density. Analytical formulas summary statistics intractable cases thus computed generating samples posterior density using Markov chain Monte Carlo simulation.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm0.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Generalized power-law model with a constant variance — gplm0","text":"Gelman, ., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, ., Rubin, D. B. (2013). Bayesian Data Analysis, Third Edition. Chapman & Hall/CRC Texts Statistical Science. Taylor & Francis. doi: https://doi.org/10.1201/b16018 Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711 Spiegelhalter, D., Best, N., Carlin, B., Van Der Linde, . (2002). Bayesian measures model complexity fit. Journal Royal Statistical Society: Series B (Statistical Methodology) 64(4), 583–639. doi: https://doi.org/10.1111/1467-9868.00353 Watanabe, S. (2010). Asymptotic equivalence Bayes cross validation widely applicable information criterion singular learning theory. J. Mach. Learn. Res. 11, 3571–3594.","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/gplm0.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generalized power-law model with a constant variance — gplm0","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) gplm0.fit <- gplm0(formula=Q~W,data=krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.64%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). summary(gplm0.fit) #> #> Formula: #> Q ~ W #> Latent parameters: #> lower-2.5% median-50% upper-97.5% #> a 1.52 1.95 2.24 #> b 1.83 1.84 1.84 #> #> Hyperparameters: #> lower-2.5% median-50% upper-97.5% #> c 7.7158 7.810 7.855 #> sigma_eps 0.0915 0.119 0.163 #> sigma_beta 0.6492 0.836 1.127 #> phi_beta 0.5724 1.207 2.965 #> #> WAIC: -27.34769 # }"},{"path":"https://sor16.github.io/bdrc/reference/jokdal.html","id":null,"dir":"Reference","previous_headings":"","what":"Jokulsa a Dal gauging station in Iceland — jokdal","title":"Jokulsa a Dal gauging station in Iceland — jokdal","text":"Data discharge stage Jokulsa Dal gauging station Iceland","code":""},{"path":"https://sor16.github.io/bdrc/reference/jokdal.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Jokulsa a Dal gauging station in Iceland — jokdal","text":"","code":"jokdal"},{"path":"https://sor16.github.io/bdrc/reference/jokdal.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Jokulsa a Dal gauging station in Iceland — jokdal","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/jokdal.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Jokulsa a Dal gauging station in Iceland — jokdal","text":"Icelandic Meteorological Office, Landsvirkjun - National Power Company Iceland, Icelandic Road Coastal Administration.","code":""},{"path":"https://sor16.github.io/bdrc/reference/jokfjoll.html","id":null,"dir":"Reference","previous_headings":"","what":"Jokulsa a Fjollum gauging station in Iceland — jokfjoll","title":"Jokulsa a Fjollum gauging station in Iceland — jokfjoll","text":"Data discharge stage Jokulsa Fjollum gauging station Iceland","code":""},{"path":"https://sor16.github.io/bdrc/reference/jokfjoll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Jokulsa a Fjollum gauging station in Iceland — jokfjoll","text":"","code":"jokfjoll"},{"path":"https://sor16.github.io/bdrc/reference/jokfjoll.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Jokulsa a Fjollum gauging station in Iceland — jokfjoll","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/jokfjoll.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Jokulsa a Fjollum gauging station in Iceland — jokfjoll","text":"Icelandic Meteorological Office, Landsvirkjun - National Power Company Iceland, Icelandic Road Coastal Administration.","code":""},{"path":"https://sor16.github.io/bdrc/reference/kallstorp.html","id":null,"dir":"Reference","previous_headings":"","what":"Kallstorp gauging station in Sweden — kallstorp","title":"Kallstorp gauging station in Sweden — kallstorp","text":"Data discharge stage Kallstorp gauging station Sweden","code":""},{"path":"https://sor16.github.io/bdrc/reference/kallstorp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Kallstorp gauging station in Sweden — kallstorp","text":"","code":"kallstorp"},{"path":"https://sor16.github.io/bdrc/reference/kallstorp.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Kallstorp gauging station in Sweden — kallstorp","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/kallstorp.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Kallstorp gauging station in Sweden — kallstorp","text":"Swedish Meteorological Hydrological Institute.","code":""},{"path":"https://sor16.github.io/bdrc/reference/krokfors.html","id":null,"dir":"Reference","previous_headings":"","what":"Krokfors gauging station in Sweden — krokfors","title":"Krokfors gauging station in Sweden — krokfors","text":"Data discharge stage Krokfors gauging station Sweden.","code":""},{"path":"https://sor16.github.io/bdrc/reference/krokfors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Krokfors gauging station in Sweden — krokfors","text":"","code":"krokfors"},{"path":"https://sor16.github.io/bdrc/reference/krokfors.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Krokfors gauging station in Sweden — krokfors","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/krokfors.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Krokfors gauging station in Sweden — krokfors","text":"Swedish Meteorological Hydrological Institute.","code":""},{"path":"https://sor16.github.io/bdrc/reference/melby.html","id":null,"dir":"Reference","previous_headings":"","what":"Melby gauging station in Sweden — melby","title":"Melby gauging station in Sweden — melby","text":"Data discharge stage Melby gauging station Sweden","code":""},{"path":"https://sor16.github.io/bdrc/reference/melby.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Melby gauging station in Sweden — melby","text":"","code":"melby"},{"path":"https://sor16.github.io/bdrc/reference/melby.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Melby gauging station in Sweden — melby","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/melby.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Melby gauging station in Sweden — melby","text":"Swedish Meteorological Hydrological Institute.","code":""},{"path":"https://sor16.github.io/bdrc/reference/nordura.html","id":null,"dir":"Reference","previous_headings":"","what":"Nordura gauging station in Iceland — nordura","title":"Nordura gauging station in Iceland — nordura","text":"Data discharge stage Nordura gauging station Iceland","code":""},{"path":"https://sor16.github.io/bdrc/reference/nordura.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Nordura gauging station in Iceland — nordura","text":"","code":"nordura"},{"path":"https://sor16.github.io/bdrc/reference/nordura.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Nordura gauging station in Iceland — nordura","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/nordura.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Nordura gauging station in Iceland — nordura","text":"Icelandic Meteorological Office, Landsvirkjun - National Power Company Iceland, Icelandic Road Coastal Administration.","code":""},{"path":"https://sor16.github.io/bdrc/reference/norn.html","id":null,"dir":"Reference","previous_headings":"","what":"Norn gauging station in Sweden — norn","title":"Norn gauging station in Sweden — norn","text":"Data discharge stage Norn gauging station Sweden.","code":""},{"path":"https://sor16.github.io/bdrc/reference/norn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Norn gauging station in Sweden — norn","text":"","code":"norn"},{"path":"https://sor16.github.io/bdrc/reference/norn.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Norn gauging station in Sweden — norn","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/norn.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Norn gauging station in Sweden — norn","text":"Swedish Meteorological Hydrological Institute.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm.html","id":null,"dir":"Reference","previous_headings":"","what":"Power-law model with variance that varies with stage. — plm","title":"Power-law model with variance that varies with stage. — plm","text":"plm used fit discharge rating curve paired measurements stage discharge using power-law model variance varies stage described Hrafnkelsson et al. (2022). See \"Details\" elaborate description model.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Power-law model with variance that varies with stage. — plm","text":"","code":"plm( formula, data, c_param = NULL, h_max = NULL, parallel = TRUE, num_cores = NULL, forcepoint = rep(FALSE, nrow(data)), verbose = TRUE )"},{"path":"https://sor16.github.io/bdrc/reference/plm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Power-law model with variance that varies with stage. — plm","text":"formula object class \"formula\", discharge column name response stage column name covariate, .e. form y~x y discharge m\\(^3/\\)s x stage m (important data correct units). data data.frame containing variables specified formula. c_param largest stage value zero discharge. NULL, treated unknown model inferred data. h_max maximum stage rating curve extrapolate . NULL, maximum stage value data selected upper bound. parallel logical value indicating whether run MCMC parallel . Defaults TRUE. num_cores integer 1 4 (number MCMC chains) indicating many cores use. used parallel=TRUE. NULL, number cores available device detected automatically. forcepoint logical vector length number rows data. element index \\(\\) TRUE indicates rating curve forced \\(\\)-th measurement. Use care, strongly influence resulting rating curve. verbose logical value indicating whether print progress diagnostic information. `TRUE`, function print messages runs. `FALSE`, function run silently. Default `TRUE`.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Power-law model with variance that varies with stage. — plm","text":"plm returns object class \"plm\". object class \"plm\" list containing following components: rating_curve data frame 2.5%, 50% 97.5% percentiles posterior predictive distribution rating curve. rating_curve_mean data frame 2.5%, 50% 97.5% percentiles posterior distribution mean rating curve. Additionally contains columns r_hat effective number samples parameter defined Gelman et al. (2013). param_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution latent- hyperparameters. sigma_eps_summary data frame 2.5%, 50% 97.5% percentiles posterior \\(\\sigma_{\\varepsilon}\\). posterior_log_likelihood_summary data frame 2.5%, 50% 97.5% percentiles posterior log-likelihood values. rating_curve_posterior matrix containing full thinned posterior samples posterior predictive distribution rating curve (excluding burn-). rating_curve_mean_posterior matrix containing full thinned posterior samples posterior distribution mean rating curve (excluding burn-). a_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\). b_posterior numeric vector containing full thinned posterior samples posterior distribution \\(b\\). c_posterior numeric vector containing full thinned posterior samples posterior distribution \\(c\\). sigma_eps_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_{\\varepsilon}\\). eta_1_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_1\\). eta_2_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_2\\). eta_3_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_3\\). eta_4_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_4\\). eta_5_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_5\\). eta_6_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_6\\). posterior_log_likelihood numeric vector containing full thinned posterior log-likelihood values, excluding burn-samples. D_hat statistic defined -2 times log-likelihood evaluated median value parameters. effective_num_param_DIC effective number parameters, calculated median(-2*posterior_log_likelihood) minus D_hat. DIC Deviance Information Criterion model, calculated D_hat plus 2*effective_num_parameters_DIC. lppd log pointwise predictive density observed data model. WAIC Widely Applicable Information Criterion model, defined -2*( lppd - effective_num_param_WAIC ). WAIC_i pointwise WAIC values, WAIC := sum(WAIC_i). effective_num_param_WAIC effective number parameters, calculated summing posterior variance log predictive density data point. autocorrelation data frame autocorrelation parameter different lags. acceptance_rate proportion accepted samples thinned MCMC chain (excluding burn-). formula object type \"formula\" provided user. data data provided user, ordered stage. run_info information input arguments specific parameters used MCMC chain.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Power-law model with variance that varies with stage. — plm","text":"power-law model, commonly used hydraulic practice, form $$Q=(h-c)^{b}$$ \\(Q\\) discharge, \\(h\\) stage \\(\\), \\(b\\) \\(c\\) unknown constants. power-law model inferred using Bayesian hierarchical model. model logarithmic scale $$\\log(Q_i) = \\log() + b \\log(h_i - c) + \\varepsilon_i, = 1,...,n$$ \\(\\varepsilon_i\\) follows normal distribution mean zero variance \\(\\sigma_\\varepsilon(h_i)^2\\) varies stage. error variance, \\(\\sigma_\\varepsilon^2(h)\\), log-discharge data modeled exponential B-spline curve, , linear combination six B-spline basis functions defined range stage observations. efficient posterior simulation achieved sampling joint posterior density hyperparameters model, sampling density latent parameters conditional hyperparameters. Bayesian inference based posterior density summary statistics posterior mean 95% posterior intervals based posterior density. Analytical formulas summary statistics intractable cases thus computed generating samples posterior density using Markov chain Monte Carlo simulation.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Power-law model with variance that varies with stage. — plm","text":"Gelman, ., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, ., Rubin, D. B. (2013). Bayesian Data Analysis, Third Edition. Chapman & Hall/CRC Texts Statistical Science. Taylor & Francis. doi: https://doi.org/10.1201/b16018 Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711 Spiegelhalter, D., Best, N., Carlin, B., Van Der Linde, . (2002). Bayesian measures model complexity fit. Journal Royal Statistical Society: Series B (Statistical Methodology) 64(4), 583–639. doi: https://doi.org/10.1111/1467-9868.00353 Watanabe, S. (2010). Asymptotic equivalence Bayes cross validation widely applicable information criterion singular learning theory. J. Mach. Learn. Res. 11, 3571–3594.","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/plm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Power-law model with variance that varies with stage. — plm","text":"","code":"# \\donttest{ data(spanga) set.seed(1) plm.fit <- plm(formula=Q~W,data=spanga,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 24.38%. #> ⚠ Warning: Some chains are not mixing well. Parameters with Rhat > 1.1: #> - sigma_eta: Rhat = 1.183 #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> ℹ Try re-running the model after inspecting the trace plots, convergence diagnostics plots, and reviewing the data for potential issues. summary(plm.fit) #> #> Formula: #> Q ~ W #> Latent parameters: #> lower-2.5% median-50% upper-97.5% #> a 11.07 12.51 13.79 #> b 1.92 2.05 2.21 #> #> Hyperparameters: #> lower-2.5% median-50% upper-97.5% #> c 9.40099 9.451 9.493 #> sigma_eta 0.00737 0.349 0.838 #> eta_1 -5.58296 -4.839 -3.778 #> eta_2 -7.61506 -5.951 -4.135 #> eta_3 -9.01113 -6.856 -3.948 #> eta_4 -9.84284 -7.299 -3.829 #> eta_5 -10.57394 -7.597 -3.569 #> eta_6 -10.96708 -7.528 -3.451 #> #> WAIC: -76.60638 # }"},{"path":"https://sor16.github.io/bdrc/reference/plm0.html","id":null,"dir":"Reference","previous_headings":"","what":"Power-law model with a constant variance — plm0","title":"Power-law model with a constant variance — plm0","text":"plm0 used fit discharge rating curve paired measurements stage discharge using power-law model constant variance described Hrafnkelsson et al. (2022). See \"Details\" elaborate description model.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm0.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Power-law model with a constant variance — plm0","text":"","code":"plm0( formula, data, c_param = NULL, h_max = NULL, parallel = TRUE, num_cores = NULL, forcepoint = rep(FALSE, nrow(data)), verbose = TRUE )"},{"path":"https://sor16.github.io/bdrc/reference/plm0.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Power-law model with a constant variance — plm0","text":"formula object class \"formula\", discharge column name response stage column name covariate, .e. form y~x y discharge m\\(^3/\\)s x stage m (important data correct units). data data.frame containing variables specified formula. c_param largest stage value zero discharge. NULL, treated unknown model inferred data. h_max maximum stage rating curve extrapolate . NULL, maximum stage value data selected upper bound. parallel logical value indicating whether run MCMC parallel . Defaults TRUE. num_cores integer 1 4 (number MCMC chains) indicating many cores use. used parallel=TRUE. NULL, number cores available device detected automatically. forcepoint logical vector length number rows data. element index \\(\\) TRUE indicates rating curve forced \\(\\)-th measurement. Use care, strongly influence resulting rating curve. verbose logical value indicating whether print progress diagnostic information. `TRUE`, function print messages runs. `FALSE`, function run silently. Default `TRUE`.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm0.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Power-law model with a constant variance — plm0","text":"plm0 returns object class \"plm0\". object class \"plm0\" list containing following components: rating_curve data frame 2.5%, 50% 97.5% percentiles posterior predictive distribution rating curve. rating_curve_mean data frame 2.5%, 50% 97.5% percentiles posterior distribution mean rating curve. param_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution latent- hyperparameters. Additionally contains columns r_hat effective number samples parameter defined Gelman et al. (2013). posterior_log_likelihood_summary data frame 2.5%, 50% 97.5% percentiles posterior log-likelihood values. rating_curve_posterior matrix containing full thinned posterior samples posterior predictive distribution rating curve (excluding burn-). rating_curve_mean_posterior matrix containing full thinned posterior samples posterior distribution mean rating curve (excluding burn-). a_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\). b_posterior numeric vector containing full thinned posterior samples posterior distribution \\(b\\). c_posterior numeric vector containing full thinned posterior samples posterior distribution \\(c\\). sigma_eps_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_{\\varepsilon}\\). posterior_log_likelihood numeric vector containing full thinned posterior log-likelihood values, excluding burn-samples. D_hat statistic defined -2 times log-likelihood evaluated median value parameters. effective_num_param_DIC effective number parameters, calculated median(-2*posterior_log_likelihood) minus D_hat. DIC Deviance Information Criterion model, calculated D_hat plus 2*effective_num_parameters_DIC. lppd log pointwise predictive density observed data model. WAIC Widely Applicable Information Criterion model, defined -2*( lppd - effective_num_param_WAIC ). WAIC_i pointwise WAIC values, WAIC := sum(WAIC_i). effective_num_param_WAIC effective number parameters, calculated summing posterior variance log predictive density data point. autocorrelation data frame autocorrelation parameter different lags. acceptance_rate proportion accepted samples thinned MCMC chain (excluding burn-). formula object type \"formula\" provided user. data data provided user, ordered stage. run_info information input arguments specific parameters used MCMC chain.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm0.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Power-law model with a constant variance — plm0","text":"power-law model, commonly used hydraulic practice, form $$Q=(h-c)^{b}$$ \\(Q\\) discharge, \\(h\\) stage \\(\\), \\(b\\) \\(c\\) unknown constants. power-law model inferred using Bayesian hierarchical model. model logarithmic scale $$\\log(Q_i) = \\log() + b \\log(h_i - c) + \\varepsilon, = 1,...,n$$ \\(\\varepsilon\\) follows normal distribution mean zero variance \\(\\sigma_\\varepsilon^2\\), independent stage. efficient posterior simulation achieved sampling joint posterior density hyperparameters model, sampling density latent parameters conditional hyperparameters. Bayesian inference based posterior density summary statistics posterior mean 95% posterior intervals based posterior density. Analytical formulas summary statistics intractable cases thus computed generating samples posterior density using Markov chain Monte Carlo simulation.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm0.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Power-law model with a constant variance — plm0","text":"Gelman, ., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, ., Rubin, D. B. (2013). Bayesian Data Analysis, Third Edition. Chapman & Hall/CRC Texts Statistical Science. Taylor & Francis. doi: https://doi.org/10.1201/b16018 Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711 Spiegelhalter, D., Best, N., Carlin, B., Van Der Linde, . (2002). Bayesian measures model complexity fit. Journal Royal Statistical Society: Series B (Statistical Methodology) 64(4), 583–639. doi: https://doi.org/10.1111/1467-9868.00353 Watanabe, S. (2010). Asymptotic equivalence Bayes cross validation widely applicable information criterion singular learning theory. J. Mach. Learn. Res. 11, 3571–3594.","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/plm0.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Power-law model with a constant variance — plm0","text":"","code":"# \\donttest{ data(skogsliden) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=skogsliden,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 37.00%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). summary(plm0.fit) #> #> Formula: #> Q ~ W #> Latent parameters: #> lower-2.5% median-50% upper-97.5% #> a 10.29 10.77 11.22 #> b 2.09 2.17 2.26 #> #> Hyperparameters: #> lower-2.5% median-50% upper-97.5% #> c 3.9042 3.9201 3.9341 #> sigma_eps 0.0455 0.0592 0.0805 #> #> WAIC: -68.50725 # }"},{"path":"https://sor16.github.io/bdrc/reference/plot.plm0.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot method for discharge rating curves — plot.plm0","title":"Plot method for discharge rating curves — plot.plm0","text":"Visualize discharge rating curve model objects","code":""},{"path":"https://sor16.github.io/bdrc/reference/plot.plm0.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot method for discharge rating curves — plot.plm0","text":"","code":"# S3 method for class 'plm0' plot( x, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... ) # S3 method for class 'plm' plot( x, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... ) # S3 method for class 'gplm0' plot( x, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... ) # S3 method for class 'gplm' plot( x, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... )"},{"path":"https://sor16.github.io/bdrc/reference/plot.plm0.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot method for discharge rating curves — plot.plm0","text":"x object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". type character denoting type plot drawn. Defaults \"rating_curve\". Possible types : rating_curve Plots rating curve. rating_curve_mean Plots posterior mean rating curve. f Plots power-law exponent. beta Plots random effect power-law exponent. sigma_eps Plots standard deviation data level. residuals Plots log residuals. trace Plots trace plots parameters given param. histogram Plots histograms parameters given param. panel Plots 2x2 panel plots: \"rating curve\", \"residuals\", \"f\" \"sigma_eps\". param character vector parameters plot. Defaults NULL used type \"trace\" \"histogram\". Allowed values parameters given model summary x well \"hyperparameters\" \"latent_parameters\" specific groups parameters. transformed logical value indicating whether quantity plotted transformed scale used Bayesian inference. Defaults FALSE. title character denoting title plot. xlim numeric vector length 2, denoting limits x axis plot. Applicable types \"rating_curve\", \"rating_curve_mean\", \"f\", \"beta\", \"sigma_eps\", \"residuals\". ylim numeric vector length 2, denoting limits y axis plot. Applicable types \"rating_curve\", \"rating_curve_mean\", \"f\", \"beta\", \"sigma_eps\", \"residuals\". ... used function","code":""},{"path":"https://sor16.github.io/bdrc/reference/plot.plm0.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot method for discharge rating curves — plot.plm0","text":"return value, called side effects.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plot.plm0.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Plot method for discharge rating curves — plot.plm0","text":"plot(plm0): Plot method plm0 plot(plm): Plot method plm plot(gplm0): Plot method gplm0 plot(gplm): Plot method gplm","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/plot.plm0.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot method for discharge rating curves — plot.plm0","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.09%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). plot(plm0.fit) plot(plm0.fit,transformed=TRUE) plot(plm0.fit,type='histogram',param='c') plot(plm0.fit,type='histogram',param='c',transformed=TRUE) plot(plm0.fit,type='histogram',param='hyperparameters') plot(plm0.fit,type='histogram',param='latent_parameters') plot(plm0.fit,type='residuals') plot(plm0.fit,type='f') plot(plm0.fit,type='sigma_eps') # }"},{"path":"https://sor16.github.io/bdrc/reference/plot.tournament.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot method for a discharge rating curve tournament — plot.tournament","title":"Plot method for a discharge rating curve tournament — plot.tournament","text":"Compare four models tournament object multiple ways","code":""},{"path":"https://sor16.github.io/bdrc/reference/plot.tournament.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot method for a discharge rating curve tournament — plot.tournament","text":"","code":"# S3 method for class 'tournament' plot(x, type = \"tournament_results\", transformed = FALSE, ...)"},{"path":"https://sor16.github.io/bdrc/reference/plot.tournament.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot method for a discharge rating curve tournament — plot.tournament","text":"x object class \"tournament\" type character denoting type plot drawn. Possible types : boxplot Creates boxplot posterior log-likelihood values, deviance scale. rating_curve Plots rating curve. rating_curve_mean Plots posterior mean rating curve. f Plots power-law exponent. sigma_eps Plots standard deviation data level. residuals Plots log residuals. tournament_results Plots diagram showing tournament results. transformed logical value indicating whether quantity plotted transformed scale used Bayesian inference. Defaults FALSE. ... used function","code":""},{"path":"https://sor16.github.io/bdrc/reference/plot.tournament.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot method for a discharge rating curve tournament — plot.tournament","text":"return value, called side effects","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/plot.tournament.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot method for a discharge rating curve tournament — plot.tournament","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) t_obj <- tournament(formula = Q ~ W, data = krokfors, num_cores = 2) #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.33%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.14%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.66%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.04%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% plot(t_obj) plot(t_obj, transformed = TRUE) plot(t_obj, type = 'boxplot') plot(t_obj, type = 'f') plot(t_obj, type = 'sigma_eps') plot(t_obj, type = 'residuals') plot(t_obj, type = 'tournament_results') # }"},{"path":"https://sor16.github.io/bdrc/reference/plot_fun.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot bdrc model objects — plot_fun","title":"Plot bdrc model objects — plot_fun","text":"Visualize results model objects bdrc, plm0, plm, gplm0, gplm","code":""},{"path":"https://sor16.github.io/bdrc/reference/plot_fun.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot bdrc model objects — plot_fun","text":"","code":"plot_fun( x, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... )"},{"path":"https://sor16.github.io/bdrc/reference/plot_fun.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot bdrc model objects — plot_fun","text":"x object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". type character denoting type plot drawn. Defaults \"rating_curve\". Possible types : rating_curve Plots rating curve. rating_curve_mean Plots posterior mean rating curve. f Plots power-law exponent. beta Plots random effect power-law exponent. sigma_eps Plots standard deviation data level. residuals Plots log residuals. trace Plots trace plots parameters given param. histogram Plots histograms parameters given param. panel Plots 2x2 panel plots: \"rating curve\", \"residuals\", \"f\" \"sigma_eps\". param character vector parameters plot. Defaults NULL used type \"trace\" \"histogram\". Allowed values parameters given model summary x well \"hyperparameters\" \"latent_parameters\" specific groups parameters. transformed logical value indicating whether quantity plotted transformed scale used Bayesian inference. Defaults FALSE. title character denoting title plot. Defaults NULL, .e. title. xlim numeric vector length 2, denoting limits x axis plot. Applicable types \"rating_curve\", \"rating_curve_mean\", \"f\", \"beta\", \"sigma_eps\", \"residuals\". ylim numeric vector length 2, denoting limits y axis plot. Applicable types \"rating_curve\", \"rating_curve_mean\", \"f\", \"beta\", \"sigma_eps\", \"residuals\".","code":""},{"path":"https://sor16.github.io/bdrc/reference/plot_fun.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot bdrc model objects — plot_fun","text":"Returns object class ggplot2.","code":""},{"path":"https://sor16.github.io/bdrc/reference/predict.plm0.html","id":null,"dir":"Reference","previous_headings":"","what":"Predict method for discharge rating curves — predict.plm0","title":"Predict method for discharge rating curves — predict.plm0","text":"Predict discharge given stage values based discharge rating curve model object.","code":""},{"path":"https://sor16.github.io/bdrc/reference/predict.plm0.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predict method for discharge rating curves — predict.plm0","text":"","code":"# S3 method for class 'plm0' predict(object, newdata = NULL, wide = FALSE, ...) # S3 method for class 'plm' predict(object, newdata = NULL, wide = FALSE, ...) # S3 method for class 'gplm0' predict(object, newdata = NULL, wide = FALSE, ...) # S3 method for class 'gplm' predict(object, newdata = NULL, wide = FALSE, ...)"},{"path":"https://sor16.github.io/bdrc/reference/predict.plm0.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predict method for discharge rating curves — predict.plm0","text":"object object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". newdata numeric vector stage values predict. omitted, stage values data used. wide logical value denoting whether produce wide prediction output. TRUE, output table median prediction values equally spaced grid stages 1 cm increments, row containing predictions decimeter range stages. ... used function","code":""},{"path":"https://sor16.github.io/bdrc/reference/predict.plm0.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Predict method for discharge rating curves — predict.plm0","text":"object class \"data.frame\" four columns: h stage. lower 2.5% posterior predictive quantile. median 50% posterior predictive quantile. upper 97.5% posterior predictive quantile. wide=TRUE, matrix described (see wide parameter) returned.","code":""},{"path":"https://sor16.github.io/bdrc/reference/predict.plm0.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Predict method for discharge rating curves — predict.plm0","text":"predict(plm0): Predict method plm0 predict(plm): Predict method plm predict(gplm0): Predict method gplm0 predict(gplm): Predict method gplm","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/predict.plm0.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Predict method for discharge rating curves — predict.plm0","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=krokfors,h_max=10,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.22%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #predict rating curve on a equally 10 cm spaced grid from 9 to 10 meters predict(plm0.fit,newdata=seq(9,10,by=0.1)) #> h lower median upper #> 1 9.0 2.423761 3.617127 5.355104 #> 2 9.1 2.988084 4.448245 6.528722 #> 3 9.2 3.616549 5.374700 7.940233 #> 4 9.3 4.291666 6.418404 9.515431 #> 5 9.4 5.056743 7.601828 11.323903 #> 6 9.5 5.914344 8.919305 13.169163 #> 7 9.6 6.893257 10.380845 15.570683 #> 8 9.7 7.860588 11.974804 17.826516 #> 9 9.8 9.052186 13.709759 20.592950 #> 10 9.9 10.158058 15.660659 23.351463 #> 11 10.0 11.489777 17.692248 26.874426 # }"},{"path":"https://sor16.github.io/bdrc/reference/print.plm0.html","id":null,"dir":"Reference","previous_headings":"","what":"Print method for discharge rating curves — print.plm0","title":"Print method for discharge rating curves — print.plm0","text":"Print discharge rating curve model object","code":""},{"path":"https://sor16.github.io/bdrc/reference/print.plm0.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Print method for discharge rating curves — print.plm0","text":"","code":"# S3 method for class 'plm0' print(x, ...) # S3 method for class 'plm' print(x, ...) # S3 method for class 'gplm0' print(x, ...) # S3 method for class 'gplm' print(x, ...)"},{"path":"https://sor16.github.io/bdrc/reference/print.plm0.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Print method for discharge rating curves — print.plm0","text":"x object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". ... used function","code":""},{"path":"https://sor16.github.io/bdrc/reference/print.plm0.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Print method for discharge rating curves — print.plm0","text":"print(plm0): Print method plm0 print(plm): Print method plm print(gplm0): Print method gplm0 print(gplm): Print method gplm","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/print.tournament.html","id":null,"dir":"Reference","previous_headings":"","what":"Print method for discharge rating curve tournament — print.tournament","title":"Print method for discharge rating curve tournament — print.tournament","text":"Print results tournament discharge rating curve model comparisons","code":""},{"path":"https://sor16.github.io/bdrc/reference/print.tournament.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Print method for discharge rating curve tournament — print.tournament","text":"","code":"# S3 method for class 'tournament' print(x, ...)"},{"path":"https://sor16.github.io/bdrc/reference/print.tournament.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Print method for discharge rating curve tournament — print.tournament","text":"x object class \"tournament\" ... used function","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/skjalf.html","id":null,"dir":"Reference","previous_headings":"","what":"Skjalfandafljot gauging station in Iceland — skjalf","title":"Skjalfandafljot gauging station in Iceland — skjalf","text":"Data discharge stage Skjalfandafljot gauging station Iceland","code":""},{"path":"https://sor16.github.io/bdrc/reference/skjalf.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Skjalfandafljot gauging station in Iceland — skjalf","text":"","code":"skjalf"},{"path":"https://sor16.github.io/bdrc/reference/skjalf.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Skjalfandafljot gauging station in Iceland — skjalf","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/skjalf.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Skjalfandafljot gauging station in Iceland — skjalf","text":"Icelandic Meteorological Office, Landsvirkjun - National Power Company Iceland, Icelandic Road Coastal Administration.","code":""},{"path":"https://sor16.github.io/bdrc/reference/skogsliden.html","id":null,"dir":"Reference","previous_headings":"","what":"Skogsliden gauging station in Sweden — skogsliden","title":"Skogsliden gauging station in Sweden — skogsliden","text":"Data discharge stage Skogsliden gauging station Sweden","code":""},{"path":"https://sor16.github.io/bdrc/reference/skogsliden.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Skogsliden gauging station in Sweden — skogsliden","text":"","code":"skogsliden"},{"path":"https://sor16.github.io/bdrc/reference/skogsliden.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Skogsliden gauging station in Sweden — skogsliden","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/skogsliden.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Skogsliden gauging station in Sweden — skogsliden","text":"Swedish Meteorological Hydrological Institute.","code":""},{"path":"https://sor16.github.io/bdrc/reference/spanga.html","id":null,"dir":"Reference","previous_headings":"","what":"Spanga gauging station in Sweden — spanga","title":"Spanga gauging station in Sweden — spanga","text":"Data discharge stage Spanga gauging station Sweden.","code":""},{"path":"https://sor16.github.io/bdrc/reference/spanga.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Spanga gauging station in Sweden — spanga","text":"","code":"spanga"},{"path":"https://sor16.github.io/bdrc/reference/spanga.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Spanga gauging station in Sweden — spanga","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/spanga.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Spanga gauging station in Sweden — spanga","text":"Swedish Meteorological Hydrological Institute.","code":""},{"path":"https://sor16.github.io/bdrc/reference/spread_draws.html","id":null,"dir":"Reference","previous_headings":"","what":"Spread MCMC chain draws to data.frame on a wide format — spread_draws","title":"Spread MCMC chain draws to data.frame on a wide format — spread_draws","text":"Useful convert MCMC chain draws particular parameters output model object wide format data wrangling","code":""},{"path":"https://sor16.github.io/bdrc/reference/spread_draws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Spread MCMC chain draws to data.frame on a wide format — spread_draws","text":"","code":"spread_draws(mod, ..., transformed = FALSE)"},{"path":"https://sor16.github.io/bdrc/reference/spread_draws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Spread MCMC chain draws to data.frame on a wide format — spread_draws","text":"mod object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". ... number character vectors containing valid names parameters model \"rating_curve\" \"rating_curve_mean\". Also accepts \"latent_parameters\" \"hyperparameters\". transformed boolean value determining whether output represented transformed scale used sampling MCMC chain original scale. Defaults FALSE.","code":""},{"path":"https://sor16.github.io/bdrc/reference/spread_draws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Spread MCMC chain draws to data.frame on a wide format — spread_draws","text":"data frame columns: chain chain number. iter iteration number. param parameter name. value parameter value.","code":""},{"path":"https://sor16.github.io/bdrc/reference/spread_draws.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Spread MCMC chain draws to data.frame on a wide format — spread_draws","text":"Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/spread_draws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Spread MCMC chain draws to data.frame on a wide format — spread_draws","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.09%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). hyp_samples <- spread_draws(plm0.fit,'hyperparameters') head(hyp_samples) #> chain iter c sigma_eps #> 1 1 1 7.693275 0.2421924 #> 2 1 2 7.708797 0.2256351 #> 3 1 3 7.704167 0.1679654 #> 4 1 4 7.666575 0.1807933 #> 5 1 5 7.658464 0.1570101 #> 6 1 6 7.709366 0.1968574 rating_curve_samples <- spread_draws(plm0.fit,'rating_curve','rating_curve_mean') head(rating_curve_samples) #> chain iter h rating_curve rating_curve_mean #> 1 1 1 7.673811 0.000000e+00 0.000000e+00 #> 2 1 2 7.673811 0.000000e+00 0.000000e+00 #> 3 1 3 7.673811 0.000000e+00 0.000000e+00 #> 4 1 4 7.673811 1.094841e-06 1.018866e-06 #> 5 1 5 7.673811 6.537614e-06 6.335393e-06 #> 6 1 6 7.673811 0.000000e+00 0.000000e+00 # }"},{"path":"https://sor16.github.io/bdrc/reference/summary.plm0.html","id":null,"dir":"Reference","previous_headings":"","what":"Summary method for discharge rating curves — summary.plm0","title":"Summary method for discharge rating curves — summary.plm0","text":"Summarize discharge rating curve model object","code":""},{"path":"https://sor16.github.io/bdrc/reference/summary.plm0.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summary method for discharge rating curves — summary.plm0","text":"","code":"# S3 method for class 'plm0' summary(object, ...) # S3 method for class 'plm' summary(object, ...) # S3 method for class 'gplm0' summary(object, ...) # S3 method for class 'gplm' summary(object, ...)"},{"path":"https://sor16.github.io/bdrc/reference/summary.plm0.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summary method for discharge rating curves — summary.plm0","text":"object object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". ... used function","code":""},{"path":"https://sor16.github.io/bdrc/reference/summary.plm0.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Summary method for discharge rating curves — summary.plm0","text":"summary(plm0): Summary method plm0 summary(plm): Summary method plm summary(gplm0): Summary method gplm0 summary(gplm): Summary method gplm","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/summary.plm0.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summary method for discharge rating curves — summary.plm0","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.09%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). summary(plm0.fit) #> #> Formula: #> Q ~ W #> Latent parameters: #> lower-2.5% median-50% upper-97.5% #> a 1.15 1.64 2.12 #> b 2.46 2.82 3.21 #> #> Hyperparameters: #> lower-2.5% median-50% upper-97.5% #> c 7.580 7.676 7.752 #> sigma_eps 0.151 0.191 0.253 #> #> WAIC: -2.864096 # }"},{"path":"https://sor16.github.io/bdrc/reference/summary.tournament.html","id":null,"dir":"Reference","previous_headings":"","what":"Summary method for a discharge rating curve tournament — summary.tournament","title":"Summary method for a discharge rating curve tournament — summary.tournament","text":"Print summary tournament model comparisons. function allows efficient fast re-run tournament different methods winning criteria.","code":""},{"path":"https://sor16.github.io/bdrc/reference/summary.tournament.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summary method for a discharge rating curve tournament — summary.tournament","text":"","code":"# S3 method for class 'tournament' summary(object, method = NULL, winning_criteria = NULL, ...)"},{"path":"https://sor16.github.io/bdrc/reference/summary.tournament.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summary method for a discharge rating curve tournament — summary.tournament","text":"object object class \"tournament\" method Optional; string specifying method use summary. NULL, uses method original tournament. Options \"WAIC\", \"DIC\", \"PMP\". winning_criteria Optional; specifies new winning criteria summary. NULL, uses criteria original tournament. See Details tournament proper formatting. ... used function","code":""},{"path":"https://sor16.github.io/bdrc/reference/summary.tournament.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summary method for a discharge rating curve tournament — summary.tournament","text":"Prints summary console.","code":""},{"path":"https://sor16.github.io/bdrc/reference/summary.tournament.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Summary method for a discharge rating curve tournament — summary.tournament","text":"either method winning_criteria provided, function re-runs tournament new parameters using fitted models.","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/summary.tournament.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summary method for a discharge rating curve tournament — summary.tournament","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) t_obj <- tournament(Q ~ W, krokfors, num_cores = 2) #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.33%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.14%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.66%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.04%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% summary(t_obj) #> #> === Tournament Model Comparison Summary === #> #> Method: WAIC #> Winning Criteria: Delta_WAIC > 2 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm 20.7794 6.8706 -27.8176 11.8918 0.5570 0.2416 #> less gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more plm 5.5842 4.2574 -2.6536 6.6635 -0.4066 0.1904 #> less plm0 <--- 5.6284 4.0984 -3.0601 6.6931 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 24.2005 9.1834 #> less plm0 5.6284 4.0984 -3.0601 6.6931 #> #> === End of Summary === # Re-run summary with different method summary(t_obj, method = \"DIC\") #> #> === Tournament Model Comparison Summary === #> #> Method: DIC #> Winning Criteria: Delta_DIC > 2 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------- #> complexity model winner D_hat eff_num_param DIC Delta_DIC #> more gplm -42.7732 6.0631 -30.6470 0.8498 #> less gplm0 <--- -42.4880 6.3454 -29.7972 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------- #> complexity model winner D_hat eff_num_param DIC Delta_DIC #> more plm -11.3400 2.9739 -5.3923 -0.3058 #> less plm0 <--- -11.4712 2.8865 -5.6982 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------- #> complexity model winner D_hat eff_num_param DIC Delta_DIC #> more gplm0 <--- -42.4880 6.3454 -29.7972 24.0991 #> less plm0 -11.4712 2.8865 -5.6982 #> #> === End of Summary === # Re-run summary with different winning criteria summary(t_obj, winning_criteria = \"Delta_WAIC > 3\") #> #> === Tournament Model Comparison Summary === #> #> Method: WAIC #> Winning Criteria: Delta_WAIC > 3 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm 20.7794 6.8706 -27.8176 11.8918 0.5570 0.2416 #> less gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more plm 5.5842 4.2574 -2.6536 6.6635 -0.4066 0.1904 #> less plm0 <--- 5.6284 4.0984 -3.0601 6.6931 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 24.2005 9.1834 #> less plm0 5.6284 4.0984 -3.0601 6.6931 #> #> === End of Summary === # }"},{"path":"https://sor16.github.io/bdrc/reference/theme_bdrc.html","id":null,"dir":"Reference","previous_headings":"","what":"Custom bdrc theme — theme_bdrc","title":"Custom bdrc theme — theme_bdrc","text":"Custom bdrc theme","code":""},{"path":"https://sor16.github.io/bdrc/reference/theme_bdrc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Custom bdrc theme — theme_bdrc","text":"","code":"theme_bdrc(scaling = 1, ...)"},{"path":"https://sor16.github.io/bdrc/reference/theme_bdrc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Custom bdrc theme — theme_bdrc","text":"scaling numerical value can used scale size text titles plot uses theme_bdrc. Defaults 1. ... used function","code":""},{"path":"https://sor16.github.io/bdrc/reference/theme_bdrc.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Custom bdrc theme — theme_bdrc","text":"returns theme object package","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament.html","id":null,"dir":"Reference","previous_headings":"","what":"Tournament - Model comparison — tournament","title":"Tournament - Model comparison — tournament","text":"tournament compares four rating curve models different complexities determines model provides best fit data hand.","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tournament - Model comparison — tournament","text":"","code":"tournament( formula = NULL, data = NULL, model_list = NULL, method = \"WAIC\", winning_criteria = NULL, verbose = TRUE, ... )"},{"path":"https://sor16.github.io/bdrc/reference/tournament.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tournament - Model comparison — tournament","text":"formula object class \"formula\", discharge column name response stage column name covariate. data data.frame containing variables specified formula. model_list list exactly four model objects types \"plm0\",\"plm\",\"gplm0\" \"gplm\" used tournament. Note model objects required run data c_param. method string specifying method used estimate predictive performance models. allowed methods \"WAIC\", \"DIC\" \"PMP\". winning_criteria Specifies criteria model selection. \"WAIC\", can numeric value string expression. \"DIC\", must numeric value. \"PMP\", must numeric value 0 1. See Details section. verbose logical value indicating whether print progress diagnostic information. `TRUE`, function print messages runs. `FALSE`, function run silently. Default `TRUE`. ... Optional arguments passed model functions.","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tournament - Model comparison — tournament","text":"object type \"tournament\" following elements: contestants model objects types \"plm0\", \"plm\", \"gplm0\" \"gplm\" compared. winner model object tournament winner. info specifics tournament; overall winner; method used; winning criteria. summary data frame information results different comparisons power-law tournament. contents data frame depend method used: methods: round: tournament round comparison: comparison number complexity: Indicates whether model \"\" \"less\" complex model comparison model: model type winner: Logical value indicating model selected corresponding comparison Additional columns method \"WAIC\": lppd: Log pointwise predictive density eff_num_param: Effective number parameters (WAIC) WAIC: Widely Applicable Information Criterion SE_WAIC: Standard error WAIC Delta_WAIC: Difference WAIC SE_Delta_WAIC: Standard error difference WAIC Additional columns method \"DIC\": D_hat: Minus two times log-likelihood evaluated median posterior samples eff_num_param: Effective number parameters (DIC) DIC: Deviance Information Criterion Delta_DIC: Difference DIC Additional columns method \"PMP\": log_marg_lik: Logarithm marginal likelihood estimated, computed harmonic-mean estimator PMP: Posterior model probability computed Bayes factor","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tournament - Model comparison — tournament","text":"Tournament model comparison method uses WAIC (default method) estimate expected prediction error four models select appropriate model given data. first round model comparisons sets model types, \"gplm\" vs. \"gplm0\" \"plm\" vs. \"plm0\". two comparisons conducted WAIC complex model (\"gplm\" \"plm\", respectively) smaller WAIC simpler models (\"gplm0\" \"plm0\", respectively) input argument called winning_criteria (default value = 2), chosen appropriate model. , simpler model chosen. appropriate models move second round compared way. winner second round chosen overall tournament winner deemed appropriate model given data. default method \"WAIC\", Widely Applicable Information Criterion (see Watanabe (2010)), used estimate predictive performance models. method fully Bayesian method uses full set posterior draws estimate expected log pointwise predictive density. Method \"DIC\", Deviance Information Criterion (see Spiegelhalter (2002)), similar \"WAIC\" instead using full set posterior draws compute estimate expected log pointwise predictive density, uses point estimate posterior distribution. Method \"PMP\" uses posterior model probabilities, calculated Bayes factor (see Jeffreys (1961) Kass Raftery (1995)), compare models, models assumed priori equally likely. method chosen default method Bayes factor calculations can quite unstable. method \"WAIC\" used, winning_criteria can either numeric value string expression. numeric, sets threshold complex model must exceed declared appropriate model. string, must valid R expression using Delta_WAIC /SE_Delta_WAIC (e.g., \"Delta_WAIC > 2 & Delta_WAIC - SE_Delta_WAIC > 0\"). method \"DIC\", winning_criteria must numeric value. method \"PMP\", winning criteria numeric value 0 1 (default value = 0.75). sets threshold value posterior probability complex model, given data, model comparison must exceed declared appropriate model. cases, default values selected give less complex models slight advantage, give less consistent results applying tournament real world data.","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Tournament - Model comparison — tournament","text":"Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711 Jeffreys, H. (1961). Theory Probability, Third Edition. Oxford University Press. Kass, R., . Raftery, . (1995). Bayes Factors. Journal American Statistical Association, 90, 773-795. doi: https://doi.org/10.1080/01621459.1995.10476572 Spiegelhalter, D., Best, N., Carlin, B., Van Der Linde, . (2002). Bayesian measures model complexity fit. Journal Royal Statistical Society: Series B (Statistical Methodology) 64(4), 583–639. doi: https://doi.org/10.1111/1467-9868.00353 Watanabe, S. (2010). Asymptotic equivalence Bayes cross validation widely applicable information criterion singular learning theory. J. Mach. Learn. Res. 11, 3571–3594.","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/tournament.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tournament - Model comparison — tournament","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) t_obj <- tournament(formula = Q ~ W, data = krokfors, num_cores = 2) #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.33%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.14%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.66%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.04%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% t_obj #> Tournament winner: gplm0 summary(t_obj) #> #> === Tournament Model Comparison Summary === #> #> Method: WAIC #> Winning Criteria: Delta_WAIC > 2 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm 20.7794 6.8706 -27.8176 11.8918 0.5570 0.2416 #> less gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more plm 5.5842 4.2574 -2.6536 6.6635 -0.4066 0.1904 #> less plm0 <--- 5.6284 4.0984 -3.0601 6.6931 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 24.2005 9.1834 #> less plm0 5.6284 4.0984 -3.0601 6.6931 #> #> === End of Summary === # Using different methods and winning criteria t_obj_dic <- tournament(Q ~ W, krokfors, num_cores = 2, method = \"DIC\", winning_criteria = 3) #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 24.81%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.42%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 26.60%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.02%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% t_obj_pmp <- tournament(Q ~ W, krokfors, num_cores = 2, method = \"PMP\", winning_criteria = 0.8) #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.10%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.05%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.47%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 35.76%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% #> ⚠ Warning: The Harmonic Mean Estimator (HME) is used to estimate the Bayes Factor for the posterior model probability (PMP), which is known to be unstable and potentially unreliable. We recommend using method \"WAIC\" (Widely Applicable Information Criterion) for model comparison instead. t_obj_waic_expr <- tournament(Q ~ W, krokfors, num_cores = 2, winning_criteria = \"Delta_WAIC > 2 & Delta_WAIC - SE_Delta_WAIC > 0\") #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.78%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.19%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.85%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 35.55%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% # }"},{"path":"https://sor16.github.io/bdrc/reference/tournament_summary_output.html","id":null,"dir":"Reference","previous_headings":"","what":"Internal function to generate a summary output for a discharge rating curve tournament — tournament_summary_output","title":"Internal function to generate a summary output for a discharge rating curve tournament — tournament_summary_output","text":"function takes summary results tournament object produces formatted console output displaying results model comparisons. supports different model selection criteria: WAIC, DIC, PMP.","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament_summary_output.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Internal function to generate a summary output for a discharge rating curve tournament — tournament_summary_output","text":"","code":"tournament_summary_output(results, method, winning_criteria)"},{"path":"https://sor16.github.io/bdrc/reference/tournament_summary_output.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Internal function to generate a summary output for a discharge rating curve tournament — tournament_summary_output","text":"results data.frame containing summary results tournament. structure data.frame determines model-selection criterion used (WAIC, DIC, PMP). method string indicating method used model comparison (\"WAIC\", \"DIC\", \"PMP\"). winning_criteria criteria used determine winning model.","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament_summary_output.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Internal function to generate a summary output for a discharge rating curve tournament — tournament_summary_output","text":"function return value; prints formatted summary console.","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament_summary_output.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Internal function to generate a summary output for a discharge rating curve tournament — tournament_summary_output","text":"function automatically detects model-selection criterion used based columns present input data frame. formats prints summary tournament results, including overall winner detailed results comparison.","code":""},{"path":"https://sor16.github.io/bdrc/news/index.html","id":"bdrc-200","dir":"Changelog","previous_headings":"","what":"bdrc 2.0.0","title":"bdrc 2.0.0","text":"Integrated C++ via Rcpp RcppArmadillo packages significant performance improvements. Multiple functions rewritten C++ speed MCMC sampling algorithm various tasks. “Deviance” posterior output transformed renamed “Posterior log-likelihood”. Deviance previously calculated -2 times Posterior log-likelihood. plot(tournament_obj, type = “Deviance”) figure now created evaluating plot(tournament_obj, type = “boxplot”). log-likelihood models now computed log-transformed discharge observations (normally distributed), rather discharge real scale (log-normally distributed). Pointwise WAIC values (WAIC_i) stored model objects. Implemented standard error computations WAIC Delta_WAIC estimates. Applied log-sum-exp trick WAIC Bayes factor calculations numerical stability. Added DOI links references. Revised summary() output tournament objects. Updated package vignettes reflect recent changes improvements.","code":""},{"path":"https://sor16.github.io/bdrc/news/index.html","id":"bdrc-110","dir":"Changelog","previous_headings":"","what":"bdrc 1.1.0","title":"bdrc 1.1.0","text":"CRAN release: 2023-03-19 tournament function now supports information criteria (WAIC & DIC) model selection criteria, WAIC new default. Six new real-world datasets Iceland Sweden containing paired observations stage discharge included package. package can now also used user-friendly interactive rating curve builder Shiny application [https://bdrc.shinyapps.io/bdrc/].","code":""},{"path":"https://sor16.github.io/bdrc/news/index.html","id":"bdrc-100","dir":"Changelog","previous_headings":"","what":"bdrc 1.0.0","title":"bdrc 1.0.0","text":"CRAN release: 2021-07-28 Release first version package.","code":""}] +[{"path":"https://sor16.github.io/bdrc/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2021 Birgir Hrafnkelsson Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://sor16.github.io/bdrc/articles/background.html","id":"bayesian-generalized-power-law-rating-curves","dir":"Articles","previous_headings":"","what":"Bayesian Generalized Power-Law Rating Curves","title":"Background","text":"power-law model commonly assumed hydraulic practice fit rating curves, mention , form Q(h)=(h−c)bQ(h) = (h-c)^{b} (1) QQ, hh, aa, bb cc , see e.g., Venetis (1970), Clarke (1999) Clarke et al. (2000). second type rating curve generalized power-law rating curve. construction based hydraulics open channel flow given formulas Chézy Manning form Q=KRxAS1/2Q = KR^{x}^{1/2} (2) KK xx constants; AA area cross section; SS slope channel; RR hydraulic radius, given R=/PR = /P, PP wetted perimeter. According Chézy x=1/2x = 1/2, Manning claimed x=2/3x = 2/3 (Chow, 1959). form generalized power-law rating curve Q=(h−c)f(h)Q = (h − c)^{f(h)} (3) aa cc constants; f(h)f(h) function hh, referred power-law exponent. relationship (2) (3) can found equating two equations. particular, form f(h)f(h) can derived, namely, f(h)=(x+1){logA(h)−logA(1)}−x{logP(h)−logP(1)}loghf(h) = \\frac{(x+1)\\{ \\log (h) - \\log (1) \\} - x \\{ \\log P(h) - \\log P(1) \\}}{\\log h} (4) Thus, f(h)f(h) function constant xx, cross-sectional area AA, wetted perimeter PP. Bayesian approach proposed estimating parameters power-law model generalized power-law model. Bayesian inference requires specification prior densities unknown parameters unknown quantities, along full probabilistic specification observed data. goal Bayesian inference obtain posterior density model parameters, interrogate posterior calculating summary statistics, posterior mean 95% posterior intervals. Analytical formulas summary statistics intractable cases thus computed generating samples posterior density using Markov chain Monte Carlo simulation. Bayesian power-law model presented logarithmic scale , log(Qi)=log()+blog(hi−c)+ϵi,=1,...,n,\\log(Q_i) = \\log() + b \\log(h_i -c) + \\epsilon_i, \\quad = 1,...,n, (5) ϵi\\epsilon_i follows normal distribution mean zero variance σϵ2\\sigma_{\\epsilon}^2, nn number paired observations, aa, bb cc . Bayesian inference scheme implemented power-law model standard, however, efficient posterior simulation, first, samples obtained joint marginal posterior density (c,σϵ2)(c, \\sigma_{\\epsilon}^2), samples obtained conditional posterior density (log(),b)(\\log(), b) conditional (c,σϵ2)(c, \\sigma_{\\epsilon}^2). Bayesian generalized power-law model presented Bayesian hierarchical model. function f(h)f(h) modeled latent level bb plus mean zero continuous stochastic process β(h)\\beta(h), assumed twice mean-square differentiable. model presented logarithmic scale , log(Qi)=log()+(b+β(hi))log(hi−c)+εi,=1,...,n,\\log (Q_i) = \\log () + (b + \\beta(h_i)) \\log(h_i -c) + \\varepsilon_i, \\quad = 1,...,n, (6) ϵi\\epsilon_i follows normal distribution mean zero variance σϵ2(hi)\\sigma_{\\epsilon}^2(h_i) can vary water elevation. parameters aa, bb cc play similar role Bayesian power-law model. stochastic process β(h)\\beta(h) assumed priori Gaussian process governed Matérn covariance function smoothness parameter ν=2.5\\nu = 2.5, see Matérn (1960). model constrained setting b=1.835b=1.835. efficient posterior simulation achieved sampling joint posterior density hyperparameters model, sampling conditional density latent parameters given hyperparameters.","code":""},{"path":"https://sor16.github.io/bdrc/articles/background.html","id":"references","dir":"Articles","previous_headings":"","what":"References","title":"Background","text":"Chow, V. (1959). Open-Channel Hydraulics. McGraw-Hill. New York. Clarke, R. (1999). Uncertainty estimation mean annual flood due rating-curve indefinition. Journal Hydrology 222(1-4). 185–190. doi: https://doi.org/10.1016/s0022-1694(99)00097-9 Clarke, R., Mendiondo, E., Brusa L. (2000). Uncertainties mean discharges two large South American rivers due rating curve variability. Hydrological Sciences 45(2). 221–236. doi: https://doi.org/10.1080/02626660009492321 Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711 Matérn, B. (1960). Spatial variation. Stochastic models application problems forest surveys sampling investigations. Meddelanden från statens Skogsforskningsinstitut. 49(5). Venetis, C. (1970). note estimation parameters logarithmic stage-discharge relationships estimates error. International Association Scientific Hydrology. Bulletin XV 2(6). 105–111. doi: https://doi.org/10.1080/02626667009493957","code":""},{"path":"https://sor16.github.io/bdrc/articles/introduction.html","id":"fitting-a-discharge-rating-curve","dir":"Articles","previous_headings":"","what":"Fitting a discharge rating curve","title":"Introduction","text":"Fitting discharge rating curve bdrc straightforward. two input arguments mandatory: formula data. formula form y ~ x, y discharge cubic meters per second (m³/s), x water elevation (stage) meters (m). crucial data correct units! data argument must data.frame including x y column names. case, Krokfors data discharge water elevation measurements stored columns named Q W, respectively. ready fit discharge rating curve using gplm function: function prints summary fitting process key MCMC diagnostics. include acceptance rate, chain mixing (assessed via Gelman-Rubin statistic, R̂\\hat{R}), effective sample sizes. checkmarks indicate algorithm met important criteria reliability. However, sometimes may encounter warnings. example: warning suggests certain parameters (case, sigma_eta) haven’t mixed well across chains, affect reliability results. cases, function provides advice: output helps assess whether discharge rating curve fitted successfully reliably using specified data. function can made run silently setting verbose=FALSE. Note parallel=TRUE default setting, utilizing available cores machine. can adjust number cores num_cores argument needed. gplm function returns object class gplm can summarize visualize using familiar functions next section, dive deeper visualizing gplm object.","code":"> gplm.fit <- gplm(Q ~ W, data = krokfors, parallel = TRUE, num_cores = 2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.33%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> ⚠ Warning: Some chains are not mixing well. Parameters with Rhat > 1.1: #> - sigma_eta: Rhat = 1.281 #> ℹ Try re-running the model after inspecting the trace plots, convergence diagnostics plots, and reviewing the data for potential issues. > summary(gplm.fit) #> #> Formula: #> Q ~ W #> Latent parameters: #> lower-2.5% median-50% upper-97.5% #> a 1.47 1.94 2.23 #> b 1.83 1.84 1.84 #> #> Hyperparameters: #> lower-2.5% median-50% upper-97.5% #> c 7.70955 7.8089 7.855 #> sigma_beta 0.42275 0.6942 1.258 #> phi_beta 0.54941 1.1775 2.861 #> sigma_eta 0.00298 0.0934 0.498 #> eta_1 -4.91521 -4.2508 -3.535 #> eta_2 -5.97953 -4.0555 -2.264 #> eta_3 -6.92387 -4.1874 -1.612 #> eta_4 -7.66667 -4.4852 -1.160 #> eta_5 -8.33270 -4.6095 -0.757 #> eta_6 -8.81259 -4.6718 -0.311 #> #> WAIC: -27.81763 > plot(gplm.fit)"},{"path":"https://sor16.github.io/bdrc/articles/introduction.html","id":"visualizing-posterior-distributions-of-different-parameters","dir":"Articles","previous_headings":"","what":"Visualizing posterior distributions of different parameters","title":"Introduction","text":"bdrc package provides several tools visualize results model objects can give insight physical properties river hand. instance, hyperparameter cc corresponds water elevation zero discharge. visualize posterior cc, can write Technically, instead inferring cc directly, hmin−ch_{min}-c inferred, hminh_{min} lowest water elevation value data. Since parameter hmin−ch_{min}-c strictly positive, transformation ζ=log(hmin−c)\\zeta=log(h_{min}-c) used Bayesian inference support real line. plot transformed posterior write param argument can also vector containing multiple parameter names. example, visualize posterior distributions parameters aa cc, can write shorthand visualize hyperparameters Similarly, writing \"latent_parameters\" plots latent parameters one plot. plot hyperparameters transformed scale Bayesian inference, write Finally, can visualize components model allowed (depending model) vary water elevation, , power-law exponent, f(h)f(h), standard deviation error terms response level, σε(h)\\sigma_{\\varepsilon}(h). gplm0 gplm generalize power-law exponent modeling sum constant term, bb, Gaussian process, β(h)\\beta(h), namely f(h)=b+β(h)f(h)=b+\\beta(h), β(h)\\beta(h) assumed twice differentiable mean zero. hand, plm plm0 model power-law exponent constant setting β(h)=0\\beta(h)=0, gives f(h)=bf(h)=b. can plot inferred power-law exponent plm gplm model standard deviation error terms response level, σε(h)\\sigma_{\\varepsilon}(h), function water elevation, using B-splines basis functions, plm0 gplm0 model standard deviation constant. can plot inferred standard deviation writing get visual summary model, \"panel\" option plot type useful:","code":"> plot(gplm.fit, type = 'histogram', param = 'c') > plot(gplm.fit, type = 'histogram', param = 'c', transformed = TRUE) > plot(gplm.fit, type = 'histogram', param = c('a', 'c')) > plot(gplm.fit, type = 'histogram', param = 'hyperparameters') > plot(gplm.fit, type = 'histogram', param = 'hyperparameters', transformed = TRUE) > plot(gplm.fit, type = 'f') > plot(gplm.fit, type = 'sigma_eps') > plot(gplm.fit, type = 'panel', transformed = TRUE)"},{"path":"https://sor16.github.io/bdrc/articles/introduction.html","id":"assessing-model-fit-and-convergence","dir":"Articles","previous_headings":"","what":"Assessing model fit and convergence","title":"Introduction","text":"package several functions convergence diagnostics bdrc model, notably residual plot, trace plots, autocorrelation plots, Gelman-Rubin diagnostic plots. log-residuals can plotted log-residuals calculated subtracting posterior estimate (median) log-discharge, log(Q̂)log(\\hat{Q}), observed log-discharge, log(Q)log(Q). Additionally, plot includes 95% predictive intervals log(Q)\\log(Q) (- -) 95% credible intervals expected value log(Q)\\log(Q) (—), latter reflecting rating curve uncertainty. plot trace plot transformed hyperparameters, write assess mixing convergence MCMC chains parameter, can visualize Gelman-Rubin statistic, R̂\\hat{R}, presented Gelman Rubin (1992) : finally, autocorrelation parameters can assessed ","code":"> plot(gplm.fit, type = 'residuals') > plot(gplm.fit, type = 'trace', param = 'c', transformed = TRUE) > plot(gplm.fit, type = 'trace', param = 'hyperparameters', transformed = TRUE) > plot(gplm.fit, type = 'r_hat') > plot(gplm.fit, type = 'autocorrelation')"},{"path":"https://sor16.github.io/bdrc/articles/introduction.html","id":"customizing-the-models","dir":"Articles","previous_headings":"","what":"Customizing the models","title":"Introduction","text":"ways customize gplm function. instances, parameter zero discharge, cc, known, might want fix model parameter known value. addition, might want extrapolate rating curve higher water elevation values adjusting maximum water elevation. Assume 7.65 m known value cc want calculate rating curve water elevation values 10 m, function call look like ","code":"> gplm.fit.known_c <- gplm(Q ~ W, krokfors, c_param = 7.65, h_max = 10, parallel = FALSE)"},{"path":"https://sor16.github.io/bdrc/articles/introduction.html","id":"prediction-for-an-equally-spaced-grid-of-water-elevations","dir":"Articles","previous_headings":"","what":"Prediction for an equally spaced grid of water elevations","title":"Introduction","text":"get rating curve predictions equally spaced grid water elevation values, can use predict function. Note values range cc h_max accepted, range Bayesian inference performed","code":"> h_grid <- seq(8, 8.2, by = 0.01) > rating_curve_h_grid <- predict(gplm.fit, newdata = h_grid) > print(rating_curve_h_grid) #> h lower median upper #> 1 8.00 0.06138853 0.08252241 0.1108601 #> 2 8.01 0.06708762 0.09009315 0.1207313 #> 3 8.02 0.07340524 0.09850833 0.1316830 #> 4 8.03 0.07972287 0.10692352 0.1426346 #> 5 8.04 0.08620981 0.11547827 0.1537808 #> 6 8.05 0.09363849 0.12480929 0.1660087 #> 7 8.06 0.10106716 0.13414031 0.1782366 #> 8 8.07 0.10861541 0.14364701 0.1906011 #> 9 8.08 0.11657272 0.15375469 0.2034327 #> 10 8.09 0.12453003 0.16386237 0.2162643 #> 11 8.10 0.13257127 0.17428375 0.2295414 #> 12 8.11 0.14080833 0.18543710 0.2438577 #> 13 8.12 0.14904540 0.19659045 0.2581741 #> 14 8.13 0.15728247 0.20774380 0.2724905 #> 15 8.14 0.16662200 0.21960922 0.2875367 #> 16 8.15 0.17662981 0.23190628 0.3030253 #> 17 8.16 0.18663761 0.24420333 0.3185138 #> 18 8.17 0.19681441 0.25692028 0.3351942 #> 19 8.18 0.20699699 0.26965158 0.3519154 #> 20 8.19 0.21718541 0.28270330 0.3691020 #> 21 8.20 0.22738677 0.29646391 0.3873183"},{"path":"https://sor16.github.io/bdrc/articles/introduction.html","id":"references","dir":"Articles","previous_headings":"","what":"References","title":"Introduction","text":"Gelman, ., & Rubin, D. B. (1992). Inference iterative simulation using multiple sequences, Statistical Science, 7(4), 457–472. doi: https://doi.org/10.1214/ss/1177011136 Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711","code":""},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"the-tournament-method","dir":"Articles","previous_headings":"","what":"The tournament method","title":"Tournament - Model comparison","text":"tournament method uses Widely Applicable Information Criterion (WAIC) (Watanabe, 2010) select appropriate model given dataset. WAIC balances two factors: Goodness--fit: well model fits observed data. Model complexity: penalty term accounting effective number parameters. lower WAIC indicates better balance model fit complexity, making preferred model. tournament process occurs two rounds: First round: gplm vs gplm0 plm vs plm0 Final round: Winners first round face comparison, calculate WAIC difference less complex model, ΔWAIC=WAICless−WAICmore\\Delta\\text{WAIC} = \\text{WAIC}_{\\text{less}} - \\text{WAIC}_{\\text{}}. positive ΔWAIC\\Delta\\text{WAIC} suggests complex model appropriate. However, advance next round, ΔWAIC\\Delta\\text{WAIC} must exceed pre-specified “winning criteria” (default value = 2). threshold helps ensure choose complex model offers substantial improvement. default winning criteria 2 based statistical guidelines model selection (Burnham & Anderson, 2002), balancing trade-model fit complexity. helps prevent overfitting requiring evidence justify complex model. following sections, ’ll provide code examples demonstrating conduct power-law tournament data using bdrc package.","code":""},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"introducing-the-tournament-function","dir":"Articles","previous_headings":"","what":"Introducing the Tournament Function","title":"Tournament - Model comparison","text":"demonstrate tournament function, ’ll use real-world dataset Krokfors stream gauging station Sweden, included bdrc package: Krokfors dataset contains 27 observations discharge measurements stream gauging station. observation consists two variables: W: Water level (stage) measured meters fixed reference point. Q: Discharge, measured cubic meters per second (m³/s). Krokfors data particularly suitable demonstrating tournament function provides real-world example type data typically used discharge rating curve analysis. dataset help illustrate different models perform across range observed water levels discharges.","code":"> library(bdrc) > data(krokfors) > head(krokfors) #> W Q #> 1 9.478000 10.8211700 #> 2 8.698000 1.5010000 #> 3 9.009000 3.3190000 #> 4 8.097000 0.1595700 #> 5 9.104000 4.5462500 #> 6 8.133774 0.2121178"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"running-a-tournament","dir":"Articles","previous_headings":"","what":"Running a tournament","title":"Tournament - Model comparison","text":"tournament function straightforward use, requiring two main arguments: formula: Specifies relationship discharge water elevation (e.g., Q ~ W). data: data.frame column names corresponding variables specified formula. important discharge represented cubic meters per second (m³/s) water elevation meters (m). Let’s run first tournament: output provides valuable information MCMC sampling process model: Shows overall progress tournament four models fitted sequentially. Indicates start Markov Chain Monte Carlo (MCMC) process model. Provides information sampling process distributed across computer’s CPU cores. example, see 4 chain sampling process distributed across 2 CPU cores (4 chains 2 jobs). Acceptance rate: proportion proposed parameter values accepted MCMC sampling scheme. Chain mixing: message reporting different MCMC chains mixed well. Effective sample size: message reporting enough independent samples drawn posterior distribution. parameters meet criteria chain mixing effective sample size (Gelman-rubin statistic (Rhat) < 1.1 mixing effective number samples (eff_n_samples) > 400 sample size), function print warning. helps identify potential issues MCMC sampling specific parameters. diagnostics help ensure reliability results. Good chain mixing sufficient effective sample sizes indicate MCMC sampling likely converged true posterior distribution. function can made run silently setting verbose = FALSE. Note: default, parallel=TRUE function automatically detects number available cores. Parallel processing used run multiple MCMC chains simultaneously, significantly reducing computation time complex models large datasets. see tournament winner: ’ve already fitted four models separately stored objects (e.g., plm0.fit, plm.fit, gplm0.fit, gplm.fit), can run tournament efficiently: tournament function creates tournament object contains four elements: summary, contestants, winner, info. components structured follows: summary: data frame detailed information results different comparisons power-law tournament. contents data frame depend method used (\"WAIC\", \"DIC\", \"PMP\") include: Common columns methods: round: Indicates tournament round (1 2). Round 1 compares generalized classical power-law models separately (gplm vs gplm0 plm vs plm0), whereas Round 2 compares winners Round 1. comparison: numeric identifier model comparison (1, 2, 3). two comparisons Round 1 one Round 2. complexity: Indicates whether model “” “less” complex model given comparison. “less” complex model given advantage defined winning_criteria. model: model type (plm0, plm, gplm0, gplm). winner: logical value (TRUE/FALSE) indicating whether model selected winner. Method-specific columns: WAIC (Widely Applicable Information Criterion): lppd: Log-pointwise predictive density, measuring well model predicts observed data eff_num_param: Effective number parameters, estimating model complexity WAIC: computed WAIC value, balancing model fit complexity SE_WAIC: Standard error WAIC estimate Delta_WAIC: Difference WAIC compared models SE_Delta_WAIC: Standard error difference WAIC DIC (Deviance Information Criterion): D_hat: Minus two times log-likelihood evaluated median posterior samples eff_num_param: Effective number parameters, estimating model complexity DIC: computed DIC value, balancing model fit complexity Delta_DIC: Difference DIC compared models PMP (Posterior Model Probability): log_marg_lik: Logarithm marginal likelihood, estimated using harmonic-mean estimator PMP: Posterior model probability computed Bayes factor, indicating probability model given data contestants: list containing fitted model objects compared tournament: plm0, plm, gplm0 gplm. winner: model object tournament winner, representing appropriate model given data. info: list containing specific information tournament: overall winner method used comparison (\"WAIC\", \"DIC\", \"PMP\") winning criteria applied structure allows users easily access final results (winner) detailed process (summary) model comparison, well full model objects analysis needed. method-specific columns provide insights model selection process: * WAIC, lower values indicate better models, Delta_WAIC showing magnitude difference models. * DIC, like WAIC, lower values preferred, Delta_DIC showing difference models. * PMP, higher probabilities indicate stronger evidence model, values closer 1 suggesting stronger support. metrics help users understand just model selected, also strength evidence selection relative performance compared models. comprehensive summary tournament results: first round tournament favors gplm0 gplm, plm0 plm, based respective ΔWAIC\\Delta\\text{WAIC} values. final round, gplm0 emerges overall winner, substantial positive ΔWAIC\\Delta\\text{WAIC} ~24 compared plm0. indicates gplm0 provides best balance model complexity fit data. standard error estimated WAIC difference, denoted SE_Delta_WAIC, rather large ~9. suggests uncertainty magnitude difference. However, ’s important note despite small sample size, SE_Delta_WAIC less half ΔWAIC\\Delta\\text{WAIC} estimate. provides confidence preference gplm0, difference WAIC two standard errors away zero. Lets investigate comparison.","code":"> set.seed(1) # set seed for reproducibility > t_obj <- tournament(Q ~ W, krokfors, parallel = TRUE, num_cores = 2) #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.33%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.14%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.66%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.04%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% > t_obj # or alternatively print(t_obj) #> Tournament winner: gplm0 > t_obj <- tournament(list(plm0.fit, plm.fit, gplm0.fit, gplm.fit)) > summary(t_obj) #> #> === Tournament Model Comparison Summary === #> #> Method: WAIC #> Winning Criteria: Delta_WAIC > 2 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm 20.7794 6.8706 -27.8176 11.8918 0.5570 0.2416 #> less gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more plm 5.5842 4.2574 -2.6536 6.6635 -0.4066 0.1904 #> less plm0 <--- 5.6284 4.0984 -3.0601 6.6931 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 24.2005 9.1834 #> less plm0 5.6284 4.0984 -3.0601 6.6931 #> #> === End of Summary ==="},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"visualizing-the-model-comparisons","dir":"Articles","previous_headings":"","what":"Visualizing the model comparisons","title":"Tournament - Model comparison","text":"gain deeper insights model comparison results, can use various visualization tools:","code":""},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"tournament-results-diagram","dir":"Articles","previous_headings":"Visualizing the model comparisons","what":"1. Tournament results diagram:","title":"Tournament - Model comparison","text":"diagram illustrates tournament progression initial four models final winner. shows model’s residual plot bottom, corresponding WAIC values . Green WAIC values indicate selected model comparison.","code":"> plot(t_obj) #default plot type is type='tournament_results'"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"log-likelihood-comparison","dir":"Articles","previous_headings":"Visualizing the model comparisons","what":"2. Log-likelihood comparison:","title":"Tournament - Model comparison","text":"boxplot compares posterior log-likelihood values model, corresponding WAIC values shown red diamonds. log-likelihood values presented deviance scale (-2 * log-likelihood) direct comparison WAIC. Lower values indicate better fit.","code":"> plot(t_obj, type = 'boxplot')"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"rating-curve-comparison","dir":"Articles","previous_headings":"Visualizing the model comparisons","what":"3. Rating curve comparison:","title":"Tournament - Model comparison","text":"plot compares estimated rating curves four models. shows water level (stage) vs. discharge, solid lines representing estimated curves dotted lines showing 95% prediction intervals. visualization helps assess model fit across different water levels. Optimal model fit indicated solid line following mean observations 95% observations falling within prediction interval.","code":"> plot(t_obj, type = 'rating_curve')"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"residual-plot-comparison","dir":"Articles","previous_headings":"Visualizing the model comparisons","what":"4. Residual plot comparison:","title":"Tournament - Model comparison","text":"residual plots also help assess well model fits data showing differences observed predicted values across water levels. can reveal patterns model performance highlight systematic - -predictions. Optimal model fit indicated rating curve mean (solid horizontal line) following mean observations, 95% observations falling within 95% prediction interval (dotted lines).","code":"> plot(t_obj, type = 'residuals')"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"model-component-comparisons","dir":"Articles","previous_headings":"Visualizing the model comparisons","what":"5. Model Component Comparisons:","title":"Tournament - Model comparison","text":"differences four models lie treatment power-law exponent, f(h)f(h), log-error standard deviation, σε2(h)\\sigma^2_{\\varepsilon}(h), either constants stage-dependent functions. Therefore, insightful examine posterior distributions elements across different models determine whether stage dependence exists assumption constancy appropriate.","code":""},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"power-law-exponent-comparison","dir":"Articles","previous_headings":"Visualizing the model comparisons > 5. Model Component Comparisons:","what":"Power-law exponent comparison:","title":"Tournament - Model comparison","text":"plots show exponent clearly constant water elevations. observation supports use generalized power-law models (gplm gplm0) classical power-law models (plm plm0), allow non-constant behavior power-law exponent.","code":"> plot(t_obj, type = 'f')"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"log-error-standard-deviation-comparison","dir":"Articles","previous_headings":"Visualizing the model comparisons > 5. Model Component Comparisons:","what":"Log-error standard deviation comparison:","title":"Tournament - Model comparison","text":"contrast exponent, log-error standard deviation show clear non-constant trend water elevations. observation suggests models constant error variance (plm0 gplm0) might sufficient dataset, aligning tournament results selected gplm0.","code":"> plot(t_obj, type = 'sigma_eps')"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"winning-model-panel","dir":"Articles","previous_headings":"Visualizing the model comparisons","what":"6. Winning model panel:","title":"Tournament - Model comparison","text":"Finally, panel option useful gain insight different model components winning model, case gplm0: panel plot provides comprehensive view winning model’s components, including rating curve, residuals, power-law exponent, log-error standard deviation. visualization particularly useful understanding different elements winning model work together relate observed data. transformed = TRUE argument transforms rating curve observations onto modeling scale (log-scale).","code":"> plot(t_obj, type = 'panel', transformed = TRUE)"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"customizing-tournaments","dir":"Articles","previous_headings":"","what":"Customizing tournaments","title":"Tournament - Model comparison","text":"several ways customize tournament :","code":""},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"fixing-the-c-parameters","dir":"Articles","previous_headings":"Customizing tournaments","what":"1. Fixing the c parameters:","title":"Tournament - Model comparison","text":"parameter zero discharge cc known, might want fix parameter known value model. Assume 7.657.65 m known value cc. can directly run tournament cc parameter fixed models:","code":"> t_obj_known_c <- tournament(formula = Q ~ W , data = krokfors, c_param = 7.65)"},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"adjusting-the-winning-criteria","dir":"Articles","previous_headings":"Customizing tournaments","what":"2. Adjusting the winning criteria:","title":"Tournament - Model comparison","text":"can change winning criteria (default value = 2) sets threshold complex model model comparison must exceed. example, increasing value winning_criteria = 5 raises threshold, thus favoring model simplicity . re-evaluate previously run tournament using different winning criteria, can simply summary function: method \"WAIC\", can also specify complex winning criteria string expression: criteria requires difference WAIC greater 2 difference minus standard error greater 0, providing conservative approach model selection. Note: Delta_WAIC SE_Delta_WAIC allowed variables winning_criteria expressions.","code":"> summary(t_obj, winning_criteria = 5) #> #> === Tournament Model Comparison Summary === #> #> Method: WAIC #> Winning Criteria: Delta_WAIC > 5 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm 20.7794 6.8706 -27.8176 11.8918 0.5570 0.2416 #> less gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more plm 5.5842 4.2574 -2.6536 6.6635 -0.4066 0.1904 #> less plm0 <--- 5.6284 4.0984 -3.0601 6.6931 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 24.2005 9.1834 #> less plm0 5.6284 4.0984 -3.0601 6.6931 #> #> === End of Summary === > summary(t_obj, winning_criteria = \"Delta_WAIC > 2 & Delta_WAIC - SE_Delta_WAIC > 0\") #> #> === Tournament Model Comparison Summary === #> #> Method: WAIC #> Winning Criteria: Delta_WAIC > 2 & Delta_WAIC - SE_Delta_WAIC > 0 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm 20.7794 6.8706 -27.8176 11.8918 0.5570 0.2416 #> less gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more plm 5.5842 4.2574 -2.6536 6.6635 -0.4066 0.1904 #> less plm0 <--- 5.6284 4.0984 -3.0601 6.6931 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 24.2005 9.1834 #> less plm0 5.6284 4.0984 -3.0601 6.6931 #> #> === End of Summary ==="},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"changing-the-model-comparison-method","dir":"Articles","previous_headings":"Customizing tournaments","what":"3. Changing the model comparison method:","title":"Tournament - Model comparison","text":"default method \"WAIC\", can also use \"DIC\" \"PMP\": \"WAIC\" (default): WAIC (Watanabe, 2010) fully Bayesian method uses full set posterior draws calculate best possible estimate expected log pointwise predictive density. \"DIC\": DIC (Spiegelhalter, 2002) similar WAIC uses point estimate posterior distribution instead full set posterior draws. \"PMP\" (posterior model probabilities): posterior model probabilities computed Bayes factors (Jeffreys, 1961; Kass Raftery, 1995), assuming models equally likely priori. winning criteria method \"PMP\" 0 1, representing threshold posterior probability complex model. default 0.75, give similar results two methods respective default values 2. method \"PMP\" chosen default method Bayes factor calculations can quite unstable. Let’s now use method, raise winning criteria 0.75 0.9 Note using summary function change method winning criteria, tournament re-run new parameters using original contestant models. allows efficient comparison different methods criteria without refit models. examples demonstrate different methods winning criteria can applied model comparison. ’s valuable explore options, generally recommend using WAIC method, provides robust theoretically sound approach model selection. WAIC uses full posterior distribution particularly well-suited hierarchical models. case Krokfors dataset, see results tournament change despite customizations, winner third final comparison still gplm0. consistency across different methods criteria suggests gplm0 indeed appropriate model particular dataset.","code":"> summary(t_obj, method = \"DIC\") #> #> === Tournament Model Comparison Summary === #> #> Method: DIC #> Winning Criteria: Delta_DIC > 2 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------- #> complexity model winner D_hat eff_num_param DIC Delta_DIC #> more gplm -42.7732 6.0631 -30.6470 0.8498 #> less gplm0 <--- -42.4880 6.3454 -29.7972 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------- #> complexity model winner D_hat eff_num_param DIC Delta_DIC #> more plm -11.3400 2.9739 -5.3923 -0.3058 #> less plm0 <--- -11.4712 2.8865 -5.6982 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------- #> complexity model winner D_hat eff_num_param DIC Delta_DIC #> more gplm0 <--- -42.4880 6.3454 -29.7972 24.0991 #> less plm0 -11.4712 2.8865 -5.6982 #> #> === End of Summary === > summary(t_obj, method = \"PMP\", winning_criteria = 0.9) #> #> === Tournament Model Comparison Summary === #> #> Method: PMP #> Winning Criteria: PMP of more complex model > 0.9 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> ------------------------------------------------------- #> complexity model winner log_marg_lik PMP #> more gplm 10.1504 0.4538 #> less gplm0 <--- 10.3357 0.5462 #> #> Comparison 2 Results: #> ------------------------------------------------------- #> complexity model winner log_marg_lik PMP #> more plm <--- 0.9781 0.9260 #> less plm0 -1.5486 0.0740 #> #> Comparison 3 Results: #> ------------------------------------------------------- #> complexity model winner log_marg_lik PMP #> more gplm0 <--- 10.3357 0.9999 #> less plm 0.9781 0.0001 #> #> === End of Summary === #> #> ⚠ Warning: The Harmonic Mean Estimator (HME) is used to estimate the Bayes Factor for the posterior model probability (PMP), which is known to be unstable and potentially unreliable. We recommend using method \"WAIC\" (Widely Applicable Information Criterion) for model comparison instead."},{"path":"https://sor16.github.io/bdrc/articles/tournament.html","id":"references","dir":"Articles","previous_headings":"","what":"References","title":"Tournament - Model comparison","text":"Burnham, K. P. Anderson, D. R. (eds) (2002). Information Likelihood Theory: Basis Model Selection Inference. New York, NY: Springer New York. 49–97, doi: https://doi.org/10.1007/978-0-387-22456-5_2 Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711 Jeffreys, H. (1961). Theory Probability, Third Edition. Oxford University Press. Kass, R., . Raftery, . (1995). Bayes Factors. Journal American Statistical Association, 90, 773-795. doi: https://doi.org/10.1080/01621459.1995.10476572 Spiegelhalter, D., Best, N., Carlin, B., Van Der Linde, . (2002). Bayesian measures model complexity fit. Journal Royal Statistical Society: Series B (Statistical Methodology) 64(4), 583–639. doi: https://doi.org/10.1111/1467-9868.00353 Watanabe, S. (2010). Asymptotic equivalence Bayes cross validation widely applicable information criterion singular learning theory. Journal Machine Learning Research, 11, 3571–3594.","code":""},{"path":"https://sor16.github.io/bdrc/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Birgir Hrafnkelsson. Author, copyright holder. Solvi Rognvaldsson. Author. Rafael Daníel Vias. Author, maintainer. Axel Orn Jansson. Author.","code":""},{"path":"https://sor16.github.io/bdrc/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Hrafnkelsson B, Rognvaldsson S, Vias R, Jansson (2024). bdrc: Bayesian Discharge Rating Curves. R package version 2.0.0, https://sor16.github.io/bdrc.","code":"@Manual{, title = {bdrc: Bayesian Discharge Rating Curves}, author = {Birgir Hrafnkelsson and Solvi Rognvaldsson and Rafael Daníel Vias and Axel Orn Jansson}, year = {2024}, note = {R package version 2.0.0}, url = {https://sor16.github.io/bdrc}, }"},{"path":"https://sor16.github.io/bdrc/index.html","id":"bdrc---bayesian-discharge-rating-curves-","dir":"","previous_headings":"","what":"bdrc - Bayesian Discharge Rating Curves","title":"Fit Bayesian Discharge Rating Curves","text":"bdrc package provides tools fitting discharge rating curves using Bayesian hierarchical models. implements classical power-law novel generalized power-law models, offering flexibility handling various hydrological scenarios. package implements four models described Hrafnkelsson et al. (2022): plm0() - Power-law model constant log-error variance. plm() - Power-law model stage-dependent log-error variance. gplm0() - Generalized power-law model constant log-error variance. gplm() - Generalized power-law model stage-dependent log-error variance.","code":""},{"path":"https://sor16.github.io/bdrc/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Fit Bayesian Discharge Rating Curves","text":"","code":"# Install release version from CRAN install.packages(\"bdrc\") # Install development version from GitHub devtools::install_github(\"sor16/bdrc\")"},{"path":"https://sor16.github.io/bdrc/index.html","id":"usage","dir":"","previous_headings":"","what":"Usage","title":"Fit Bayesian Discharge Rating Curves","text":"Fitting discharge rating curve bdrc straightforward:","code":"library(bdrc) data(krokfors) gplm.fit <- gplm(Q ~ W, krokfors) summary(gplm.fit) plot(gplm.fit)"},{"path":"https://sor16.github.io/bdrc/index.html","id":"key-features","dir":"","previous_headings":"","what":"Key-features","title":"Fit Bayesian Discharge Rating Curves","text":"Easy--use interface fitting Bayesian discharge rating curves Features novel Generalized power-law rating curve model (Hrafnkelsson et al., 2022) Multiple model options suit different hydrological scenarios Built-visualization tools model results diagnostics Integrates R C++ efficient MCMC sampling parallel processing","code":""},{"path":"https://sor16.github.io/bdrc/index.html","id":"getting-started","dir":"","previous_headings":"","what":"Getting started","title":"Fit Bayesian Discharge Rating Curves","text":"deeper dive package’s functionality, visualization options, underlying theory models, please check vignettes: Background Introduction Power-law tournament (model selection)","code":""},{"path":"https://sor16.github.io/bdrc/index.html","id":"references","dir":"","previous_headings":"","what":"References","title":"Fit Bayesian Discharge Rating Curves","text":"Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711","code":""},{"path":"https://sor16.github.io/bdrc/reference/autoplot.plm0.html","id":null,"dir":"Reference","previous_headings":"","what":"Autoplot method for discharge rating curves — autoplot.plm0","title":"Autoplot method for discharge rating curves — autoplot.plm0","text":"Visualize discharge rating curve model objects","code":""},{"path":"https://sor16.github.io/bdrc/reference/autoplot.plm0.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Autoplot method for discharge rating curves — autoplot.plm0","text":"","code":"# S3 method for class 'plm0' autoplot( object, ..., type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL ) # S3 method for class 'plm' autoplot( object, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... ) # S3 method for class 'gplm0' autoplot( object, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... ) # S3 method for class 'gplm' autoplot( object, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... )"},{"path":"https://sor16.github.io/bdrc/reference/autoplot.plm0.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Autoplot method for discharge rating curves — autoplot.plm0","text":"object object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". ... used function type character denoting type plot drawn. Defaults \"rating_curve\". Possible types : rating_curve Plots rating curve. rating_curve_mean Plots posterior mean rating curve. f Plots power-law exponent. beta Plots random effect power-law exponent. sigma_eps Plots standard deviation data level. residuals Plots log residuals. trace Plots trace plots parameters given param. histogram Plots histograms parameters given param. param character vector parameters plot. Defaults NULL used type \"trace\" \"histogram\". Allowed values parameters given model summary x well \"hyperparameters\" \"latent_parameters\" specific groups parameters. transformed logical value indicating whether quantity plotted transformed scale used Bayesian inference. Defaults FALSE. title character denoting title plot. xlim numeric vector length 2, denoting limits x axis plot. Applicable types \"rating_curve\", \"rating_curve_mean\", \"f\", \"beta\", \"sigma_eps\", \"residuals\". ylim numeric vector length 2, denoting limits y axis plot. Applicable types \"rating_curve\", \"rating_curve_mean\", \"f\", \"beta\", \"sigma_eps\", \"residuals\".","code":""},{"path":"https://sor16.github.io/bdrc/reference/autoplot.plm0.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Autoplot method for discharge rating curves — autoplot.plm0","text":"Returns object class \"ggplot2\".","code":""},{"path":"https://sor16.github.io/bdrc/reference/autoplot.plm0.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Autoplot method for discharge rating curves — autoplot.plm0","text":"autoplot(plm0): Autoplot method plm0 autoplot(plm): Autoplot method plm autoplot(gplm0): Autoplot method gplm0 autoplot(gplm): Autoplot method gplm","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/autoplot.plm0.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Autoplot method for discharge rating curves — autoplot.plm0","text":"","code":"# \\donttest{ library(ggplot2) data(krokfors) set.seed(1) plm0.fit <- plm0(Q~W,krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.09%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). autoplot(plm0.fit) autoplot(plm0.fit,transformed=TRUE) autoplot(plm0.fit,type='histogram',param='c') autoplot(plm0.fit,type='histogram',param='c',transformed=TRUE) autoplot(plm0.fit,type='histogram',param='hyperparameters') autoplot(plm0.fit,type='histogram',param='latent_parameters') autoplot(plm0.fit,type='residuals') autoplot(plm0.fit,type='f') autoplot(plm0.fit,type='sigma_eps') # }"},{"path":"https://sor16.github.io/bdrc/reference/autoplot.tournament.html","id":null,"dir":"Reference","previous_headings":"","what":"Autoplot method for discharge rating curve tournament — autoplot.tournament","title":"Autoplot method for discharge rating curve tournament — autoplot.tournament","text":"Compare four discharge rating curves tournament object different ways","code":""},{"path":"https://sor16.github.io/bdrc/reference/autoplot.tournament.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Autoplot method for discharge rating curve tournament — autoplot.tournament","text":"","code":"# S3 method for class 'tournament' autoplot(object, type = \"boxplot\", ...)"},{"path":"https://sor16.github.io/bdrc/reference/autoplot.tournament.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Autoplot method for discharge rating curve tournament — autoplot.tournament","text":"object object class \"tournament\" type character denoting type plot drawn. Possible types ... used function boxplot Creates boxplot posterior log-likelihood values transformed deviance scale.","code":""},{"path":"https://sor16.github.io/bdrc/reference/autoplot.tournament.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Autoplot method for discharge rating curve tournament — autoplot.tournament","text":"Returns object class \"ggplot2\".","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/autoplot.tournament.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Autoplot method for discharge rating curve tournament — autoplot.tournament","text":"","code":"# \\donttest{ library(ggplot2) data(krokfors) set.seed(1) t_obj <- tournament(formula = Q ~ W, data = krokfors, num_cores = 2) #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.33%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.14%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.66%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.04%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% autoplot(t_obj) # }"},{"path":"https://sor16.github.io/bdrc/reference/evaluate_comparison.html","id":null,"dir":"Reference","previous_headings":"","what":"Compare two models using a specified model-selection criteria — evaluate_comparison","title":"Compare two models using a specified model-selection criteria — evaluate_comparison","text":"evaluate_comparison uses Widely Applicable Information Criterion (WAIC), Deviance Information Criterion (DIC), posterior model probabilities (PMP), calculated Bayes factor, determine whether one model appropriate given data hand.","code":""},{"path":"https://sor16.github.io/bdrc/reference/evaluate_comparison.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compare two models using a specified model-selection criteria — evaluate_comparison","text":"","code":"evaluate_comparison(m, method, winning_criteria)"},{"path":"https://sor16.github.io/bdrc/reference/evaluate_comparison.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compare two models using a specified model-selection criteria — evaluate_comparison","text":"m list two model objects fit dataset. allowed model objects \"gplm\", \"gplm0\", \"plm\" \"plm0\" method string specifying method used estimate predictive performance models. allowed methods \"WAIC\", \"DIC\" \"PMP\". winning_criteria \"WAIC\", can either numeric value string expression. \"DIC\", must numeric value. \"PMP\", must numeric value 0 1. sets threshold determining appropriate model. See Details information.","code":""},{"path":"https://sor16.github.io/bdrc/reference/evaluate_comparison.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compare two models using a specified model-selection criteria — evaluate_comparison","text":"data.frame summary results comparison, including: complexity: Indicates whether model \"\" \"less\" complex model comparison model: type model (gplm, gplm0, plm, plm0) Method-specific columns (see Details) winner: Logical value indicating model selected","code":""},{"path":"https://sor16.github.io/bdrc/reference/evaluate_comparison.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Compare two models using a specified model-selection criteria — evaluate_comparison","text":"\"WAIC\" method: winning_criteria numeric, complex model wins Delta_WAIC > winning_criteria winning_criteria string, must valid R expression using Delta_WAIC /SE_Delta_WAIC Returns columns: lppd, eff_num_param, WAIC, SE_WAIC, Delta_WAIC, SE_Delta_WAIC \"DIC\" method: winning_criteria must numeric complex model wins Delta_DIC > winning_criteria Returns columns: D_hat, eff_num_param, DIC, Delta_DIC \"PMP\" method: winning_criteria must numeric value 0 1 complex model wins PMP > winning_criteria Returns columns: log_marg_lik, PMP","code":""},{"path":"https://sor16.github.io/bdrc/reference/evaluate_comparison.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Compare two models using a specified model-selection criteria — evaluate_comparison","text":"Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/gather_draws.html","id":null,"dir":"Reference","previous_headings":"","what":"Gather MCMC chain draws to data.frame on a long format — gather_draws","title":"Gather MCMC chain draws to data.frame on a long format — gather_draws","text":"Useful convert MCMC chain draws particular parameters output model object long format data wrangling","code":""},{"path":"https://sor16.github.io/bdrc/reference/gather_draws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Gather MCMC chain draws to data.frame on a long format — gather_draws","text":"","code":"gather_draws(mod, ..., transformed = F)"},{"path":"https://sor16.github.io/bdrc/reference/gather_draws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Gather MCMC chain draws to data.frame on a long format — gather_draws","text":"mod object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". ... number character vectors containing valid names parameters model \"rating_curve\" \"rating_curve_mean\". Also accepts \"latent_parameters\" \"hyperparameters\". transformed boolean value determining whether parameter represented transformed scale used sampling MCMC chain original scale. Defaults FALSE.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gather_draws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Gather MCMC chain draws to data.frame on a long format — gather_draws","text":"data frame columns: chain chain number. iter iteration number. param parameter name. value parameter value.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gather_draws.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Gather MCMC chain draws to data.frame on a long format — gather_draws","text":"Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/gather_draws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Gather MCMC chain draws to data.frame on a long format — gather_draws","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.09%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). hyp_samples <- gather_draws(plm0.fit,'hyperparameters') head(hyp_samples) #> chain iter name value #> 1 1 1 c 7.693275 #> 2 1 2 c 7.708797 #> 3 1 3 c 7.704167 #> 4 1 4 c 7.666575 #> 5 1 5 c 7.658464 #> 6 1 6 c 7.709366 rating_curve_samples <- gather_draws(plm0.fit,'rating_curve','rating_curve_mean') head(rating_curve_samples) #> chain iter h name value #> 1 1 1 7.673811 rating_curve 0.000000e+00 #> 2 1 2 7.673811 rating_curve 0.000000e+00 #> 3 1 3 7.673811 rating_curve 0.000000e+00 #> 4 1 4 7.673811 rating_curve 1.094841e-06 #> 5 1 5 7.673811 rating_curve 6.537614e-06 #> 6 1 6 7.673811 rating_curve 0.000000e+00 # }"},{"path":"https://sor16.github.io/bdrc/reference/get_report.html","id":null,"dir":"Reference","previous_headings":"","what":"Report for a discharge rating curve or tournament — get_report","title":"Report for a discharge rating curve or tournament — get_report","text":"Save pdf file report discharge rating curve object tournament.","code":""},{"path":"https://sor16.github.io/bdrc/reference/get_report.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Report for a discharge rating curve or tournament — get_report","text":"","code":"get_report(x, path = NULL, type = 1, ...) # S3 method for class 'plm0' get_report(x, path = NULL, type = 1, ...) # S3 method for class 'plm' get_report(x, path = NULL, type = 1, ...) # S3 method for class 'gplm0' get_report(x, path = NULL, type = 1, ...) # S3 method for class 'gplm' get_report(x, path = NULL, type = 1, ...) # S3 method for class 'tournament' get_report(x, path = NULL, type = 1, ...)"},{"path":"https://sor16.github.io/bdrc/reference/get_report.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Report for a discharge rating curve or tournament — get_report","text":"x object class \"tournament\", \"plm0\", \"plm\", \"gplm0\" \"gplm\". path file path pdf file report saved. NULL, current working directory used. type integer denoting type report produced. Defaults type 1. type 1 permissible object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". Possible types : 1 Produces report displaying results model (winning model tournament provided). first page contains panel four plots summary posterior distributions parameters. second page tabular prediction discharge equally spaced grid stages displayed. prediction table can span multiple pages. 2 Produces ten page report permissible objects class \"tournament\". first four pages contain panel four plots summary posterior distributions parameters four models tournament, fifth page shows summary tournament model comparison, sixth page convergence diagnostics plots, final four pages shows histograms parameters four models. ... arguments passed methods (currently unused).","code":""},{"path":"https://sor16.github.io/bdrc/reference/get_report.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Report for a discharge rating curve or tournament — get_report","text":"return value, called side effects.","code":""},{"path":"https://sor16.github.io/bdrc/reference/get_report.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Report for a discharge rating curve or tournament — get_report","text":"function can used interactive R session asks permission user write file system.","code":""},{"path":"https://sor16.github.io/bdrc/reference/get_report.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Report for a discharge rating curve or tournament — get_report","text":"get_report(plm0): Get report plm0 model object get_report(plm): Get report plm model object get_report(gplm0): Get report gplm0 model object get_report(gplm): Get report gplm get_report(tournament): Get report discharge rating curve tournament","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/get_report.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Report for a discharge rating curve or tournament — get_report","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.09%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). # } if (FALSE) { # \\dontrun{ get_report(plm0.fit) } # }"},{"path":"https://sor16.github.io/bdrc/reference/get_report_pages.html","id":null,"dir":"Reference","previous_headings":"","what":"Report pages for a discharge rating curve or tournament — get_report_pages","title":"Report pages for a discharge rating curve or tournament — get_report_pages","text":"Get list pages report discharge rating curve model tournament","code":""},{"path":"https://sor16.github.io/bdrc/reference/get_report_pages.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Report pages for a discharge rating curve or tournament — get_report_pages","text":"","code":"get_report_pages(x, type = 1) # S3 method for class 'plm0' get_report_pages(x, type = 1) # S3 method for class 'plm' get_report_pages(x, type = 1) # S3 method for class 'gplm0' get_report_pages(x, type = 1) # S3 method for class 'gplm' get_report_pages(x, type = 1) # S3 method for class 'tournament' get_report_pages(x, type = 1)"},{"path":"https://sor16.github.io/bdrc/reference/get_report_pages.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Report pages for a discharge rating curve or tournament — get_report_pages","text":"x object class \"tournament\", \"plm0\", \"plm\", \"gplm0\" \"gplm\". type integer denoting type report produced. Defaults type 1. Possible types : 1 Produces report displaying results model (winning model tournament provided). first page contains panel four plots summary posterior distributions parameters. second page tabular prediction discharge equally spaced grid stages displayed. prediction table can span multiple pages. 2 Produces ten page report permissible objects class \"tournament\". first four pages contain panel four plots summary posterior distributions parameters four models tournament, fifth page shows summary tournament model comparison, sixth page convergence diagnostics plots, final four pages shows histograms parameters four models.","code":""},{"path":"https://sor16.github.io/bdrc/reference/get_report_pages.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Report pages for a discharge rating curve or tournament — get_report_pages","text":"list objects type \"grob\" correspond pages rating curve report.","code":""},{"path":"https://sor16.github.io/bdrc/reference/get_report_pages.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Report pages for a discharge rating curve or tournament — get_report_pages","text":"get_report_pages(plm0): Get report pages plm0 model object get_report_pages(plm): Get report pages plm model object get_report_pages(gplm0): Get report pages gplm0 model object get_report_pages(gplm): Get report pages gplm model object get_report_pages(tournament): Get report pages discharge rating curve tournament model object","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/get_report_pages.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Report pages for a discharge rating curve or tournament — get_report_pages","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.09%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). plm0_pages <- get_report_pages(plm0.fit) # }"},{"path":"https://sor16.github.io/bdrc/reference/gplm.html","id":null,"dir":"Reference","previous_headings":"","what":"Generalized power-law model with variance that varies with stage. — gplm","title":"Generalized power-law model with variance that varies with stage. — gplm","text":"gplm used fit discharge rating curve paired measurements stage discharge using generalized power-law model variance varies stage described Hrafnkelsson et al. (2022). See \"Details\" elaborate description model.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generalized power-law model with variance that varies with stage. — gplm","text":"","code":"gplm( formula, data, c_param = NULL, h_max = NULL, parallel = TRUE, num_cores = NULL, forcepoint = rep(FALSE, nrow(data)), verbose = TRUE )"},{"path":"https://sor16.github.io/bdrc/reference/gplm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generalized power-law model with variance that varies with stage. — gplm","text":"formula object class \"formula\", discharge column name response stage column name covariate, .e. form y~x y discharge m\\(^3/\\)s x stage m (important data correct units). data data.frame containing variables specified formula. c_param largest stage value zero discharge. NULL, treated unknown model inferred data. h_max maximum stage rating curve extrapolate . NULL, maximum stage value data selected upper bound. parallel logical value indicating whether run MCMC parallel . Defaults TRUE. num_cores integer 1 4 (number MCMC chains) indicating many cores use. used parallel=TRUE. NULL, number cores available device detected automatically. forcepoint logical vector length number rows data. element index \\(\\) TRUE indicates rating curve forced \\(\\)-th measurement. Use care, strongly influence resulting rating curve. verbose logical value indicating whether print progress diagnostic information. `TRUE`, function print messages runs. `FALSE`, function run silently. Default `TRUE`.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generalized power-law model with variance that varies with stage. — gplm","text":"gplm returns object class \"gplm\". object class \"gplm\" list containing following components: rating_curve data frame 2.5%, 50% 97.5% percentiles posterior predictive distribution rating curve. rating_curve_mean data frame 2.5%, 50% 97.5% percentiles posterior distribution mean rating curve. param_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution latent- hyperparameters. Additionally contains columns r_hat effective number samples parameter defined Gelman et al. (2013). f_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution \\(f(h)\\). beta_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution \\(\\beta(h)\\). sigma_eps_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution \\(\\sigma_\\varepsilon(h)\\). posterior_log_likelihood_summary data frame 2.5%, 50% 97.5% percentiles posterior log-likelihood values. rating_curve_posterior matrix containing full thinned posterior samples posterior predictive distribution rating curve excluding burn-samples. rating_curve_mean_posterior matrix containing full thinned posterior samples posterior distribution mean rating curve excluding burn-samples. a_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\) excluding burn-samples. b_posterior numeric vector containing full thinned posterior samples posterior distribution \\(b\\) excluding burn-samples. c_posterior numeric vector containing full thinned posterior samples posterior distribution \\(c\\) excluding burn-samples. sigma_beta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_\\beta\\) excluding burn-samples. phi_beta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\phi_\\beta\\) excluding burn-samples. sigma_eta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_\\eta\\) excluding burn-samples. eta_1_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_1\\) excluding burn-samples. eta_2_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_2\\) excluding burn-samples. eta_3_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_3\\) excluding burn-samples. eta_4_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_4\\) excluding burn-samples. eta_5_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_5\\) excluding burn-samples. eta_6_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_6\\) excluding burn-samples. f_posterior numeric vector containing full thinned posterior samples posterior distribution \\(f(h)\\) excluding burn-samples. beta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\beta(h)\\) excluding burn-samples. sigma_eps_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_\\varepsilon(h)\\) excluding burn-samples. posterior_log_likelihood numeric vector containing full thinned posterior log-likelihood values, excluding burn-samples. D_hat statistic defined -2 times log-likelihood evaluated median value parameters. effective_num_param_DIC effective number parameters, calculated median(-2*posterior_log_likelihood) minus D_hat. DIC Deviance Information Criterion model, calculated D_hat plus 2*effective_num_parameters_DIC. lppd log pointwise predictive density observed data model. WAIC Widely Applicable Information Criterion model, defined -2*( lppd - effective_num_param_WAIC ). WAIC_i pointwise WAIC values, WAIC := sum(WAIC_i). effective_num_param_WAIC effective number parameters, calculated summing posterior variance log predictive density data point. autocorrelation data frame autocorrelation parameter different lags. acceptance_rate proportion accepted samples thinned MCMC chain (excluding burn-). formula object type \"formula\" provided user. data data provided user, ordered stage. run_info information input arguments specific parameters used MCMC chain.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Generalized power-law model with variance that varies with stage. — gplm","text":"generalized power-law model form $$Q=(h-c)^{f(h)}$$ \\(Q\\) discharge, \\(h\\) stage, \\(\\) \\(c\\) unknown constants \\(f\\) function \\(h\\), referred generalized power-law exponent. generalized power-law model inferred using Bayesian hierarchical model. function \\(f\\) modeled latent level fixed constant \\(b\\) plus continuous stochastic process, \\(\\beta(h)\\), assumed twice differentiable. model logarithmic scale $$\\log(Q_i) = \\log() + (b + \\beta(h_i)) \\log(h_i - c) + \\varepsilon_i, = 1,...,n$$ \\(\\varepsilon_i\\) follows normal distribution mean zero variance \\(\\sigma_\\varepsilon(h_i)^2\\) varies stage. stochastic process \\(\\beta(h)\\) assumed priori Gaussian process governed Matern covariance function smoothness parameter \\(\\nu = 2.5\\). error variance, \\(\\sigma_\\varepsilon^2(h)\\), log-discharge data modeled exponential B-spline curve, , linear combination six B-spline basis functions defined range stage observations. efficient posterior simulation achieved sampling joint posterior density hyperparameters model, sampling density latent parameters conditional hyperparameters. Bayesian inference based posterior density summary statistics posterior mean 95% posterior intervals based posterior density. Analytical formulas summary statistics intractable cases thus computed generating samples posterior density using Markov chain Monte Carlo simulation.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Generalized power-law model with variance that varies with stage. — gplm","text":"Gelman, ., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, ., Rubin, D. B. (2013). Bayesian Data Analysis, Third Edition. Chapman & Hall/CRC Texts Statistical Science. Taylor & Francis. doi: https://doi.org/10.1201/b16018 Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711 Spiegelhalter, D., Best, N., Carlin, B., Van Der Linde, . (2002). Bayesian measures model complexity fit. Journal Royal Statistical Society: Series B (Statistical Methodology) 64(4), 583–639. doi: https://doi.org/10.1111/1467-9868.00353 Watanabe, S. (2010). Asymptotic equivalence Bayes cross validation widely applicable information criterion singular learning theory. J. Mach. Learn. Res. 11, 3571–3594.","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/gplm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generalized power-law model with variance that varies with stage. — gplm","text":"","code":"# \\donttest{ data(norn) set.seed(1) gplm.fit <- gplm(formula=Q~W,data=norn,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 22.81%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). summary(gplm.fit) #> #> Formula: #> Q ~ W #> Latent parameters: #> lower-2.5% median-50% upper-97.5% #> a 13.40 24.55 32.51 #> b 1.83 1.84 1.84 #> #> Hyperparameters: #> lower-2.5% median-50% upper-97.5% #> c 396.421 396.669 396.812 #> sigma_beta 0.165 0.338 0.806 #> phi_beta 1.343 2.987 6.894 #> sigma_eta 0.048 0.436 0.897 #> eta_1 -6.128 -5.395 -4.399 #> eta_2 -7.692 -5.974 -4.521 #> eta_3 -9.093 -7.048 -5.072 #> eta_4 -10.429 -8.051 -5.135 #> eta_5 -11.473 -8.717 -5.092 #> eta_6 -12.436 -9.279 -5.095 #> #> WAIC: -141.1422 # }"},{"path":"https://sor16.github.io/bdrc/reference/gplm0.html","id":null,"dir":"Reference","previous_headings":"","what":"Generalized power-law model with a constant variance — gplm0","title":"Generalized power-law model with a constant variance — gplm0","text":"gplm0 used fit discharge rating curve paired measurements stage discharge using generalized power-law model constant variance described Hrafnkelsson et al. (2022). See \"Details\" elaborate description model.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm0.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generalized power-law model with a constant variance — gplm0","text":"","code":"gplm0( formula, data, c_param = NULL, h_max = NULL, parallel = TRUE, num_cores = NULL, forcepoint = rep(FALSE, nrow(data)), verbose = TRUE )"},{"path":"https://sor16.github.io/bdrc/reference/gplm0.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generalized power-law model with a constant variance — gplm0","text":"formula object class \"formula\", discharge column name response stage column name covariate, .e. form y~x y discharge m\\(^3/\\)s x stage m (important data correct units). data data.frame containing variables specified formula. c_param largest stage value zero discharge. NULL, treated unknown model inferred data. h_max maximum stage rating curve extrapolate . NULL, maximum stage value data selected upper bound. parallel logical value indicating whether run MCMC parallel . Defaults TRUE. num_cores integer 1 4 (number MCMC chains) indicating many cores use. used parallel=TRUE. NULL, number cores available device detected automatically. forcepoint logical vector length number rows data. element index \\(\\) TRUE indicates rating curve forced \\(\\)-th measurement. Use care, strongly influence resulting rating curve. verbose logical value indicating whether print progress diagnostic information. `TRUE`, function print messages runs. `FALSE`, function run silently. Default `TRUE`.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm0.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generalized power-law model with a constant variance — gplm0","text":"gplm0 returns object class \"gplm0\". object class \"gplm0\" list containing following components: rating_curve data frame 2.5%, 50% 97.5% percentiles posterior predictive distribution rating curve. rating_curve_mean data frame 2.5%, 50% 97.5% percentiles posterior distribution mean rating curve. param_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution latent- hyperparameters. Additionally contains columns r_hat effective number samples parameter defined Gelman et al. (2013). beta_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution \\(\\beta\\). posterior_log_likelihood_summary data frame 2.5%, 50% 97.5% percentiles posterior log-likelihood values. rating_curve_posterior matrix containing full thinned posterior samples posterior predictive distribution rating curve (excluding burn-). rating_curve_mean_posterior matrix containing full thinned posterior samples posterior distribution mean rating curve (excluding burn-). a_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\). b_posterior numeric vector containing full thinned posterior samples posterior distribution \\(b\\). c_posterior numeric vector containing full thinned posterior samples posterior distribution \\(c\\). sigma_eps_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_{\\varepsilon}\\). sigma_beta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_{\\beta}\\). phi_beta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\phi_{\\beta}\\). sigma_eta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_{\\eta}\\). beta_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\beta\\). posterior_log_likelihood numeric vector containing full thinned posterior log-likelihood values, excluding burn-samples. D_hat statistic defined -2 times log-likelihood evaluated median value parameters. effective_num_param_DIC effective number parameters, calculated median(-2*posterior_log_likelihood) minus D_hat. DIC Deviance Information Criterion model, calculated D_hat plus 2*effective_num_parameters_DIC. lppd log pointwise predictive density observed data model. WAIC Widely Applicable Information Criterion model, defined -2*( lppd - effective_num_param_WAIC ). WAIC_i pointwise WAIC values, WAIC := sum(WAIC_i). effective_num_param_WAIC effective number parameters, calculated summing posterior variance log predictive density data point. autocorrelation data frame autocorrelation parameter different lags. acceptance_rate proportion accepted samples thinned MCMC chain (excluding burn-). formula object type \"formula\" provided user. data data provided user, ordered stage. run_info information input arguments specific parameters used MCMC chain.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm0.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Generalized power-law model with a constant variance — gplm0","text":"generalized power-law model form $$Q=(h-c)^{f(h)}$$ \\(Q\\) discharge, \\(h\\) stage, \\(\\) \\(c\\) unknown constants \\(f\\) function \\(h\\) referred generalized power-law exponent. generalized power-law model inferred using Bayesian hierarchical model. function \\(f\\) modeled latent level fixed constant $b$ plus continuous stochastic process,\\(\\beta(h)\\), assumed twice differentiable. model logarithmic scale $$\\log(Q_i) = \\log() + (b + \\beta(h_i)) \\log(h_i - c) + \\varepsilon, = 1,...,n$$ \\(\\varepsilon\\) follows normal distribution mean zero variance \\(\\sigma_\\varepsilon^2\\), independent stage. stochastic process \\(\\beta(h)\\) assumed priori Gaussian process governed Matern covariance function smoothness parameter \\(\\nu = 2.5\\). efficient posterior simulation achieved sampling joint posterior density hyperparameters model, sampling density latent parameters conditional hyperparameters. Bayesian inference based posterior density summary statistics posterior mean 95% posterior intervals based posterior density. Analytical formulas summary statistics intractable cases thus computed generating samples posterior density using Markov chain Monte Carlo simulation.","code":""},{"path":"https://sor16.github.io/bdrc/reference/gplm0.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Generalized power-law model with a constant variance — gplm0","text":"Gelman, ., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, ., Rubin, D. B. (2013). Bayesian Data Analysis, Third Edition. Chapman & Hall/CRC Texts Statistical Science. Taylor & Francis. doi: https://doi.org/10.1201/b16018 Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711 Spiegelhalter, D., Best, N., Carlin, B., Van Der Linde, . (2002). Bayesian measures model complexity fit. Journal Royal Statistical Society: Series B (Statistical Methodology) 64(4), 583–639. doi: https://doi.org/10.1111/1467-9868.00353 Watanabe, S. (2010). Asymptotic equivalence Bayes cross validation widely applicable information criterion singular learning theory. J. Mach. Learn. Res. 11, 3571–3594.","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/gplm0.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generalized power-law model with a constant variance — gplm0","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) gplm0.fit <- gplm0(formula=Q~W,data=krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.64%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). summary(gplm0.fit) #> #> Formula: #> Q ~ W #> Latent parameters: #> lower-2.5% median-50% upper-97.5% #> a 1.52 1.95 2.24 #> b 1.83 1.84 1.84 #> #> Hyperparameters: #> lower-2.5% median-50% upper-97.5% #> c 7.7158 7.810 7.855 #> sigma_eps 0.0915 0.119 0.163 #> sigma_beta 0.6492 0.836 1.127 #> phi_beta 0.5724 1.207 2.965 #> #> WAIC: -27.34769 # }"},{"path":"https://sor16.github.io/bdrc/reference/jokdal.html","id":null,"dir":"Reference","previous_headings":"","what":"Jokulsa a Dal gauging station in Iceland — jokdal","title":"Jokulsa a Dal gauging station in Iceland — jokdal","text":"Data discharge stage Jokulsa Dal gauging station Iceland","code":""},{"path":"https://sor16.github.io/bdrc/reference/jokdal.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Jokulsa a Dal gauging station in Iceland — jokdal","text":"","code":"jokdal"},{"path":"https://sor16.github.io/bdrc/reference/jokdal.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Jokulsa a Dal gauging station in Iceland — jokdal","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/jokdal.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Jokulsa a Dal gauging station in Iceland — jokdal","text":"Icelandic Meteorological Office, Landsvirkjun - National Power Company Iceland, Icelandic Road Coastal Administration.","code":""},{"path":"https://sor16.github.io/bdrc/reference/jokfjoll.html","id":null,"dir":"Reference","previous_headings":"","what":"Jokulsa a Fjollum gauging station in Iceland — jokfjoll","title":"Jokulsa a Fjollum gauging station in Iceland — jokfjoll","text":"Data discharge stage Jokulsa Fjollum gauging station Iceland","code":""},{"path":"https://sor16.github.io/bdrc/reference/jokfjoll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Jokulsa a Fjollum gauging station in Iceland — jokfjoll","text":"","code":"jokfjoll"},{"path":"https://sor16.github.io/bdrc/reference/jokfjoll.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Jokulsa a Fjollum gauging station in Iceland — jokfjoll","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/jokfjoll.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Jokulsa a Fjollum gauging station in Iceland — jokfjoll","text":"Icelandic Meteorological Office, Landsvirkjun - National Power Company Iceland, Icelandic Road Coastal Administration.","code":""},{"path":"https://sor16.github.io/bdrc/reference/kallstorp.html","id":null,"dir":"Reference","previous_headings":"","what":"Kallstorp gauging station in Sweden — kallstorp","title":"Kallstorp gauging station in Sweden — kallstorp","text":"Data discharge stage Kallstorp gauging station Sweden","code":""},{"path":"https://sor16.github.io/bdrc/reference/kallstorp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Kallstorp gauging station in Sweden — kallstorp","text":"","code":"kallstorp"},{"path":"https://sor16.github.io/bdrc/reference/kallstorp.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Kallstorp gauging station in Sweden — kallstorp","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/kallstorp.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Kallstorp gauging station in Sweden — kallstorp","text":"Swedish Meteorological Hydrological Institute.","code":""},{"path":"https://sor16.github.io/bdrc/reference/krokfors.html","id":null,"dir":"Reference","previous_headings":"","what":"Krokfors gauging station in Sweden — krokfors","title":"Krokfors gauging station in Sweden — krokfors","text":"Data discharge stage Krokfors gauging station Sweden.","code":""},{"path":"https://sor16.github.io/bdrc/reference/krokfors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Krokfors gauging station in Sweden — krokfors","text":"","code":"krokfors"},{"path":"https://sor16.github.io/bdrc/reference/krokfors.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Krokfors gauging station in Sweden — krokfors","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/krokfors.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Krokfors gauging station in Sweden — krokfors","text":"Swedish Meteorological Hydrological Institute.","code":""},{"path":"https://sor16.github.io/bdrc/reference/melby.html","id":null,"dir":"Reference","previous_headings":"","what":"Melby gauging station in Sweden — melby","title":"Melby gauging station in Sweden — melby","text":"Data discharge stage Melby gauging station Sweden","code":""},{"path":"https://sor16.github.io/bdrc/reference/melby.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Melby gauging station in Sweden — melby","text":"","code":"melby"},{"path":"https://sor16.github.io/bdrc/reference/melby.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Melby gauging station in Sweden — melby","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/melby.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Melby gauging station in Sweden — melby","text":"Swedish Meteorological Hydrological Institute.","code":""},{"path":"https://sor16.github.io/bdrc/reference/nordura.html","id":null,"dir":"Reference","previous_headings":"","what":"Nordura gauging station in Iceland — nordura","title":"Nordura gauging station in Iceland — nordura","text":"Data discharge stage Nordura gauging station Iceland","code":""},{"path":"https://sor16.github.io/bdrc/reference/nordura.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Nordura gauging station in Iceland — nordura","text":"","code":"nordura"},{"path":"https://sor16.github.io/bdrc/reference/nordura.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Nordura gauging station in Iceland — nordura","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/nordura.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Nordura gauging station in Iceland — nordura","text":"Icelandic Meteorological Office, Landsvirkjun - National Power Company Iceland, Icelandic Road Coastal Administration.","code":""},{"path":"https://sor16.github.io/bdrc/reference/norn.html","id":null,"dir":"Reference","previous_headings":"","what":"Norn gauging station in Sweden — norn","title":"Norn gauging station in Sweden — norn","text":"Data discharge stage Norn gauging station Sweden.","code":""},{"path":"https://sor16.github.io/bdrc/reference/norn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Norn gauging station in Sweden — norn","text":"","code":"norn"},{"path":"https://sor16.github.io/bdrc/reference/norn.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Norn gauging station in Sweden — norn","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/norn.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Norn gauging station in Sweden — norn","text":"Swedish Meteorological Hydrological Institute.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm.html","id":null,"dir":"Reference","previous_headings":"","what":"Power-law model with variance that varies with stage. — plm","title":"Power-law model with variance that varies with stage. — plm","text":"plm used fit discharge rating curve paired measurements stage discharge using power-law model variance varies stage described Hrafnkelsson et al. (2022). See \"Details\" elaborate description model.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Power-law model with variance that varies with stage. — plm","text":"","code":"plm( formula, data, c_param = NULL, h_max = NULL, parallel = TRUE, num_cores = NULL, forcepoint = rep(FALSE, nrow(data)), verbose = TRUE )"},{"path":"https://sor16.github.io/bdrc/reference/plm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Power-law model with variance that varies with stage. — plm","text":"formula object class \"formula\", discharge column name response stage column name covariate, .e. form y~x y discharge m\\(^3/\\)s x stage m (important data correct units). data data.frame containing variables specified formula. c_param largest stage value zero discharge. NULL, treated unknown model inferred data. h_max maximum stage rating curve extrapolate . NULL, maximum stage value data selected upper bound. parallel logical value indicating whether run MCMC parallel . Defaults TRUE. num_cores integer 1 4 (number MCMC chains) indicating many cores use. used parallel=TRUE. NULL, number cores available device detected automatically. forcepoint logical vector length number rows data. element index \\(\\) TRUE indicates rating curve forced \\(\\)-th measurement. Use care, strongly influence resulting rating curve. verbose logical value indicating whether print progress diagnostic information. `TRUE`, function print messages runs. `FALSE`, function run silently. Default `TRUE`.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Power-law model with variance that varies with stage. — plm","text":"plm returns object class \"plm\". object class \"plm\" list containing following components: rating_curve data frame 2.5%, 50% 97.5% percentiles posterior predictive distribution rating curve. rating_curve_mean data frame 2.5%, 50% 97.5% percentiles posterior distribution mean rating curve. Additionally contains columns r_hat effective number samples parameter defined Gelman et al. (2013). param_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution latent- hyperparameters. sigma_eps_summary data frame 2.5%, 50% 97.5% percentiles posterior \\(\\sigma_{\\varepsilon}\\). posterior_log_likelihood_summary data frame 2.5%, 50% 97.5% percentiles posterior log-likelihood values. rating_curve_posterior matrix containing full thinned posterior samples posterior predictive distribution rating curve (excluding burn-). rating_curve_mean_posterior matrix containing full thinned posterior samples posterior distribution mean rating curve (excluding burn-). a_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\). b_posterior numeric vector containing full thinned posterior samples posterior distribution \\(b\\). c_posterior numeric vector containing full thinned posterior samples posterior distribution \\(c\\). sigma_eps_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_{\\varepsilon}\\). eta_1_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_1\\). eta_2_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_2\\). eta_3_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_3\\). eta_4_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_4\\). eta_5_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_5\\). eta_6_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\eta_6\\). posterior_log_likelihood numeric vector containing full thinned posterior log-likelihood values, excluding burn-samples. D_hat statistic defined -2 times log-likelihood evaluated median value parameters. effective_num_param_DIC effective number parameters, calculated median(-2*posterior_log_likelihood) minus D_hat. DIC Deviance Information Criterion model, calculated D_hat plus 2*effective_num_parameters_DIC. lppd log pointwise predictive density observed data model. WAIC Widely Applicable Information Criterion model, defined -2*( lppd - effective_num_param_WAIC ). WAIC_i pointwise WAIC values, WAIC := sum(WAIC_i). effective_num_param_WAIC effective number parameters, calculated summing posterior variance log predictive density data point. autocorrelation data frame autocorrelation parameter different lags. acceptance_rate proportion accepted samples thinned MCMC chain (excluding burn-). formula object type \"formula\" provided user. data data provided user, ordered stage. run_info information input arguments specific parameters used MCMC chain.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Power-law model with variance that varies with stage. — plm","text":"power-law model, commonly used hydraulic practice, form $$Q=(h-c)^{b}$$ \\(Q\\) discharge, \\(h\\) stage \\(\\), \\(b\\) \\(c\\) unknown constants. power-law model inferred using Bayesian hierarchical model. model logarithmic scale $$\\log(Q_i) = \\log() + b \\log(h_i - c) + \\varepsilon_i, = 1,...,n$$ \\(\\varepsilon_i\\) follows normal distribution mean zero variance \\(\\sigma_\\varepsilon(h_i)^2\\) varies stage. error variance, \\(\\sigma_\\varepsilon^2(h)\\), log-discharge data modeled exponential B-spline curve, , linear combination six B-spline basis functions defined range stage observations. efficient posterior simulation achieved sampling joint posterior density hyperparameters model, sampling density latent parameters conditional hyperparameters. Bayesian inference based posterior density summary statistics posterior mean 95% posterior intervals based posterior density. Analytical formulas summary statistics intractable cases thus computed generating samples posterior density using Markov chain Monte Carlo simulation.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Power-law model with variance that varies with stage. — plm","text":"Gelman, ., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, ., Rubin, D. B. (2013). Bayesian Data Analysis, Third Edition. Chapman & Hall/CRC Texts Statistical Science. Taylor & Francis. doi: https://doi.org/10.1201/b16018 Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711 Spiegelhalter, D., Best, N., Carlin, B., Van Der Linde, . (2002). Bayesian measures model complexity fit. Journal Royal Statistical Society: Series B (Statistical Methodology) 64(4), 583–639. doi: https://doi.org/10.1111/1467-9868.00353 Watanabe, S. (2010). Asymptotic equivalence Bayes cross validation widely applicable information criterion singular learning theory. J. Mach. Learn. Res. 11, 3571–3594.","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/plm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Power-law model with variance that varies with stage. — plm","text":"","code":"# \\donttest{ data(spanga) set.seed(1) plm.fit <- plm(formula=Q~W,data=spanga,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 24.38%. #> ⚠ Warning: Some chains are not mixing well. Parameters with Rhat > 1.1: #> - sigma_eta: Rhat = 1.183 #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> ℹ Try re-running the model after inspecting the trace plots, convergence diagnostics plots, and reviewing the data for potential issues. summary(plm.fit) #> #> Formula: #> Q ~ W #> Latent parameters: #> lower-2.5% median-50% upper-97.5% #> a 11.07 12.51 13.79 #> b 1.92 2.05 2.21 #> #> Hyperparameters: #> lower-2.5% median-50% upper-97.5% #> c 9.40099 9.451 9.493 #> sigma_eta 0.00737 0.349 0.838 #> eta_1 -5.58296 -4.839 -3.778 #> eta_2 -7.61506 -5.951 -4.135 #> eta_3 -9.01113 -6.856 -3.948 #> eta_4 -9.84284 -7.299 -3.829 #> eta_5 -10.57394 -7.597 -3.569 #> eta_6 -10.96708 -7.528 -3.451 #> #> WAIC: -76.60638 # }"},{"path":"https://sor16.github.io/bdrc/reference/plm0.html","id":null,"dir":"Reference","previous_headings":"","what":"Power-law model with a constant variance — plm0","title":"Power-law model with a constant variance — plm0","text":"plm0 used fit discharge rating curve paired measurements stage discharge using power-law model constant variance described Hrafnkelsson et al. (2022). See \"Details\" elaborate description model.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm0.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Power-law model with a constant variance — plm0","text":"","code":"plm0( formula, data, c_param = NULL, h_max = NULL, parallel = TRUE, num_cores = NULL, forcepoint = rep(FALSE, nrow(data)), verbose = TRUE )"},{"path":"https://sor16.github.io/bdrc/reference/plm0.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Power-law model with a constant variance — plm0","text":"formula object class \"formula\", discharge column name response stage column name covariate, .e. form y~x y discharge m\\(^3/\\)s x stage m (important data correct units). data data.frame containing variables specified formula. c_param largest stage value zero discharge. NULL, treated unknown model inferred data. h_max maximum stage rating curve extrapolate . NULL, maximum stage value data selected upper bound. parallel logical value indicating whether run MCMC parallel . Defaults TRUE. num_cores integer 1 4 (number MCMC chains) indicating many cores use. used parallel=TRUE. NULL, number cores available device detected automatically. forcepoint logical vector length number rows data. element index \\(\\) TRUE indicates rating curve forced \\(\\)-th measurement. Use care, strongly influence resulting rating curve. verbose logical value indicating whether print progress diagnostic information. `TRUE`, function print messages runs. `FALSE`, function run silently. Default `TRUE`.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm0.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Power-law model with a constant variance — plm0","text":"plm0 returns object class \"plm0\". object class \"plm0\" list containing following components: rating_curve data frame 2.5%, 50% 97.5% percentiles posterior predictive distribution rating curve. rating_curve_mean data frame 2.5%, 50% 97.5% percentiles posterior distribution mean rating curve. param_summary data frame 2.5%, 50% 97.5% percentiles posterior distribution latent- hyperparameters. Additionally contains columns r_hat effective number samples parameter defined Gelman et al. (2013). posterior_log_likelihood_summary data frame 2.5%, 50% 97.5% percentiles posterior log-likelihood values. rating_curve_posterior matrix containing full thinned posterior samples posterior predictive distribution rating curve (excluding burn-). rating_curve_mean_posterior matrix containing full thinned posterior samples posterior distribution mean rating curve (excluding burn-). a_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\). b_posterior numeric vector containing full thinned posterior samples posterior distribution \\(b\\). c_posterior numeric vector containing full thinned posterior samples posterior distribution \\(c\\). sigma_eps_posterior numeric vector containing full thinned posterior samples posterior distribution \\(\\sigma_{\\varepsilon}\\). posterior_log_likelihood numeric vector containing full thinned posterior log-likelihood values, excluding burn-samples. D_hat statistic defined -2 times log-likelihood evaluated median value parameters. effective_num_param_DIC effective number parameters, calculated median(-2*posterior_log_likelihood) minus D_hat. DIC Deviance Information Criterion model, calculated D_hat plus 2*effective_num_parameters_DIC. lppd log pointwise predictive density observed data model. WAIC Widely Applicable Information Criterion model, defined -2*( lppd - effective_num_param_WAIC ). WAIC_i pointwise WAIC values, WAIC := sum(WAIC_i). effective_num_param_WAIC effective number parameters, calculated summing posterior variance log predictive density data point. autocorrelation data frame autocorrelation parameter different lags. acceptance_rate proportion accepted samples thinned MCMC chain (excluding burn-). formula object type \"formula\" provided user. data data provided user, ordered stage. run_info information input arguments specific parameters used MCMC chain.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm0.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Power-law model with a constant variance — plm0","text":"power-law model, commonly used hydraulic practice, form $$Q=(h-c)^{b}$$ \\(Q\\) discharge, \\(h\\) stage \\(\\), \\(b\\) \\(c\\) unknown constants. power-law model inferred using Bayesian hierarchical model. model logarithmic scale $$\\log(Q_i) = \\log() + b \\log(h_i - c) + \\varepsilon, = 1,...,n$$ \\(\\varepsilon\\) follows normal distribution mean zero variance \\(\\sigma_\\varepsilon^2\\), independent stage. efficient posterior simulation achieved sampling joint posterior density hyperparameters model, sampling density latent parameters conditional hyperparameters. Bayesian inference based posterior density summary statistics posterior mean 95% posterior intervals based posterior density. Analytical formulas summary statistics intractable cases thus computed generating samples posterior density using Markov chain Monte Carlo simulation.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plm0.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Power-law model with a constant variance — plm0","text":"Gelman, ., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, ., Rubin, D. B. (2013). Bayesian Data Analysis, Third Edition. Chapman & Hall/CRC Texts Statistical Science. Taylor & Francis. doi: https://doi.org/10.1201/b16018 Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711 Spiegelhalter, D., Best, N., Carlin, B., Van Der Linde, . (2002). Bayesian measures model complexity fit. Journal Royal Statistical Society: Series B (Statistical Methodology) 64(4), 583–639. doi: https://doi.org/10.1111/1467-9868.00353 Watanabe, S. (2010). Asymptotic equivalence Bayes cross validation widely applicable information criterion singular learning theory. J. Mach. Learn. Res. 11, 3571–3594.","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/plm0.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Power-law model with a constant variance — plm0","text":"","code":"# \\donttest{ data(skogsliden) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=skogsliden,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 37.00%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). summary(plm0.fit) #> #> Formula: #> Q ~ W #> Latent parameters: #> lower-2.5% median-50% upper-97.5% #> a 10.29 10.77 11.22 #> b 2.09 2.17 2.26 #> #> Hyperparameters: #> lower-2.5% median-50% upper-97.5% #> c 3.9042 3.9201 3.9341 #> sigma_eps 0.0455 0.0592 0.0805 #> #> WAIC: -68.50725 # }"},{"path":"https://sor16.github.io/bdrc/reference/plot.plm0.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot method for discharge rating curves — plot.plm0","title":"Plot method for discharge rating curves — plot.plm0","text":"Visualize discharge rating curve model objects","code":""},{"path":"https://sor16.github.io/bdrc/reference/plot.plm0.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot method for discharge rating curves — plot.plm0","text":"","code":"# S3 method for class 'plm0' plot( x, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... ) # S3 method for class 'plm' plot( x, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... ) # S3 method for class 'gplm0' plot( x, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... ) # S3 method for class 'gplm' plot( x, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... )"},{"path":"https://sor16.github.io/bdrc/reference/plot.plm0.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot method for discharge rating curves — plot.plm0","text":"x object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". type character denoting type plot drawn. Defaults \"rating_curve\". Possible types : rating_curve Plots rating curve. rating_curve_mean Plots posterior mean rating curve. f Plots power-law exponent. beta Plots random effect power-law exponent. sigma_eps Plots standard deviation data level. residuals Plots log residuals. trace Plots trace plots parameters given param. histogram Plots histograms parameters given param. panel Plots 2x2 panel plots: \"rating curve\", \"residuals\", \"f\" \"sigma_eps\". param character vector parameters plot. Defaults NULL used type \"trace\" \"histogram\". Allowed values parameters given model summary x well \"hyperparameters\" \"latent_parameters\" specific groups parameters. transformed logical value indicating whether quantity plotted transformed scale used Bayesian inference. Defaults FALSE. title character denoting title plot. xlim numeric vector length 2, denoting limits x axis plot. Applicable types \"rating_curve\", \"rating_curve_mean\", \"f\", \"beta\", \"sigma_eps\", \"residuals\". ylim numeric vector length 2, denoting limits y axis plot. Applicable types \"rating_curve\", \"rating_curve_mean\", \"f\", \"beta\", \"sigma_eps\", \"residuals\". ... used function","code":""},{"path":"https://sor16.github.io/bdrc/reference/plot.plm0.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot method for discharge rating curves — plot.plm0","text":"return value, called side effects.","code":""},{"path":"https://sor16.github.io/bdrc/reference/plot.plm0.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Plot method for discharge rating curves — plot.plm0","text":"plot(plm0): Plot method plm0 plot(plm): Plot method plm plot(gplm0): Plot method gplm0 plot(gplm): Plot method gplm","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/plot.plm0.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot method for discharge rating curves — plot.plm0","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.09%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). plot(plm0.fit) plot(plm0.fit,transformed=TRUE) plot(plm0.fit,type='histogram',param='c') plot(plm0.fit,type='histogram',param='c',transformed=TRUE) plot(plm0.fit,type='histogram',param='hyperparameters') plot(plm0.fit,type='histogram',param='latent_parameters') plot(plm0.fit,type='residuals') plot(plm0.fit,type='f') plot(plm0.fit,type='sigma_eps') # }"},{"path":"https://sor16.github.io/bdrc/reference/plot.tournament.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot method for a discharge rating curve tournament — plot.tournament","title":"Plot method for a discharge rating curve tournament — plot.tournament","text":"Compare four models tournament object multiple ways","code":""},{"path":"https://sor16.github.io/bdrc/reference/plot.tournament.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot method for a discharge rating curve tournament — plot.tournament","text":"","code":"# S3 method for class 'tournament' plot(x, type = \"tournament_results\", transformed = FALSE, ...)"},{"path":"https://sor16.github.io/bdrc/reference/plot.tournament.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot method for a discharge rating curve tournament — plot.tournament","text":"x object class \"tournament\" type character denoting type plot drawn. Possible types : boxplot Creates boxplot posterior log-likelihood values, deviance scale. rating_curve Plots rating curve. rating_curve_mean Plots posterior mean rating curve. f Plots power-law exponent. sigma_eps Plots standard deviation data level. residuals Plots log residuals. tournament_results Plots diagram showing tournament results. transformed logical value indicating whether quantity plotted transformed scale used Bayesian inference. Defaults FALSE. ... used function","code":""},{"path":"https://sor16.github.io/bdrc/reference/plot.tournament.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot method for a discharge rating curve tournament — plot.tournament","text":"return value, called side effects","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/plot.tournament.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot method for a discharge rating curve tournament — plot.tournament","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) t_obj <- tournament(formula = Q ~ W, data = krokfors, num_cores = 2) #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.33%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.14%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.66%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.04%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% plot(t_obj) plot(t_obj, transformed = TRUE) plot(t_obj, type = 'boxplot') plot(t_obj, type = 'f') plot(t_obj, type = 'sigma_eps') plot(t_obj, type = 'residuals') plot(t_obj, type = 'tournament_results') # }"},{"path":"https://sor16.github.io/bdrc/reference/plot_fun.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot bdrc model objects — plot_fun","title":"Plot bdrc model objects — plot_fun","text":"Visualize results model objects bdrc, plm0, plm, gplm0, gplm","code":""},{"path":"https://sor16.github.io/bdrc/reference/plot_fun.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot bdrc model objects — plot_fun","text":"","code":"plot_fun( x, type = \"rating_curve\", param = NULL, transformed = FALSE, title = NULL, xlim = NULL, ylim = NULL, ... )"},{"path":"https://sor16.github.io/bdrc/reference/plot_fun.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot bdrc model objects — plot_fun","text":"x object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". type character denoting type plot drawn. Defaults \"rating_curve\". Possible types : rating_curve Plots rating curve. rating_curve_mean Plots posterior mean rating curve. f Plots power-law exponent. beta Plots random effect power-law exponent. sigma_eps Plots standard deviation data level. residuals Plots log residuals. trace Plots trace plots parameters given param. histogram Plots histograms parameters given param. panel Plots 2x2 panel plots: \"rating curve\", \"residuals\", \"f\" \"sigma_eps\". param character vector parameters plot. Defaults NULL used type \"trace\" \"histogram\". Allowed values parameters given model summary x well \"hyperparameters\" \"latent_parameters\" specific groups parameters. transformed logical value indicating whether quantity plotted transformed scale used Bayesian inference. Defaults FALSE. title character denoting title plot. Defaults NULL, .e. title. xlim numeric vector length 2, denoting limits x axis plot. Applicable types \"rating_curve\", \"rating_curve_mean\", \"f\", \"beta\", \"sigma_eps\", \"residuals\". ylim numeric vector length 2, denoting limits y axis plot. Applicable types \"rating_curve\", \"rating_curve_mean\", \"f\", \"beta\", \"sigma_eps\", \"residuals\".","code":""},{"path":"https://sor16.github.io/bdrc/reference/plot_fun.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot bdrc model objects — plot_fun","text":"Returns object class ggplot2.","code":""},{"path":"https://sor16.github.io/bdrc/reference/predict.plm0.html","id":null,"dir":"Reference","previous_headings":"","what":"Predict method for discharge rating curves — predict.plm0","title":"Predict method for discharge rating curves — predict.plm0","text":"Predict discharge given stage values based discharge rating curve model object.","code":""},{"path":"https://sor16.github.io/bdrc/reference/predict.plm0.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predict method for discharge rating curves — predict.plm0","text":"","code":"# S3 method for class 'plm0' predict(object, newdata = NULL, wide = FALSE, ...) # S3 method for class 'plm' predict(object, newdata = NULL, wide = FALSE, ...) # S3 method for class 'gplm0' predict(object, newdata = NULL, wide = FALSE, ...) # S3 method for class 'gplm' predict(object, newdata = NULL, wide = FALSE, ...)"},{"path":"https://sor16.github.io/bdrc/reference/predict.plm0.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predict method for discharge rating curves — predict.plm0","text":"object object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". newdata numeric vector stage values predict. omitted, stage values data used. wide logical value denoting whether produce wide prediction output. TRUE, output table median prediction values equally spaced grid stages 1 cm increments, row containing predictions decimeter range stages. ... used function","code":""},{"path":"https://sor16.github.io/bdrc/reference/predict.plm0.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Predict method for discharge rating curves — predict.plm0","text":"object class \"data.frame\" four columns: h stage. lower 2.5% posterior predictive quantile. median 50% posterior predictive quantile. upper 97.5% posterior predictive quantile. wide=TRUE, matrix described (see wide parameter) returned.","code":""},{"path":"https://sor16.github.io/bdrc/reference/predict.plm0.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Predict method for discharge rating curves — predict.plm0","text":"predict(plm0): Predict method plm0 predict(plm): Predict method plm predict(gplm0): Predict method gplm0 predict(gplm): Predict method gplm","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/predict.plm0.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Predict method for discharge rating curves — predict.plm0","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=krokfors,h_max=10,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.22%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #predict rating curve on a equally 10 cm spaced grid from 9 to 10 meters predict(plm0.fit,newdata=seq(9,10,by=0.1)) #> h lower median upper #> 1 9.0 2.423761 3.617127 5.355104 #> 2 9.1 2.988084 4.448245 6.528722 #> 3 9.2 3.616549 5.374700 7.940233 #> 4 9.3 4.291666 6.418404 9.515431 #> 5 9.4 5.056743 7.601828 11.323903 #> 6 9.5 5.914344 8.919305 13.169163 #> 7 9.6 6.893257 10.380845 15.570683 #> 8 9.7 7.860588 11.974804 17.826516 #> 9 9.8 9.052186 13.709759 20.592950 #> 10 9.9 10.158058 15.660659 23.351463 #> 11 10.0 11.489777 17.692248 26.874426 # }"},{"path":"https://sor16.github.io/bdrc/reference/print.plm0.html","id":null,"dir":"Reference","previous_headings":"","what":"Print method for discharge rating curves — print.plm0","title":"Print method for discharge rating curves — print.plm0","text":"Print discharge rating curve model object","code":""},{"path":"https://sor16.github.io/bdrc/reference/print.plm0.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Print method for discharge rating curves — print.plm0","text":"","code":"# S3 method for class 'plm0' print(x, ...) # S3 method for class 'plm' print(x, ...) # S3 method for class 'gplm0' print(x, ...) # S3 method for class 'gplm' print(x, ...)"},{"path":"https://sor16.github.io/bdrc/reference/print.plm0.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Print method for discharge rating curves — print.plm0","text":"x object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". ... used function","code":""},{"path":"https://sor16.github.io/bdrc/reference/print.plm0.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Print method for discharge rating curves — print.plm0","text":"print(plm0): Print method plm0 print(plm): Print method plm print(gplm0): Print method gplm0 print(gplm): Print method gplm","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/print.tournament.html","id":null,"dir":"Reference","previous_headings":"","what":"Print method for discharge rating curve tournament — print.tournament","title":"Print method for discharge rating curve tournament — print.tournament","text":"Print results tournament discharge rating curve model comparisons","code":""},{"path":"https://sor16.github.io/bdrc/reference/print.tournament.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Print method for discharge rating curve tournament — print.tournament","text":"","code":"# S3 method for class 'tournament' print(x, ...)"},{"path":"https://sor16.github.io/bdrc/reference/print.tournament.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Print method for discharge rating curve tournament — print.tournament","text":"x object class \"tournament\" ... used function","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/skjalf.html","id":null,"dir":"Reference","previous_headings":"","what":"Skjalfandafljot gauging station in Iceland — skjalf","title":"Skjalfandafljot gauging station in Iceland — skjalf","text":"Data discharge stage Skjalfandafljot gauging station Iceland","code":""},{"path":"https://sor16.github.io/bdrc/reference/skjalf.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Skjalfandafljot gauging station in Iceland — skjalf","text":"","code":"skjalf"},{"path":"https://sor16.github.io/bdrc/reference/skjalf.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Skjalfandafljot gauging station in Iceland — skjalf","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/skjalf.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Skjalfandafljot gauging station in Iceland — skjalf","text":"Icelandic Meteorological Office, Landsvirkjun - National Power Company Iceland, Icelandic Road Coastal Administration.","code":""},{"path":"https://sor16.github.io/bdrc/reference/skogsliden.html","id":null,"dir":"Reference","previous_headings":"","what":"Skogsliden gauging station in Sweden — skogsliden","title":"Skogsliden gauging station in Sweden — skogsliden","text":"Data discharge stage Skogsliden gauging station Sweden","code":""},{"path":"https://sor16.github.io/bdrc/reference/skogsliden.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Skogsliden gauging station in Sweden — skogsliden","text":"","code":"skogsliden"},{"path":"https://sor16.github.io/bdrc/reference/skogsliden.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Skogsliden gauging station in Sweden — skogsliden","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/skogsliden.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Skogsliden gauging station in Sweden — skogsliden","text":"Swedish Meteorological Hydrological Institute.","code":""},{"path":"https://sor16.github.io/bdrc/reference/spanga.html","id":null,"dir":"Reference","previous_headings":"","what":"Spanga gauging station in Sweden — spanga","title":"Spanga gauging station in Sweden — spanga","text":"Data discharge stage Spanga gauging station Sweden.","code":""},{"path":"https://sor16.github.io/bdrc/reference/spanga.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Spanga gauging station in Sweden — spanga","text":"","code":"spanga"},{"path":"https://sor16.github.io/bdrc/reference/spanga.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Spanga gauging station in Sweden — spanga","text":"data frame columns: W Measurements water stage meters Q Measurements water discharge cubic meters per second","code":""},{"path":"https://sor16.github.io/bdrc/reference/spanga.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Spanga gauging station in Sweden — spanga","text":"Swedish Meteorological Hydrological Institute.","code":""},{"path":"https://sor16.github.io/bdrc/reference/spread_draws.html","id":null,"dir":"Reference","previous_headings":"","what":"Spread MCMC chain draws to data.frame on a wide format — spread_draws","title":"Spread MCMC chain draws to data.frame on a wide format — spread_draws","text":"Useful convert MCMC chain draws particular parameters output model object wide format data wrangling","code":""},{"path":"https://sor16.github.io/bdrc/reference/spread_draws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Spread MCMC chain draws to data.frame on a wide format — spread_draws","text":"","code":"spread_draws(mod, ..., transformed = FALSE)"},{"path":"https://sor16.github.io/bdrc/reference/spread_draws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Spread MCMC chain draws to data.frame on a wide format — spread_draws","text":"mod object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". ... number character vectors containing valid names parameters model \"rating_curve\" \"rating_curve_mean\". Also accepts \"latent_parameters\" \"hyperparameters\". transformed boolean value determining whether output represented transformed scale used sampling MCMC chain original scale. Defaults FALSE.","code":""},{"path":"https://sor16.github.io/bdrc/reference/spread_draws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Spread MCMC chain draws to data.frame on a wide format — spread_draws","text":"data frame columns: chain chain number. iter iteration number. param parameter name. value parameter value.","code":""},{"path":"https://sor16.github.io/bdrc/reference/spread_draws.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Spread MCMC chain draws to data.frame on a wide format — spread_draws","text":"Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/spread_draws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Spread MCMC chain draws to data.frame on a wide format — spread_draws","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.09%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). hyp_samples <- spread_draws(plm0.fit,'hyperparameters') head(hyp_samples) #> chain iter c sigma_eps #> 1 1 1 7.693275 0.2421924 #> 2 1 2 7.708797 0.2256351 #> 3 1 3 7.704167 0.1679654 #> 4 1 4 7.666575 0.1807933 #> 5 1 5 7.658464 0.1570101 #> 6 1 6 7.709366 0.1968574 rating_curve_samples <- spread_draws(plm0.fit,'rating_curve','rating_curve_mean') head(rating_curve_samples) #> chain iter h rating_curve rating_curve_mean #> 1 1 1 7.673811 0.000000e+00 0.000000e+00 #> 2 1 2 7.673811 0.000000e+00 0.000000e+00 #> 3 1 3 7.673811 0.000000e+00 0.000000e+00 #> 4 1 4 7.673811 1.094841e-06 1.018866e-06 #> 5 1 5 7.673811 6.537614e-06 6.335393e-06 #> 6 1 6 7.673811 0.000000e+00 0.000000e+00 # }"},{"path":"https://sor16.github.io/bdrc/reference/summary.plm0.html","id":null,"dir":"Reference","previous_headings":"","what":"Summary method for discharge rating curves — summary.plm0","title":"Summary method for discharge rating curves — summary.plm0","text":"Summarize discharge rating curve model object","code":""},{"path":"https://sor16.github.io/bdrc/reference/summary.plm0.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summary method for discharge rating curves — summary.plm0","text":"","code":"# S3 method for class 'plm0' summary(object, ...) # S3 method for class 'plm' summary(object, ...) # S3 method for class 'gplm0' summary(object, ...) # S3 method for class 'gplm' summary(object, ...)"},{"path":"https://sor16.github.io/bdrc/reference/summary.plm0.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summary method for discharge rating curves — summary.plm0","text":"object object class \"plm0\", \"plm\", \"gplm0\" \"gplm\". ... used function","code":""},{"path":"https://sor16.github.io/bdrc/reference/summary.plm0.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Summary method for discharge rating curves — summary.plm0","text":"summary(plm0): Summary method plm0 summary(plm): Summary method plm summary(gplm0): Summary method gplm0 summary(gplm): Summary method gplm","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/summary.plm0.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summary method for discharge rating curves — summary.plm0","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) plm0.fit <- plm0(formula=Q~W,data=krokfors,num_cores=2) #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.09%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). summary(plm0.fit) #> #> Formula: #> Q ~ W #> Latent parameters: #> lower-2.5% median-50% upper-97.5% #> a 1.15 1.64 2.12 #> b 2.46 2.82 3.21 #> #> Hyperparameters: #> lower-2.5% median-50% upper-97.5% #> c 7.580 7.676 7.752 #> sigma_eps 0.151 0.191 0.253 #> #> WAIC: -2.864096 # }"},{"path":"https://sor16.github.io/bdrc/reference/summary.tournament.html","id":null,"dir":"Reference","previous_headings":"","what":"Summary method for a discharge rating curve tournament — summary.tournament","title":"Summary method for a discharge rating curve tournament — summary.tournament","text":"Print summary tournament model comparisons. function allows efficient fast re-run tournament different methods winning criteria.","code":""},{"path":"https://sor16.github.io/bdrc/reference/summary.tournament.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summary method for a discharge rating curve tournament — summary.tournament","text":"","code":"# S3 method for class 'tournament' summary(object, method = NULL, winning_criteria = NULL, ...)"},{"path":"https://sor16.github.io/bdrc/reference/summary.tournament.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summary method for a discharge rating curve tournament — summary.tournament","text":"object object class \"tournament\" method Optional; string specifying method use summary. NULL, uses method original tournament. Options \"WAIC\", \"DIC\", \"PMP\". winning_criteria Optional; specifies new winning criteria summary. NULL, uses criteria original tournament. See Details tournament proper formatting. ... used function","code":""},{"path":"https://sor16.github.io/bdrc/reference/summary.tournament.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summary method for a discharge rating curve tournament — summary.tournament","text":"Prints summary console.","code":""},{"path":"https://sor16.github.io/bdrc/reference/summary.tournament.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Summary method for a discharge rating curve tournament — summary.tournament","text":"either method winning_criteria provided, function re-runs tournament new parameters using fitted models.","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/summary.tournament.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summary method for a discharge rating curve tournament — summary.tournament","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) t_obj <- tournament(Q ~ W, krokfors, num_cores = 2) #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.33%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.14%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.66%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.04%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% summary(t_obj) #> #> === Tournament Model Comparison Summary === #> #> Method: WAIC #> Winning Criteria: Delta_WAIC > 2 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm 20.7794 6.8706 -27.8176 11.8918 0.5570 0.2416 #> less gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more plm 5.5842 4.2574 -2.6536 6.6635 -0.4066 0.1904 #> less plm0 <--- 5.6284 4.0984 -3.0601 6.6931 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 24.2005 9.1834 #> less plm0 5.6284 4.0984 -3.0601 6.6931 #> #> === End of Summary === # Re-run summary with different method summary(t_obj, method = \"DIC\") #> #> === Tournament Model Comparison Summary === #> #> Method: DIC #> Winning Criteria: Delta_DIC > 2 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------- #> complexity model winner D_hat eff_num_param DIC Delta_DIC #> more gplm -42.7732 6.0631 -30.6470 0.8498 #> less gplm0 <--- -42.4880 6.3454 -29.7972 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------- #> complexity model winner D_hat eff_num_param DIC Delta_DIC #> more plm -11.3400 2.9739 -5.3923 -0.3058 #> less plm0 <--- -11.4712 2.8865 -5.6982 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------- #> complexity model winner D_hat eff_num_param DIC Delta_DIC #> more gplm0 <--- -42.4880 6.3454 -29.7972 24.0991 #> less plm0 -11.4712 2.8865 -5.6982 #> #> === End of Summary === # Re-run summary with different winning criteria summary(t_obj, winning_criteria = \"Delta_WAIC > 3\") #> #> === Tournament Model Comparison Summary === #> #> Method: WAIC #> Winning Criteria: Delta_WAIC > 3 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm 20.7794 6.8706 -27.8176 11.8918 0.5570 0.2416 #> less gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more plm 5.5842 4.2574 -2.6536 6.6635 -0.4066 0.1904 #> less plm0 <--- 5.6284 4.0984 -3.0601 6.6931 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 24.2005 9.1834 #> less plm0 5.6284 4.0984 -3.0601 6.6931 #> #> === End of Summary === # }"},{"path":"https://sor16.github.io/bdrc/reference/theme_bdrc.html","id":null,"dir":"Reference","previous_headings":"","what":"Custom bdrc theme — theme_bdrc","title":"Custom bdrc theme — theme_bdrc","text":"Custom bdrc theme","code":""},{"path":"https://sor16.github.io/bdrc/reference/theme_bdrc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Custom bdrc theme — theme_bdrc","text":"","code":"theme_bdrc(scaling = 1, ...)"},{"path":"https://sor16.github.io/bdrc/reference/theme_bdrc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Custom bdrc theme — theme_bdrc","text":"scaling numerical value can used scale size text titles plot uses theme_bdrc. Defaults 1. ... used function","code":""},{"path":"https://sor16.github.io/bdrc/reference/theme_bdrc.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Custom bdrc theme — theme_bdrc","text":"returns theme object package","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament.html","id":null,"dir":"Reference","previous_headings":"","what":"Tournament - Model comparison — tournament","title":"Tournament - Model comparison — tournament","text":"tournament compares four rating curve models different complexities determines model provides best fit data hand.","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tournament - Model comparison — tournament","text":"","code":"tournament( formula = NULL, data = NULL, model_list = NULL, method = \"WAIC\", winning_criteria = NULL, verbose = TRUE, ... )"},{"path":"https://sor16.github.io/bdrc/reference/tournament.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tournament - Model comparison — tournament","text":"formula object class \"formula\", discharge column name response stage column name covariate. data data.frame containing variables specified formula. model_list list exactly four model objects types \"plm0\",\"plm\",\"gplm0\" \"gplm\" used tournament. Note model objects required run data c_param. method string specifying method used estimate predictive performance models. allowed methods \"WAIC\", \"DIC\" \"PMP\". winning_criteria Specifies criteria model selection. \"WAIC\", can numeric value string expression. \"DIC\", must numeric value. \"PMP\", must numeric value 0 1. See Details section. verbose logical value indicating whether print progress diagnostic information. `TRUE`, function print messages runs. `FALSE`, function run silently. Default `TRUE`. ... Optional arguments passed model functions.","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tournament - Model comparison — tournament","text":"object type \"tournament\" following elements: contestants model objects types \"plm0\", \"plm\", \"gplm0\" \"gplm\" compared. winner model object tournament winner. info specifics tournament; overall winner; method used; winning criteria. summary data frame information results different comparisons power-law tournament. contents data frame depend method used: methods: round: tournament round comparison: comparison number complexity: Indicates whether model \"\" \"less\" complex model comparison model: model type winner: Logical value indicating model selected corresponding comparison Additional columns method \"WAIC\": lppd: Log pointwise predictive density eff_num_param: Effective number parameters (WAIC) WAIC: Widely Applicable Information Criterion SE_WAIC: Standard error WAIC Delta_WAIC: Difference WAIC SE_Delta_WAIC: Standard error difference WAIC Additional columns method \"DIC\": D_hat: Minus two times log-likelihood evaluated median posterior samples eff_num_param: Effective number parameters (DIC) DIC: Deviance Information Criterion Delta_DIC: Difference DIC Additional columns method \"PMP\": log_marg_lik: Logarithm marginal likelihood estimated, computed harmonic-mean estimator PMP: Posterior model probability computed Bayes factor","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tournament - Model comparison — tournament","text":"Tournament model comparison method uses WAIC (default method) estimate expected prediction error four models select appropriate model given data. first round model comparisons sets model types, \"gplm\" vs. \"gplm0\" \"plm\" vs. \"plm0\". two comparisons conducted WAIC complex model (\"gplm\" \"plm\", respectively) smaller WAIC simpler models (\"gplm0\" \"plm0\", respectively) input argument called winning_criteria (default value = 2), chosen appropriate model. , simpler model chosen. appropriate models move second round compared way. winner second round chosen overall tournament winner deemed appropriate model given data. default method \"WAIC\", Widely Applicable Information Criterion (see Watanabe (2010)), used estimate predictive performance models. method fully Bayesian method uses full set posterior draws estimate expected log pointwise predictive density. Method \"DIC\", Deviance Information Criterion (see Spiegelhalter (2002)), similar \"WAIC\" instead using full set posterior draws compute estimate expected log pointwise predictive density, uses point estimate posterior distribution. Method \"PMP\" uses posterior model probabilities, calculated Bayes factor (see Jeffreys (1961) Kass Raftery (1995)), compare models, models assumed priori equally likely. method chosen default method Bayes factor calculations can quite unstable. method \"WAIC\" used, winning_criteria can either numeric value string expression. numeric, sets threshold complex model must exceed declared appropriate model. string, must valid R expression using Delta_WAIC /SE_Delta_WAIC (e.g., \"Delta_WAIC > 2 & Delta_WAIC - SE_Delta_WAIC > 0\"). method \"DIC\", winning_criteria must numeric value. method \"PMP\", winning criteria numeric value 0 1 (default value = 0.75). sets threshold value posterior probability complex model, given data, model comparison must exceed declared appropriate model. cases, default values selected give less complex models slight advantage, give less consistent results applying tournament real world data.","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Tournament - Model comparison — tournament","text":"Hrafnkelsson, B., Sigurdarson, H., Rögnvaldsson, S., Jansson, . Ö., Vias, R. D., Gardarsson, S. M. (2022). Generalization power-law rating curve using hydrodynamic theory Bayesian hierarchical modeling, Environmetrics, 33(2):e2711. doi: https://doi.org/10.1002/env.2711 Jeffreys, H. (1961). Theory Probability, Third Edition. Oxford University Press. Kass, R., . Raftery, . (1995). Bayes Factors. Journal American Statistical Association, 90, 773-795. doi: https://doi.org/10.1080/01621459.1995.10476572 Spiegelhalter, D., Best, N., Carlin, B., Van Der Linde, . (2002). Bayesian measures model complexity fit. Journal Royal Statistical Society: Series B (Statistical Methodology) 64(4), 583–639. doi: https://doi.org/10.1111/1467-9868.00353 Watanabe, S. (2010). Asymptotic equivalence Bayes cross validation widely applicable information criterion singular learning theory. J. Mach. Learn. Res. 11, 3571–3594.","code":""},{"path":[]},{"path":"https://sor16.github.io/bdrc/reference/tournament.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tournament - Model comparison — tournament","text":"","code":"# \\donttest{ data(krokfors) set.seed(1) t_obj <- tournament(formula = Q ~ W, data = krokfors, num_cores = 2) #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.33%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.14%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.66%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.04%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% t_obj #> Tournament winner: gplm0 summary(t_obj) #> #> === Tournament Model Comparison Summary === #> #> Method: WAIC #> Winning Criteria: Delta_WAIC > 2 #> Overall Winner: gplm0 #> #> Comparison 1 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm 20.7794 6.8706 -27.8176 11.8918 0.5570 0.2416 #> less gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 #> #> Comparison 2 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more plm 5.5842 4.2574 -2.6536 6.6635 -0.4066 0.1904 #> less plm0 <--- 5.6284 4.0984 -3.0601 6.6931 #> #> Comparison 3 Results: #> -------------------------------------------------------------------------------------------------- #> complexity model winner lppd eff_num_param WAIC SE_WAIC Delta_WAIC SE_Delta_WAIC #> more gplm0 <--- 20.3710 6.7406 -27.2606 12.0360 24.2005 9.1834 #> less plm0 5.6284 4.0984 -3.0601 6.6931 #> #> === End of Summary === # Using different methods and winning criteria t_obj_dic <- tournament(Q ~ W, krokfors, num_cores = 2, method = \"DIC\", winning_criteria = 3) #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 24.81%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.42%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 26.60%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 36.02%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% t_obj_pmp <- tournament(Q ~ W, krokfors, num_cores = 2, method = \"PMP\", winning_criteria = 0.8) #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.10%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.05%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.47%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 35.76%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% #> ⚠ Warning: The Harmonic Mean Estimator (HME) is used to estimate the Bayes Factor for the posterior model probability (PMP), which is known to be unstable and potentially unreliable. We recommend using method \"WAIC\" (Widely Applicable Information Criterion) for model comparison instead. t_obj_waic_expr <- tournament(Q ~ W, krokfors, num_cores = 2, winning_criteria = \"Delta_WAIC > 2 & Delta_WAIC - SE_Delta_WAIC > 0\") #> Running tournament [ ] 0% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.78%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm finished [============ ] 25% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 31.19%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ gplm0 finished [======================== ] 50% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 25.85%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm finished [==================================== ] 75% #> #> Progress: #> Initializing Metropolis MCMC algorithm... #> Multiprocess sampling (4 chains in 2 jobs) ... #> #> MCMC sampling completed! #> #> Diagnostics: #> Acceptance rate: 35.55%. #> ✔ All chains have mixed well (Rhat < 1.1). #> ✔ Effective sample sizes sufficient (eff_n_samples > 400). #> #> ✔ plm0 finished [================================================] 100% # }"},{"path":"https://sor16.github.io/bdrc/reference/tournament_summary_output.html","id":null,"dir":"Reference","previous_headings":"","what":"Internal function to generate a summary output for a discharge rating curve tournament — tournament_summary_output","title":"Internal function to generate a summary output for a discharge rating curve tournament — tournament_summary_output","text":"function takes summary results tournament object produces formatted console output displaying results model comparisons. supports different model selection criteria: WAIC, DIC, PMP.","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament_summary_output.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Internal function to generate a summary output for a discharge rating curve tournament — tournament_summary_output","text":"","code":"tournament_summary_output(results, method, winning_criteria)"},{"path":"https://sor16.github.io/bdrc/reference/tournament_summary_output.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Internal function to generate a summary output for a discharge rating curve tournament — tournament_summary_output","text":"results data.frame containing summary results tournament. structure data.frame determines model-selection criterion used (WAIC, DIC, PMP). method string indicating method used model comparison (\"WAIC\", \"DIC\", \"PMP\"). winning_criteria criteria used determine winning model.","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament_summary_output.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Internal function to generate a summary output for a discharge rating curve tournament — tournament_summary_output","text":"function return value; prints formatted summary console.","code":""},{"path":"https://sor16.github.io/bdrc/reference/tournament_summary_output.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Internal function to generate a summary output for a discharge rating curve tournament — tournament_summary_output","text":"function automatically detects model-selection criterion used based columns present input data frame. formats prints summary tournament results, including overall winner detailed results comparison.","code":""},{"path":"https://sor16.github.io/bdrc/news/index.html","id":"bdrc-200","dir":"Changelog","previous_headings":"","what":"bdrc 2.0.0","title":"bdrc 2.0.0","text":"Integrated C++ via Rcpp RcppArmadillo packages significant performance improvements. Multiple functions rewritten C++ speed MCMC sampling algorithm various tasks. “Deviance” posterior output transformed renamed “Posterior log-likelihood”. Deviance previously calculated -2 times Posterior log-likelihood. plot(tournament_obj, type = “Deviance”) figure now created evaluating plot(tournament_obj, type = “boxplot”). log-likelihood models now computed log-transformed discharge observations (normally distributed), rather discharge real scale (log-normally distributed). Pointwise WAIC values (WAIC_i) stored model objects. Implemented standard error computations WAIC Delta_WAIC estimates. Applied log-sum-exp trick WAIC Bayes factor calculations numerical stability. Added DOI links references. Revised summary() output tournament objects. Updated package vignettes reflect recent changes improvements.","code":""},{"path":"https://sor16.github.io/bdrc/news/index.html","id":"bdrc-110","dir":"Changelog","previous_headings":"","what":"bdrc 1.1.0","title":"bdrc 1.1.0","text":"CRAN release: 2023-03-19 tournament function now supports information criteria (WAIC & DIC) model selection criteria, WAIC new default. Six new real-world datasets Iceland Sweden containing paired observations stage discharge included package. package can now also used user-friendly interactive rating curve builder Shiny application [https://bdrc.shinyapps.io/bdrc/].","code":""},{"path":"https://sor16.github.io/bdrc/news/index.html","id":"bdrc-100","dir":"Changelog","previous_headings":"","what":"bdrc 1.0.0","title":"bdrc 1.0.0","text":"CRAN release: 2021-07-28 Release first version package.","code":""}]