convert_to_ggmcmc {oHMMed}R Documentation

Converts MCMC Samples into ggmcmc Format

Description

This helper function converts MCMC samples into ggmcmc format

Usage

convert_to_ggmcmc(
  x,
  pattern = c("mean", "sigma", "beta", "alpha", "pois_means", "T"),
  include_warmup = FALSE
)

Arguments

x

(mcmc_hmm_*) MCMC HMM object

pattern

(character) pattern(s) with model parameters to be included in the output

include_warmup

(logical) include warmup samples. By default FALSE

Details

By default, for a given model, all parameters are converted into ggmcmc format.

The parameter pattern can be used to extract specific parameters. For instance pattern="mean" extracts all mean parameters from a hmm_mcmc_normal model.

If a specific parameter is of interest it can be matched by an exact name: pattern=c("mean[1]", "T[1,1]").

Value

data.frame compatible with functions from the ggmcmc package

Examples

# Convert all parameters (Normal model)
convert_normal_all <- convert_to_ggmcmc(example_hmm_mcmc_normal)
unique(convert_normal_all$Parameter)
head(convert_normal_all)
tail(convert_normal_all)

# Convert only means (Normal model)
convert_normal_means <- convert_to_ggmcmc(example_hmm_mcmc_normal, 
                                          pattern = "mean")
unique(convert_normal_means$Parameter)

# Convert selected parameter (Normal model)
pattern_normal <- c("mean[1]", "sigma[1]", "T[1,1]")
convert_normal_param <- convert_to_ggmcmc(example_hmm_mcmc_normal, 
                                          pattern = pattern_normal)
unique(convert_normal_param$Parameter)

# Convert all parameters (Poisson-Gamma model)
convert_pois_gamma_all <- convert_to_ggmcmc(example_hmm_mcmc_gamma_poisson)
unique(convert_pois_gamma_all$Parameter)

[Package oHMMed version 1.0.2 Index]