Performs the same basic function as R2OpenBUGS::write.model()

write_model(fun, file)

Arguments

fun

A function object containing BUGS/JAGS model code

file

A character vector of length == 1: the name of the file to write to

Value

Nothing, but file is written to disk.

Details

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.

Examples

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") }