Performs the same basic function as R2OpenBUGS::write.model()
write_model(fun, file)
fun | A function object containing BUGS/JAGS model code |
---|---|
file | A character vector of length == 1: the name of the file to write to |
Nothing, but file
is written to disk.
Performs the same basic function as R2OpenBUGS::write.model()
,
but with slightly better output (scientific notation, spacing, etc.). The main reason it was created
for use in 'postpack' was to remove the need for using the 'R2OpenBUGS' package when not using OpenBUGS.
if (interactive()) { # define some simple BUGS model as an R function # note the use of %_% to include a truncation mod = function() { # PRIORS mu ~ dnorm(0,0.001) %_% T(0,) sig ~ dunif(0,10) tau <- 1/sig^2 # LIKELIHOOD for (i in 1:n) { y[i] ~ dnorm(mu, tau) } } # write model to a text file to be called by BUGS/JAGS write_model(mod, "model.txt") }