Skip to contents

Simulate a time series from a Gaussian-hidden Markov model

Usage

sim_hmm(Tp, N, theta)

Arguments

Tp

An integer, the number of observations.

N

An integer, the number of states.

theta

A numeric vector of model parameters.

  • The first N*(N-1) elements are the logarithms of the non-diagonal elements of the transition probability matrix.

  • The next N elements are the mean values of the state-dependent normal distributions.

  • The last N elements are the logarithms of the standard deviations of the state-dependent normal distributions.

Value

A numeric vector, the simulated time series.

See also

f_ll_hmm() for computing the log-likelihood of a Gaussian-hidden Markov model

Examples

tpm <- matrix(c(0.8, 0.1, 0.2, 0.9), nrow = 2)
mu <- c(-2, 2)
sigma <- c(0.5, 1)
theta <- c(log(tpm[row(tpm) != col(tpm)]), mu, log(sigma))
data <- sim_hmm(Tp = 100, N = 2, theta = theta)
plot(data, type = "l")