HMMextra0s-package {HMMextra0s} | R Documentation |
Hidden Markov Models with Extra Zeros Hidden Markov Models (HMMs) with Extra Zeros
Description
The DESCRIPTION file:
Package: | HMMextra0s |
Type: | Package |
Title: | Hidden Markov Models with Extra Zeros |
Version: | 1.1.0 |
Imports: | mvtnorm, ellipse |
Suggests: | HiddenMarkov |
Depends: | methods |
Date: | 2021-08-02 |
Author: | Ting Wang, Wolfgang Hayek, and Alexander Pletzer |
Maintainer: | Ting Wang <ting.wang@otago.ac.nz> |
Description: | Contains functions for hidden Markov models with observations having extra zeros as defined in the following two publications, Wang, T., Zhuang, J., Obara, K. and Tsuruoka, H. (2016) <doi:10.1111/rssc.12194>; Wang, T., Zhuang, J., Buckby, J., Obara, K. and Tsuruoka, H. (2018) <doi:10.1029/2017JB015360>. The observed response variable is either univariate or bivariate Gaussian conditioning on presence of events, and extra zeros mean that the response variable takes on the value zero if nothing is happening. Hence the response is modelled as a mixture distribution of a Bernoulli variable and a continuous variable. That is, if the Bernoulli variable takes on the value 1, then the response variable is Gaussian, and if the Bernoulli variable takes on the value 0, then the response is zero too. This package includes functions for simulation, parameter estimation, goodness-of-fit, the Viterbi algorithm, and plotting the classified 2-D data. Some of the functions in the package are based on those of the R package 'HiddenMarkov' by David Harte. This updated version has included an example dataset and R code examples to show how to transform the data into the objects needed in the main functions. We have also made changes to increase the speed of some of the functions. |
LazyData: | no |
ZipData: | no |
License: | GPL(>=2) |
URL: | https://www.stats.otago.ac.nz/?people=ting_wang |
Packaged: | 2021-08-02 01:56:30 UTC; twang |
NeedsCompilation: | yes |
Index of help topics:
HMMextra0s-package Hidden Markov Models with Extra Zeros Hidden Markov Models (HMMs) with Extra Zeros Kii Tremor data in the Kii region in 2002 and 2003 for use in function hmm0norm2d Viterbi.hmm0norm Viterbi Path of a 1-D HMM with Extra Zeros Viterbi.hmm0norm2d Viterbi Path of a Bivariate HMM with Extra Zeros cumdist.hmm0norm Cumulative distribution of an HMM with Extra Zeros hmm0norm Parameter Estimation of an HMM with Extra Zeros hmm0norm2d Parameter Estimation of a bivariate HMM with Extra Zeros plotVitloc2d Plot the Classified 2-D Data of a Bivariate HMM With Extra Zeros plotVitpath2d Plot the Viterbi Path of a Bivariate HMM With Extra Zeros sim.hmm0norm Simulation of a 1-D HMM with Extra Zeros sim.hmm0norm2d Simulation of a Bivariate HMM with Extra Zeros
This package contains functions to estimate the parameters of the HMMs with extra zeros using hmm0norm
(1-D HMM)
and hmm0norm2d
(2-D HMM), to calculate the cumulative distribution of the 1-D HMM using cumdist.hmm0norm
,
to estimate the Viterbi path using Viterbi.hmm0norm
(1-D HMM) and Viterbi.hmm0norm2d
(2-D HMM), to
simulate this class of models using sim.hmm0norm
(1-D HMM) and sim.hmm0norm2d
(2-D HMM), to plot the
classified 2-D data with different colours representing different hidden states using plotVitloc2d
, and to plot the
Viterbi path using plotVitloc2d
.
Details
This package is used to estimate the parameters, carry out simulations, and estimate the Viterbi path for 1-D and 2-D HMMs with extra zeros as defined in the two publications in the reference (also briefly defined below). It contains examples using simulated data for how to set up initial values for a data analysis and how to plot the results.
An HMM is a statistical model in which the observed process is dependent on an unobserved Markov chain. A Markov chain is a sequence
of states which exhibits a short-memory property such that the current state of the chain is dependent only on the previous state in
the case of a first-order Markov chain. Assume that the Markov chain has m
states, where m
can be estimated from the data.
Let S_t \in \{1,\cdots,m\}
denote the state of the Markov chain at time t
. The probability of a first-order Markov chain
in state j
at time t
given the previous states is P(S_t=j|S_{t-1},\cdots,S_{1})=P(S_t=j|S_{t-1})
.
These states are not observable. The observation Y_t
at time t
depends on the state S_t
of the Markov chain.
In this framework, we are interested in estimating the transition probability matrix \Gamma=(\gamma_{ij})_{m\times m}
of the
Markov chain that describes the migration pattern and the density function f(y_t|S_t=i)
that gives the distribution feature of
observations in state i
, where \gamma_{ij}=P(S_t=j|S_{t-1}=i)
.
Let Z_t
be a Bernoulli variable, with Z_t=1
if an event is present at t
, and Z_t=0
, otherwise.
Let \mathbf{X}_t
be the response variable (e.g., location of the tremor cluster in 2D space) at time t
.
We set P(Z_t=0|S_t=i)=1-p_i
and P(Z_t=1|S_t=i)=p_i
. We assume that, given Z_t=1
and S_t=i
,
\mathbf{X}_t
follows a univariate or bivariate normal distribution, e.g. for a bivariate normal,
f(\mathbf{x}_t|Z_t=1, S_t=i)=\frac{1}{2\pi |\bm{\Sigma}_i|^{1/2}}\exp\left(-\frac{1}{2}
(\mathbf{x}_t-\bm{\mu}_i)^T\bm{\Sigma}_i^{-1}(\mathbf{x}_t-\bm{\mu}_i)\right).
The joint probability density function of Z_t
and \mathbf{X}_t
conditional on the system being in state i
at time t
is
f(\mathbf{x}_t,z_t | S_t=i)=(1-p_i)^{1-z_t}\left[p_i\frac{1}{2\pi |\bm{\Sigma}_i|^{1/2}}\exp\left(-\frac{1}{2}(\mathbf{x}_t-\bm{\mu}_i)^T\bm{\Sigma}_i^{-1}(\mathbf{x}_t-\bm{\mu}_i)\right)\right]^{z_t},
where p_i
, \bm{\mu}_i=E(\mathbf{X}_t|S_t=i,Z_t=1)
and \bm{\Sigma}_i=Var(\mathbf{X}_t|S_t=i,Z_t=1)
are parameters to be
estimated.
Author(s)
Ting Wang, Wolfgang Hayek, and Alexander Pletzer
Maintainer: Ting Wang <ting.wang@otago.ac.nz>
References
Wang, T., Zhuang, J., Obara, K. and Tsuruoka, H. (2016) Hidden Markov Modeling of Sparse Time Series from Non-volcanic Tremor Observations. Journal of the Royal Statistical Society, Series C, Applied Statistics, 66, Part 4, 691-715.
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.
Some of the functions in the package are based on those of the R package “HiddenMarkov":
Harte, D. (2021) HiddenMarkov: Hidden Markov Models. R package version 1.8-13. URL: https://cran.r-project.org/package=HiddenMarkov