All the code in this repo are mainly for our simulation study.
rstan 2.19.2; stan_version 2.19.1
nimble 0.9.0
R2jags 0.5.7; JAGS 4.2.0
Treat this as a template builder to build the BUGS and STAN scripts for the models in the paper.
-
In source.R, run the fitmod function by specifying the type of model you would like to run.
- Please see name.R to see how to correctly specify the type of model.
- It will generate the appropriate BUGS/STAN script in the template subfolder in jags_dir, nimble_dir, stan_dir.
-
fit.R inside fitmod will try to parse through the details and run the model. Ideally, it should build its own separate script for so user know how to set up the initial parameters, data and constants parameters, but it currently doesn't do this (maybe in the future).
- reads in BUGS script
- constructs the model object
- Adapt 1000 iterations
-
Takes the adaptive model object and run (n.burnin + n.iterations)
-
Keeps the last n.iterations
-
Check convergence via Rhat < 1.1 (ESS > 40 optional, currently NA)
-
If covergence test fails, sample another n.iterations from the previous chains and repeat last two steps.
- reads in BUGS script
- construct model object
- start with 2000 iterations
- Takes the model object and run n.iterations (half burnin)
- If convergence test fails, redo previous step with double the amount of iterations.