Error in metropolis with mh_nblocks=1

I’m estimating a model using the metropolis algorithm, and I only want to do one block, so in my estimation call I have the parameter mh_nblocks=1.

When I run this the metropolis algorithm runs but then after it runs I get an error in line 711 in the metroplis.m file, which is:
trun = cumulated_number_of_simulations_per_file(nfile+1);

The error is because nfile is equal to -1, and so it is therefore trying to access entry 0 of cumulated_number_of_simulations_per_file, which doesn’t exist.

I think that this is happening back on line 345 of metropolis.m.
Line 344 is:
files = eval(‘dir(’’’ fname_ ‘_mh*.mat’’);’]);

When I run this with one block there is only ONE file in my directory matching that name. It is: mymodel_mh0.mat. Line 345 is:
nfile = size(files,1)-2;

So since files just has one file, then nfile is getting set to -1.

Why are we subtracting 2 from the size of files? It seems to me this will always cause the same problem. is this a bug? When I change the -2 to a -1 then nfile gets set to 0 and everything runs hunky dory. I’m just worried if that will screw up things in possibly other models in the future.

Hope someone can help or at least let me know if that’s a known bug.

Thanks!
AS

Hi,

This looks like a bug… I will correct it as soon as possible. You should try with dynare version 4 instead (I think there is no problem in this case).

Best,
Stéphane.

Thanks. I’ll try it.

BTW I think this is specific to the Linux/Mac version. I got the same error running it on a Mac and a Linux machine. I however didn’t get the error with the windows version. My guess is that maybe case sensitivity is different on windows vs. mac/linux?

Cheers,
AS

Yes, windows is not case sensitive… When I wrote this file I was working under windows…

Best, Stéphane.

[quote=“shwayder”]Thanks. I’ll try it.

BTW I think this is specific to the Linux/Mac version. I got the same error running it on a Mac and a Linux machine. I however didn’t get the error with the windows version. My guess is that maybe case sensitivity is different on windows vs. mac/linux?

Cheers,
AS[/quote]