ARFIMA estimation with ox on fmrisc.bc.edu


With Jurgen Doornik's generous assistance we now have a version of ox, his matrix programming language, containing 'native' ARFIMA routines (equivalent to those available with DLLs for Windows) that run much faster than the ox-language version. I have created a separate executable image, oxarfima, containing these routines. The difference in timing (user mode is the program) is quite noticeable:

original version (ox interpreted code)
=======================================
# /usr/bin/time ox fracest1.ox -DNO_DLL > fracest1.out

Real   8.89
User   5.72
System 0.04

native ARFIMA code
==================
# /usr/bin/time ox fracest1d.ox > fracest1d.out

Real   0.38
User   0.33
System 0.05

The new version is invoked on fmrisc.bc.edu as oxarfima rather than ox, and the NO_DLL option is NOT used; thus if one has the file testjob1.ox it would be executed via

$ oxarfima testjob1.ox

To place the results in a file,

$ oxarfima testjob1.ox > testjob1.out

To run in batch mode,

$ batch
$ oxarfima testjob1.ox > testjob1.out
ctrl-D

(more than one invocation of oxarfima could be placed between 'batch' and 'ctrl-D').

Programs using native ARFIMA in this implementation differ only slightly from those documented in the ox ARFIMA manual (available from 'Guide to Information Resources' heading on the economics department web page). For instance, the fracest1.ox program, given in the documentation, must be modified thusly:

diff fracest1.ox fracest1d.ox
2c2
< #include "arfima.h"
---
> #include "arfimad.h"
6c6
< #include "arfima.ox"
---
> #include "arfimad.ox"
So that the revised program reads:

#include oxstd.h
#include "arfimad.h"

#pragma  link("maximize.oxo")
#pragma  link("database.oxo")
#include "arfimad.ox"

main()
{
    decl arfima, vx;

    // create an object of class Arfima
    arfima = new Arfima();

    // load the data into a matrix vx
    // the first two numbers in rpiinfk.mat have
    // the data dimensions, here (1 x 136).
    vx = loadmat("/usr/local/ox/arfima/rpiinfk.mat");

    // Note: it is possible to load PcGive/spreadsheet
    // files directly into the database.

    // create the database for storage
    // frequency: 1, startyear: 1, startperiod: 1,
    // endyear: #columns in vx,  endperiod: 1.
    arfima->Create(1,1,1,columns(vx),1);

    // store vx in the database with name "Y"
    arfima->Append(vx', {"Y"}, 0);

    // formulate arfima model, select "Y" as Y_VAR
    // from lag 0 to lag 0 (i.e. current only)
    arfima->Select(Y_VAR, { "Y", 0, 0 } );

    // specify an ARMA(1,d,0) model, d is used by default,
    // but can be fixed at 0 for ARMA(1,0)
    arfima->Arma(1,0);

    // select the maximum sample period
    arfima->SetSample(-1, 1, -1, 1);

    // print iteration output every 20 iterations
    MaxControl(-1,20);

    // estimate, automatically prints the results
    arfima->Estimate();

    // done with arfima: delete the object
    delete arfima;
}

Further timing results
======================

# /usr/bin/time ox fracest2.ox -DNO_DLL >fracest2.out

Real   105.77
User   62.82
System 0.01

# /usr/bin/time oxarfima fracest2d.ox > fracest2d.out

Real   0.62
User   0.61
System 0.01




# /usr/bin/time ox fracest4.ox -DNO_DLL >fracest4.out

Real   327.88
User   193.20
System 0.04
#
# /usr/bin/time oxarfima fracest4.ox >fracest4d.out

Real   3.45
User   2.51
System 0.02



C F Baum
Last updated: 29 August 1997