Git Product home page Git Product logo

Comments (5)

helske avatar helske commented on September 27, 2024 1

This should work now, with the latest github version I get no errors and reasonable results. I'll update the CRAN version soon.

from seqhmm.

helske avatar helske commented on September 27, 2024

This sounds like a bug, but I think I would need a fully reproducible example to track it down, as I don't immediately see how this kind of error could occur.

from seqhmm.

robertladwig avatar robertladwig commented on September 27, 2024

I am getting the same error with this example, too:

df = data.frame('event_1' = c(2,2,2,2,2),
                'event_2' = c(4,9,5,8,4),
                'event_3' = c(9,4,9,4,8),
                'event_4' = c(8,8,8,9,6),
                'event_5' = c(6,6,4,6,9),
                'event_6' = c(5,1,6,5,1),
                'event_7' = c(1,7,1,1,5),
                'event_8' = c(7,5,7,7,7),
                'event_9' = c(3,3,3,3,3))

pheno_seq <- seqdef(df, start = 1)

sc_initmod <- build_mm(observations = pheno_seq)

sc_fit <- fit_model(sc_initmod, em_step = TRUE, global_step = TRUE, local_step = TRUE, 
                    control_em = list(print_level = 2, restart = list(times = 10, reltol = 1e-20)))

sc_fit$logLik

which produces

iter: 1 logLik: -38.901 relative change: 1
Error in if (em.con$reltol < resEM$change) { : argument is of length zero
In addition: There were 11 warnings (use warnings() to see them)

from seqhmm.

helske avatar helske commented on September 27, 2024

edit: If I remove the last sequence from your data everything seems to work fine.

There seems to be a bug in build_mm, which leads to incorrect transition matrix (notice the row 3 is full of zeroes):

 sc_initmod$transition_probs
    to
from   1 2   3   4   5   6   7   8   9
   1 0.0 0 0.0 0.0 0.2 0.0 0.8 0.0 0.0
   2 0.0 0 0.0 0.4 0.2 0.0 0.0 0.2 0.2
   3 0.0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
   4 0.0 0 0.0 0.0 0.0 0.2 0.0 0.4 0.4
   5 0.4 0 0.2 0.0 0.0 0.0 0.2 0.0 0.2
   6 0.4 0 0.0 0.0 0.4 0.0 0.0 0.0 0.2
   7 0.0 0 0.8 0.0 0.2 0.0 0.0 0.0 0.0
   8 0.0 0 0.0 0.4 0.0 0.6 0.0 0.0 0.0
   9 0.2 0 0.0 0.2 0.0 0.2 0.0 0.4 0.0
   

from seqhmm.

helske avatar helske commented on September 27, 2024

Actually it is not really a bug, because there is zero transitions from 3, so even though by definition the transition probabilities from each state should sum to one, we don't have any clue for those for state 3. I'll change the function so that it will define such a state absorbing i.e. that the corresponding diagonal element is 1.

Running the above example with sc_initmod$transition_probs[3,3]<-1 seems to work for local and global steps, but the EM still does not work properly, likely because within EM algorithm we are dividing by the number of transition from state 3 which is zero.

from seqhmm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.