The Model Menu
Contents
General properties
Specification...
Update...
Monitor Metropolis
Save State
Seed...
Script
General properties
[top]
The commands in this menu either apply to the whole statistical model or open dialog boxes. This menu is only on display if the focus view is a text window or a Doodle.
Specification...
[top]
This non-modal dialog box acts on the focus view.
check model
: If the focus view contains text,
WinBUGS
assumes the model is specified in the
BUG
S language. The
check model
button parses the
BUG
S language description of the statistical model, as in the classic version of
BUG
S. If a syntax error is detected the cursor is placed where the error was found and a description of the error is
given on the status line (lower left corner of screen). If a
stretch of text is highlighted the parsing starts from the first character highlighted
(i.e
. highlight the word model) else parsing starts at the top of the window.
If the focus view contains a Doodle
(i.e.
the Doodle has been selected and is surrounded by a hairy border
), WinBUG
S assumes the model has been specified graphically. If a syntax error is detected the node where the error was found is highlighted and a description of the error is given on the status line.
load data:
The
load dat
a button acts on the focus view; it will be greyed out unless the focus view contains text.
Data can be identified in two ways:
1) if the data is in a separate document, the window containing that document needs to be in the focus view (the windows title bar will be coloured not grey) when the
load dat
a command is used;
2) if the data is specified as part of a document, the first character of the data (either list if in S-Plus format, or the first array name if in rectangular format) must be highlighted and the data will be read from there on.
See here for details of data format
s
Any syntax errors or data inconsistencies are displayed in the status line. Corrections can be made to the data without returning to th
e check mode
l stage. When the data have been loaded successfully, 'Data Loaded' should appear in the status line.
The
load dat
a button becomes active once a model has been successfully checked, and ceases to be active once the model has been successfully compiled.
num of chains:
The number of chains to be simulated can be entered into the text entry field next to the caption
num of chains
. This field can be typed in after the model has been checked and before the model has been compiled. By default, one chain is simulated.
compile:
The
compil
e button builds the data structures needed to carry out MCMC sampling. The model is checked for completeness and consistency with the data.
A node called 'deviance' is automatically created which calculates minus twice the log-likelihood at each iteration, up to a constant. This node can be used like any other node in the graphical model.
This command becomes active once the model has been successfully checked, and when the model has been successfully compiled, 'model compiled' should appear in the status line.
load inits:
The
load init
s button acts on the focus view: it will be greyed out unless the focus view contains text. The initial values will be loaded for the chain indicated in the text entry field to the right of the caption
for chai
n. The value of this text field can be edited to load initial values for any of the chains.
Initial values are specified in exactly the same way as data files. If some of the elements in an array are known (say because they are constraints in a parameterisation), those elements should be specified as missing (NA) in the initial values file.
This command becomes active once the model has been successfully compiled, and checks that initial values are in the form of an S-Plus object or rectangular array and that they are consistent with any previously loaded data. Any syntax errors or inconsistencies in the initial value are displayed.
If, after loading the initial values, the model is fully initialized this will be reported by displaying the message
initial values loaded: model initialize
d. Otherwise the status line will show the message
initial values loaded: model contains uninitialized node
s. The second message can have several meanings:
a) If only one chain is simulated it means that the chain contains some nodes that have not been initialized yet.
b) If several chains are to be simulated it could mean that no initial values have been loaded for one of the chains.
In either case further initial values can be loaded, or the
gen init
s button can be pressed to try and generate initial values for
al
l the uninitialized nodes in
al
l the simulated chains.
Generally it is recommended to load initial values for all fixed effect nodes (founder nodes with no parents) for all chains, initial values for random effects can be generated using the
gen init
s button.
This
load init
s button can still be executed once Gibbs sampling has been started. It will have the effect of starting the sampler out on a new trajectory. A modal warning message will appear if the command is used in this context.
gen inits:
The
gen init
s button attempts to generate initial values by sampling either from the prior or from an approximation to the prior. In the case of discrete variables a check is made that a configuration of zero probability is not generated. This command will generate extreme values if any of the priors are very vague. If the command is successful the message 'initial values generated: model initialized' is displayed otherwise the message
'could not generate initial values' is displayed
.
The
gen init
s button becomes active once the model has been successfully compiled, and will cease to be active once the model has been initialized.
Update..
.
[top
]
This menu will become active once the model has been compiled and initialized, and has fields:
updates
:
update
s *
thi
n MCMC updates will be carried out.
refresh
: the number of updates divided by
thi
n between redrawing the screen.
thin
: the samples from every
kt
h iteration will be used for inference, where
k is the value of
thi
n. Setting
k
> 1 can help to reduce the autocorrelation in the sample, but there is no real advantage in thinning except to reduce storage requirements.
update
: Click to start updating the model. Clicking on
updat
e during sampling will pause the simulation after the current block of iterations, as defined by
refres
h, has been completed; the number of updates required can then be changed if needed. Clicking on update again will restart the simulation. This button becomes active when the model has been successfully compiled and given initial values.
iteration
: the total number of iterations carried out divided by thin.
over relax
: click on this box (a tick will then appear) to select an over-relaxed form of MCMC (Neal, 1998)
which will be executed where possible. This generates multiple samples at each iteration and then selects one that is negatively correlated with the current value. The time per iteration will be increased, but the within-chain correlations should be reduced and hence fewer iterations may be necessary. However, this method is not always effective and should be used with caution. The auto-correlation function may be used to check whether the mixing of the chain is improved.
adapting
: This box will be ticked while the Metropolis or slice-sampling MCMC algorithm is in its initial tuning phase where some optimization parameters are tuned. All statistics for the model will ignore
information from this adapting phase. The Metropolis and slice-sampling algorithms have adaptive phases of 4000 and 500 iterations respectively which will be discarded from all statistics. For details of how to change these default settings please see
Update options..
.
Monitor Metropoli
s
[top
]
This command is only active if the Metropolis algorithm is being used for the model. This shows the minimum, maximum and average acceptance rate averaged over 100 iterations as the Metropolis algorithm adapts over the first N iterations. The rate should lie between the two horizontal lines. The first N iterations of the simulation cannot be used for statistical inference. The default value of N is 4000 (see
Update options..
.
for details of how to change this value).
Save Stat
e
[top
]
Opens a window showing the current state of all the stochastic variables in the model, displayed in S-Plus format. This could then be used as an initial value file for future runs.
Seed..
.
[top
]
Opens a non-modal dialog box containing:
seed:
a text entry field where the new seed of the random number generator can be typed.
coverage:
the pseudo-random number generator used by
WinBUGS
generates a finite (albeit very long) sequence of distinct numbers, which would eventually be repeated if the sampler were run for a sufficiently long time. The
coverage
field shows the percentage of this sequence covered during the current
WinBUGS
session.
set:
sets the seed to the value entered into the dialog box. The seed must be set
after
the model is checked (via 'check model' - see
Specification...
) in order for the new value to apply to the current analysis.
Script
[top]
The Script command is used to run "model scripts" in batch-mode: if the focus-view contains a series of
WinBUGS
batch-mode commands then selecting this command from the
Model
menu will cause the script to be executed. Please see
Batch-mode: Scripts
for full details.