"problem creating switch function for getParam" error with custom distributions / functions(?)

30 views
Skip to first unread message

pcoll...@berkeley.edu

unread,
Nov 8, 2017, 10:17:57 PM11/8/17
to nimble-users
I'm a brand new user, checking out NIMBLE for some crude hidden population models. My first attempt at compiling a model with a couple of 'custom' distributions (hypergeometric, discrete uniform) and one custom function (log binomial coefficient calculator) has run up against an error which I cannot interpret. Upon compilation, sometime during the later subfunction calls, the program fails with error "problem creating switch function for getParam...". See attached R markdown for the code used and the exact text of the error.

Any pointers on what the problem is? Thanks in advance.




Basic_S1&S3_Nimble_model_share.Rmd
Basic_S1_S3_Nimble_model_share.html

Perry de Valpine

unread,
Nov 9, 2017, 2:20:09 PM11/9/17
to pcoll...@berkeley.edu, nimble-users
Thanks for the reproducible example.

Oops, it turns out there is a problem when parameters of a user-defined distribution are named "lower" or "upper".  If you rename those parameters, it works.  I'll file a github issue so we can fix that.

In addition, dbin (aliased by dbinom) is an example of a distribution defined by BUGS with different default parameter order from R.  So you'll want:

S1_ct[v,t] ~ dbinom(size = Q[v,t], prob = p_S1)

There remains a problem with some initial values yielding NaNs from your nlchoose function (I suspect n-k+1 <= 0), which I leave to you to resolve.

Perry


On Wed, Nov 8, 2017 at 7:17 PM, <pcoll...@berkeley.edu> wrote:
I'm a brand new user, checking out NIMBLE for some crude hidden population models. My first attempt at compiling a model with a couple of 'custom' distributions (hypergeometric, discrete uniform) and one custom function (log binomial coefficient calculator) has run up against an error which I cannot interpret. Upon compilation, sometime during the later subfunction calls, the program fails with error "problem creating switch function for getParam...". See attached R markdown for the code used and the exact text of the error.

Any pointers on what the problem is? Thanks in advance.




--
You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users+unsubscribe@googlegroups.com.
To post to this group, send email to nimble...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/6c99706a-0c3d-4718-a624-486e61891847%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

pcoll...@berkeley.edu

unread,
Nov 9, 2017, 2:48:24 PM11/9/17
to nimble-users
Thanks much Perry. I somehow sussed out that the 'lower' 'upper' nomenclature was the problem as well. I'll tinker around to see if I can fix the NaN issues.

   

On Thursday, November 9, 2017 at 11:20:09 AM UTC-8, pdevalpine wrote:
Thanks for the reproducible example.

Oops, it turns out there is a problem when parameters of a user-defined distribution are named "lower" or "upper".  If you rename those parameters, it works.  I'll file a github issue so we can fix that.

In addition, dbin (aliased by dbinom) is an example of a distribution defined by BUGS with different default parameter order from R.  So you'll want:

S1_ct[v,t] ~ dbinom(size = Q[v,t], prob = p_S1)

There remains a problem with some initial values yielding NaNs from your nlchoose function (I suspect n-k+1 <= 0), which I leave to you to resolve.

Perry

On Wed, Nov 8, 2017 at 7:17 PM, <pcoll...@berkeley.edu> wrote:
I'm a brand new user, checking out NIMBLE for some crude hidden population models. My first attempt at compiling a model with a couple of 'custom' distributions (hypergeometric, discrete uniform) and one custom function (log binomial coefficient calculator) has run up against an error which I cannot interpret. Upon compilation, sometime during the later subfunction calls, the program fails with error "problem creating switch function for getParam...". See attached R markdown for the code used and the exact text of the error.

Any pointers on what the problem is? Thanks in advance.




--
You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users...@googlegroups.com.

pcoll...@berkeley.edu

unread,
Nov 9, 2017, 3:47:24 PM11/9/17
to nimble-users
I think I've fixed the nlchoose function to deal with log(-#) errors (updated markdown files attached), but there's another cryptic error upon compilation. This time the error occurs within the 

for (i in whichUnits) {
      ans
[[i]] <- project$compileModel(units[[i]], control = control,
        showCompilerOutput
= showCompilerOutput)
     
if (names(units)[i] != "")
        names
(ans)[i] <- names(units)[i]
   
}

chunk of the compileNimble() call, and seems to be a problem with taking the maximum of two S4 typed variables, but again what's going on is pretty opaque to me, so help would be greatly appreciated.

Error in max(a1nDim, a2nDim) : invalid 'type' (S4) of argument


Basic_S1_S3_Nimble_model_share.html
Basic_S1&S3_Nimble_model_share.Rmd

Perry de Valpine

unread,
Nov 9, 2017, 3:56:14 PM11/9/17
to pcoll...@berkeley.edu, nimble-users
It looks like the problem is that nlchoose needs a returnType(double(0)) statement.

I'll think about how we could trap that and provide a more useful message.


--
You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users+unsubscribe@googlegroups.com.

To post to this group, send email to nimble...@googlegroups.com.

pcoll...@berkeley.edu

unread,
Nov 9, 2017, 3:59:23 PM11/9/17
to nimble-users
Great! That's done it.
Reply all
Reply to author
Forward
0 new messages