Closed paciorek closed 1 year ago
Problem appears to be the result of commit 46e273cc0034c9b6c4ac7cefe90c429bd8b9c7c4
What's happening is that the NA
s in inits
are over-writing the data values for the RHSonly nodes, in model$setData
. This happens only in the case that the variable has a mix of RHSonly and stochastic nodes. The problem arises because in that case model$setData
copies only the non-data elements into the variable, and the RHSonly elements are now non-data (they were previously data), so they are copied from inits, and that results in the NA
s being used when they shouldn't be.
A workaround is to replace the NA
s in the inits
with the same data values for the RHSonly portion of the variable. In the above example, this change appears to fix it:
inits <- list(
x = matrix(c(NA, 0, 0,
0, 0, 0), byrow = TRUE, nrow = 2)
)
I'll say more in the design document on nimbleCoreTeam, but just a couple notes here that I am seeing things differently than @perrydv :
setData
; it's just that the RHSonly nodes are now being overwritten in setInits
(because they are no longer flagged as data
), which is invoked after setData
in newModel()
.inits
values now overwrite values given in data
for RHSonly elements. E.g.,code <- nimbleCode({y ~ dnorm(mu,1)})
m=nimbleModel(code, data = list(y=1, mu=1), inits = list(mu=0))
m$mu # `0` as of version 1.0.0; `1` previously
Report from Daniel:
Example below works correctly in previous versions.