--
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+unsubscribe@googlegroups.com.
To post to this group, send email to nimble...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/50c8481b-dfbc-43d4-9e29-5dfaa244194d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thanks Chris,
I am not sure I understand. Are you saying that if I build and compile a model and MCMC function, then in my simulation loop I simply need to place the line “Cmod$setData(newData)”, where newData are some data I generate (not simulated from the model itself), and then I do not need to recompile the model nor recreate or recompile the MCMC function? When I do simply set data like that, I sometimes get a repeated warning (“warning: problem initializing stochastic node, logProb less than -1e12”) and the posteriors seem to simply reflect the priors (with the pump example I don’t get the warning, but the posteriors don’t seem correct). I guess don’t understand how the previously compiled MCMC relates back to the previously compiled model, which now has newly inserted data.
As to your other point about resetting the MCMC, I could do Cmcmc$run(10000, reset=TRUE), but if I use the runMCMC function it resets automatically, right? (i.e., reset=FALSE is not available)
Glenn
--
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users...@googlegroups.com.
--
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users+unsubscribe@googlegroups.com.
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/CAG%3DM9LoBNJC24uwnAZ2r2NCxxq05xj1Mq1OY%2BjnAMt%3D2Ab-Beg%40mail.gmail.com.
Chris and Perry,
Thanks again for the help. Your example does work as expected. The only thing I was doing differently was omitting the data statement when the model was defined (so the model was compiled with NAs rather than data), then setting data prior to the call to runMCMC. Doing so does lead to the behavior I described, even in your example (see code below). Not sure if it is supposed to work that way, but in any case it seems that as long I include data (anything with the right name and dimension) in the call to nimbleModel, then I can compile and subsequently change the data and all looks OK.
Glenn
code=nimbleCode({
y ~ dnorm(mu, sd=.1)
mu ~ dnorm(0, sd = 4)
})
m = nimbleModel(code) # this doesn’t seem to work
#m = nimbleModel(code,data=list(y=5)) # this does seem to work
cm = compileNimble(m)
mcmc = buildMCMC(m)
cmcmc = compileNimble(mcmc,project=m)
cm$setData(list(y = 1))
out1 = runMCMC(cmcmc,niter=10000) # posterior mean is near 1
cm$setData(list(y = -2))
out2 = runMCMC(cmcmc,niter=10000) # posterior mean is near -2
x11(8,4);par(mfrow=c(1,2));hist(out1);hist(out2)
From: Perry de Valpine [mailto:pdeva...@berkeley.edu]
Sent: Tuesday, March 28, 2017 7:51 PM
To: Chris Paciorek
Cc: Glenn Stauffer; nimble-users
Subject: Re: R workspace cogs up after repeated data simulation/analysis iterations
Another option instead of the setData line is simply:
--
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users...@googlegroups.com.
To post to this group, send email to nimble...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/50c8481b-dfbc-43d4-9e29-5dfaa244194d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users+unsubscribe@googlegroups.com.
To post to this group, send email to nimble-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/50c8481b-dfbc-43d4-9e29-5dfaa244194d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to nimble-users@googlegroups.com.
To view this discussion on the web visit
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/CAG%3DM9LoKU6-1qJOCavfhe1XsOfN_S5e3PhBkQJVV6jw-uNR1rw%40mail.gmail.com.To post to this group, send email to nimble...@googlegroups.com.
Daniel,
Thanks for chiming in. I think that makes sense, and I’m beginning to get a better handle now on the build-compile-run process. Now, maybe my next step is to get the chains to run in parallel!
Glenn