Size: 3601
Comment:
|
Size: 7755
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 5: | Line 5: |
Porting of Dynare to Octave is under progress. Development is done using Octave version 3.0. | Porting of Dynare to Octave is under progress. Development is done using Octave versions 3.0.0 and 3.0.1. |
Line 11: | Line 11: |
It normally runs in a command window, but a graphical frontend is available (see below). | It normally runs in a command window, and displays graphics in separate windows (using Gnuplot). |
Line 18: | Line 18: |
* List of [http://www.gnu.org/software/octave/FAQ.html#MATLAB-compatibility differences between Octave and Matlab] * [http://www.unige.ch/math/folks/loisel/www.math.mcgill.ca/loisel/octave-workshop/ Octave workshop]: graphical user interface for Octave == Development of Dynare for Octave == A specific subversion branch has been created under {{{branches/dynare_v4_octave}}}. Note that this branch is supposed to work on both Matlab and Octave (using tests to differentiate between the two when necessary). Please report any failure to run under Matlab. It is possible to view the differences between Matlab and Octave versions of Dynare by issuing: {{{ svn diff http://www.cepremap.cnrs.fr/svn/dynare_v4 http://www.cepremap.cnrs.fr/svn/branches/dynare_v4_octave }}} ''Note:'' be aware that recent changes to Matlab version of Dynare may not have been yet merged into the Octave branch, and may thus appear as spurious differences. |
* On the compatibility between Octave and Matlab: * List of [http://www.gnu.org/software/octave/FAQ.html#MATLAB-compatibility differences between Octave and Matlab] * List of [http://wiki.octave.org/wiki.pl?MissingMatlabFunctions missing Matlab functions] in Octave * More on [http://wiki.octave.org/wiki.pl?MatlabOctaveCompatibility Matlab/Octave compatibility] * [http://en.wikibooks.org/wiki/Octave_Programming_Tutorial Octave Programming Tutorial] on Wiki``Books |
Line 33: | Line 26: |
=== Octave === | === GNU/Linux === |
Line 35: | Line 28: |
Under Debian "Lenny", install package {{{octave3.0}}} | For Debian "Lenny" or Ubuntu "Hardy Heron", see InstallOnDebianOrUbuntu. |
Line 37: | Line 30: |
For Windows, the Cygwin package is quite outdated. You should rather download [http://sourceforge.net/project/showfiles.php?group_id=2888&package_id=40078 precompiled binaries from Octave Forge]. | For other distributions, you should begin by installing the {{{octave3.0}}} package. |
Line 39: | Line 32: |
=== Dynare for Octave === If you don't already have a subversion copy of the whole Dynare tree, you should type (under Linux or Cygwin prompt, assuming you have installed the {{{subversion}}} package): |
Then pickup Dynare sources via the daily snapshot, or via SVN with: |
Line 43: | Line 34: |
svn checkout http://www.cepremap.cnrs.fr/svn/branches/dynare_v4_octave | svn checkout http://www.cepremap.cnrs.fr/svn/dynare_v4 |
Line 46: | Line 37: |
Don't forget to update regularly your working copy, using {{{svn update}}}. | Compile the preprocessor by typing {{{make}}} in the {{{preprocessor}}} directory. Finally, compile the dynamic libraries (MEX-files) by typing {{{octave build_octave.m}}} from the {{{mex/sources}}} directory. === Windows === The recommended Octave distribution is the [http://sourceforge.net/project/showfiles.php?group_id=2888&package_id=40078 precompiled binaries from Octave Forge]. Pick up the {{{octave-3.0.1-vs2008-setup.exe}}} installer. Note that this binary distribution has a bug which makes Octave crash everytime one types {{{clear all}}} (and therefore everytime one runs Dynare!). A simple workaround is to type the following command the first time you run Octave: {{{ pkg rebuild -noauto ftp ann database }}} [http://wiki.octave.org/wiki.pl?CategoryInstall Other binary packages for Windows] are listed on Octave Wiki, but they look not very stable. Also note that the Cygwin package is quite outdated. Then, form a Cygwin prompt, assuming you have installed the {{{subversion}}} package, download the source tree in the current directory with: {{{ svn checkout http://www.cepremap.cnrs.fr/svn/dynare_v4 }}} Compile the preprocessor by typing {{{make}}} in the {{{preprocessor}}} directory. The dynamic libraries (MEX-files) can be compiled with [http://www.microsoft.com/express/download/default.aspx Microsoft Visual C++ 2008], which is now freely downloadable. The exact procedure will be soon detailed. |
Line 58: | Line 71: |
Then, from Octave, add the path to {{{dynare_v4_octave}}} using the {{{addpath}}} command, as you would under Matlab: | It is also possible to run [http://www.gnu.org/software/octave/doc/interpreter/Emacs.html Octave under Emacs]. Then, from Octave, add the path to Dynare with the {{{addpath}}} command, as you would under Matlab: |
Line 60: | Line 75: |
addpath REPLACE_WITH_RIGHT_PATH/dynare_v4_octave/matlab | addpath REPLACE_WITH_INSTALL_PATH/matlab |
Line 64: | Line 79: |
At first glance, Octave doesn't accept short syntax when typing {{{dynare}}} command (need to investigate that issue). In other words, to run Dynare on {{{ramst.mod}}}, you need to type: | Unless you tell it to do otherwise, Octave won't accept the short syntax when typing {{{dynare}}} command. In other words, to run Dynare on {{{ramst.mod}}}, you need to type: |
Line 73: | Line 88: |
== Main changes between Matlab and Octave versions of Dynare == * Warning handling is different between Matlab and Octave, and necessitated some adjustments. * Adjustments were obviously necessary where {{{version()}}} function is called * Generalized eigenvalues are not implemented as a primitive (i.e. {{{eig(A,B)}}} doesn't exist in Octave). This implied a change in {{{dr1.m}}} |
However, you can force Octave to accept the short syntax by typing the following (or by adding it to your {{{.octaverc}}}): {{{ mark_as_command dynare }}} |
Line 81: | Line 95: |
* Simple deterministic models should work | * Simple deterministic models should work (tested on {{{ramst.mod}}}) * Simple stochastic simulation should work (tested on {{{example1.mod}}}) * Simple bayesian estimation should work (tested on {{{arima/mod1a.mod}}}) * Results are saved in {{{.mat}}} files which can be read from Matlab 6, 7 and from Octave * Graphics display: * basically works * however window titles ("Priors", ...) don't show up * the scale is sometimes ugly (overlapping characters) * warnings about missing font file show up * Graphics saving on filesystem works for EPS, but not for PDF and FIG formats * Excel data files are not supported by Octave. A workaround is to convert the file to a text format (more details to come shortly) * MEX files: * can be compiled using {{{mex/sources/build_octave.m}}} * successfully tested under Linux * under Windows, since the Octave-Forge pre-compiled binary is build using Microsoft Visual C++ 2008, one need this compiler to create MEX files == Main changes between Matlab and Octave versions of Dynare == * '''Generalized eigenvalues:''' {{{eig(A,B)}}} doesn't exist in Octave. But a call to {{{lambda = qz(A,B)}}} does the same job. Implied a change in {{{dr1.m}}} * '''QZ decomposition''': {{{[AA,BB,Q,Z] = qz(A,B)}}} works under Octave, but the convention for {{{Q}}} is different. We have {{{AA = Q*A*Z}}} under Matlab and {{{AA = Q'*A*Z}}} under Octave. Implied changes in {{{gensylv/sylvester3.m}}} and {{{qz/mjdgges.m}}} * '''Reciprocal condition number''': {{{rcond(A)}}} doesn't exist under Octave. For the moment, the workaround is to create a {{{rcond.m}}} M-file which does {{{1/(norm(A,1)*norm(inv(A), 1))}}}. The {{{rcond()}}} function should be available in the next major release of Octave, see [http://www.cae.wisc.edu/pipermail/octave-maintainers/2008-May/007332.html this post] and its reply. * '''Saving data on the filesystem''': * Octave can read and write Matlab's MAT format. A call to {{{default_save_options('-mat')}}} was added in {{{dynare.m}}} to make Dynare for Octave create MAT files * But {{{save()}}} and {{{load()}}} under Octave don't assume the {{{.mat}}} extension. Need to explicitly add them * '''Saving graphics on the filesystem''': * Saving graphics with {{{saveas()}}} don't work, since it uses a Matlab specific format * Creation of PDF files is not supported (through {{{print -dpdf}}}). This comes from the fact that PDF support in GNUPlot is non-free, and therefore not available under Debian/Ubuntu or Windows package. See [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=248426 Debian bug #248426] * Creation of EPS files works (though file extension is not automatically added by Octave, contrary to Matlab) * '''Warning handling''' is different between Matlab and Octave, and necessitated some adjustments * Adjustments were obviously necessary where {{{version()}}} function is called * The operator {{{&}}} under Matlab is buggy: it doesn't execute its second argument if the first is false. This behaviour should be restricted to {{{&&}}}. Implied a change in {{{mh_optimal_bandwith.m}}}, since this file expects the buggy behaviour * {{{waitbar()}}} exists under Octave, but is text-only and is not very flexible. Replaced by calls to {{{printf()}}} in {{{random_walk_metropolis_hastings.m}}} * {{{mkdir()}}} works slightly differently under Octave: it won't simultaneously create several depths of subdirectories. Implied a change in {{{CheckPath.m}}} * {{{setdiff()}}} doesn't return a second argument under Octave. Implied a workaround in {{{dynare_estimation.m}}} and {{{dynare_estimation_init.m}}} |
Dynare for Octave
Porting of Dynare to Octave is under progress. Development is done using Octave versions 3.0.0 and 3.0.1.
About Octave
Octave is a free clone of Matlab, running under Linux, Windows and MacOS.
It normally runs in a command window, and displays graphics in separate windows (using Gnuplot).
Some ressources:
[http://www.octave.org Octave official site]
[http://octave.sourceforge.net Octave Forge]: a set of extensions for Octave
Official [http://www.gnu.org/software/octave/doc/interpreter/ Octave manual] online
- On the compatibility between Octave and Matlab:
List of [http://www.gnu.org/software/octave/FAQ.html#MATLAB-compatibility differences between Octave and Matlab]
List of [http://wiki.octave.org/wiki.pl?MissingMatlabFunctions missing Matlab functions] in Octave
More on [http://wiki.octave.org/wiki.pl?MatlabOctaveCompatibility Matlab/Octave compatibility]
[http://en.wikibooks.org/wiki/Octave_Programming_Tutorial Octave Programming Tutorial] on WikiBooks
Installing Dynare for Octave
GNU/Linux
For Debian "Lenny" or Ubuntu "Hardy Heron", see InstallOnDebianOrUbuntu.
For other distributions, you should begin by installing the octave3.0 package.
Then pickup Dynare sources via the daily snapshot, or via SVN with:
svn checkout http://www.cepremap.cnrs.fr/svn/dynare_v4
Compile the preprocessor by typing make in the preprocessor directory.
Finally, compile the dynamic libraries (MEX-files) by typing octave build_octave.m from the mex/sources directory.
Windows
The recommended Octave distribution is the [http://sourceforge.net/project/showfiles.php?group_id=2888&package_id=40078 precompiled binaries from Octave Forge]. Pick up the octave-3.0.1-vs2008-setup.exe installer.
Note that this binary distribution has a bug which makes Octave crash everytime one types clear all (and therefore everytime one runs Dynare!). A simple workaround is to type the following command the first time you run Octave:
pkg rebuild -noauto ftp ann database
[http://wiki.octave.org/wiki.pl?CategoryInstall Other binary packages for Windows] are listed on Octave Wiki, but they look not very stable. Also note that the Cygwin package is quite outdated.
Then, form a Cygwin prompt, assuming you have installed the subversion package, download the source tree in the current directory with:
svn checkout http://www.cepremap.cnrs.fr/svn/dynare_v4
Compile the preprocessor by typing make in the preprocessor directory.
The dynamic libraries (MEX-files) can be compiled with [http://www.microsoft.com/express/download/default.aspx Microsoft Visual C++ 2008], which is now freely downloadable. The exact procedure will be soon detailed.
Running Dynare for Octave
First, you should run Octave.
Under Linux, at the prompt, just type:
octave
Under Windows, you should have a shortcut already installed in your Start menu.
It is also possible to run [http://www.gnu.org/software/octave/doc/interpreter/Emacs.html Octave under Emacs].
Then, from Octave, add the path to Dynare with the addpath command, as you would under Matlab:
addpath REPLACE_WITH_INSTALL_PATH/matlab
It is possible to autoexecute this command at each Octave start by adding it to the .octaverc startup file (under Linux, this file should be put in the home directory; under Windows, it should be put at the root of the user home under Documents and Settings).
Unless you tell it to do otherwise, Octave won't accept the short syntax when typing dynare command. In other words, to run Dynare on ramst.mod, you need to type:
dynare('ramst')
rather than:
dynare ramst
However, you can force Octave to accept the short syntax by typing the following (or by adding it to your .octaverc):
mark_as_command dynare
Current status of development
Simple deterministic models should work (tested on ramst.mod)
Simple stochastic simulation should work (tested on example1.mod)
Simple bayesian estimation should work (tested on arima/mod1a.mod)
Results are saved in .mat files which can be read from Matlab 6, 7 and from Octave
- Graphics display:
- basically works
- however window titles ("Priors", ...) don't show up
- the scale is sometimes ugly (overlapping characters)
- warnings about missing font file show up
- Graphics saving on filesystem works for EPS, but not for PDF and FIG formats
- Excel data files are not supported by Octave. A workaround is to convert the file to a text format (more details to come shortly)
- MEX files:
can be compiled using mex/sources/build_octave.m
- successfully tested under Linux
- under Windows, since the Octave-Forge pre-compiled binary is build using Microsoft Visual C++ 2008, one need this compiler to create MEX files
Main changes between Matlab and Octave versions of Dynare
Generalized eigenvalues: eig(A,B) doesn't exist in Octave. But a call to lambda = qz(A,B) does the same job. Implied a change in dr1.m
QZ decomposition: [AA,BB,Q,Z] = qz(A,B) works under Octave, but the convention for Q is different. We have AA = Q*A*Z under Matlab and AA = Q'*A*Z under Octave. Implied changes in gensylv/sylvester3.m and qz/mjdgges.m
Reciprocal condition number: rcond(A) doesn't exist under Octave. For the moment, the workaround is to create a rcond.m M-file which does 1/(norm(A,1)*norm(inv(A), 1)). The rcond() function should be available in the next major release of Octave, see [http://www.cae.wisc.edu/pipermail/octave-maintainers/2008-May/007332.html this post] and its reply.
Saving data on the filesystem:
Octave can read and write Matlab's MAT format. A call to default_save_options('-mat') was added in dynare.m to make Dynare for Octave create MAT files
But save() and load() under Octave don't assume the .mat extension. Need to explicitly add them
Saving graphics on the filesystem:
Saving graphics with saveas() don't work, since it uses a Matlab specific format
Creation of PDF files is not supported (through print -dpdf). This comes from the fact that PDF support in GNUPlot is non-free, and therefore not available under Debian/Ubuntu or Windows package. See [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=248426 Debian bug #248426]
- Creation of EPS files works (though file extension is not automatically added by Octave, contrary to Matlab)
Warning handling is different between Matlab and Octave, and necessitated some adjustments
Adjustments were obviously necessary where version() function is called
The operator & under Matlab is buggy: it doesn't execute its second argument if the first is false. This behaviour should be restricted to &&. Implied a change in mh_optimal_bandwith.m, since this file expects the buggy behaviour
waitbar() exists under Octave, but is text-only and is not very flexible. Replaced by calls to printf() in random_walk_metropolis_hastings.m
mkdir() works slightly differently under Octave: it won't simultaneously create several depths of subdirectories. Implied a change in CheckPath.m
setdiff() doesn't return a second argument under Octave. Implied a workaround in dynare_estimation.m and dynare_estimation_init.m