@ESS{[JAGS]} provides 4 features.  First, JAGS syntax is described to
allow for proper fontification of statements, distributions,
functions, commands and comments in JAGS model files, command files
and log files.  Second, @ESS{} creates templates for the command file
from the model file so that a JAGS batch process can be defined by a
single file.  Third, @ESS{} provides a JAGS batch script that allows @ESS{}
to set JAGS batch parameters.  Fourth, key sequences are defined to
create a command file and submit a JAGS batch process. 

@section ESS[JAGS]--Model files

Files with the @file{.jag} extension are edited in @ESS{[JAGS]} mode.
Three keys are bound for your use in @ESS{[JAGS]}, @kbd{F2}, @kbd{C-c C-c} and @kbd{=}.
@kbd{F2} performs the same action as it does in @ESS{[SAS]},
@xref{ESS(SAS)--Function keys for batch processing}.  @kbd{C-c C-c} performs the
function @code{ess-bugs-next-action} which you will use a lot.  Pressing it
in an empty buffer for a model file will produce a template for you.  @kbd{=}
inserts the set operator, @code{<-}.

The first press of @kbd{C-c C-c} will set up a template, including some
necessary file-local variables in an empty buffer.  These variables are
@code{ess-jags-chains}, @code{ess-jags-monitor}, @code{ess-jags-thin},
@code{ess-jags-burnin} and @code{ess-jags-update}; they appear in the
@code{Local Variables} section.  When you are finished editing your
model file, pressing @kbd{C-c C-c} will perform the necessary actions to
build your command file for you.

The @code{ess-jags-chains} variable is the number of chains that
you want to initialize and sample from; defaults to 1.
The @code{ess-jags-monitor} variable is a list of variables
that you want monitored: encase each variable in double quotes.  
When you press @kbd{C-c C-c}, the
appropriate statements are created in the command file to monitor the
list of variables.  By default, no variables are explicitly monitored 
which means JAGS will implicitly monitor all ``default'' variables. 
The @code{ess-jags-thin} variable is the thinning parameter.  
By default, the thinning parameter is set to 1, i.e. no thinning. 
The @code{ess-jags-burnin} variable is the number of initial samples
to discard.  By default, the burnin parameter is set to 10000.
The @code{ess-jags-update} variable is the number of post-burnin samples
to keep.  By default, the update parameter is set to 10000.  Both 
@code{ess-jags-burnin} and @code{ess-jags-update} are multiplied by
@code{ess-jags-thin} since JAGS does not do it automatically.

@section ESS[JAGS]--Command files

Files ending in @file{.jmd} are for JAGS command files.  For your 
@file{.jmd} file, there is only one variable, @code{ess-jags-command}, 
in the @code{Local Variables} section.  When you have
finished editing your model file and press @kbd{C-c C-c}, a command
file is created if one does not already exist.  
When you are finished editing your command file, pressing @kbd{C-c C-c} 
again will submit your command file as a batch job. 
The @code{ess-jags-command} variable allows you to specify a different
JAGS program to use to run your model; defaults to ``jags''.

@section ESS[JAGS]--Log files

The @file{.jog} extension is used for JAGS log
files.  You may find @kbd{F2} useful to refresh the @file{.jog} if the batch
process over-writes or appends it.

