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

View source: R/extract_draws.R

gather_drawsR Documentation

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

Description

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

Usage

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

A 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

A data frame with columns:

chain

The chain number.

iter

The iteration number.

param

The parameter name.

value

The parameter value.

References

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

See Also

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

Examples


 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)
 rating_curve_samples <- gather_draws(plm0.fit,'rating_curve','rating_curve_mean')
 head(rating_curve_samples)


sor16/RCmodels documentation built on Sept. 13, 2024, 4:51 a.m.