Useful to convert MCMC chain draws of particular parameters or output from the model object to a long format for further data wrangling

gather_draws(mod, ..., transformed = F)

Arguments

mod

an object of class "plm0","plm","gplm0" or "gplm".

...

any number of character vectors containing valid names of parameters in the model or "rating_curve" and "rating_curve_mean". Also accepts "latent_parameters" and "hyperparameters".

transformed

boolean value determining whether the parameter is to be represented on the transformed scale used for sampling in the MCMC chain or the original scale. Defaults to FALSE.

Value

Data frame with columns chain

iter

param

value

References

B. Hrafnkelsson, H. Sigurdarson, S.M. Gardarsson, 2020, Generalization of the power-law rating curve using hydrodynamic theory and Bayesian hierarchical modeling. arXiv preprint 2010.04769

See also

plm0, plm, gplm0, gplm for further information on parameters

Examples

# \donttest{
data(krokfors)
set.seed(1)
plm0.fit <- plm0(formula=Q~W,data=krokfors,num_cores=2)
hyp_samples <- gather_draws(plm0.fit,'hyperparameters')
head(hyp_samples)
#>   chain iter name    value
#> 1     1    1    c 7.684278
#> 2     1    2    c 7.632519
#> 3     1    3    c 7.621310
#> 4     1    4    c 7.728676
#> 5     1    5    c 7.681251
#> 6     1    6    c 7.657240
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 7.931522e-05
#> 3     1    3 7.673811 rating_curve 1.837430e-04
#> 4     1    4 7.673811 rating_curve 0.000000e+00
#> 5     1    5 7.673811 rating_curve 0.000000e+00
#> 6     1    6 7.673811 rating_curve 1.008884e-05
# }