Error in predictive nodes

266 views
Skip to first unread message

EN Pete

unread,
Jun 13, 2023, 11:04:09 AM6/13/23
to nimble-users
Hi All-

I keep getting this error when I do a test run for nimble model: "Checking model calculations
Error in addDefaultSampler(nodes = nodes, useConjugacy = useConjugacy,  :
  predictive node IDs in model appear to be set wrong" .

Im really not sure what is creating this error since all the indices are correct. I have attached the model code (WriteModel_spattemp_nimble.R) and the runMCMC.R code which calls the model, sets up the data list and model components etc. I have also attached the model/test data (modeldata.RDS) and my neighborhood object nbWB_A.R to run the nimble model with all needed components. 

In short I have a Bayesian hierarchical model with 3 data models, and a spate-temporal process model. 

All/Any help much much appreciated.

Emily
WriteModel_spattemp_nimble.R
modeldata.RDS
RunMCMC.R
nbWB_A.R

Daniel Turek

unread,
Jun 13, 2023, 1:29:53 PM6/13/23
to EN Pete, nimble-users
Emily, thanks for the detailed report, and also the files to reproduce your workflow.

There certainly have been significant changes to nimble in the recent release, which do relate to predictive node IDs, determination of these, and error-checking along the way.  So it's very, very believable that we've overlooked some particular cases, and something is going wrong... and we'd like to get to the bottom of this.

That said, I wasn't able to reproduce the error you're experiencing.  I'mm attaching the modified script I used (RunMCMC_DT.R), which contains only very minimal changes, mostly relating to directories and the function you defined called "RunMCMC".  That said, when I execute the script I'm attaching, I don't get the error you mentioned.

Can you confirm what version of the nimble package you're using?  When you load the nimble library, it should output "nimble version X is loaded", and just let me know what that says.  We'll keep trying to troubleshoot from there.

Thanks,
Daniel




--
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 on the web visit https://groups.google.com/d/msgid/nimble-users/6603227b-f1fe-43a9-a9c5-5909f484972an%40googlegroups.com.
RunMCMC_DT.R

baug...@vt.edu

unread,
Sep 13, 2023, 1:24:04 PM9/13/23
to nimble-users

I don't have a reproducible example to submit, but I just wanted to report I have been getting the same error message and figured out it happens when I modify and recompile the model. The message does not appear if I restart R after changing themodel. Seems like a similar issue to having to deregister and recompile a custom distribution if you change it, but nimble didn't used to behave this way for me.

Chris Paciorek

unread,
Sep 16, 2023, 2:32:40 PM9/16/23
to baug...@vt.edu, nimble-users
Hi Ben,

I realize you don't have a reproducible example but can you give us any more details on what you mean by "modify a model"? Are you taking a model object created by `nimbleModel` and then modifying values in it? Or something else?  If you can list the series of steps you did up to the point you see the message (which presumably comes from `configureMCMC` or `buildMCMC`), that would be helpful.

We definitely want to track down the issue, but we can't reproduce the problem from Emily's code, so I thought I'd see if I could cook up a simple example based on your report.

-Chris

Emily Weiser

unread,
Sep 27, 2023, 4:53:29 PM9/27/23
to nimble-users
Ben, thanks so much for posting--I was getting that error today and I was very confused! Restarting a clean R session did the trick. I use nimble extensively and have not updated it recently; I'm running nimble 0.13.1 on R 4.2.2 on Windows 10.0.19045 Build 19045. (My system is centrally administered and we're always behind on R.)

I have not been able to replicate the error despite some fairly extensive effort. When I got it, I'd edited the model (running nimbleCode again) as well as the data. It's possible I forgot to update one of the inputs accordingly, and perhaps that caused the error. Or maybe this was a recompiling issue too and I simply haven't hit on the right workflow to replicate it.

It's running fine now, so I'm good to go, but figured I'd add to the conversation in case that helps someone else.

Thanks,

Emily (a different one from the OP!)

David Christianson

