regularly save output in nimble

16 views
Skip to first unread message

Dusit Ngoprasert

unread,
Jul 10, 2024, 2:57:38 PM (12 days ago) Jul 10
to nimble-users
Hi everyone,
I wonder, is there any package that works like "saveJAGS", but for nimble? I have a problem with the power outage after running three days. The model should run longer than that, so I am afraid to get nothing again. 
Best regards,
Dusit

Dusit Ngoprasert

unread,
Jul 11, 2024, 11:33:38 AM (11 days ago) Jul 11
to Cyril Milleret, nimble-users
Dear Cyril,
Thanks for your suggestion. I will check that link.
Best,
Dusit

On Jul 11, 2024, at 19:58, Cyril Milleret <cyril.m...@gmail.com> wrote:



Hi Dusit,

It is possible to save the state of the model following this vignette:
https://danielturek.github.io/public/saveMCMCstate/saveMCMCstate.html.

This means that you could run the model with a small number of iterations, save the state of the model, and then continue or restart (in case of power outage) the model to run more iterations, and so on… Saving the state of the model allows you to restart it in case anytime after it stopped running. 
For example: 
Run a few (XXXX) iterations:
 Cmcmc$run(XXXX)

Then save the state of the model and the posteriors (functions available in the vignette):

stateList <- list(modelState = getModelState(Cmodel),
                  mcmcState = getMCMCstate(conf, Cmcmc))
#save model state
saveRDS(stateList, file = fileName)
#save posteriors: 
samples <- Cmcmc$mvSamples
save(samples, file = « samples.RData”)

 

And then re-run more iterations:

Cmcmc$run(XXXX)
 

Then if you need to restart the model, you can do it using the model state that you saved. See instructions in the vignette.

 

Hope this helps,

 

Best,

Cyril

--
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/d2f1239c-9f4c-4ed6-9a88-aa304cf43843n%40googlegroups.com.

Cyril Milleret

unread,
Jul 14, 2024, 8:53:41 PM (8 days ago) Jul 14
to Dusit Ngoprasert, nimble-users

Hi everyone,

--

Reply all
Reply to author
Forward
0 new messages