Output dynare results into excel

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.

Output dynare results into excel

Postby diatrochoi » Fri Jul 18, 2014 3:49 pm

Hi

I have a nested loops of 3 different parameters and I want to generate the number of eigenvalues with mod>1, the total number of eigenvalues and whether the rank condition is verified into an excel file to check for determinacy/indeterminacy with each set of parameters. Is there a way that dynare can output that directly into an excel file? I heard dynare can read from excel file for estimation purpose so shouldn't it be able to write to excel file also? Manual copying just takes too much time. Or if I can just produce a matrix of result in dynare and then copy it to excel that'll be good also

Thanks.
diatrochoi
 
Posts: 14
Joined: Tue Jul 08, 2014 10:45 pm

Re: Output dynare results into excel

Postby diatrochoi » Sat Jul 19, 2014 2:32 pm

Is it possible to do so in dynare?
diatrochoi
 
Posts: 14
Joined: Tue Jul 08, 2014 10:45 pm

Re: Output dynare results into excel

Postby jpfeifer » Sun Jul 20, 2014 6:59 am

On looping, see http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=4891
The easiest thing is to read out the eigenvalues from oo_.dr.eigval. You can count them yourself using Matlab code. Regarding writing the final matrix to Excel, just use the xlswrite-command of Matlab.
------------
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: Output dynare results into excel

Postby diatrochoi » Mon Jul 21, 2014 9:58 pm

What about the rank condition? which file in the workspace would contain the info about the rank condition for each case? Could I write that to excel using xlswrite too? Also why did it record infinite eigenvalue as 65535?

When I write oo_.dr.eigval to excel file, it seems that it only writes the real part of the eigenvalues instead of the modulus part. How could I make it write the modulus part?

Also, the xlswrite function requires specifying which cell you want to write to. Since I'm doing a loop, I want matlab to keep writing to the next cell, let's say to the right. But the argument for the cell you want to write to is a string. How do I keep write to the next cell in row then? Right now I can only write to different sheets when I run the loop since the argument for the sheet number is an integer.

Thanks
diatrochoi
 
Posts: 14
Joined: Tue Jul 08, 2014 10:45 pm

Re: Output dynare results into excel

Postby jpfeifer » Wed Jul 23, 2014 9:29 am

Failure of the rank conditions is coded in the info-variable returned by stoch_simul (see print_info.m for the error codes). If info is not 0, there was an issue. Excel has no code for infinity and uses the maximum value for its integers, which is 65535

If you are only interested in the modulus, write abs(oo_.dr.eigval) to Excel file.

You can use the num2str command of Matlab to convert numbers to strings:
Code: Select all
xlxwrite('MyExcelFile',abs(oo_.dr.eigval)',1,['A' num2str(iter)])
------------
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: Output dynare results into excel

Postby diatrochoi » Thu Jul 24, 2014 2:22 am

So how can I write the result of the rank condition to the excel file using write function of matlab? Which array should I use?

Also, is there a way that I could write the array horizontally to excel instead of vertically? Right now it only writes vertically but since I have so many cases for the parameters, when it comes to column with double or tripple letters, it is going to be nasty to do the coding. I can code it to write horizontally but everytime it has to write one element of the array instead of the array as a whole and so it is taking too much time. Is there a better solution to this, like a command to write immediately to the next column or a command to write the entire array as a whole but horizontally?

Thanks
diatrochoi
 
Posts: 14
Joined: Tue Jul 08, 2014 10:45 pm

Re: Output dynare results into excel

Postby jpfeifer » Thu Jul 24, 2014 6:25 am

You can just write the variable "info" returned by stoch_simul to Excel. It will contain the error codes

The code I posted above should exactly do that. If you write a row vector to Excel, it will be written horizontally. As dr.eigval is a column vector, you have to use its transpose as indicated above.
------------
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: No registered users and 5 guests