Size: 7762
Comment:
|
Size: 7821
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 3: | Line 3: |
= Dynare for Octave = | = Dynare with Octave = |
Line 5: | Line 5: |
Porting of Dynare to Octave is under progress. Development is done using Octave versions 3.0.0 and 3.0.1. | Dynare is now able to run on GNU Octave, which is basically a free clone of MATLAB. Octave versions ranging from 3.2.2 to 3.6 are supported (the unstable version requires 3.4 at least). |
Line 9: | Line 11: |
Octave is a free clone of Matlab, running under Linux, Windows and MacOS. | GNU Octave is a free clone of MATLAB, running under GNU/Linux, Windows and MacOS. |
Line 15: | Line 17: |
* [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 |
* [[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 * A graphical frontend to Octave: [[http://qtoctave.wordpress.com/|QtOctave]] |
Line 19: | Line 22: |
* 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 |
* 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]] * Octave tutorials: * [[http://en.wikibooks.org/wiki/Octave_Programming_Tutorial|Octave Programming Tutorial]] on Wiki``Books * [[http://www8.cs.umu.se/~fotios/OctaveRevPack.pdf|GNU Octave/MATLAB revision pack]] |
Line 24: | Line 29: |
== Development of Dynare for Octave == | == Installing Dynare 4.3 with Octave == |
Line 26: | Line 31: |
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. | === Windows (without Cygwin) === |
Line 28: | Line 33: |
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. |
This is the recommended way for Windows users. |
Line 34: | Line 35: |
== Installing Dynare for Octave == | * Download and install [[http://www.dynare.org/octave/Octave3.6.1_gcc4.6.2_20120303-setup.exe|Octave 3.6.1 (MinGW)]]. * Download and install the latest Dynare package for Windows, see [[http://www.dynare.org/download/dynare-4.3/windows]]. |
Line 36: | Line 38: |
=== Octave === | === Windows (with Cygwin) === |
Line 38: | Line 40: |
Under Debian "Lenny" or Ubuntu "Hardy Heron", install packages {{{octave3.0}}} and {{{octave-miscellaneous}}} (for {{{waitbar()}}}) | * Download and uncompress Dynare 4.3 sources from [[http://www.dynare.org/download/dynare-4.3/source]] * Follow the instructions for Cygwin on BuildingDynareFromSource. |
Line 40: | Line 43: |
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]. | Note that graphics are not supported when Octave is run from the Cygwin prompt; you need to use the option {{{nograph}}} in your MOD file. If you want graphics, install the X windows server. |
Line 42: | Line 45: |
[http://wiki.octave.org/wiki.pl?CategoryInstall More installation instructions] can be found on Octave Wiki. | === GNU/Linux === |
Line 44: | Line 47: |
=== Dynare for Octave === | For Debian or Ubuntu distributions, see InstallOnDebianOrUbuntu. |
Line 46: | Line 49: |
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): {{{ svn checkout http://www.cepremap.cnrs.fr/svn/branches/dynare_v4_octave }}} |
For other distributions: * install the package for Octave from your distribution * download and uncompress Dynare 4.3 sources from [[http://www.dynare.org/download/dynare-4.3/source]] * follow the instructions on BuildingDynareFromSource |
Line 51: | Line 54: |
Under Linux, you also need to compile the preprocessor by going into the {{{preprocessor/}}} subdirectory and typing {{{make}}}. Don't forget to update regularly your working copy, using {{{svn update}}}. == Running Dynare for Octave == |
== Running Dynare with Octave == |
Line 59: | Line 58: |
Under Linux, at the prompt, just type: | Under GNU/Linux, at the prompt, just type: |
Line 65: | Line 64: |
It is also possible to run [http://www.gnu.org/software/octave/doc/interpreter/Emacs.html Octave under Emacs]. | It is also possible to run [[http://www.gnu.org/software/octave/doc/interpreter/Emacs.html|Octave under Emacs]]. |
Line 67: | Line 66: |
Then, from Octave, add the path to {{{dynare_v4_octave}}} using the {{{addpath}}} command, as you would under Matlab: | Then, from Octave, add the path to Dynare with the {{{addpath}}} command, as you would under MATLAB: |
Line 69: | Line 68: |
addpath REPLACE_WITH_RIGHT_PATH/dynare_v4_octave/matlab | addpath REPLACE_WITH_INSTALL_PATH/matlab |
Line 73: | Line 72: |
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: |
=== Invoking Dynare === If your MOD file is {{{ramst.mod}}}, just type: |
Line 82: | Line 79: |
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 Dynare with Octave == |
Line 87: | Line 81: |
== 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 |
* Deterministic simulation works (tested on {{{ramst.mod}}}) * Stochastic simulation works (tested on {{{example1.mod}}}) * Bayesian estimation works (tested on {{{arima/mod1a.mod}}}). However, Excel data files are not supported by Octave. A workaround is to convert the file to a text format (more details to come shortly) * Ramsey policy works * Results are saved in {{{.mat}}} files which can be read from MATLAB and from Octave |
Line 95: | Line 89: |
* 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 * 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++, one need this compiler to create MEX files |
* however window titles ("Priors", ...) don't show up (with GNUplot backend) * the scale is sometimes ugly (overlapping characters) (with GNUplot backend) * warnings about missing font file show up (with GNUplot backend) * graphics are vertically shrinked when several plots are on the same window (with JHandles backend) * graphics saving on filesystem works for EPS, but not for PDF and FIG formats * currently, Dynare crashes when Octave is run without graphical capabilities; a workaround is to use option "nograph" |
Line 104: | Line 96: |
== Main changes between Matlab and Octave versions of Dynare == | == Main differences between MATLAB and Octave which are dealt with by Dynare == |
Line 106: | Line 98: |
* '''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. |
* '''Generalized eigenvalues:''' {{{eig(A,B)}}} doesn't exist in Octave. A call to {{{lambda = qz(A,B)}}} does the same job, except that it doesn't return infinite eigenvalues, so we can't use it. 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 a change in {{{gensylv/sylvester3.m}}} * Octave is only able to compute real QZ, while MATLAB can do both complex and real, and does complex by default. As a consequence, {{{qz/mjdgges.m}}} is implemented differently for Octave and MATLAB: under MATLAB we compute the complex decomposition, and use Sims' code for reordering the eigenvalues; under Octave, we use the native reordered QZ, but as a consequence the criterium is de facto always 1.0 * '''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 is now available in Octave 3.2. |
Line 114: | Line 108: |
* 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 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]] |
Line 118: | Line 112: |
* 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. Implied changes in {{{random_walk_metropolis_hastings.m}}} |
* The operator {{{&}}} under MATLAB is buggy: it doesn't execute its second argument if the first is false, when used in an {{{if}}} statement. This behaviour should be restricted to {{{&&}}}. This also applies to {{{|}}} and {{{||}}}. 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}}} |
Line 122: | Line 116: |
* {{{matrix.h}}} header doesn't exist under Octave for MEX files, and can just be omitted. The same probably applies to Matlab, since {{{mex.h}}} is supposed to define everything. Implied a change in {{{A_times_B_kronecker_C.cc}}} and {{{sparse_hessian_times_B_kronecker_C.cc}}} | * {{{ordeig()}}} doesn't exist under Octave (nor on MATLAB < 7.0.1). Use {{{my_ordeig()}}} instead. * '''Case sensitivity''' : under GNU/Linux, calls to Octave functions and variables are case sensitive. So non preprocessed instructions at the end of modfiles should be written with lowercase. |
Dynare with Octave
Dynare is now able to run on GNU Octave, which is basically a free clone of MATLAB.
Octave versions ranging from 3.2.2 to 3.6 are supported (the unstable version requires 3.4 at least).
About Octave
GNU Octave is a free clone of MATLAB, running under GNU/Linux, Windows and MacOS.
It normally runs in a command window, and displays graphics in separate windows (using Gnuplot).
Some ressources:
Octave Forge: a set of extensions for Octave
Official Octave manual online
A graphical frontend to Octave: QtOctave
- On the compatibility between Octave and Matlab:
List of missing Matlab functions in Octave
More on Matlab/Octave compatibility
- Octave tutorials:
Installing Dynare 4.3 with Octave
Windows (without Cygwin)
This is the recommended way for Windows users.
Download and install Octave 3.6.1 (MinGW).
Download and install the latest Dynare package for Windows, see http://www.dynare.org/download/dynare-4.3/windows.
Windows (with Cygwin)
Download and uncompress Dynare 4.3 sources from http://www.dynare.org/download/dynare-4.3/source
Follow the instructions for Cygwin on BuildingDynareFromSource.
Note that graphics are not supported when Octave is run from the Cygwin prompt; you need to use the option nograph in your MOD file. If you want graphics, install the X windows server.
GNU/Linux
For Debian or Ubuntu distributions, see InstallOnDebianOrUbuntu.
For other distributions:
- install the package for Octave from your distribution
download and uncompress Dynare 4.3 sources from http://www.dynare.org/download/dynare-4.3/source
follow the instructions on BuildingDynareFromSource
Running Dynare with Octave
First, you should run Octave.
Under GNU/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 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).
Invoking Dynare
If your MOD file is ramst.mod, just type:
dynare ramst
Current status of Dynare with Octave
Deterministic simulation works (tested on ramst.mod)
Stochastic simulation works (tested on example1.mod)
Bayesian estimation works (tested on arima/mod1a.mod).
- However, Excel data files are not supported by Octave. A workaround is to convert the file to a text format (more details to come shortly)
- Ramsey policy works
Results are saved in .mat files which can be read from MATLAB and from Octave
- Graphics display:
- basically works
- however window titles ("Priors", ...) don't show up (with GNUplot backend)
- the scale is sometimes ugly (overlapping characters) (with GNUplot backend)
- warnings about missing font file show up (with GNUplot backend)
- graphics are vertically shrinked when several plots are on the same window (with JHandles backend)
- graphics saving on filesystem works for EPS, but not for PDF and FIG formats
- currently, Dynare crashes when Octave is run without graphical capabilities; a workaround is to use option "nograph"
Main differences between MATLAB and Octave which are dealt with by Dynare
Generalized eigenvalues: eig(A,B) doesn't exist in Octave. A call to lambda = qz(A,B) does the same job, except that it doesn't return infinite eigenvalues, so we can't use it. 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 a change in gensylv/sylvester3.m
Octave is only able to compute real QZ, while MATLAB can do both complex and real, and does complex by default. As a consequence, qz/mjdgges.m is implemented differently for Octave and MATLAB: under MATLAB we compute the complex decomposition, and use Sims' code for reordering the eigenvalues; under Octave, we use the native reordered QZ, but as a consequence the criterium is de facto always 1.0
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 is now available in Octave 3.2.
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 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, when used in an if statement. This behaviour should be restricted to &&. This also applies to | and ||. 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
ordeig() doesn't exist under Octave (nor on MATLAB < 7.0.1). Use my_ordeig() instead.
Case sensitivity : under GNU/Linux, calls to Octave functions and variables are case sensitive. So non preprocessed instructions at the end of modfiles should be written with lowercase.