www.delorie.com/gnu/docs/mcsim/mcsim_43.html   search  
Buy GNU books!

MCSim User' Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.5.1 Level definition

Markov chain Monte Carlo simulations require the definition of a statistical model and the use of the Level keyword. At least one level must be defined. A level section starts with the keyword Level and is enclosed in curly braces. It can include any number of sub-levels or Experiments. Experiments (where the data are specified) form the lowest level of the hierarchy (see section 6.4.1 Experiment definition. There must be one and only one top level and at most 10 sub-levels in the hierarchy. This limit of 10 levels can be increased (up to 255) by changing MAX_LEVELS in the header file `sim.h' and recompiling.

A level can make modifications to the sampling distribution of any model parameter. For example:

Level { # this is the top level

  Distrib(A, Uniform, 0, 1);

  Level { # this is sub-level 1
    Distrib(A, Normal, A, 1);
    Experiment { ... } # experiment 1
    Experiment { ... } # experiment 2

These distribution assignments apply to all sub-levels of the level where they take place. If several assignments are given, their position within the level section is irrelevant (although a logical order is recommended for clarity).

A level can also make modifications to any model parameter that was defined in the global section of the model description file. The syntax is the same, except that variables can only take constant values. So, for example, in an experiment, the parameter A could be modified with:

A = 2.0;

This overrides any previously assigned values, even if randomly sampled, for the specified parameter. This assignment also applies to the sub-levels of the level where they take place.

An important concept to grasp here is that of "instance". In the code fragment given above, the parameter A, defined at sub-level 1, is "cloned" as many times as there are sub-levels or experiments enclosed in sub-level 1 (hence, it will be cloned twice in the example above, once for each Experiment defined). In that way, the parameters distributions defined at one level in fact apply to the next lower sub-level, or at the Experiment level. This convention saves a lot writing and effort in the long run. For example, the uniform distribution assigned to A, at the top level, applies to the sub-level 1. There is only one "clone" of A at sub-level 1 since only one sub-level is included in the top level. In contrast, two normally-distributed "clones" of A will be defined and sampled. The first one will apply to experiment 1, and will be conditioned by the data of that experiment only, and the other will apply to experiment 2. A total of three variables of "type" A will be sampled and will be printed in the output file (coded so that the position in the hierarchy is apparent): the "parent" A(1), a priori uniformly distributed, and two "dependents" A(1.1) and A(1.2), a priori normally distributed around A(1).

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003