Getting Started with OxMetrics

This document corresponds to Chapters 2 to 5 of the OxMetrics book.

Table of contents
Return to OxMetrics Help

2 Getting Started: Windows
  2.1 Starting OxMetrics
  2.2 Registering OxMetrics
  2.3 Loading and viewing the tutorial data set
  2.4 OxMetrics graphics
  2.4.1 A first graph
  2.4.2 Multiple graphs
  2.4.3 Graph saving and printing
  2.4.4 Using the clipboard for graph pasting
  2.5 Calculator
  2.6 Algebra
  2.7 The workspace
3 Getting Started: OS X
  3.1 Starting OxMetrics
  3.2 Registering OxMetrics
  3.3 Loading and viewing the tutorial data set
  3.4 OxMetrics graphics
  3.4.1 A first graph
  3.4.2 Multiple graphs
  3.4.3 Graph saving and printing
  3.4.4 Using the clipboard for graph pasting
  3.5 Calculator
  3.6 Algebra
  3.7 The workspace
4 Getting Started: Linux
  4.1 Starting OxMetrics
  4.2 Registering OxMetrics
  4.3 Loading and viewing the tutorial data set
  4.4 OxMetrics graphics
  4.4.1 A first graph
  4.4.2 Multiple graphs
  4.4.3 Graph saving and printing
  4.4.4 Using the clipboard for graph pasting
  4.5 Calculator
  4.6 Algebra
  4.7 The workspace
5 OxMetrics Modules
  5.1 OxMetrics Modules
  5.2 Financial data
  5.3 Weekly and daily data
  5.4 PcGive
  5.4.1 Formulate a model
  5.5 TSP
  5.5.1 TSP in interactive mode
  5.5.2 TSP Help
  5.5.3 TSP in batch mode
  5.5.4 Explorer options
List of figures
  Figure:2.1 Time plot of CONS and INC
  Figure:2.2 Multiple graphs
  Figure:3.1 Time plot of CONS and INC
  Figure:3.2 Multiple graphs
  Figure:4.1 Time plot of CONS and INC
  Figure:4.2 Multiple graphs
  Figure:5.1 Dow Jones returns, ACF of returns, ACF of squared returns
  Figure:5.2 GARCH(1,1) model for Dow Jones returns

Chapter 2 Getting Started: Windows

gwtstac1

This chapter discusses some of the basic skills required to get started with OxMetrics on Windowstm. Since OxMetrics provides the data which other modules analyze, and receives all the text output and graphics which you create in (say) PcGive, you should begin by briefly learning how OxMetrics works.

Once OxMetrics has started, you will be able to load data, create graphs, and transform data using the OxMetrics calculator or algebra. Then, use the Model command on the Model menu to start econometric modelling using, for example, PcGive. When you exit OxMetrics it will automatically close all active modules which depend on it. In some of the coming tutorials we shall be using OxMetrics as a stand-alone program. There are many interesting things to be done even without using additional modules!

2.1 Starting OxMetrics

Start OxMetrics from the OxMetrics group on the Windows Start menu, or from a desktop icon. If this is the first time you use the new OxMetrics, you may wish to reset the size of the various windows. Catch the edge of the relevant window with the mouse pointer which should change form to a double arrow, and expand or contract as desired. Your initial screen could look like the capture shown on the previous page (we could only fit part of OxMetrics on the page).

Clicking on a menu item (e.g., File, Edit etc.) drops down the menu as shown on page 2.3 for File. Then moving the arrow keys drops down each menu in turn. For example, clicking on Window shows the open windows, and clicking on the desired choice makes it the focus; if part of that window shows on screen, directly clicking on it with the mouse also works.

2.2 Registering OxMetrics

gwtstac1a

If you install OxMetrics normally, it will already be registered, and you can start working immediately. An unregistered version will show the registration dialog on screen, as displayed above.

Enter the licensing code and your name in the respective fields (you must enter the code provided by your distributor).

An OxMetrics Enterprise licensing code enables most modules. Otherwise, many modules have their own additional licence code, which can be entered in the dialog. Once OxMetrics has the first registration code, the above dialog will not appear automatically anymore. To enter additional codes, activate the Help/Registration menu.

We trust that you use a legal copy of OxMetrics and client modules. That will allow us to keep developing the programs.

2.3 Loading and viewing the tutorial data set

Without data, there is not much that can be done, so the first step is to load data. Many tutorials use a data set called data.in7.

We shall load this tutorial data set here. Access the File menu in OxMetrics, and choose Open:

gwtstac2

If you installed in the default directory structure, the data will be in the directory \Program Files\OxMetrics7\data, so locate that directory and select the Data file:

gwtstac3

By default, all files are displayed, but you can refine the files listed from the Files of type drop-down box:

gwtstac3a

The data file contions artificial data on consumption, income, inflation and output, denoted by CONS, INC, INFLAT, and OUTPUT respectively. The in7 extension indicates a OxMetrics data file (a format which has remained the same for versions 7 and 8 of PcGive, then GiveWin, and is now used for OxMetrics, with some minor extensions in the file format). The in7 file is a human-readable file, describing the data (variable names, frequency, sample period, documentation etc.). There is a companion bn7 file, which holds the actual numbers (in binary format, so this file cannot be edited directly). OxMetrics can handle a wide range of data files, among them Excel files. You can also cut and paste data series directly from a spreadsheet (but not formulae).

Tip
By default, Windows does not show extensions of registered file types. Those registered by OxMetrics extensions are displayed, however, to facilitate discrimination between the different types. If you wish to see the all your registered extension, start the Windows Explorer. Deselect the option labelled: Hide extensions for known file types, which is listed under Model/Folder Options/View.

It is also possible to do this for individual files only: in Folder Options/File Types locate the relevant extension. Then click on Advanced and mark Always show extension.

The data file will be loaded, and become the currently active database for plotting and transformations. More than one database can be loaded, and the name of the currently active database is shown in the the toolbar:

gwtstac4

If more than one database is open, this toolbar box can be used to switch active database:

gwtstac4a

A notification of the loaded file is written to the Results window, so the loaded database does not acquire the focus. To see the database, click on it in the workspace. Although data values are stored internally with about 15 to 16 digit accuracy (8 byte floating point values), the data are displayed with 6 digits only in the spreadsheet:

gwtstac5

On the bottom right of the OxMetrics window, in the status bar, the observation under the cursor is shown with full accuracy:

gwtstac5a

Double clicking on the variable name shows the name and documentation of the variable, both of which can be changed. For the CONS variable:

gwtstac6

The data can be manipulated, much like in a spreadsheet program. Pressing the left mouse button, and keeping it depressed, then dragging the mouse highlights a block of data which can be copied to the clipboard for insertion in another part of the database (click on the two-pages icon for copy, or the Ctrl+C key; paste is the clipboard icon or the Ctrl+V key).

Right-clicking on the variable name brings up a context menu related to that variable, e.g. to quickly graph it. Here it is shown for INC:

gwtstac6d

Double clicking on an observation brings up a revision box, where corrected values can be entered (or missing values set to an observed outcome):

gwtstac6a

While two separate clicks will bring up the inline editor:

gwtstac6b

2.4 OxMetrics graphics

The graphics facilities of OxMetrics are powerful yet easy to use. This section will show you how to make time plots and scatter plots of variables in the database. OxMetrics offers automatic selections of scaling etc., but you will be able to edit these graphs, and change the default layout such as line colours and line types. Graphs can also be saved in a variety of formats for later use in a word processor, or for reloading into OxMetrics.

