Description Usage Arguments Details Value See Also Examples
Simulation of sequences of observations and underlying paths for hidden semi-Markov models.
1 2 3 4 5 6 7 8 9 |
n |
Positive integer containing the number of observations to simulate. |
od |
Character containing the name of the conditional distribution of the observations. For details see |
rd |
Character containing the name of the runlength distribution (or sojourn time, dwell time distribution). See |
pi.par |
Vector of length J containing the values for the intitial probabilities of the semi-Markov chain. |
tpm.par |
Matrix of dimension J x J containing the parameter values for the transition probability matrix of the embedded Markov chain. The diagonal entries must all be zero, absorbing states are not permitted. |
rd.par |
List with the values for the parameters of the runlength distributions. For details see |
od.par |
List with the values for the parameters of the conditional observation distributions. For details see |
M |
Positive integer containing the maximum runlength. |
seed |
Seed for the random number generator (integer). |
The function hsmm.sim
simulates the observations and the underlying state sequence of a
hidden semi-Markov model.
The simulation requires the specification of the runlength and the conditional observation distributions
as well as all corresponding parameters.
Note: The simulation of t-distributed conditional observations is performed by the functions rmt
and rvm
,
extracted from the package csampling
and CircStats
, respectively.
call |
The matched call. |
obs |
A vector of length n containing the simulated observations. |
path |
A vector of length n containing the simulated underlying semi-Markov chain. |
hsmm
, hsmm.smooth
, hsmm.viterbi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # Simulation of sequences of observations and hidden states from a
# 3-state HSMM with a logarithmic runlength distribution and a
# conditional Gaussian distributions.
### Setting up the parameter values:
# Initial probabilities of the semi-Markov chain:
pipar <- rep(1/3, 3)
# Transition probabilites:
# (Note: For two states, the matrix degenerates, taking 0 for the
# diagonal and 1 for the off-diagonal elements.)
tpmpar <- matrix(c(0, 0.5, 0.5,
0.7, 0, 0.3,
0.8, 0.2, 0), 3, byrow = TRUE)
# Runlength distibution:
rdpar <- list(p = c(0.98, 0.98, 0.99))
# Observation distribution:
odpar <- list(mean = c(-1.5, 0, 1.5), var = c(0.5, 0.6, 0.8))
# Invoking the simulation:
sim <- hsmm.sim(n = 2000, od = "norm", rd = "log",
pi.par = pipar, tpm.par = tpmpar,
rd.par = rdpar, od.par = odpar, seed = 3539)
# The first 15 simulated observations:
round(sim$obs[1:15], 3)
# The first 15 simulated states:
sim$path[1:15]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.