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 |

` tpm.par` |
Matrix of dimension |

` 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 |

`path` |
A vector of length |

`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]
``` |

```
Loading required package: mvtnorm
[1] -0.335 1.263 -2.104 -1.518 -0.375 -0.465 1.454 -2.229 -1.187 -1.264
[11] -1.765 -1.529 -2.177 -2.868 -1.701
[1] 2 2 1 2 2 2 2 1 1 1 1 1 1 1 1
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.