2nd Edition

Hidden Markov Models for Time Series
An Introduction Using R, Second Edition

ISBN 9781482253832
Published June 7, 2016 by Chapman and Hall/CRC
370 Pages 80 B/W Illustrations

USD $105.00

Prices & shipping based on shipping country


Book Description

Hidden Markov Models for Time Series: An Introduction Using R, Second Edition illustrates the great flexibility of hidden Markov models (HMMs) as general-purpose models for time series data. The book provides a broad understanding of the models and their uses.

After presenting the basic model formulation, the book covers estimation, forecasting, decoding, prediction, model selection, and Bayesian inference for HMMs. Through examples and applications, the authors describe how to extend and generalize the basic model so that it can be applied in a rich variety of situations.

The book demonstrates how HMMs can be applied to a wide range of types of time series: continuous-valued, circular, multivariate, binary, bounded and unbounded counts, and categorical observations. It also discusses how to employ the freely available computing environment R to carry out the computations.


  1. Presents an accessible overview of HMMs
  2. Explores a variety of applications in ecology, finance, epidemiology, climatology, and sociology
  3. Includes numerous theoretical and programming exercises
  4. Provides most of the analysed data sets online

New to the second edition

  1. A total of five chapters on extensions, including HMMs for longitudinal data, hidden semi-Markov models and models with continuous-valued state process
  2. New case studies on animal movement, rainfall occurrence and capture-recapture data

Table of Contents

Model structure, properties and methods
Preliminaries: mixtures and Markov chains
Independent mixture models
Markov chains

Hidden Markov models: definition and properties
A simple hidden Markov model
The basics
The likelihood

Direct maximization of the likelihood
Scaling the likelihood computation
Maximization subject to constraints
Other problems
Example: earthquakes
Standard errors and confidence intervals
Example: parametric bootstrap

Estimation by the EM algorithm
Forward and backward probabilities
The EM algorithm
Examples of EM applied to Poisson-HMMs

Forecasting, decoding and state prediction
Conditional distributions
Forecast distributions
State prediction
HMMs for classification

Model selection and checking
Model selection by AIC and BIC
Model checking with pseudo-residuals

Bayesian inference for Poisson-HMMs
Applying the Gibbs sampler to Poisson-HMMs
Bayesian estimation of the number of states
Example: earthquakes

R packages
The package depmixS4
The package HiddenMarkov
The package msm
The package R20penBUGS

General state-dependent distributions
Univariate state-dependent distribution
Multinomial and categorical HMMs
Multivariate state-dependent distribution

Covariates and other extra dependencies
HMMs with covariates
HMMs based on a second-order Markox chain
HMMs with other additional dependencies

Continuous-valued state processes
Models with continous-valued state process
Fitting an SSM to the earthquake data

Hidden semi-Markov models as HMMs
Semi-Markov processes, hidden semi-Markov models and approximating HMMs
Examples of HSMMs as HMMs
General HSMM
R code
Some examples of dwell-time distributions
Fitting HSMMs via the HMM representation
Example: earthquakes

HMMs for longitudinal data
Some parameters constant across components
Models with random effects

Introduction to applications

Epileptic seizures
Models fitted
Model checking by pseudo-residuals

Daily rainfall occurrence
Models fitted

Eruptions of the Old Faithful geyser
The data
Binary time series of short and long eruptions
Normal-HMMs for durations and waiting times
Bivariate model for durations and waiting times

HMMs for animal movement
Directional data
HMMs for movement data
Basic HMM for Drosophila movement
HMMs and HSMMs for bison movement
Mixed HMMs for woodpecker movement

Wind direction at Koeberg
Wind direction classified into 16 categories
Wind direction as a circular variable

Models for financial series
Multivariate HMM for returns on four shares
Stochastic volatility models

Births at Edendale Hospital
Models for the proportion Caesarean
Models for the total number of deliveries

Homicides and suicides in Cape Town
Firearm homicides as a proportion of all homicides, suicides and legal intervention homicides
The number of firearm homicides
Firearm homicide and suicide proportions
Proportion in each of the five categories

Animal behaviour model with feedback
The model
Likelihood evaluation
Parameter estimation by maximum likelihood
Model checking
Inferring the underlying state
Models for a heterogeneous group of subjects
Other modifications or extensions
Application to caterpillar feeding behaviour

