apaMarkov.SemiHidden.Gaussian.Estimate(DataMatrix, numStates, maxDuration, nMultiStarts, Seed)
=apaMarkov.SemiHidden.Gaussian.Estimate(DataMatrix, numStates, maxDuration, nMultiStarts, Seed)Result
Estimates a Gaussian hidden semi-Markov model (HSMM) with explicit state duration distributions and returns the parameters, the duration statistics and the state probabilities. The function is non-volatile.
Syntax
DataMatrix: r x c matrix of return data, each column containing an asset return series
numStates: number of states to impose
maxDuration: maximum explicit state duration
nMultiStarts: number of multi-starts. Default value: 1 (also used if omitted or below 1)
Seed: seed of the random number generator. Default value: 1 (also used if omitted or 0)
Algorithm
Inputs are validated: non-empty DataMatrix, numStates ≥ 1, maxDuration ≥ 1.
The parameters are estimated with an EM algorithm based on a segment forward-backward recursion. Each state has an explicit duration distribution over 1 to maxDuration observations, and a new segment always moves to a different state, so maxDuration is the longest possible regime length and should exceed the longest regime expected in the data. The first segment starts with the first observation and the last segment ends with the last observation. The E-step yields the posterior probabilities of each segment (state, duration, end time) and of each switch between states; the state means and covariances, the switching probabilities and the duration probabilities are their posterior-weighted averages.
Remarks
Covariances are maximum-likelihood (EM) estimates: probability-weighted, population-type, no small-sample correction.