2.4.1 A first graph

Graphics is the first entry on the Model menu. Alternatively, click on the graphics icon on the toolbar:

gwtstac6c

Either way brings up the following dialog box. This is an example of a dialog with a multiple selection list control. In such a list, you mark as many items as you want. Here we mark all the variables we wish to graph. With the keyboard, you can only mark a single variable (by using the arrow up and down keys), or range of variables (hold the shift key down while using the arrow up or down keys).

With the mouse there is more flexibility:

gwtstac7

Here we select CONS and INC and then press the << button. This moves the variables from the database list to the selection list, activating the buttons at the bottom:

gwtstac7a

Press Actual series. Now the graph appears, which looks very much like Figure Figure:2.1. The only difference is the position of the legend. You can pick that up with the mouse, and move it to another position in the graph as desired.

gwtstaf1

Figure:2.1 Time plot of CONS and INC

Most graphs in this book are boxed in. You can change the default, for the current graph only, by double clicking on the graph (or selecting Edit/Edit Graph), then clicking on Graph layout in the left-hand column, and activating Box all areas, as shown here:

gwtstac8

Alternatively, choose Graphics from the Model/Preferences menu, and activate Box all areas:

gwtstac7b

This will change the default for all future graphs that are made with OxMetrics.

Note that, when the graph is active, and the mouse is moved over the graph, the status bar at the foot of the OxMetrics window displays the graph coordinates. Inside a graph these are the `real-world coordinates' (X,Y), the actual data values. Outside these are `pixel coordinates' (pX,pY): a graphics window in OxMetrics runs from (0,0) in the bottom left, to (15000,10000) in the top right.

2.4.2 Multiple graphs

One of the powerful features of OxMetrics is the ability to draw multiple graphs simultaneously on-screen within one graphics window (and you are not restricted to just one graphics window). We shall now get two graphs on screen, with the second a cross-plot of CONS and INC. Click on the Graphics toolbar button, note that CONS and INC are still selected (you can also variables to the opposing listbox by double clicking on them, or empty the selection by pressing Clear). The first variable in the selected list, CONS here, will be the Y variable (if CONS is not on top you can select it, and press the Move up button). Click on Scatter plot (YX) to create the plot.

If you accidentally did it wrong, click in the new sub plot (or plot area, as we tend to call it), selecting the entire second area, then press delete to remove it again.

gwtstaf2

Figure:2.2 Multiple graphs

A useful aspect of OxMetrics is that graphs can be edited and features added while they are on screen, and after adding other graphs if desired. Double click on the scatter plot graph, select Regression in the Edit Graphics dialog, and add one regression line as shown:

gwtstac9

The final result is in Figure Figure:2.2. The editing possibilities are manifold.

Finally, you can undo and redo the changes that were made. In this case, Undo will remove the graphics line again. Graph saving clears the undo/redo buffer, to avoid excessive memory use.

2.4.3 Graph saving and printing

To print a graph directly to the printer when the graphics window has the focus, click on the printer icon in the toolbar. You can preview the result first using the Print Preview command from the File menu. If you have a PostScript printer, you can save the graph to disk as PostScript, and then print it from the command line.

Graphs can be saved to disk in various formats:

The GWG format is particular to OxMetrics; no other program can read it and no printer can handle it. OxMetrics requires the GWG format, because it needs to be able to allow re-editing of the graph when it is reloaded; the other formats do not store sufficient information. When you save a graph in any format, the GWG file is automatically saved alongside it. Then, when loading a previously saved EPS file (say), OxMetrics can use the GWG file to reload the graph.

2.4.4 Using the clipboard for graph pasting

There is an important distinction between copying graphs for use in internal OxMetrics graphs, or for external use.

To paste the graph into Word, for example, you can use Edit/Copy Metafile to Clipboard, and then paste it into Word. A metafile stores the actual Windows commands that were used to draw the graph, and thus scales well. The alternative is to copy the bitmap to the clipboard.

[Note: We use LaTeX for our typesetting system, and save all graphs as .eps files.]

The standard copy command is used for internal paste. If no area is selected, the whole graph is copied, otherwise the selected area only.

Try this by clicking on the second area in the current graph. Once selected (shown by a hatched boundary) copy the area to the clipboard. Then first deselect the area by clicking somewhere in the margin of the graph. A subsequent paste will add a copy as the third area. Next, select the first area and paste again: this inserts the cross-plot into the time-series plot (not a useful graph).

2.5 Calculator

Two options are available for transforming data: by algebra or by a dialog approach, which mimics the operation of a pocket calculator. We begin with the latter, as it is the simplest.

Please note that OxMetrics and client modules are sensitive to the case of the variable names so that `cons', `Cons', and `CONS' are treated as different variables. This can be useful for distinguishing real (lower case) from nominal (capitals) variables, or logs from levels, etc.

In several cases OxMetrics will offer a default name for a newly created variable:

So can you guess what DLCONS_1 is likely to be?

The aim is to build up an algebraic expression for the transformation (which is valid Algebra code: see §2.6). Press on the Calculator button leading to the capture shown below (or via the Model menu and Calculator choice).

gwtstaca

