Need help to check Matlab compatibility

The attached code implements an econometric estimator for a simple DSGE model, as described in the Dynare working paper “Indirect Likelihood Inference” by Dennis Kristensen and myself We are finishing a revision of the paper, and I’d like to make easy to use example code available. The attached code, for a slightly more interesting model than that of the first version of the paper, runs fine with Octave, but I’m not sure if it runs on Matlab. If anyone with Dynare/Matlab could run it and let me know how it goes, I’d be very grateful. Thanks. (9.01 KB)

It won’t run because

  1. Matlab uses ~ instead of ! for the not command
  2. There is no endif in Matlab, just end
  3. You use the use_dll without providing the compiler name to Dynare (msvc or cygwin)
  4. There is no Matlab lags function

Thanks! I thought I had gotten rid of the endif and endfors, etc., but I’ll look again. I wasn’t aware of the ~ vs. ! difference, but I’ll adapt that, too. I’m not sure what to do about the compiler problem, I guess that most people running Windows won’t have a compiler installed - do you have any advice on how to present code that would work with minimal requirements other than Matlab and Dynare? Thanks again.

I am not sure why you need the use_dll option at all. Why don’t you just drop it?

You’re right, it’s not needed, and in fact it’s faster without it. Some time in the past I got the idea that a 3rd order solution was faster with this option, perhaps for a different model, and I’ve been using it since. I have made the changes, would you mind trying the code one more time? Many thanks. (9.38 KB)

rlabels must be

rlabels = char(... 'alpha',... 'beta',... 'delta',... 'gam',... 'rho1',... 'sig1',... 'rho2',... 'sig2',... 'nss',... 'psi'... );
Moreover, there still is no lag() (only a lagmatrix if you have the econometrics toolbox). Also, vech is not a Matlab function. Seems like you are using LeSage’s econometrics toolbox.

P.S.: use_dll was required a few versions ago to compute the third order solution. Now, it is only advised for really big models.

OK, I think this next try will work, if your patience has not run out. I added my lag() function, and have included the vech() function from Octave. I’m surprised that’s not in Matlab. About use_dll, I think that was required when I started with this project, and I guess I never noticed that it no longer is. Removing it makes a significant speed difference for this simple model, which is important for this estimator, which uses many solutions at parameter vectors drawn from a prior. (10.9 KB)

Your vech function does not run in Matlab. It has the wrong quote signs and uses cellslices, which is unknown. Apart from that
aux_stat has

temp = (data - m)./s; temp2 = (lagdata - m)./s;

but data is a matrix, while m and s are vectors. In Matlab this crashes because of non-conformable dimensions.

Here’s another try, with these issues fixed. Many thanks for your help! (10 KB)

Almost. Now shift.m used in

temp = shift(temp,i,2);
is missing.

Perhaps this will be the last iteration? Thanks again! (10 KB)

I want to thank Johannes for his help with this. Here’s a last version that runs on both Octave and Matlab. (9.92 KB)