Description Usage Arguments Value Author(s) References Examples
View source: R/sim.hmm0norm2d.R
Simulates the observed process and the associated binary variable of a bivariate HMM with extra zeros.
1 | sim.hmm0norm2d(mu, sig, pie, gamma, delta, nsim = 1, mc.hist = NULL, seed = NULL)
|
pie |
is a vector of length m, the jth element of which is the probability of Z=1 when the process is in state j. |
gamma |
is the transition probability matrix (m * m) of the hidden Markov chain. |
mu |
is an m * 2 matrix, the jth row of which is the mean of the bivariate (Gaussian) distribution of the observations in state j. |
sig |
is a 2 * 2 * m array. The matrix |
delta |
is a vector of length m, the initial distribution vector of the Markov chain. |
nsim |
is an integer, the number of observations to simulate. |
mc.hist |
is a vector containing the history of the hidden Markov chain. This is mainly used for forecasting. If we fit an HMM to the data, and obtained the Viterbi path for the data, we can let |
seed |
is the seed for simulation. Default |
x |
is the simulated observed process. |
z |
is the simulated binary data with the value 1 indicating that an event was observed and 0 otherwise. |
mcy |
is the simulated hidden Markov chain. |
Ting Wang
Wang, T., Zhuang, J., Buckby, J., Obara, K. and Tsuruoka, H. (2018) Identifying the recurrence patterns of non-volcanic tremors using a 2D hidden Markov model with extra zeros. Journal of Geophysical Research, doi: 10.1029/2017JB015360.
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 | ## Simulating a sequence of data without using any history.
pie <- c(0.002,0.2,0.4)
gamma <- matrix(c(0.99,0.007,0.003,
0.02,0.97,0.01,
0.04,0.01,0.95),byrow=TRUE, nrow=3)
mu <- matrix(c(35.03,137.01,
35.01,137.29,
35.15,137.39),byrow=TRUE,nrow=3)
sig <- array(NA,dim=c(2,2,3))
sig[,,1] <- matrix(c(0.005, -0.001,
-0.001,0.01),byrow=TRUE,nrow=2)
sig[,,2] <- matrix(c(0.0007,-0.0002,
-0.0002,0.0006),byrow=TRUE,nrow=2)
sig[,,3] <- matrix(c(0.002,0.0018,
0.0018,0.003),byrow=TRUE,nrow=2)
delta <- c(1,0,0)
y <- sim.hmm0norm2d(mu,sig,pie,gamma,delta, nsim=5000)
## Forecast future tremor occurrences and locations when tremor occurs.
R <- y$x
Z <- y$z
HMMEST <- hmm0norm2d(R, Z, pie, gamma, mu, sig, delta)
Viterbi3 <- Viterbi.hmm0norm2d(R,Z,HMMEST)
y <- sim.hmm0norm2d(mu,sig,pie,gamma,delta,nsim=2,mc.hist=Viterbi3$y)
# This only forecasts two steps forward when we use nsim=2.
# One can increase nsim to get longer simulated forecasts.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.