Skip to contents

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

Usage

Coda_to_tibble(
  CodaObj = NULL,
  Type = NULL,
  EnvFile = ".env",
  NOmega = 100,
  FromHPC = TRUE
)

Arguments

CodaObj

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

Type

A character string specifying the parameter type to transform and extract. Must be one of rho, alpha, omega, or beta.

EnvFile

A character string specifying the path to the environment file that contains necessary variables for beta parameter transformation. Defaults to .env. Only required for the beta and Omega parameters.

NOmega

An integer specifying the number of species to be sampled for the Omega parameter transformation. Defaults to 100.

FromHPC

Logical. Indicates whether the function is being run on an HPC environment, affecting file path handling. Default: TRUE.

Value

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

Details

The function reads the following environment variables:

  • DP_R_TaxaInfo (if FromHPC = TRUE) or DP_R_TaxaInfo_Local (if FromHPC = FALSE) for the location of the Species_List_ID.txt file containing species information.

Author

Ahmed El-Gabbas

Examples

library(Hmsc)
#> Loading required package: coda
library(coda)
library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:raster’:
#> 
#>     intersect, select, union
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
Coda <- Hmsc::convertToCodaObject(Hmsc::TD$m)
IASDT.R::Coda_to_tibble(CodaObj = Coda$Alpha[[1]], 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