I'm trying to identify states in a high-dimensional binary time series, I want to use Hidden Markov Modelling specifically. The binary time series represent the output of a neural network with 500 neurons. The entire network is always in one of five possible states. The documentation for hmmtrain and hmmgenerate is sparse and makes no mention of multivariate emissions. However hmmtrain does allow a matrix to me used as the sequence, suggesting that it can use a multivariate emissions sequence. It doesn't say what dimension to put the extra emissions variable on so I guessed the 3rd dimension. It does work (see below).
Here is a failed example of using hmmgenerate:
[seq,states] = hmmgenerate(T,transition_mat,emission_mat);
"sample_spike" should have size 500x150. Instead it is 1x150. Nonetheless I can use "states" to generate a spike series and test "hmmtrain".
Here is a failed example of using hmmtrain:
[ESTTR,ESTEMIT] = hmmtrain(1+sample_spike_train,guess_transition_mat,guess_emit_mat) ;
This yeilds obviously wrong results. ESTTR is identical to guess_transition_mat, and (bizarrely) ESTEMIT has size N_states x 394 irrespective of how many neurons I use. I expect ESTTR~transition_mat and ESTEMIT~emission_mat.
It variously produces poor results (the transistion matrix is not even close to correct) or runs into infinity/nan issues when T is large.
Here is a failed example of using an external package.
nex = 1;
M = 1;
cov_type = 'full';
prior0 = normalise(rand(N_states,1));
transmat0 = ones(N_states)/N_states;
[mu0, Sigma0] = mixgauss_init(N_states*M, 1+sample_spike_train', cov_type);
mixmat0 = mk_stochastic(rand(N_states,M));
[LL, prior1, transmat1, mu1, Sigma1, mixmat1] = ...
mhmm_em(1+sample_spike_train', prior0, transmat0, mu0, Sigma0, mixmat0, 'max_iter', 100);
Any help, or explanation is appreciated. I've seen HMMs used in neuroscience for multiple neurons at once, but it looks like custom software was used and it is not available. Why does hmmtrain allow matrix input if it isn't multivariate?