Model Comparison

In case more than one model is defined to explain the same data set the BCModelManager can come in handy. Separate BCModels m1 and m2 and their prior probabilities (70 % vs 30 %) are added to the model manager via

mgr.AddModel(&m1, 0.7);
mgr.AddModel(&m2, 0.3);

For convenience, some of the most important methods for handling BCModels are forwarded to each model in the manager. For example

mgr.SetPrecision(BCEngineMCMC::kQuick);

is equivalent to

for (unsigned i = 0; i < mgr.GetNModels(); ++i) {
mgr.GetModel(i)->SetPrecision(BCEngineMCMC::kQuick);
}

To do model comparison, the evidence is needed for each model, then the Bayes factors and the posterior odds are immediately available. Models are index by an unsigned; the first model has index 0 etc.:

mgr.Integrate();
double B = mgr.BayesFactor(0, 1);
See also
examples/advanced/polynomialFit