hsmm.sim: Hidden Semi-Markov Models

Description Usage Arguments Details Value See Also Examples

View source: R/hsmm.sim.r

Description

Simulation of sequences of observations and underlying paths for hidden semi-Markov models.

Usage

1
2
3
4
5
6
7
8
9
hsmm.sim(n,
         od, 
         rd, 
         pi.par,
         tpm.par,
         od.par,
         rd.par,
         M = NA,
         seed = NULL)

Arguments

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 hsmm.

rd

Character containing the name of the runlength distribution (or sojourn time, dwell time distribution). See hsmm for details.

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 hsmm.

od.par

List with the values for the parameters of the conditional observation distributions. For details see hsmm.

M

Positive integer containing the maximum runlength.

seed

Seed for the random number generator (integer).

Details

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.

Value

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.

See Also

hsmm, hsmm.smooth, hsmm.viterbi

Examples

 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]

hsmm documentation built on May 30, 2017, 3:31 a.m.