resetting monitors after initial compilation

34 views
Skip to first unread message

Rebecca Taylor

unread,
Mar 8, 2023, 4:07:54 PM3/8/23
to nimble-users

Hello all.  I have a question about resetting monitors after an object has been compiled. I believe I am following the instructions correctly, but in so doing, I keep crashing R.

Here is the code that worked to create and run the initial model:

Rmodel <- nimbleModel(code=code, constants=consts, data=data, dimensions = dimensions,calculate=T, check=T, inits=I1)

conf  <- configureMCMC(Rmodel, monitors=parms, control = list(adaptInterval = MCMCcontrol$nadapt), thin = MCMCcontrol$nthin, useConjugacy = TRUE)

Rmcmc <- buildMCMC(conf)                                               

Cmodel<-compileNimble(Rmodel)                                      

Cmcmc <- compileNimble(Rmcmc, project = Rmodel)  

out <- runMCMC(Cmcmc, niter = MCMCcontrol$niter, nburnin = MCMCcontrol$nburn, thin=MCMCcontrol$nthin, nchains=MCMCcontrol$nchains,setSeed = seq(1:nchains), inits = I1, progressBar = TRUE, samplesAsCodaMCMC = TRUE)

To reset the monitors, I first redefined “parms”, the vector of variable names  to monitor. The second step (shown below) appeared to work correctly:

conf$setMonitors(parms).

The next step reliably crashes R:

 Rmcmc <- buildMCMC(conf).

What am I missing?

Thank you!

Rebecca

 

 

 

 

 

Taylor, Rebecca L

unread,
Mar 9, 2023, 1:40:01 PM3/9/23
to 'Taylor, Rebecca L' via nimble-users
This is an update to the question I posted yesterday. 

I think the problem has to do with the fact that I am trying to run nimble after reopening a saved R workspace. All of the objects I expect to be there are indeed present in the workspace. But I get the following errors if I don’t change anything and just try to rerun the model. 

When I try Cmcmc$run(niter), I get the following error: 

Error in .Call("CALL_MCMC_run", niter, reset, resetMV, time, progressBar,  : C symbol name "CALL_MCMC_run" not in load table 

When I try this, 

out   <- runMCMC(Cmcmc, niter = MCMCcontrol$niter, nburnin = MCMCcontrol$nburn, thin=MCMCcontrol$nthin, nchains=MCMCcontrol$nchains, setSeed = seq(1:nchains), inits = I1, progressBar = TRUE, samplesAsCodaMCMC = TRUE) 

I get this error: 

Error in .Call(NULL, <pointer: (nil)>, 1L) : first argument must be a string (of length 1) or native symbol reference 

Is there a way to rerun a nimble model from a saved workspace without going through the configureMCMC step again? (That is the time consuming part for my model.) 

Thank you! 


Rebecca Taylor
Research Statistician
Alaska Science Center
U. S. Geological Survey



From: 'Rebecca Taylor' via nimble-users <nimble...@googlegroups.com>
Sent: Wednesday, March 8, 2023 12:07 PM
To: nimble-users <nimble...@googlegroups.com>
Subject: [EXTERNAL] resetting monitors after initial compilation
 


--
You received this message because you are subscribed to a topic in the Google Groups "nimble-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nimble-users/NXC3SmOwng0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nimble-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/5c88a97b-b0e6-435b-90fb-1584f9b57c2en%40googlegroups.com.

Chris Paciorek

unread,
Mar 10, 2023, 10:40:40 AM3/10/23
to Taylor, Rebecca L, nimble-users
Hi Rebecca,

Unfortunately, you cannot save and reload nimble objects (models, MCMCs, etc.). The reason has to do with how objects in C++ are set up and accessed from R. 
It's a known shortcoming and one we have been working on a solution for, but it's part of a long-term effort.

-Chris 

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/BY5PR09MB51541919FD6848753C374560D4B59%40BY5PR09MB5154.namprd09.prod.outlook.com.

Taylor, Rebecca L

unread,
Mar 10, 2023, 10:44:12 AM3/10/23
to paci...@stat.berkeley.edu, nimble-users
Chris,

Ahh-thank you. It is good to know that so I will quit struggling with it. (I will also talk to my IT department about some of our required reboots.)

Cheers,

Rebecca


Rebecca Taylor
Research Statistician
Alaska Science Center
U. S. Geological Survey

Pronouns: She/her
Please note I sometimes send and answer email outside normal work hours. 
This helps me with my schedule but is not intended to pressure others to do the same. 

From: Chris Paciorek <paci...@stat.berkeley.edu>
Sent: Friday, March 10, 2023 6:40 AM
To: Taylor, Rebecca L <rebecc...@usgs.gov>
Cc: nimble-users <nimble...@googlegroups.com>
Subject: [EXTERNAL] Re: update to resetting monitors after initial compilation
 

 

 This email has been received from outside of DOI - Use caution before clicking on links, opening attachments, or responding.  

Marwan Naciri

unread,
Oct 5, 2026, 6:34:58 AM (6 days ago) Oct 5
to nimble-users
Hi Chris and all,
Just checking on this issue. Have you been able to develop a solution to this problem? Or have you identified a workaround?
I'm trying to prolong an MCMC chain in an R session independent of the R session on which the first MCMC iterations were run  (this way I can check the output of the first run and, if more iterations are needed, launch another R script; the whole thing is done on a cluster, so I can't keep the same R session open, as far as I know)

Thanks in advance,
Cheers,
Marwan

Chris Paciorek

unread,
Oct 6, 2026, 8:14:08 PM (4 days ago) Oct 6
to Marwan Naciri, nimble-users
hi Marwan,

We are hard at work on version 2 of NIMBLE, which will provide a solution for this. It's not quite ready, but we hope to be getting folks to test it out in a few months.

-Chris 

Reply all
Reply to author
Forward
0 new messages