Need help to check Matlab compatibility

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Need help to check Matlab compatibility

Postby MichaelCreel » Sat May 25, 2013 9:15 am

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 http://www.dynare.org/wp-repo/dynarewp008.pdf. 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. michael.creel@uab.es
Attachments
DSGE_SBIL_Simple.zip
(9.01 KiB) Downloaded 243 times
MichaelCreel
 
Posts: 25
Joined: Tue Sep 28, 2010 12:11 pm

Re: Need help to check Matlab compatibility

Postby jpfeifer » Sat May 25, 2013 12:29 pm

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
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Need help to check Matlab compatibility

Postby MichaelCreel » Sat May 25, 2013 3:18 pm

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.
MichaelCreel
 
Posts: 25
Joined: Tue Sep 28, 2010 12:11 pm

Re: Need help to check Matlab compatibility

Postby jpfeifer » Sat May 25, 2013 4:25 pm

I am not sure why you need the use_dll option at all. Why don't you just drop it?
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Need help to check Matlab compatibility

Postby MichaelCreel » Sat May 25, 2013 4:37 pm

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.
Attachments
DSGE_SBIL_Simple.zip
(9.38 KiB) Downloaded 120 times
MichaelCreel
 
Posts: 25
Joined: Tue Sep 28, 2010 12:11 pm

Re: Need help to check Matlab compatibility

Postby jpfeifer » Sat May 25, 2013 10:35 pm

rlabels must be
Code: Select all
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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Need help to check Matlab compatibility

Postby MichaelCreel » Sun May 26, 2013 4:56 am

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.
Attachments
DSGE_SBIL_Simple.zip
(10.93 KiB) Downloaded 127 times
MichaelCreel
 
Posts: 25
Joined: Tue Sep 28, 2010 12:11 pm

Re: Need help to check Matlab compatibility

Postby jpfeifer » Sun May 26, 2013 7:22 am

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
Code: Select all
         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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Need help to check Matlab compatibility

Postby MichaelCreel » Sun May 26, 2013 8:23 am

Here's another try, with these issues fixed. Many thanks for your help!
Attachments
DSGE_SBIL_Simple.zip
(10.02 KiB) Downloaded 122 times
MichaelCreel
 
Posts: 25
Joined: Tue Sep 28, 2010 12:11 pm

Re: Need help to check Matlab compatibility

Postby jpfeifer » Sun May 26, 2013 10:18 am

Almost. Now shift.m used in
Code: Select all
temp = shift(temp,i,2);

is missing.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Need help to check Matlab compatibility

Postby MichaelCreel » Sun May 26, 2013 4:36 pm

Perhaps this will be the last iteration? Thanks again!
Attachments
DSGE_SBIL_Simple.zip
(10.03 KiB) Downloaded 124 times
MichaelCreel
 
Posts: 25
Joined: Tue Sep 28, 2010 12:11 pm

Re: Need help to check Matlab compatibility

Postby MichaelCreel » Mon May 27, 2013 12:28 pm

I want to thank Johannes for his help with this. Here's a last version that runs on both Octave and Matlab.
Attachments
DSGE_SBIL_Simple.zip
(9.92 KiB) Downloaded 620 times
MichaelCreel
 
Posts: 25
Joined: Tue Sep 28, 2010 12:11 pm


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 7 guests