Open genisprat opened 4 years ago
I think that in
choice,state=rand(hmm, Ntrials, seq = true) #create synthetic data
it should be
state,choice=rand(hmm, Ntrials, seq = true) #create synthetic data
where choice
are the observations and state
the unobserved data. Next line you compute the likelihood with states instead of observations.
See
https://github.com/maxmouchet/HMMBase.jl/blob/8ad8254d95f30c56dbff874fb6e8040969849e05/examples/basic_usage.jl#L24
I did not try to verify if it solves the problem.
Hi, First of all, thank you for this nice package. I would like to use this package in a research project but I can not recover the original parameters when I use fit_mle. I create synthetic data using the function rand() and then I try to fit it with different initial conditions. For a HMM with bernulli distribution. The Transition matrix is correctly fit it but the fitted emission probabilities aare close to 1. Probably I am doing something wrong but I can not find my error. Here my code:
P=[0.7 0.3 0.1 0.9]
T=[0.7 0.3 0.1 0.9]
NDataSets=100 Nconditions=20 Nstates=2 Nout=2 Ntrials=1000 LlOriginal=zeros(NDataSets) LlBest=zeros(NDataSets)
TBest=zeros(NDataSets,Nstates,Nstates) PiBest=zeros(NDataSets,Nstates) PBest=zeros(NDataSets,Nstates,Nout) TFinal=zeros(Nconditions,Nstates,Nstates) PiFinal=zeros(Nconditions,Nstates) PFinal=zeros(Nconditions,Nstates,Nout) Ll=zeros(Nconditions)
for idata in 1:NDataSets println("iDataSet: ",idata)
end
plot([T[1,1],T[1,1]],[1,3],"r-") plot([T[2,2],T[2,2]],[1,3],"r-")
plot([P[1,1],P[1,1]],[3,5],"b--") plot([P[2,2],P[2,2]],[3,5],"b--")