unread,
Apr 1, 2025, 4:46:31 PM4/1/25
to nimble-users
This was helpful. I had the same issue and could not debug until I restarted R.  

heather...@gmail.com

unread,
Apr 2, 2025, 9:36:47 PM4/2/25
to nimble-users
This seems to be an issue for folks in the Bayesian class I'm teaching.

For the sake of helping the nimble folks track down the internal error, here's an example of what caused it. 
One student had this error after running:
prepnim <- nimbleModel(code = CJS_sex_year, constants = constants, dat = data_list,
                       inits = inits, calculate = T)

and then trying to do:

mcmc_out <- nimbleMCMC(
  code = CJS_sex_year,
  constants = constants,
  data = data_list,
  inits = inits,
  monitors = params,
  niter = 6000,
  nburnin = 3000,
  nchains = 3,
  thin = 1,
  samplesAsCodaMCMC = TRUE
)

It seems that sometimes the two forms of running the model clash somehow, even if everything in R is cleared but R is not restarted. Restarting R seems to help. 

Chris Paciorek

unread,
Apr 4, 2025, 2:14:23 PM4/4/25
to heather...@gmail.com, nimble-users
Hi Heather, thanks for this report. As you've seen from the email chain, we've had trouble reproducing the error ourselves, and hence haven't been able to fix it.

1. Are you able to provide us with a full reproducible example (either on- or off-list)? 

2. If that is not possible or a pain, could you:
 a.  Tell us whether the student did anything after running `nimbleModel` and before running `nimbleMCMC`. For example, did the student compile `prepnim` or run any algorithms on `prepnim`?
 b.  It would also help to see the details of what was attempted in terms of clearing objects. 
 c.  Show us the model code. I'd like to see what form the predictive nodes take.

-chris

heather...@gmail.com

unread,
Apr 4, 2025, 5:07:47 PM4/4/25
to nimble-users
Here's what *seems* to be reproducible code to get this error. It's a wiggly beast. I think it actually has to do with interrupting the nimbleMCMC mid way through? At least that's the best way I can make this error happen. 
BreakNimble.R

Chris Paciorek

unread,
Apr 4, 2025, 7:59:48 PM4/4/25
to heather...@gmail.com, nimble-users
So you are seeing the error when you do Ctrl-C in the middle of the `nimbleMCMC` execution? Is that right? Do you know if the error ever occurs without using Ctrl-C?



heather...@gmail.com

unread,
Apr 4, 2025, 8:27:02 PM4/4/25
to paci...@stat.berkeley.edu, nimble-users
I just use escape on my computer. No idea on Ctrl-c. I’m on a Mac if that makes a difference. 

Sent from my iPhone; please excuse any typos

On Apr 4, 2025, at 7:59 PM, Chris Paciorek <paci...@stat.berkeley.edu> wrote:



Chris Paciorek

unread,
Apr 6, 2025, 12:24:27 PM4/6/25
to heather...@gmail.com, nimble-users
Hmm, well I can give a few thoughts, but nothing that is really helpful. In part this is because I can't reproduce the error on my own system. It may be that it matters what step of `nimbleMCMC` is interrupted.

1. `nimbleMCMC` creates a new model object. When it does so, it should be irrelevant whether another version of the model is already created (i.e., when you create `prepnim`). So I don't think that that is part of the problem.

2. We do some non-standard things with compiled objects during the nimble compilation process. That is why sometimes one needs to use the `resetFunctions` argument to `compileNimble` when one uses `compileNimble` directly rather than indirectly through `nimbleMCMC`. That said, the error message about predictive nodes happens during MCMC configuration, which shouldn't be related to compilation.

3. If this only occurs if one interrupts `nimbleMCMC` (and therefore probably an internal call to `compileNimble`), I don't think this is something we would necessarily call a bug, though ideally it wouldn't happen.

In summary, I don't think there's much we can do with this particular example, unfortunately.
Reply all
Reply to author
Forward
0 new messages