simulate_hmm {seqHMM} | R Documentation |
Simulate hidden Markov models
Description
Simulate sequences of observed and hidden states given parameters of a hidden Markov model.
Usage
simulate_hmm(
n_sequences,
initial_probs,
transition_probs,
emission_probs,
sequence_length
)
Arguments
n_sequences |
Number of simulations. |
initial_probs |
A vector of initial state probabilities. |
transition_probs |
A matrix of transition probabilities. |
emission_probs |
A matrix of emission probabilities or a list of such objects (one for each channel). |
sequence_length |
Length for simulated sequences. |
Value
A list of state sequence objects of class stslist
.
See Also
build_hmm
and fit_model
for building
and fitting hidden Markov models; ssplot
for plotting
multiple sequence data sets; seqdef
for more
information on state sequence objects; and simulate_mhmm
for simulating mixture hidden Markov models.
Examples
# Parameters for the HMM
emission_probs <- matrix(c(0.5, 0.2, 0.5, 0.8), 2, 2)
transition_probs <- matrix(c(5 / 6, 1 / 6, 1 / 6, 5 / 6), 2, 2)
initial_probs <- c(1, 0)
# Setting the seed for simulation
set.seed(1)
# Simulating sequences
sim <- simulate_hmm(
n_sequences = 10, initial_probs = initial_probs,
transition_probs = transition_probs,
emission_probs = emission_probs,
sequence_length = 20
)
ssplot(sim, sortv = "mds.obs", type = "I")
[Package seqHMM version 1.2.6 Index]