hmm_mcmc_normal | R Documentation |
MCMC Sampler for the Hidden Markov Model with Normal emission densities
hmm_mcmc_normal(
data,
prior_T,
prior_means,
prior_sd,
iter = 600,
warmup = floor(iter/5),
thin = 1,
seed = sample.int(.Machine$integer.max, 1),
init_T = NULL,
init_means = NULL,
init_sd = NULL,
print_params = TRUE,
verbose = TRUE
)
data |
(numeric) normal data |
prior_T |
(matrix) prior transition matrix |
prior_means |
(numeric) prior means |
prior_sd |
(numeric) a single prior standard deviation |
iter |
(integer) number of MCMC iterations |
warmup |
(integer) number of warmup iterations |
thin |
(integer) thinning parameter. By default, |
seed |
(integer) |
init_T |
(matrix) |
init_means |
(numeric) |
init_sd |
(numeric) |
print_params |
(logical) |
verbose |
(logical) |
Please see supplementary information at \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1186/s12859-024-05751-4")} for more details on the algorithm.
For usage recommendations please see https://github.com/LynetteCaitlin/oHMMed/blob/main/UsageRecommendations.pdf.
List with following elements:
data
: data used for simulation
samples
: list with samples
estimates
: list with various estimates
idx
: indices with iterations after the warmup period
priors
: prior parameters
inits
: initial parameters
last_iter
: list with samples from the last MCMC iteration
info
: list with various meta information about the object
Claus Vogl, Mariia Karapetiants, Burçin Yıldırım, Hrönn Kjartansdóttir, Carolin Kosiol, Juraj Bergman, Michal Majka, Lynette Caitlin Mikula. Inference of genomic landscapes using ordered Hidden Markov Models with emission densities (oHMMed). BMC Bioinformatics 25, 151 (2024). \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1186/s12859-024-05751-4")}
# Simulate normal data
N <- 2^10
true_T <- rbind(c(0.95, 0.05, 0),
c(0.025, 0.95, 0.025),
c(0.0, 0.05, 0.95))
true_means <- c(-5, 0, 5)
true_sd <- 1.5
simdata_full <- hmm_simulate_normal_data(L = N,
mat_T = true_T,
means = true_means,
sigma = true_sd)
simdata <- simdata_full$data
hist(simdata,
breaks = 40,
probability = TRUE,
main = "Distribution of the simulated normal data")
lines(density(simdata), col = "red")
# Set numbers of states to be inferred
n_states_inferred <- 3
# Set priors
prior_T <- generate_random_T(n_states_inferred)
prior_means <- c(-18, -1, 12)
prior_sd <- 3
# Simmulation settings
iter <- 50
warmup <- floor(iter / 5) # 20 percent
thin <- 1
seed <- sample.int(10000, 1)
print_params <- FALSE # if TRUE then parameters are printed in each iteration
verbose <- FALSE # if TRUE then the state of the simulation is printed
# Run MCMC sampler
res <- hmm_mcmc_normal(data = simdata,
prior_T = prior_T,
prior_means = prior_means,
prior_sd = prior_sd,
iter = iter,
warmup = warmup,
seed = seed,
print_params = print_params,
verbose = verbose)
res
summary(res) # summary output can be also assigned to a variable
coef(res) # extract model estimates
# plot(res) # MCMC diagnostics
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.