definitions for RHS of distribution declarations

5 views
Skip to first unread message

Brook Milligan

unread,
Sep 9, 2025, 7:24:35 PMSep 9
to nimble-users
Hi all,

I am trying to understand the rules for defining variables within a nimble model. It seems that there should be some simple rules that are generally applicable, but some of that is eluding me.

The nimble manual (section 6.1.1.1) states the following:

Values for nodes that appear only on the right-hand side of BUGS declarations (e.g., covariates/predictors) can be provided as constants or as data or initial values. There is no real difference between providing as data or initial values and the values can be added after building a model via setInits or setData.

Although the second sentence is not quite as inclusive as the first, the first directly states that RHS variables can be defined via any of the three possible means: constants, data, initial values.

I have a simple case (see attached) that demonstrates to me that this is not the case. There are three different calls to nimbleMCMC that differ only in the way that a RHS variable is defined (one per possibility, see lambda). Case 3 (using constants) fails with the following, so at least in this case they are not all equivalent and possible.

Defining model
Error in addMissingIndexingRecurse(code[[i]], dimensionsList) :
inconsistent dimensionality provided for node 'lambda’
Calls: nimbleMCMC ... addMissingIndexingRecurse -> addMissingIndexingRecurse
Execution halted

I must be missing something here, but I do not see it. What are the rules that govern initialization of model variables?

Thanks a lot for your help.

Cheers,
Brook

test-1.R

Perry de Valpine

unread,
Sep 10, 2025, 3:15:42 AMSep 10
to Brook Milligan, nimble-users
Ok, that's an interesting case.
The problem is happening because nx=1. nimble has some tripping points over the distinction between a true scalar (which does not exist in R but is used in nimble for C++) and a vector of length 1. In this case, for the case of providing lambda as a vector of length 1 and using it as lambda[i] with i=1, nimble is tripping on it when lambda is provided as a constant. If you set nx=2 (and make x and lambda length 2) the problem goes away. I'll file an issue.
Perry
 

--
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.
To view this discussion visit https://groups.google.com/d/msgid/nimble-users/02FB27B4-77BB-4A2D-B113-1C091B613162%40biology.nmsu.edu.


--
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.
To view this discussion visit https://groups.google.com/d/msgid/nimble-users/02FB27B4-77BB-4A2D-B113-1C091B613162%40biology.nmsu.edu.
Reply all
Reply to author
Forward
0 new messages