Getting Started with OxMetrics

This document corresponds to Chapters 2 and 3 of the OxMetrics book.
Table of contents
Return to OxMetrics Help

2 Getting Started
  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 OxMetrics Modules
  3.1 OxMetrics Modules
  3.2 Financial data
  3.3 Weekly and daily data
  3.4 PcGive
  3.4.1 Formulate a model
List of figures
  Figure:2.1 Time plot of CONS and INC
  Figure:2.2 Multiple graphs
  Figure:3.1 Dow Jones returns, ACF of returns, ACF of squared returns
  Figure:3.2 GARCH(1,1) model for Dow Jones returns

Chapter 2 Getting Started

gwtstac1

This second chapter discusses some of the basic skills required to get started with OxMetrics. Since OxMetrics provides the data which other modules analyze, and receives all the text output and graphics which you create in (say) TSP, 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 (more likely, the second toolbar will appear on the right of the first toolbar --- here we had to make the window quite small).

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 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\OxMetrics5\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 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). OxMetrics can handle a wide range of data files, among them Excel (.xls worksheet or workbook) 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. The name of the currently active database (more than one database can be loaded) is shown in the the toolbar:

gwtstac4

If more than one database is loaded, this toolbar 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 documentation of the variable. 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 Shift+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

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.

gwtstaf1

Figure:2.1 Time plot of CONS and INC

gwtstac8

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.

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 above.

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 (further explanation is in Chapter ??).

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.

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

gwtstaf2

Figure:2.2 Multiple graphs

The result is in Fig. Figure:2.2. The editing possibilities are manifold: Chapter ?? provides a detailed discussion, but you can always play around with graphs at your leisure.

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 click 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. Press on the Calculator button leading to the capture shown below (or via the Model menu and Calculator choice).

gwtstaca

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). 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.

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 (Shift+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.

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 ??.

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. 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 folder item (Data, Graphics, Code, or Text) gives a context menu. For data it is:

gwtstacf

while right clicking on the document name gives:

gwtstacg

Chapter 3 OxMetrics Modules

3.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.

3.2 Financial data

Load the dowjones.xls data set from the OxMetrics5\data folder. The DOWJONES variable holds the weekly Dow--Jones index (Dow Jones Industrial Average): close at midweek from Janary 1980 to September 1994, 770 observations in total.

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

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

The outcomes are given in the top panel of Figure Figure:3.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.

dowjones

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

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:

gwmoduc2

The outcomes are in the second panel of top panel of Figure Figure:3.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:3.1 (remember to reset the transformation back to none). This plot suggests that there is indeed some persistence in volatility.

3.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.

3.4 PcGive

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

Once started, the databases loaded in OxMetrics are also accessible from PcGive.

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.

gwmoduc8

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:

gwmoduc9

3.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. Double click on the DLDOWJONES variable:

gwmoduc10

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

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:3.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 (, ).

dowjonesmodel

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