Convert a Coda object to a tibble with specified parameter transformations
Source:R/Mod_Coda_to_tibble.R
Coda_to_tibble.Rd
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
.
Arguments
- CodaObj
An object of class
mcmc.list
ormcmc
, representing the MCMC output.- Type
A character string specifying the parameter type to transform and extract. Must be one of
rho
,alpha
,omega
, orbeta
.- 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 thebeta
andOmega
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
(ifFromHPC
=TRUE
) orDP_R_TaxaInfo_Local
(ifFromHPC
=FALSE
) for the location of theSpecies_List_ID.txt
file containing species information.
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