Comparing models

Dear All

Does anyone have a simple example that compares models. I use matlab and see that the dynare folder contains PosteriorOddsTable function. I guess this is what I need, but I have no idea how to call it from dynare. Presumably, I have standard output saved from two mod-files, each of which does Bayesian “estimate” of a DGSE model. The difference between the two models is only in coefficients.

Many thanks

Here is an example around a model by Rabanal and Rubio (2003).

The keyword model_comparison must be followed by the name of two *.mod files. By default, the comparison is done on the basis of the Laplace approximation of log data density and therefor this can be used after just posterior mode finding.

The is an option model_comparison_approximation that can take the value of either laplace or modifiedharmonicmean (the latter requires metropolis iterations)


rabanal2.mod (1.8 KB)
rabanal1.mod (1.64 KB)
datarabanal.m (5.33 KB)

Dear Michel

Many thanks for this. Do you know how to set this option?
For example, in the *.mod file, is it in the same line , or in a separate line? I could not find help on this and several variants with brackets did not work

model_comparison file1, file2;

Separate question: is there anything available that does posterior predictive check? And if so, then again how to call it?

Many thanks again

You are right there is a problem with the option. I corrected it in SVN and it will be available in tomorrow’s snapshot for Dynare version 3.

The correct syntax for the option is, for example:

model_comparison(model_comparison_approximation=laplace) rabanal1, rabanal2;



Please excuse me, but I simply followed the above:

model_comparison(model_comparison_approximation=laplace) rabanal1.mod, rabanal2.mod

But the system returns:

??? model_comparison(model_comparison_approximation=laplace) rabanal1.mod, rabanal2.mod
Error: The expression to the left of the equals sign is not a valid target for an assignment.

Then I tried:

model_comparison rabanal1.mod, rabanal2.mod

And the system returns:

??? Input argument “ModelPriors” is undefined.

Error in ==> model_comparison at 24
if isempty(ModelPriors)

Finally I even modified CompareModels.m by assigning the value for “ModelPriors” , but it still doesn’t work.
Could someone offer the correct syntax for this simple problem?

If anybody is still interested in this: the following worked in my case. In Matlab code you write (for two models for example)

file_names = cell(nomodels,1);

model_priors = [1;1];
PosteriorOddsTable = model_comparison(file_names,model_priors);

In this case it does what it should do. However, the field in Options is now changed into ‘Laplace’. I guess you will nneed to have a line like
options_.model_comparison_approximation=’ '; or delete this field if you later want to use different approximation.