Survival rates of Soay sheep
MRR data without use of covariates
MRR data involving covariate information
Application to Soay sheep data

Examples of R code
The functions
Examples of code using the above functions

Some proofs
Factorization needed for forward probabilities
Two results for backward probabilities
Conditional independence of Xt1 and XTt+1


Author index

Subject index

View More


"This book is an excellent resource for researchers of all levels, from undergraduate students to researchers already working with hidden Markov models. The book initially provides the mathematical theory and underlying intuition of hidden Markov models in a clear and concise manner before describing more advanced, recently developed techniques and a wide range of applications using real data. One focus of the book is the practical application of hidden Markov models. R code is usefully provided throughout the text (and combined within the appendix) aiding researchers in applying the techniques to their own problems, in addition to the description of some specific R packages. Thus the book is a valuable resource for both researchers new to hidden Markov models and as a reference for individuals already familiar with the models and concepts. In particular, the inclusion of the new Part II ("Extensions") for the second edition relating to the recent advanced techniques is an excellent addition, providing a clear description of state-of-the-art hidden Markov-type models and associated issues. Overall, the book is exceptionally well written and will be a well thumbed book in my collection."
Ruth King, Thomas Bayes' Chair of Statistics, University of Edinburgh

 "…this is far and away the most accessible, up-to-date, and comprehensive introductory text on HMMs that there is, for students, applied statisticians, and indeed any quantitatively able researcher. It doubles as an excellent reference text for researchers who use HMMs. The addition of new R code and illustration of the use of HMM packages in R makes the text all the more useful, and the new chapters on applications in ecology and the environment will extend the appeal of the book into an area in which the huge potential of HMMs has only recently become apparent. If you want to find out about and use HMMs, ranging from the simplest to those at the cutting-edge research, this is the book for you!"
David Borchers, Professor of Statistics, University of St Andrews

"The authoritative text on HMMs has become even better. This second edition is welcome and timely, filled with many examples of HMMs in the real world, and very useful snippets of code to help us get going. The authors have once again hit the jackpot."
Trevor Hastie, Statistics Department, Stanford University

"The first edition of ‘Hidden Markov Models for Time Series: An Introduction using R’ was the clearest and most comprehensive description of the theory and applications of HMMs in print. This new second edition from Zucchini et al contains a highly useful update to the already impressive body of material covered in the first edition. New additions include chapters on Hidden Semi-Markov Models, continuous-valued state processes, and new application sections detailing the use of HMMs for animal movement and survival estimation. The R code provided outlines key computational procedures and provides a workable foundation upon which researchers can build their own bespoke implementations of HMMs and understand the working of other software packages, which are now considered in detail. This book is structured in an accessible, yet thorough, manner which will be appreciated by statistically literate researchers and students from a variety of disciplines. This book is highly recommended for anyone wishing to understand or use Hidden Markov models."
Dr. Toby Patterson, Senior Research Scientist, CSIRO Oceans and Atmosphere

"The first edition profoundly influenced my research and this new edition adds substantial material on R packages, hidden semi-Markov models and more. The book is a must have for any applied statistician interested in modeling incomplete encounter history or movement data for animals. The simplicity and generality of hidden Markov models make them an elegant solution for many applications and an essential method to have in an applied statistician's toolbox."
Prof. Jeff Laake, Marine Mammal Laboratory, Alaska Fisheries Science Center, Seattle

"This book is an essential for all researchers in the area of hidden Markov models and indeed, more generally, in the broad arena of statistical modelling. The theory underpinning hidden Markov models (HMMs) is meticulously delineated and perfectly complemented by a broad range of applications chosen from real-world settings in, for example, finance, zoology and the health sciences.
This second edition of the book now includes particularly valuable chapters on recent extensions to HMMs and intriguing new applications in ecology and the environment. Fragments of R code are provided throughout the text and in the Appendix and serve to fix ideas relating to both theory and practice. In summary, the book is a most welcome addition to the statistician's armoury and can be used both as a comprehensive reference work and as a well-crafted textbook."
Linda Haines, Emeritus Professor, Department of Statistical Sciences, University of Cape Town.