algo.hmm {surveillance}R Documentation

Hidden Markov Model (HMM) method

Description

This function implements on-line HMM detection of outbreaks based on the retrospective procedure described in Le Strat and Carret (1999). Using the function msm (library msm) a specified HMM is estimated, the decoding problem, i.e. the most probable state configuration, is found by the Viterbi algorithm and the most probable state of the last observation is recorded. On-line detection is performed by sequentally repeating this procedure.

Warning: This function can be very slow - a more efficient implementation would be nice!

Usage

  algo.hmm(disProgObj, control = list(range=range, Mtilde=-1, 
             noStates=2, trend=TRUE, noHarmonics=1,
             covEffectEqual=FALSE))

Arguments

disProgObj object of class disProg (including the observed and the state chain)
control control object:
range
determines the desired time points which should be evaluated. Note that opposite to other surveillance methods an initial parameter estimation occurs in the HMM. Note that range should be high enough to allow for enough reference values for estimating the HMM
Mtilde
number of observations back in time to use for fitting the HMM (including current). Reasonable values are a multiple of disProgObj$freq, the default is Mtilde=-1, which means to use all possible values - for long series this might take very long time!
noStates
number of hidden states in the HMM – the typical choice is 2. The initial rates are set such that the noState'th state is the one having the highest rate. I.e. this state is considered the outbreak state.
trend
Boolean stating whether a linear time trend exists, i.e. if TRUE (default) then β != 0
noHarmonics
number of harmonic waves to include in the linear predictor. Default is 1.
covEffectEqual
see details

Details

For each time point t the reference values values are extracted. If the number of requested values is larger than the number of possible values the latter is used. Now the following happens on these reference values:

A noState-State Hidden Markov Model (HMM) is used based on the Poisson distribution with linear predictor on the log-link scale. I.e.

Y_t|X_t = j ~ Po(μ_t^j),

where

log(mu_t^j) = alpha_j + beta_j t + sum_{i=1}^{nH} gamma_j^i cos(2*i*pi/freq * (t-1)) + delta_j^i sin(2*i*pi/freq * (t-1))

and nH=noHarmonics and freq=12,52 depending on the sampling frequency of the surveillance data. In the above t-1 is used, because the first week is always saved as t=1, i.e. we want to ensure that the first observation corresponds to cos(0) and sin(0).

If covEffectEqual then all covariate effects parameters are equal for the states, i.e. β_j=β, gamma_j^i=gamma^i, delta_j^i=delta^i for all j=1,...,noState.

In case more complicated HMM models are to be fitted it is possible to modify the msm code used in this function. Using e.g. AIC one can select between different models (see the msm package for further details).

Using the Viterbi algorithms the most probable state configuration is obtained for the reference values and if the most probable configuration for the last reference value (i.e. time t) equals control$noOfStates then an alarm is given.

Note: The HMM is re-fitted from scratch every time, sequential updating schemes of the HMM would increase speed considerably! A major advantage of the approach is that outbreaks in the reference values are handled automatically.

Value

survRes algo.hmm gives a list of class survRes which includes the vector of alarm values for every timepoint in range. No upperbound can be specified and is put equal to zero.
The resulting object contains a slot control$hmm, which contains the msm object with the fitted HMM.

Author(s)

M. Höhle

References

Y. Le Strat and F. Carrat, Monitoring Epidemiologic Surveillance Data using Hidden Markov Models (1999), Statistics in Medicine, 18, 3463–3478

I.L. MacDonald and W. Zucchini, Hidden Markov and Other Models for Discrete-valued Time Series, (1997), Chapman & Hall, Monographs on Statistics and applied Probability 70

See Also

msm

Examples

set.seed(123)
#Simulate outbreak data from HMM
counts <- sim.pointSource(p = 0.98, r = 0.8, length = 3*52,
                              A = 1, alpha = 1, beta = 0, phi = 0,
                              frequency = 1, state = NULL, K = 1.5)

#Do surveillance using a two state HMM without trend component and
#the effect of the harmonics being the same in both states. A sliding
#window of two years is used to fit the HMM
surv <- algo.hmm(counts, control=list(range=(2*52):length(counts$observed),
                                   Mtilde=2*52,noStates=2,trend=FALSE,
                                   covEffectsEqual=TRUE))
plot(surv,legend=list(x="topright"))


[Package surveillance version 1.0-3 Index]