GithubHelp home page GithubHelp logo

nimbleecology's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nimbleecology's Issues

warning in AD-enabled nimbleEcology

We'll need to address this warning that arises for dCJS:

[Note] Detected use of function(s) that are not supported for derivative tracking in a function or method for which `buildDerivs` has been requested: is.na.

dCJS enforces probSurvive >= (len - 1), but rCJS enforces probSurvive == len - 1

This creates an inconsistency where inputs that work fine for probability calculation errors during simulation, but there isn't a good reason simulation should behave differently.

I suggest we change the condition in dCJS to match that in rCJS. This is stricter and there's a risk it'd break something someone is doing, although I'd argue that it's too easy to misinterpret what's going on without this.

multiple use of registerDistributions

Not sure if this is just duplication or there or a reason but dDHMM and dDHMMo are registered in both zzz.R (i.e., via .onAttach) and in dDHMM.R. Perhaps the registration in the latter is needed to build the package?

Strict checking of sum(init) != 1 can be false in R and true in C++

In dHMM and other distributions, there is a check of whether sum(init) != 1, with an error if true.

Even if the init vector satisfies sum(init) == 1 in R, this condition can be false in C++, presumably due to floating point arithmetic issues, with possibly different orders in R vs C++ or something like that.

In such a case, which was reported by a user, it can be hard to work around. One can normalize the vector in R and still have sum(init) != 1 in C++.

How about replacing this condition with something like abs(sum(init) - 1) < 1e-6 or perhaps a stricter tolerance? This is similar to the other checks in nearby code that allow some numerical imprecision.

Example at https://rdrr.io/github/nimble-dev/nimbleEcology/man/dHMM.html throws an error

Hei! The example at https://rdrr.io/github/nimble-dev/nimbleEcology/man/dHMM.html throws an error: "Error in genVarInfo3() :
dimensions specified are smaller than model specification for variable 'probObs'"

Cheers
Matt

len <- 5 # length of dataset
dat <- c(1,2,1,1,2) # A vector of observations
init <- c(0.4, 0.2, 0.4) # A vector of initial state probabilities
probObs <- t(array( # A matrix of observation probabilities
  c(1, 0,
    0, 1,
    0.2, 0.8), c(2, 3)))
probTrans <- t(array( # A matrix of transition probabilities
  c(0.6, 0.3, 0.1,
    0, 0.7, 0.3,
    0, 0, 1), c(3,3)))

# Define code for a nimbleModel
nc <- nimbleCode({
  x[1:5] ~ dHMM(init[1:3], probObs = probObs[1:2,1:3],
                probTrans = probTrans[1:3, 1:3], len = 5)
  
  for (i in 1:3) {
    init[i] ~ dunif(0,1)
    
    for (j in 1:3) {
      probTrans[i,j] ~ dunif(0,1)
    }
    
    probObs[i, 1] ~ dunif(0,1)
    probObs[i, 2] <- 1 - probObs[1,i]
  }
})

# Build the model
HMM_model <- nimbleModel(nc,
                         data = list(x = dat),
                         inits = list(init = init,
                                      probObs = probObs,
                                      probTrans = probTrans))
#Error here
#defining model...
#Error in genVarInfo3() : 
#  dimensions specified are smaller than model specification for variable 'probObs'

# Calculate log probability of data from the model
HMM_model$calculate()
# Use the model for a variety of other purposes...

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.