Suppose I have samples from a previous JAGS run.
How can I pass the last of these samples (or the mean, etc) to JAGS to initialise variables for a new run? I have many many variables so transcribing manually is too hard.
Thanks!
Suppose I have samples from a previous JAGS run.
How can I pass the last of these samples (or the mean, etc) to JAGS to initialise variables for a new run? I have many many variables so transcribing manually is too hard.
Thanks!
Using the rjags package you can use the coef
function to get the current state of any chain. Here is an example using the BLOCKER bugs example:
> m <- jags.model("blocker.bug", data, inits, n.chains = 2, quiet=TRUE) > update(m, 3000) |**************************************************| 100% > coef(m, chain=2) $d [1] -0.2380885 $delta [1] -0.117981074 -0.209540191 -0.097065004 -0.324211821 -0.002261029 [6] -0.355814837 -0.571193962 -0.327327590 -0.385089076 -0.251702755 [11] -0.235192262 -0.097494862 0.173934550 -0.006762717 -0.097974005 [16] -0.315847308 -0.605264102 -0.115847918 -0.408291936 0.152284433 [21] -0.503832347 -0.054519856 $delta.new [1] 0 $mu [1] -2.343209 -2.153912 -2.185737 -2.423854 -2.368968 -2.474559 -1.623658 [8] -2.025789 -1.696715 -2.361026 -2.259855 -1.526192 -2.918440 -2.819129 [15] -1.491852 -1.340488 -2.027257 -3.195235 -3.200288 -1.477025 -2.112073 [22] -3.039956 $tau [1] 21.42443
With the command line interface, there is a command parameters to
which does the opposite of parameters in
, e.g.
model in blocker.bug data in blocker-data.R load glm compile, nchains(2) parameters in blocker-init.R initialize update 3000 parameters to blocker-newinit.R, chain(2)
Thanks Martyn - this is exactly what I needed! My model takes a long time to adapt from random starting values, so this should help me get second and later runs going much closer to the parameter modes.
I've only been using JAGS for a week now and it's a fantastic program - you've saved me a lot of time.
Log in to post a comment.