3

If I have fit a model mf with depmix() and fit() using depmixS4 package, and I want to know the log-likelihood of generating a given sequence s, how should I do?

I know in the HiddenMarkov package I can use forwardback(s, mf$Pi, mf$...)$LL to get the log-likelihood, but I find the forwardbackward() function in depmixS4 does not work similarly.

Lytze
  • 755
  • 6
  • 12

1 Answers1

3

Finally I found the way myself, as first time working with S4...

Firstly initialize a model (depmix obj) with depmix(), and then update it with parameters in the fitted mf using setpars(). After that the forwardbackward() will work

init_mod <- depmix(respones, data, nstates) ## no solid value
mod <- setpars(init_mod, getpars(fm))
forwardbackward(mod)

Anyone knows better solution plz tell me...

Lytze
  • 755
  • 6
  • 12