The first transformation is to take the first difference of CONS. Click on the CONS variable just to highlight it (don't double click), and then on the diff button, accept a lag length of one, to see in the top part of the dialog:

gwtstacb

Click on the large button with the = sign, and accept the default name of DCONS, which will be created in the database, and added to the list of variables. A two-period difference is just as easy to compute: select CONS, press the diff button and change the length of the differencing period.

Another transformation to try: INC-CONS. Double click on INC, click on the minus button, and then double click on CONS. The expression now reads INC--CONS, press on = to evaluate. Name the variable SAVING (you could use a name like INC--CONS, but must enclose such a name in double quotes when using it in expressions).

Finally, we create a step dummy (or indicator variable), where the step lasts from 1979(2) to 1980(4). We need zeros outside that period, ones inside. Click on the dummy button, and enter:

gwtstacc

Click on OK, and then on = to create the dummy. Give it an informative name, such as s792t804.

Tip
We deliberately gave no examples involving lags. For estimation in modules such as TSP or PcGive, lags are best created at the model formulation stage, where the programs will keep track of their presence for dynamic analysis.

Three additional operations can be performed on variables inside the listbox in the Calculator:

All changes to the database can be undone from the Edit menu.

Exit the calculator (Esc or click on the x button), and graph some of the variables to check whether the transformations are correct. All transformations are logged to the Results window:

    Algebra code for data.in7:
    DCONS = diff(CONS,1);
    SAVING = INC-CONS;
    s792t804 = dummy(1979,2, 1980,4);

This leads us to the next topic.

2.6 Algebra

Algebra enables us to do transformations by typing the expressions directly into an editor. It also allows saving and loading from disk of a whole chunk of statements.

As an example, we rerun the transformations of the previous section. To verify if that will work, activate the database, and press Undo until the database is back in its original state. Now set focus to the Results window. Locate the logged Algebra code in the Results window. There are two ways to quickly run this code:

Because the former is straightforward, we now discuss the latter method.

Highlight the three algebra lines, and copy them to the clipboard (Ctrl+C). From the Model menu, select Algebra, and paste the code (Ctrl+V) to see:

gwtstacd

Now press Run. The variables have been recreated. We can inspect the database to see what happened. The algebra code is again logged to the Results window.

Tip
The bottom part of the Algebra editor is there to save typing. For example, to insert the code LCONS=log(CONS);, select CONS in the Database box of the Algebra editor. Next, selext log(VAR) under Functions, and click on Write Algebra Code.
Tip
As in the Calculater, database variables can be deleted, moved and renamed.

The only variable names allowed in Algebra are those that would be valid names in computer languages like Ox or C: the first character must be a letter or an underscore, the rest a letter, underscore or digit. Names which do not follow this convention must be enclosed in double quotes.

Algebra uses database variables as follows: if a left-hand variable is already in the database it will be overwritten, otherwise it will be created. Variables on the right must exist, possibly because of preceding lines of algebra code. Algebra is case-sensitive, meaning that LCONS, LCons and lcons refer to three different variables.

As a more advanced example, we explain how it is possible to create the same dummy using the insample function and a conditional assignment. The insample function has four arguments: startyear, startperiod, endyear, endperiod. It returns 1 (or TRUE: everything which is not 0 is TRUE) if the observation under consideration falls within the sample, otherwise it returns 0 (FALSE). The conditional assignment works as follows: the conditional statement (the `if' part) is followed by a question mark and the `then' part, which is followed by a colon and the `else' part. Read:

i1980p1 = insample(1980, 1, 1980, 1) ? 1 : 0;
as: i1980p1 takes on the value 1 for the observations which are in the specified sample, and the value 0 for the other observations. In this case, the same result can be obtained by writing:
i1980p1 = insample(1980, 1, 1980, 1);.

An error message pops up if you make a mistake. The error can be corrected on returning to the algebra editor. The text at the top of the Algebra error shows the text of the last error (if one occurred).

Tip
A sensible strategy is to store algebra code and basic data only, and recompute transforms during each run: this economizes on storage and facilitates updating analyses when data are revised or corrected.
Tip
If you load a database, text file, or graph from disk, and make a change to it, this is shown by a star before the name. When the document is saved, the star disappears again.

Do not save the modified data set. Either undo the changes, or quit the data set, and reload the original data.in7/data.bn7. Algebra is documented in Chapter Algebra.

This completes the getting-started chapter. Before giving some examples on modelling with OxMetrics, we briefly discuss the workspace window. The remainder of the tutorial are more detailed examples on graph editing, graphics, data loading and saving, and data transformations.

2.7 The workspace

Often, after working in OxMetrics for a while, there are many open windows, with graphs, data and results. The workspace helps navigating between these, by showing which documents are open in OxMetrics, as shown in the example on the next page.

Here there is one data file open, data.in7, which has been modified (as indicated by the * in front of the name). There is one save graph (also modified), and the default Data Plot window. In addition, there is simnor.ox (bold, so the active document) under Code, and the finally the Results window. The available modules are listed under Modules (with all interactive modelling packages such as PcGive, STAMP, etc. now grouped under the Model header).

The Help pane is also shown, here with the Ox help index. Double-clicking on acf() would open the Ox documentation at the acf function.

gwtstace

Right clicking on the document category (Data, Graphics, Code, or Text) gives a context menu. For Data it is:

gwtstacf

while right clicking on the document name gives:

gwtstacg

Chapter 5, which is the next in line, introduces the OxMetrics modules. This includes an example on estimating a GARCH(1,1) model using PcGive. Because OxMetrics behaves very similarly on Windows, OS X and Linux, we shall not explicitly distinguish anymore in the remainder.

Chapter 3 Getting Started: OS X

gwtstac1_osx

This chapter discusses some of the basic skills required to get started with OxMetrics on OS Xtm, the operating system for Apple Macs. Since OxMetrics provides the data which other modules analyze, and receives all the text output and graphics which you create in (say) PcGive, you should begin by briefly learning how OxMetrics works.

Once OxMetrics has started, you will be able to load data, create graphs, and transform data using the OxMetrics calculator or algebra. Then, use the Model command on the Model menu to start econometric modelling using, for example, PcGive. When you exit OxMetrics it will automatically close all active modules which depend on it. In some of the coming tutorials we shall be using OxMetrics as a stand-alone program. There are many interesting things to be done even without using additional modules!

3.1 Starting OxMetrics

OxMetrics is installed in the Applications folder, to a subfolder called OxMetrics7 for version 7 of OxMetrics. The main applications, OxMetrics and OxEdit are in the root of that folder:

gwtstac1b_osx

Start OxMetrics by double clicking on it (you can also drag it to the dock for more convenient startup). If this is the first time you use the new OxMetrics, you may wish to reset the size of the various windows. Catch the edge of the relevant window with the mouse pointer which should change form to a double arrow, and expand or contract as desired. Your initial screen could look like the capture shown on the previous page.

Clicking on a menu item (e.g., File, Edit etc.) at the top of the screen drops down the menu as shown on page 3.3 for File. You can select a different document window by clicking on the relevant entry in the left panel (the `workspace'), for example Results for the default results windows of the modelling packages. Alternatively, you can use the row of tabs just below the toolbars.

3.2 Registering OxMetrics

gwtstac1a_osx

If you install OxMetrics normally, it will already be registered, and you can start working immediately. A licence code entered during installation is available to all users of the computer (which would require a multiple-user licence). To add more shared licences, rerun the installer.

An unregistered version of OxMetrics will show the registration dialog on screen, as displayed above. Note that a licensing code entered when running the program as the current user is only available to that user. Enter the licensing code and your name in the respective fields (you must enter the code provided by your distributor).

An OxMetrics Enterprise licensing code enables most modules. Otherwise, many modules have their own additional licence code, which can be entered in the registration dialog. Once OxMetrics has the first registration code, the above dialog will not appear automatically anymore. To enter additional codes, activate the Help/Registration menu (current user only), or rerun the installer package (shared licence).

We trust that you use a legal copy of OxMetrics and client modules. That will allow us to keep developing the programs.

3.3 Loading and viewing the tutorial data set

Without data, there is not much that can be done, so the first step is to load data. Many tutorials use a data set called data.in7.

We shall load this tutorial data set here. Access the File menu in OxMetrics, and choose Open:

gwtstac2_osx

If you installed in the default directory structure, the data will be in the directory /Applications/OxMetrics7/data, so locate that directory and select the Data file:

gwtstac3_osx

By default, all files are displayed, but you can refine the files listed from the Enable pop-up list:

gwtstac3a_osx

The data file contions artificial data on consumption, income, inflation and output, denoted by CONS, INC, INFLAT, and OUTPUT respectively. The in7 extension indicates a OxMetrics data file (a format which has remained the same for versions 7 and 8 of PcGive, then GiveWin, and is now used for OxMetrics, with some minor extensions in the file format). The in7 file is a human-readable file, describing the data (variable names, frequency, sample period, documentation etc.). There is a companion bn7 file, which holds the actual numbers (in binary format, so this file cannot be edited directly). OxMetrics can handle a wide range of data files, among them Excel files. You can also cut and paste data series directly from a spreadsheet (but not formulae).

The data file will be loaded, and become the currently active database for plotting and transformations. More than one database can be loaded, and the name of the currently active database is shown in the the toolbar. If more than one database is loaded, this toolbar box can be used to switch active database:

gwtstac4_osx

A notification of the loaded file is written to the Results window, so the loaded database does not acquire the focus. To see the database, click on it in the workspace. Although data values are stored internally with about 15 to 16 digit accuracy (8 byte floating point values), the data are displayed with 6 digits only in the spreadsheet:

gwtstac5_osx

On the bottom right of the OxMetrics window, in the status bar, the observation under the cursor is shown with full accuracy:

gwtstac5a_osx

Double clicking on the variable name shows the name and documentation of the variable, both of which can be changed. For the CONS variable:

gwtstac6_osx

Right-clicking on the variable name brings up a context menu related to that variable, e.g. to quickly graph it. Here it is shown for INC:

gwtstac6d_osx

The data can be manipulated, much like in a spreadsheet program. Pressing the left mouse button, and keeping it depressed, then dragging the mouse highlights a block of data which can be copied to the clipboard for insertion in another part of the database (click on the two-pages icon for copy, or the Cmd+C key; paste is the clipboard icon or the Cmd+V key).

Double clicking on an observation brings up a revision box, where corrected values can be entered (or missing values set to an observed outcome):

gwtstac6a_osx

While two separate clicks will bring up the inline editor:

gwtstac6b_osx

3.4 OxMetrics graphics

The graphics facilities of OxMetrics are powerful yet easy to use. This section will show you how to make time plots and scatter plots of variables in the database. OxMetrics offers automatic selections of scaling etc., but you will be able to edit these graphs, and change the default layout such as line colours and line types. Graphs can also be saved in a variety of formats for later use in a word processor, or for reloading into OxMetrics.

3.4.1 A first graph

Graphics is the first entry on the Model menu. Alternatively, click on the graphics icon on the toolbar. Either way brings up the following dialog box:

gwtstac7_osx

This is an example of a dialog with a multiple selection list control. In such a list, you mark as many items as you want. Here we mark all the variables we wish to graph. With the keyboard, you can only mark a single variable (by using the arrow up and down keys), or range of variables (hold the shift key down while using the arrow up or down keys).

With the mouse there is more flexibility:

Here we select CONS and INC and then press the << button. This moves the variables from the database list to the selection list, activating the buttons at the bottom, as shown on the next page.

Press Actual series. Now the graph appears, which looks very much like Figure Figure:3.1. The only difference is the position of the legend. You can pick that up with the mouse, and move it to another position in the graph as desired.

gwtstac7a_osx

gwtstaf1_osx

Figure:3.1 Time plot of CONS and INC

Note that, when the graph is active, and the mouse is moved over the graph, the status bar at the foot of the OxMetrics window displays the graph coordinates. Inside a graph these are the `real-world coordinates' (X,Y), the actual data values. Outside these are `pixel coordinates' (pX,pY): a graphics window in OxMetrics runs from (0,0) in the bottom left, to (15000,10000) in the top right.

Most graphs in this book are boxed in. You can change the default, for the current graph only, by double clicking on the graph (or selecting Edit/Edit Graph), then clicking on Graph layout in the left-hand column, and activating Box all areas:

gwtstac7b_osx

Alternatively, choose Graphics from the OxMetrics/Preferences menu, and activate Box all areas, as shown on the nect page. This will change the default for all future graphs that are made with OxMetrics.

gwtstac8_osx

3.4.2 Multiple graphs

One of the powerful features of OxMetrics is the ability to draw multiple graphs simultaneously on-screen within one graphics window (and you are not restricted to just one graphics window). We shall now get two graphs on screen, with the second a cross-plot of CONS and INC. Click on the Graphics toolbar button, note that CONS and INC are still selected (you can also variables to the opposing listbox by double clicking on them, or empty the selection by pressing Clear). The first variable in the selected list, CONS here, will be the Y variable (if CONS is not on top you can select it, and press the Move up button). Click on Scatter plot (YX) to create the plot.

If you accidentally did it wrong, click in the new sub plot (or plot area, as we tend to call it), selecting the entire second area, then press delete to remove it again.

gwtstaf2_osx

Figure:3.2 Multiple graphs

A useful aspect of OxMetrics is that graphs can be edited and features added while they are on screen, and after adding other graphs if desired. Double click on the scatter plot graph, select Regression in the Edit Graphics dialog, and add one regression line as shown:

gwtstac9_osx

The final result is in Figure Figure:3.2. The editing possibilities are manifold.

Finally, you can undo and redo the changes that were made. In this case, Undo will remove the graphics line again. Graph saving clears the undo/redo buffer, to avoid excessive memory use.

3.4.3 Graph saving and printing

To print a graph directly to the printer when the graphics window has the focus, click on the printer icon in the toolbar. You can preview the result first using the Print Preview command from the File menu. If you have a PostScript printer, you can save the graph to disk as PostScript, and then print it from the command line.

Graphs can be saved to disk in various formats (note that you can extend the view of this dialog by clicking on the buttom next to the suggested filename):

gwtstac9a_osx

The GWG format is particular to OxMetrics; no other program can read it and no printer can handle it. OxMetrics requires the GWG format, because it needs to be able to allow re-editing of the graph when it is reloaded; the other formats do not store sufficient information. When you save a graph in any format, the GWG file is automatically saved alongside it. Then, when loading a previously saved EPS file (say), OxMetrics can use the GWG file to reload the graph.

3.4.4 Using the clipboard for graph pasting

There is an important distinction between copying graphs for use in internal OxMetrics graphs, or for external use. When copying to the clipboard, the whole graphs is copied, and two formats are available:

To paste the graph into Word, for example, you can use Edit/Copy Metafile to Clipboard, and then paste it into Word. A metafile stores the actual vector graphics commands that were used to draw the graph, and thus scales well. The alternative is to copy the bitmap to the clipboard.

[Note: We use LaTeX for our typesetting system, and save all graphs as .eps files.]

The standard copy command is used for internal paste. If no area is selected, the whole graph is copied, otherwise the selected area only.

Try this by clicking on the second area in the current graph. Once selected (shown by a hatched boundary) copy the area to the clipboard. Then first deselect the area by clicking somewhere in the margin of the graph. A subsequent paste will add a copy as the third area. Next, select the first area and paste again: this inserts the cross-plot into the time-series plot (not a useful graph).

3.5 Calculator

Please note that OxMetrics and client modules are sensitive to the case of the variable names so that `cons', `Cons', and `CONS' are treated as different variables. This can be useful for distinguishing real (lower case) from nominal (capitals) variables, or logs from levels, etc.

Two options are available for transforming data: by algebra or by a dialog approach, which mimics the operation of a pocket calculator. We begin with the latter, as it is the simplest. Press on the Calculator button leading to the capture shown below (or via the Model menu and Calculator choice).

gwtstaca_osx

In several cases OxMetrics will offer a default name for a newly created variable:

So can you guess what DLCONS_1 is likely to be?

The aim is to build up an algebraic expression for the transformation (which is valid Algebra code: see §2.6). The first transformation is to take the first difference of CONS. Click on the CONS variable just to highlight it (don't double click), and then on the diff button, accept a lag length of one, to see in the top part of the dialog:

gwtstacb_osx

Click on the large button with the = sign, and accept the default name of DCONS, which will be created in the database, and added to the list of variables. A two-period difference is just as easy to compute: select CONS, press the diff button and change the length of the differencing period.

Another transformation to try: INC-CONS. Double click on INC, click on the minus button, and then double click on CONS. The expression now reads INC--CONS, press on = to evaluate. Name the variable SAVING (you could use a name like INC--CONS, but must enclose such a name in double quotes when using it in expressions).

Finally, we create a step dummy (or indicator variable), where the step lasts from 1979(2) to 1980(4). We need zeros outside that period, ones inside. Click on the dummy button, and enter:

gwtstacc_osx

Click on OK, and then on = to create the dummy. Give it an informative name, such as s792t804.

Tip
We deliberately gave no examples involving lags. For estimation in modules such as TSP or PcGive, lags are best created at the model formulation stage, where the programs will keep track of their presence for dynamic analysis.

Three additional operations can be performed on variables inside the listbox in the Calculator:

All changes to the database can be undone from the Edit menu.

Exit the calculator (Esc or click on the x button), and graph some of the variables to check whether the transformations are correct. All transformations are logged to the Results window:

    Algebra code for data.in7:
    DCONS = diff(CONS,1);
    SAVING = INC - CONS;
    dumm1979 = dummy(1979,2, 1980,4);

This leads us to the next topic.

3.6 Algebra

Algebra enables us to do transformations by typing the expressions directly into an editor. It also allows saving and loading from disk of a whole chunk of statements.

The only variable names allowed in Algebra are those that would be valid names in computer languages like Ox or C: the first character must be a letter or an underscore, the rest a letter, underscore or digit. Names which do not follow this convention must be enclosed in double quotes.

Algebra uses database variables as follows: if a left-hand variable is already in the database it will be overwritten, otherwise it will be created. Variables on the right must exist, possibly because of preceding lines of algebra code. Algebra is case-sensitive, meaning that LCONS, LCons and lcons refer to three different variables.

As an example, we rerun the transformations of the previous section. To verify if that will work, activate the database, and press Undo until the database is back in its original state. Now set focus to the Results window. Locate the logged Algebra code in the Results window. There are two ways to quickly run this code:

Because the former is straightforward, we now discuss the latter method.

Highlight the three algebra lines, and copy them to the clipboard (Cmd+C). From the Model menu, select Algebra, and paste the code (Cmd+V) to see the dialog on the next page.

Now press Run. The variables have been recreated. We can inspect the database to see what happened. The algebra code is again logged to the Results window.

Tip
The bottom part of the Algebra editor is there to save typing. For example, to insert the code LCONS=log(CONS);, select CONS in the Database box of the Algebra editor. Next, selext log(VAR) under Functions, and click on Write Algebra Code.
Tip
As in the Calculater, database variables can be deleted, moved and renamed.

gwtstacd_osx

As a more advanced example, we explain how it is possible to create the same dummy using the insample function and a conditional assignment. The insample function has four arguments: startyear, startperiod, endyear, endperiod. It returns 1 (or TRUE: everything which is not 0 is TRUE) if the observation under consideration falls within the sample, otherwise it returns 0 (FALSE). The conditional assignment works as follows: the conditional statement (the `if' part) is followed by a question mark and the `then' part, which is followed by a colon and the `else' part. Read:

i1980p1 = insample(1980, 1, 1980, 1) ? 1 : 0;
as: i1980p1 takes on the value 1 for the observations which are in the specified sample, and the value 0 for the other observations. In this case, the same result can be obtained by writing:
i1980p1 = insample(1980, 1, 1980, 1);.

An error message pops up if you make a mistake. The error can be corrected on returning to the algebra editor. The text at the top of the Algebra error shows the text of the last error (if one occurred).

Tip
A sensible strategy is to store algebra code and basic data only, and recompute transforms during each run: this economizes on storage and facilitates updating analyses when data are revised or corrected.
Tip
If you load a database, text file, or graph from disk, and make a change to it, this is shown by a star before the name. When the document is saved, the star disappears again.

Do not save the modified data set. Either undo the changes, or quit the data set, and reload the original data.in7/data.bn7. Algebra is documented in Chapter Algebra.

This completes the getting-started chapter. Before giving some examples on modelling with OxMetrics, we briefly discuss the workspace window. The remainder of the tutorial are more detailed examples on graph editing, graphics, data loading and saving, and data transformations.

3.7 The workspace

Often, after working in OxMetrics for a while, there are many open windows, with graphs, data and results. The workspace helps navigating between these, by showing which documents are open in OxMetrics, as shown here:

gwtstace_osx

Here there are two data file open, data.in7, which has been modified (as indicated by the * in front of the name), and dowjones.xls. There is one save graph (also modified), and the default Data Plot window. In addition, there is the Results window. The available modules are listed under Modules (with all interactive modelling packages such as PcGive, STAMP, etc. now grouped under the Model header).

The Help pane is also shown, here with the Ox help index. Double-clicking on acf() would open the Ox documentation at the acf function in trhe default web browser.

Cmd+clicking on the document category (Data, Graphics, Code, or Text) gives a context menu. For Data it is:

gwtstacf_osx

while Cmd+clicking on the document name gives:

gwtstacg_osx

Chapter 5, which is the next in line, introduces the OxMetrics modules. This includes an example on estimating a GARCH(1,1) model using PcGive. Because OxMetrics behaves very similarly on Windows, OS X and Linux, we shall not explicitly distinguish anymore in the remainder.

Chapter 4 Getting Started: Linux

gwtstac1_lnx

This chapter discusses some of the basic skills required to get started with OxMetrics on Linux. Since OxMetrics provides the data which other modules analyze, and receives all the text output and graphics which you create in (say) PcGive, you should begin by briefly learning how OxMetrics works.

Once OxMetrics has started, you will be able to load data, create graphs, and transform data using the OxMetrics calculator or algebra. Then, use the Model command on the Model menu to start econometric modelling using, for example, PcGive. When you exit OxMetrics it will automatically close all active modules which depend on it. In some of the coming tutorials we shall be using OxMetrics as a stand-alone program. There are many interesting things to be done even without using additional modules!

4.1 Starting OxMetrics

OxMetrics is installed in the /usr/share folder, to a subfolder called OxMetrics7 for version 7 of OxMetrics. Shortcuts to the main applications OxMetrics and OxEdit are also installed under Education and Programming:

gwtstac1b_lnx

All the screen captures in this chapter were taken under Fedora 7 (x86_64) running GNOME 2.18.3. Start OxMetrics by double clicking on the menu entry. If this is the first time you use the new OxMetrics, you may wish to reset the size of the various windows. Catch the edge of the relevant window with the mouse pointer which should change form to a double arrow, and expand or contract as desired. Your initial screen could look like the capture shown on the previous page.

Clicking on a menu item (e.g., File, Edit etc.) at the top of the screen drops down the menu as shown on page 4.3 for File. You can select a different document window by clicking on the relevant entry in the left panel (the `workspace'), for example Results for the default results windows of the modelling packages. Alternatively, you can use the row of tabs just below the toolbars.

4.2 Registering OxMetrics

gwtstac1a_lnx

Installation of OxMetrics does not automatically prompt for a licensing code (unlike Windows or OS X) because this is against the RPM guidelines. When running OxMetrics for the first time, it will be unregistered and show the registration dialog on screen, as displayed above. Enter the licensing code and your name in the respective fields (you must enter the code provided by your distributor).

You can enter your code this way, but note that it will only be available to the current user. That should be sufficient if you have a single licence. A multi-user licence may need to be shared and requires the registration to be run as superuser. To do this, run the /usr/share/OxMetrics7/register script from a terminal as superuser.

An OxMetrics Enterprise licensing code enables most modules. Otherwise, many modules have their own additional licence code, which can be entered in the dialog. Once OxMetrics has the first registration code, the above dialog will not appear automatically anymore. To enter additional codes, activate the Help/Registration menu, or rerun the register script as superuser.

We trust that you use a legal copy of OxMetrics and client modules. That will allow us to keep developing the programs.

4.3 Loading and viewing the tutorial data set

Without data, there is not much that can be done, so the first step is to load data. Many tutorials use a data set called data.in7.

The data file contains artificial data on consumption, income, inflation and output, denoted by CONS, INC, INFLAT, and OUTPUT respectively. The in7 extension indicates a OxMetrics data file (a format which has remained the same for versions 7 and 8 of PcGive, then GiveWin, and is now used for OxMetrics, with some minor extensions in the file format). The in7 file is a human-readable file, describing the data (variable names, frequency, sample period, documentation etc.). There is a companion bn7 file, which holds the actual numbers (in binary format, so this file cannot be edited directly). OxMetrics can handle a wide range of data files, among them Excel files. You can also cut and paste data series directly from a spreadsheet (but not formulae).

We shall load this tutorial data set here. Access the File menu in OxMetrics, and choose Open:

gwtstac2_lnx

If you installed in the default directory structure, the data will be in the directory /usr/share/OxMetrics7/data, so locate that directory and select the Data file, as shown here:

gwtstac3_lnx

By default, all files are displayed, but you can refine the files listed from the All files pop-up list:

gwtstac3a_lnx

The data file will be loaded, and become the currently active database for plotting and transformations. More than one database can be loaded, and the name of the currently active database is shown in the the toolbar. If more than one database is loaded, this toolbar box can be used to switch active database:

gwtstac4_lnx

A notification of the loaded file is written to the Results window, so the loaded database does not acquire the focus. To see the database, click on it in the workspace. Although data values are stored internally with about 15 to 16 digit accuracy (8 byte floating point values), the data are displayed with 6 digits only in the spreadsheet:

gwtstac5_lnx

On the bottom right of the OxMetrics window, in the status bar, the observation under the cursor is shown with full accuracy:

gwtstac5a_lnx

Double clicking on the variable name shows the name and documentation of the variable, both of which can be changed. For the CONS variable:

gwtstac6_lnx

Right-clicking on the variable name brings up a context menu related to that variable, e.g. to quickly graph it. Here it is shown for INC:

gwtstac6d_lnx

The data can be manipulated, much like in a spreadsheet program. Pressing the left mouse button, and keeping it depressed, then dragging the mouse highlights a block of data which can be copied to the clipboard for insertion in another part of the database (click on the two-pages icon for copy, or the Ctrl+C key; paste is the clipboard icon or the Ctrl+V key).

Double clicking on an observation brings up a revision box, where corrected values can be entered (or missing values set to an observed outcome):

gwtstac6a_lnx

While two separate clicks will bring up the inline editor:

gwtstac6b_lnx

4.4 OxMetrics graphics

The graphics facilities of OxMetrics are powerful yet easy to use. This section will show you how to make time plots and scatter plots of variables in the database. OxMetrics offers automatic selections of scaling etc., but you will be able to edit these graphs, and change the default layout such as line colours and line types. Graphs can also be saved in a variety of formats for later use in a word processor, or for reloading into OxMetrics.

4.4.1 A first graph

Graphics is the first entry on the Model menu. Alternatively, click on the graphics icon on the toolbar. Either way brings up the following dialog box as shown on the next page.

This is an example of a dialog with a multiple selection list control. In such a list, you mark as many items as you want. Here we mark all the variables we wish to graph. With the keyboard, you can only mark a single variable (by using the arrow up and down keys), or range of variables (hold the shift key down while using the arrow up or down keys).

With the mouse there is more flexibility:

gwtstac7_lnx

Here we select CONS and INC and then press the << button. This moves the variables from the database list to the selection list, activating the buttons at the bottom:

gwtstac7a_lnx

Press Actual series. Now the graph appears, which looks very much like Figure Figure:4.1. The only difference is the position of the legend. You can pick that up with the mouse, and move it to another position in the graph as desired.

gwtstaf1_lnx

Figure:4.1 Time plot of CONS and INC

Note that, when the graph is active, and the mouse is moved over the graph, the status bar at the foot of the OxMetrics window displays the graph coordinates. Inside a graph these are the `real-world coordinates' (X,Y), the actual data values. Outside these are `pixel coordinates' (pX,pY): a graphics window in OxMetrics runs from (0,0) in the bottom left, to (15000,10000) in the top right.

Most graphs in this book are boxed in. You can change the default, for the current graph only, by double clicking on the graph (or selecting Edit/Edit Graph), then clicking on Graph layout in the left-hand column, and activating Box all areas, as shown on the next page.

Alternatively, choose Graphics from the Model/Preferences menu, and activate Box all areas, as shown in the second capture on the next page.

gwtstac7b_lnx

gwtstac8_lnx

The second method will change the default for all future graphs that are made with OxMetrics.

4.4.2 Multiple graphs

One of the powerful features of OxMetrics is the ability to draw multiple graphs simultaneously on-screen within one graphics window (and you are not restricted to just one graphics window). We shall now get two graphs on screen, with the second a cross-plot of CONS and INC. Click on the Graphics toolbar button, note that CONS and INC are still selected (you can also variables to the opposing listbox by double clicking on them, or empty the selection by pressing Clear). The first variable in the selected list, CONS here, will be the Y variable (if CONS is not on top you can select it, and press the Move up button). Click on Scatter plot (YX) to create the plot.

If you accidentally did it wrong, click in the new sub plot (or plot area, as we tend to call it), selecting the entire second area, then press delete to remove it again.

gwtstaf2_lnx

Figure:4.2 Multiple graphs

A useful aspect of OxMetrics is that graphs can be edited and features added while they are on screen, and after adding other graphs if desired. Double click on the scatter plot graph, select Regression in the Edit Graphics dialog, and add one regression line as shown:

gwtstac9_lnx

The final result is in Figure Figure:4.2. The editing possibilities are manifold.

Finally, you can undo and redo the changes that were made. In this case, Undo will remove the graphics line again. Graph saving clears the undo/redo buffer, to avoid excessive memory use.

4.4.3 Graph saving and printing

To print a graph directly to the printer when the graphics window has the focus, click on the printer icon in the toolbar. You can preview the result first using the Print Preview command from the File menu. If you have a PostScript printer, you can save the graph to disk as PostScript, and then print it from the command line.

Graphs can be saved to disk in various formats (note that you can extend the view of this dialog by clicking on the buttom next to the suggested filename):

The GWG format is particular to OxMetrics; no other program can read it and no printer can handle it. OxMetrics requires the GWG format, because it needs to be able to allow re-editing of the graph when it is reloaded; the other formats do not store sufficient information. When you save a graph in any format, the GWG file is automatically saved alongside it. Then, when loading a previously saved EPS file (say), OxMetrics can use the GWG file to reload the graph.

4.4.4 Using the clipboard for graph pasting

There is an important distinction between copying graphs for use in internal OxMetrics graphs, or for external use. When copying to the clipboard, the whole graphs is copied, and only one the Copy Bitmap to Clipboard option is available. This means that the graph is copied as a bitmap, which is less desirable for insertion in documents than a vector format.

The standard copy command is used for internal paste. If no area is selected, the whole graph is copied, otherwise the selected area only.

Try this by clicking on the second area in the current graph. Once selected (shown by a hatched boundary) copy the area to the clipboard. Then first deselect the area by clicking somewhere in the margin of the graph. A subsequent paste will add a copy as the third area. Next, select the first area and paste again: this inserts the cross-plot into the time-series plot (not a useful graph).

4.5 Calculator

Please note that OxMetrics and client modules are sensitive to the case of the variable names so that `cons', `Cons', and `CONS' are treated as different variables. This can be useful for distinguishing real (lower case) from nominal (capitals) variables, or logs from levels, etc.

Two options are available for transforming data: by algebra or by a dialog approach, which mimics the operation of a pocket calculator. We begin with the latter, as it is the simplest. Press on the Calculator button leading to the capture shown below (or via the Model menu and Calculator choice).

In several cases OxMetrics will offer a default name for a newly created variable:

So can you guess what DLCONS_1 is likely to be?

gwtstaca_lnx

The aim is to build up an algebraic expression for the transformation (which is valid Algebra code: see §2.6). The first transformation is to take the first difference of CONS. Click on the CONS variable just to highlight it (don't double click), and then on the diff button, accept a lag length of one, to see in the top part of the dialog:

gwtstacb_lnx

Click on the large button with the = sign, and accept the default name of DCONS, which will be created in the database, and added to the list of variables. A two-period difference is just as easy to compute: select CONS, press the diff button and change the length of the differencing period.

Another transformation to try: INC-CONS. Double click on INC, click on the minus button, and then double click on CONS. The expression now reads INC--CONS, press on = to evaluate. Name the variable SAVING (you could use a name like INC--CONS, but must enclose such a name in double quotes when using it in expressions).

Tip
We deliberately give no examples involving lags. For estimation in modules such as TSP or PcGive, lags are best created at the model formulation stage, where the programs will keep track of their presence for dynamic analysis.

Three additional operations can be performed on variables inside the listbox in the Calculator:

All changes to the database can be undone from the Edit menu.

Finally, we create a step dummy (or indicator variable), where the step lasts from 1979(2) to 1980(4). We need zeros outside that period, ones inside. Click on the dummy button, and enter:

gwtstacc_lnx

Click on OK, and then on = to create the dummy. Give it an informative name, such as s792t804.

Exit the calculator (Esc or click on the x button), and graph some of the variables to check whether the transformations are correct. All transformations are logged to the Results window:

    Algebra code for data.in7:
    DCONS = diff(CONS,1);
    SAVING = INC - CONS;
    dumm1979 = dummy(1979,2, 1980,4);

This leads us to the next topic.

4.6 Algebra

Algebra enables us to do transformations by typing the expressions directly into an editor. It also allows saving and loading from disk of a whole chunk of statements.

The only variable names allowed in Algebra are those that would be valid names in computer languages like Ox or C: the first character must be a letter or an underscore, the rest a letter, underscore or digit. Names which do not follow this convention must be enclosed in double quotes.

Algebra uses database variables as follows: if a left-hand variable is already in the database it will be overwritten, otherwise it will be created. Variables on the right must exist, possibly because of preceding lines of algebra code. Algebra is case-sensitive, meaning that LCONS, LCons and lcons refer to three different variables.

As an example, we rerun the transformations of the previous section. To verify if that will work, activate the database, and press Undo until the database is back in its original state. Now set focus to the Results window. Locate the logged Algebra code in the Results window. There are two ways to quickly run this code:

Because the former is straightforward, we now discuss the latter method.

Highlight the three algebra lines, and copy them to the clipboard (Ctrl+C). From the Model menu, select Algebra, and paste the code (Ctrl+V) to see the dialog on the next page.

Now press Run. The variables have been recreated. We can inspect the database to see what happened. The algebra code is again logged to the Results window.

Tip
The bottom part of the Algebra editor is there to save typing. For example, to insert the code LCONS=log(CONS);, select CONS in the Database box of the Algebra editor. Next, selext log(VAR) under Functions, and click on Write Algebra Code.
Tip
As in the Calculater, database variables can be deleted, moved and renamed.

gwtstacd_lnx

As a more advanced example, we explain how it is possible to create the same dummy using the insample function and a conditional assignment. The insample function has four arguments: startyear, startperiod, endyear, endperiod. It returns 1 (or TRUE: everything which is not 0 is TRUE) if the observation under consideration falls within the sample, otherwise it returns 0 (FALSE). The conditional assignment works as follows: the conditional statement (the `if' part) is followed by a question mark and the `then' part, which is followed by a colon and the `else' part. Read:

i1980p1 = insample(1980, 1, 1980, 1) ? 1 : 0;
as: i1980p1 takes on the value 1 for the observations which are in the specified sample, and the value 0 for the other observations. In this case, the same result can be obtained by writing:
i1980p1 = insample(1980, 1, 1980, 1);.

An error message pops up if you make a mistake. The error can be corrected on returning to the algebra editor. The text at the top of the Algebra error shows the text of the last error (if one occurred).

Tip
A sensible strategy is to store algebra code and basic data only, and recompute transforms during each run: this economizes on storage and facilitates updating analyses when data are revised or corrected.
Tip
If you load a database, text file, or graph from disk, and make a change to it, this is shown by a star before the name. When the document is saved, the star disappears.

Do not save the modified data set. Either undo the changes, or quit the data set, and reload the original data.in7/data.bn7. Algebra is documented in Chapter Algebra.

This completes the getting-started chapter. Before giving some examples on modelling with OxMetrics, we briefly discuss the workspace window. The remainder of the tutorial are more detailed examples on graph editing, graphics, data loading and saving, and data transformations.

4.7 The workspace

Often, after working in OxMetrics for a while, there are many open windows, with graphs, data and results. The workspace helps navigating between these, by showing which documents are open in OxMetrics, as shown here:

gwtstace_lnx

Here there are two data file open, data.in7, which has been modified (as indicated by the * in front of the name), and dowjones.xls. There is one save graph (also modified), and the default Data Plot window. In addition, there is the Results window. The available modules are listed under Modules (with all interactive modelling packages such as PcGive, STAMP, etc. now grouped under the Model header).

The Help pane is also shown, here with the Ox help index. Double-clicking on acf() would open the Ox documentation at the acf function in trhe default web browser.

Right clicking on the document category (Data, Graphics, Code, or Text) gives a context menu. For Data it is:

gwtstacf_lnx

while right clicking on the document name gives:

gwtstacg_lnx

Chapter 5, which is the next in line, introduces the OxMetrics modules. This includes an example on estimating a GARCH(1,1) model using PcGive. Because OxMetrics behaves very similarly on Windows, OS X and Linux, we shall not explicitly distinguish anymore in the remainder.

Chapter 5 OxMetrics Modules

5.1 OxMetrics Modules

There is an increasing number of computer programs which cooperate with OxMetrics to deliver an easy-to-use yet powerful user experience. Such modules implement different services, and may use OxMetrics:

At the time of writing, the OxMetrics compatible modules include:

The above modules (except for TSP) are all accessed via the Model command. In addition, there are interactive packages written in Ox which can be run via OxPack.

It is possible that only a subset of the modules are installed. The remainder of this chapter gives a brief introduction on how to use PcGive. Even if PcGive is not one of the modules you plan to use, it will still be useful to read it: most modules work in a similar way. Before we start, we load another database, and digress by talking about financial data.

5.2 Financial data

Load the dowjones.xls data set from the OxMetrics7\data folder. The DOWJONES variable holds the weekly Dow--Jones index (Dow Jones Industrial Average): close at midweek

[Note: The figures are for Wednesday, or Tuesday if the stock market was closed on Wednesday. The data are from www.djindexes.com.]

from Janary 1980 to September 1994, 770 observations in total.

We are interested in the returns, log Yt- log Yt-1, already in the database as DLDOWJONES. First, we illustrate the the returns can also be plotted directly from the levels. Make sure dowjones.xls is the active database. Click on Graphics, select DOWJONES, and click on All plot types>. Then select transformation Growth rates:

gwmoduc1

dowjones

Figure:5.1 Dow Jones returns, ACF of returns, ACF of squared returns

The outcomes are given in the top panel of Figure Figure:5.1. The large negative return of -17.4% corresponds to the Black Monday crash of 19 October 1987. The data show behaviour that is typical of financial time-series: clustering of volatility and so-called thick tails: there are more observations in the tail than can be expected from a normal distribution.

Next, activate Graphics again, using the same variable. Select time-series properties and note that the transformation is still set to growth rates. Click on ACF, and set the lag length to 50 as shown on the next page.

The outcomes are in the second panel of top panel of Figure Figure:5.1, indicating that there does not seem to be much memory, if any, in the returns. This should be expected. Next, use the calculator, and create the squared returns. The ACF of the squared returns are in the final panel of Figure Figure:5.1 (remember to reset the transformation back to none). This plot suggests that there is indeed some persistence in volatility.

gwmoduc2

5.3 Weekly and daily data

When moving the cursor over the graph of the actual returns, the status bar at the bottom can be seen to display the date in the plot. There are too many observations for an accurate reading, but the large negative shock can be pinpointed in October 1987.

Inspection of the database reveals that the first variable is called Date, and shows the same dates as in the row labels:

gwmoduc3

Double-clicking on the variable name reveals that it is of type Date. Changing it to Default changes the labelling to an undated dataset, and the Date values to large numbers:

gwmoduc4

These are the numbers that OxMetrics and Ox use to represent dates. Any fractional value represents fractional time (so 0.5 is 12:00 and 0.75 18:00 on the 24-hour clock).

Undo the changes to get back to the dated database. With weekly data, there are some years that have 52 weeks, and others with 53. Therefore, the method of using a fixed frequency, as used for annual, quarterly and monthly databases, does not work. Instead, a database can now be dated:

These criteria are satisfied in dowjones.xls, and the Excel dates are translated in Ox dates when reading the file (and the other way round when saving). Database!--- with dates

Next, to illustrate the modelling sequence in OxMetrics, we estimate a GARCH model without paying too much attention to the actual outcomes.

5.4 PcGive

PcGive is an interactive program for dynamic econometric modelling. Like other interactive modelling packages, it can be started in three ways:

The modelling dialog gives access to all the modelling features of the OxMetrics modules. In this case, only STAMP and PcGive are listed, but you may have more. The module will use one of the databases loaded in OxMetrics.

The first step is to select a model category, and for the category a model type. The images at the top allow you to see the choices for all available modules, or to restrict it to a specific module. In your case, it is likely that Module is set to all (if not, click on the OxMetrics item for All, or on PcGive).

Change the Category to financial data and the model to GARCH.

gwmoduc8

gwmoduc9

5.4.1 Formulate a model

Click on the large Formulate button, to see the standard formulation dialog. On the right-hand side is the list with the database content, while the box on the left, empty as yet, is for the model.

This dialog is used by most modules to formulate the linear part of the model. Other actions that can be taken are:

Double click on the DLDOWJONES variable:

gwmoduc10

Press on OK to set the GARCH model properties. There are quite a few options, but the default of a GARCH(1,1) model suffices:

gwmoduc11

The final step is the estimation period, where we can accept the default again:

gwmoduc12

Click on OK and the output appears in the results window. To end this section, click on the Test button:

gwmoduc13

Check Graphic analysis:

gwmoduc14

and accept the default choice. The figure is as in Figure Figure:5.2. Note that in the middle panel (the standardized residuals), we zoomed in on the crash and changed the style to index lines. It is quite likely that this large outlier affects the quality of this model (, and , ).

dowjonesmodel

Figure:5.2 GARCH(1,1) model for Dow Jones returns

5.5 TSP

TSPtm is a complete language for the estimation and simulation of econometric models. It works in two modes:

Both modes can be used in OxMetrics. As an example, we start by entering a small program interactively, which is then saved an run in batch mode.

5.5.1 TSP in interactive mode

Start TSP from the Modules menu:

gwmoduc15

This starts the TSP launcher, which allows for the selection of a default working folder (here still shown in its OxMetrics 5 implementation): gwmoduc16
Press the Start TSP Session button to start:

If there is a database open in OxMetrics, TSP will offer to load it. Press N to skip. If you press enter you may see (here we accepted loading AIRLINE.in7):

    Read OxMetrics database "AIRLINE.IN7"? [Yes]/No/All/nOne
    
    Current sample:  1949:1 to 1960:12
    *** NOTE:  If you update or open new OxMetrics databases,
     use the RELOAD command to read them into TSP.
    
    Enter TSP statements:
      1 ?

Otherwise you'll be taken directly to the TSP prompt.

Then enter the commands given in bold below, pressing the Enter key at the end of every command line.

Make sure there is no database loaded, if necessary use the Clear command to start from scratch.

Enter TSP statements:
1 ? smpl 1 100
2 ? random eps
3 ? random(uniform) x
4 ? y = 1 + 2 * x + eps
5 ? graph y x
6 ? olsq y c x

These commands set the frequency to annual, the sample to 1--100, generate a variable eps from the standard normal distribution, and x from the uniform distribution. Then y is created as a linear combination of these. The graph command creates a scatter plot with x on the horizontal axis, and y on the vertical axis. The final command regresses y on a constant and x.

Afterwards, the screen could look like the capture shown below.

gwmoduc17

The following may be noticed:

A command wizard assists in formulating TSP commands. For example, type olsq at the command prompt, and press Ctrl+W (or click on the wizard icon):

gwmoduc18

A useful feature is that commands can be sent to TSP (the active module) from any window, by selecting the block of text, and typing Ctrl+I. As an example, try the following: type plot @res in the Results window, then select it and press Ctrl+I. The TSP Plot window will pop up to show the residuals from the regression. (If the TSP Plot window is hidden behind another window, you can locate it through the Windows menu.)

Finally, type quit to stop the interactive session.

5.5.2 TSP Help

TSP Help is available from the OxMetrics Help menu

5.5.3 TSP in batch mode

It is possible to create a TSP input file from an interactive session. The easiest way is as follows:

  1. Active the TSP Session window, right-click in the window and select Copy Commands. This copies all commands you entered to the clipboard (with a maximum of 50). This option is available even after the interactive session has terminated.
  2. Create a new text window using File/New/TSP, and paste the text into that window.
  3. Add semicolons at the end of each line.
  4. Use File/Save As to save the file as a .tsp file, e.g. tutreg.tsp.

With comments added, the file could be:

smpl 1 100; ? Specify the range of data as 1-100. random eps; ? Standard normal disturbances. random(uniform) x; ? Uniform x. y = 1 + 2 * x + eps; ? Generate y. graph y x; ? Cross plot of x and y. olsq y c x; ? Regress y on x and a constant.

Now, when tutreg.tsp as the active window, the file can be run directly using one of the following:

All are equivalent, and will create a window entitled tuttsp.out for the text output, as well as a TSP Graph window.

5.5.4 Explorer options

When clicking the right mouse button on a TSP file in the Windows Explorer, there are two related options on the context menu: