
Simulate sequences of observed and hidden states given parameters of a hidden Markov model.
simulate_hmm(
n_sequences,
initial_probs,
transition_probs,
emission_probs,
sequence_length
)
Number of simulations.
A vector of initial state probabilities.
A matrix of transition probabilities.
A matrix of emission probabilities or a list of such objects (one for each channel).
Length for simulated sequences.
A list of state sequence objects of class stslist
.
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.
# NOT RUN {
# 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")
# }
Run the code above in your browser using DataLab