Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide more informative error msgs for nimbleModel() and compileNimble() when dimension info not sufficient in BUGS code #19

Closed
paciorek opened this issue May 3, 2015 · 2 comments

Comments

@paciorek
Copy link
Contributor

paciorek commented May 3, 2015

In a number of cases our error msgs are non-informative when no brackets are provided for non-scalars (see below) (note we are much better when brackets are provided but the indexing is missing). One possibility would be to write a little system to check code based on knowing dimensions of distribution values and parameters and knowing expected dimensions for various DSL functions.

Examples:
code <- nimbleCode({
b[1:2] ~ dmnorm(mn[1:2], I[1:2,1:2])
z <- Z%*%b
})

m <- nimbleModel(code, inits = list(mn = rep(0, 2), I = diag(rep(0,2)), b = c(1,2), Z =matrix(rnorm(4),2)))
Error in parentExprReplaced[[iI + 2]] :
object of type 'symbol' is not subsettable

code <- nimbleCode({
b ~ dmnorm(mn, I)
})

m <- nimbleModel(code, inits = list(mn = rep(0, 2), I = diag(rep(1,2)), b = c(1,2)))
cm <- compileNimble(m)
Error: Error, sizeUnaryCwiseSquare was called with an argument that is not a matrix

code <- nimbleCode({
b ~ dmnorm(mn, I)
z[1:2] <- Z[1:2,1:2]%*%b[1:2]
})

m <- nimbleModel(code, inits = list(mn = rep(0, 2), I = diag(rep(1,2)), b = c(1,2), Z =matrix(rnorm(4),2)))
Error in if (is.numeric(v) && any(v < 0)) { :
missing value where TRUE/FALSE needed

@paciorek
Copy link
Contributor Author

paciorek commented Jun 2, 2015

I fixed a portion of this. In some (but not all) cases if a RHS term is missing indexing we now tell the user that that variable might be the one needing indexing.

E.g., that works for
y[1:3]~dmulti(p,n)
y[1:3]~dmnorm(mu[1:3], prec)

but not for
p[1:3]~ddirch(alpha)
y[1:3]~dmnorm(mu, prec[1:3,1:3])

still investigating...

@paciorek
Copy link
Contributor Author

We've basically dealt with this in an incomplete way with the size checking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant