modelInits {BRugs} | R Documentation |
Loading initial values
Description
This function loads initial values for the MCMC simulation.
Usage
modelInits(fileName, chainNum = NULL)
Arguments
fileName |
Character vector of filenames containing the initial values in OpenBUGS format. |
chainNum |
The initial values will be loaded for the chain number |
Details
This function checks that initial values are in the form of an appropriate R object or rectangular array and that they are consistent with any previously loaded data. 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.
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 modelGenInits
function.
Value
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 ‘model initialized’. Otherwise the message ‘initial values loaded but this or another chain contain uninitialized variables’ will be displayed. 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 (a) or that no initial values have been loaded for one of the chains. |
In either case further initial values can be loaded, or modelGenInits
can be executed to try and generate initial values for all the uninitialized nodes in all the simulated chains.
Note
This function can be executed once the model has been successfully compiled. It can still be executed once MCMC sampling has been started having the effect of starting the sampler out on a new trajectory.
If an attempt is made to execute this function in an inappropriate context the generic error message ‘command is not allowed (greyed out)’ is displayed.