Evaluating sequence with a fitted model using depmixS4 in R

1.1k views Asked by At

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.

1

There are 1 answers

0
Lytze On

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...