matrices in dynare 3 are not recognized/processed in dynare4

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.

matrices in dynare 3 are not recognized/processed in dynare4

Postby patrickH » Fri Feb 19, 2010 2:13 pm

Hi,

I am currently working with Dynare 3.65 with a model where I am using some matrix algebra in the model section, e.g. I write:
# A = [ rho 0 0 ; 1 0 0 ; 0 0 rho ];
# B = eye(3);
# C = A*B;
and then I use specific elements of matrix C as coefficients for some variables in the model section.

This code does not work in dynare 4 anymore, as it seems that I cannot declare matrices and do some algebra with the matrices. Is there a trick/possibility to enter matrices in dynare 4?

Thank you very much in advance for your support.
Best,
Patrick
patrickH
 
Posts: 2
Joined: Fri Feb 19, 2010 2:04 pm

Re: matrices in dynare 3 are not recognized/processed in dynare4

Postby SébastienVillemot » Mon Feb 22, 2010 3:48 pm

No sorry, this is not possible in Dynare 4.

You need to write your algebra in mono-dimensional form.

Best
Sébastien Villemot
Economist at OFCE – Sciences Po
SébastienVillemot
 
Posts: 706
Joined: Fri Dec 07, 2007 2:29 pm
Location: Paris, France

Re: matrices in dynare 3 are not recognized/processed in dynare4

Postby patrickH » Mon Mar 01, 2010 9:14 am

There is a trick to incorporate matrix algebra in the model section; in fact one can use any Matlab function.

Using the steps outlined in viewtopic.php?f=1&t=1834 one can manipulate the model_steadystate.m file to incorporate steady state values. Following this advise one can use the parameters of the model to do any kind of Matlab calculations. In my case I do some matrix algebra and define the elements of interest of some matrix as new variables, e.g. A23=A(2,3) where A is a matrix calculated in the model_steadystate.m file. In my mod-file I define A23 to be a parameter. I can then use A23 as a coefficient for a variable in the model section.

Patrick
patrickH
 
Posts: 2
Joined: Fri Feb 19, 2010 2:04 pm

Re: matrices in dynare 3 are not recognized/processed in dyn

Postby timjackson » Tue Mar 08, 2016 3:32 pm

Hi,

Would anyone be able to elaborate on this? I would like to run a model with some matrices in Dynare but cannot see how to do it.

Thank you for any help!

Best,

Tim
timjackson
 
Posts: 7
Joined: Tue Mar 08, 2016 3:29 pm

Re: matrices in dynare 3 are not recognized/processed in dyn

Postby jpfeifer » Thu Mar 10, 2016 10:52 am

Please have a look at https://github.com/JohannesPfeifer/DSGE_mod/tree/master/Chari_et_al_2007 where I use a steady state file to do matrix computations and then assign the results back to paramaters of the model
------------
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: matrices in dynare 3 are not recognized/processed in dyn

Postby timjackson » Tue Apr 05, 2016 2:03 pm

Thank you for this update, I see Dynare allows us to use matrices in calculations of steady states which will be very uesful but I would also like to have matrices in my model itself.

My model equations have been completed with matrix algebra, do you have any advice on how to implement these into the model of Dynare?

I have started to rewrite the model using (many) "for" loop macro-expressions in Dynare which would be fine if it weren't for an inverted matrix which appears in one of my model equations. I am about to start translating some manual code to invert a matrix into Dynare macro-expressions but any advice on better ways to achieve this result would be much appreciated!

Thank you,

Tim
timjackson
 
Posts: 7
Joined: Tue Mar 08, 2016 3:29 pm

Re: matrices in dynare 3 are not recognized/processed in dyn

Postby jpfeifer » Tue Apr 05, 2016 7:32 pm

This is a current limitation of Dynare. You cannot use matrices in the model block and I don't see a good way around this. Again, you would have to do the inversion in the steady state file and pass the result back.
------------
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: matrices in dynare 3 are not recognized/processed in dyn

Postby timjackson » Tue Apr 05, 2016 9:01 pm

Thank you.

Sadly, the matrix I would like to include in the model is made up of endogenous variables so its elements will be changing as the shock hits the system so I don't think I will be able to use the steady state file as you suggest, though do correct me if I am wrong!

In any case, I will find a workaround by rewriting the model in mono-dimensional form and using macro-expressions.
timjackson
 
Posts: 7
Joined: Tue Mar 08, 2016 3:29 pm

Re: matrices in dynare 3 are not recognized/processed in dyn

Postby jpfeifer » Wed Apr 06, 2016 7:54 am

This sounds like a case where you need to use an external function to capture the derivatives correctly.
------------
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


Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 14 guests