Skip to contents

This function converts a Coda object (mcmc.list or mcmc) into a tibble format, facilitating further analysis and visualisation. It supports transformation for specific parameter types: rho, alpha, omega, and beta.

Usage

coda_to_tibble(
  coda_object = NULL,
  posterior_type = NULL,
  env_file = ".env",
  n_omega = 100
)

Arguments

coda_object

An object of class mcmc.list or mcmc, representing the MCMC output.

posterior_type

Character. The parameter type to transform and extract. Must be one of rho, alpha, omega, or beta.

env_file

Character. Path to the environment file containing paths to data sources. Defaults to .env.

n_omega

Integer. The number of species to be sampled for the Omega parameter transformation. Defaults to 100.

Value

A tibble containing the transformed parameters based on the specified posterior_type. The structure of the returned tibble varies depending on the posterior_type parameter.

Author

Ahmed El-Gabbas

Examples

ecokit::load_packages(Hmsc, coda, dplyr)

coda_object <- Hmsc::convertToCodaObject(Hmsc::TD$m)
IASDT.R::coda_to_tibble(
   coda_object = coda_object$Alpha[[1]], posterior_type = "Alpha")
#> # A tibble: 400 × 6
#>    Alpha           AlphaNum Factor  Chain  Iter Value
#>    <fct>           <fct>    <fct>   <fct> <int> <dbl>
#>  1 Alpha1[factor1] Alpha1   factor1 1        51     0
#>  2 Alpha1[factor1] Alpha1   factor1 1        52     0
#>  3 Alpha1[factor1] Alpha1   factor1 1        53     0
#>  4 Alpha1[factor1] Alpha1   factor1 1        54     0
#>  5 Alpha1[factor1] Alpha1   factor1 1        55     0
#>  6 Alpha1[factor1] Alpha1   factor1 1        56     0
#>  7 Alpha1[factor1] Alpha1   factor1 1        57     0
#>  8 Alpha1[factor1] Alpha1   factor1 1        58     0
#>  9 Alpha1[factor1] Alpha1   factor1 1        59     0
#> 10 Alpha1[factor1] Alpha1   factor1 1        60     0
#> # ℹ 390 more rows