Oxmetrics Manual
Oxmetrics Manual
Doornik
An Introduction to
OxMetricsTM 7
OxMetrics 7
Published by Timberlake Consultants Ltd
www.timberlake.co.uk
www.timberlake-consultancy.com
www.oxmetrics.net, www.doornik.com
An Introduction to OxMetricsTM 7
A Software System for Data Analysis and Forecasting
c
Copyright
2013
Jurgen A Doornik
First published by Timberlake Consultants in 2005
Revised in 2007, 2009, 2013
All rights reserved. No part of this work, which is copyrighted, may be reproduced
or used in any form or by any means graphic, electronic, or mechanical, including
photocopy, record taping, or information storage and retrieval systems without the
written consent of the Publisher, except in accordance with the provisions of the
Copyright Designs and Patents Act 1988.
Whilst the Publisher has taken all reasonable care in the preparation of this book, the
Publisher makes no representation, express or implied, with regard to the accuracy
of the information contained in this book and cannot accept any legal responsability
or liability for any errors or omissions from the book, or from the software, or the
consequences thereof.
Published by
Timberlake Consultants Ltd
Unit B3, Broomsleigh Business Park
London SE26 5BN, UK
http://www.timberlake.co.uk
Trademark notice
All Companies and products referred to in this book are either trademarks or registered trademarks of their associated Companies.
Contents
Front matter
iii
Contents
List of Figures
xiii
List of Tables
xv
Preface
1
xvii
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3
3
4
4
5
5
5
5
6
6
6
7
7
7
8
8
8
9
10
11
12
12
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
vi
CONTENTS
2.3
2.4
2.5
2.6
2.7
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 . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
13
16
16
19
21
21
22
24
25
.
.
.
.
.
.
.
.
.
.
.
28
29
30
30
34
34
36
38
38
39
41
43
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
45
46
47
47
51
51
55
56
57
57
60
62
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 .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
64
64
64
67
68
69
73
73
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
vii
CONTENTS
5.5.2
5.5.3
5.5.4
6
TSP Help . . . . . . . . . . . . . . . . . . . . . . . . .
TSP in batch mode . . . . . . . . . . . . . . . . . . . .
Explorer options . . . . . . . . . . . . . . . . . . . . . .
75
76
76
Tutorial on Graphics
6.1
Descriptive graphics . . . . . . . . . . . . . . . . .
6.2
Actual series with optional transformations . . . . .
6.3
Multiple series with optional transformations . . . .
6.4
Scatter plots . . . . . . . . . . . . . . . . . . . . . .
6.5
Distribution . . . . . . . . . . . . . . . . . . . . . .
6.5.1
Density estimation: Histogram and density .
6.5.2
Distribution . . . . . . . . . . . . . . . . .
6.5.3
Frequencies . . . . . . . . . . . . . . . . .
6.5.4
Box plot . . . . . . . . . . . . . . . . . . .
6.6
Time-series: ACF etc. . . . . . . . . . . . . . . . .
6.6.1
Autocorrelation function or correlogram . .
6.6.2
Partial autocorrelation function (PACF) . .
6.6.3
Cross-correlation function . . . . . . . . .
6.6.4
Spectrum and periodogram . . . . . . . . .
6.7
QQ plots . . . . . . . . . . . . . . . . . . . . . . .
6.8
Two series by a third . . . . . . . . . . . . . . . . .
6.9
3-dimensional plots . . . . . . . . . . . . . . . . . .
6.9.1
Surface from scatter . . . . . . . . . . . . .
6.9.2
Surface from table . . . . . . . . . . . . . .
6.10 Conclusions . . . . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
79
79
82
84
84
87
87
87
89
89
90
90
91
91
91
92
94
96
96
98
99
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
100
100
100
102
102
102
103
103
107
108
109
110
110
111
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
viii
8
CONTENTS
Tutorial on Data Input and Output
8.1
Open Data File and file types . . . . . . . . . . . . . . . .
8.2
From paper to OxMetrics . . . . . . . . . . . . . . . . . .
8.2.1
Directly into the database . . . . . . . . . . . . .
8.2.2
Using the clipboard; using OxMetrics as editor .
8.3
From OxMetrics to disk . . . . . . . . . . . . . . . . . .
8.4
From disk to OxMetrics . . . . . . . . . . . . . . . . . .
8.4.1
Loading OxMetrics files . . . . . . . . . . . . .
8.4.2
Loading spreadsheet files . . . . . . . . . . . . .
8.4.3
Loading a human-readable (text) file . . . . . . .
8.5
Adding variables using the clipboard . . . . . . . . . . . .
8.6
Changing the sample period . . . . . . . . . . . . . . . .
8.6.1
Extending the sample period . . . . . . . . . . .
8.6.2
Reset starting date . . . . . . . . . . . . . . . . .
8.7
Appending data . . . . . . . . . . . . . . . . . . . . . . .
8.8
Working with daily and weekly data . . . . . . . . . . . .
8.8.1
Using Change Sample to create a daily database .
8.8.2
Using Algebra to create a daily database . . . . .
8.9
Working with choice variables . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
113
114
114
114
117
119
119
119
119
120
120
121
121
121
121
122
123
124
125
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
128
128
130
130
130
130
133
135
137
10 OxMetrics Statistics
10.1 Actual series and scatter plots . . . . . . . . .
10.2 Mean, standard deviation and variance . . . . .
10.3 Autocorrelation function (ACF) or covariogram
10.4 Partial autocorrelation function (PACF) . . . .
10.5 Correlogram . . . . . . . . . . . . . . . . . .
10.6 Cross-correlation function (CCF) . . . . . . .
10.7 Periodogram . . . . . . . . . . . . . . . . . .
10.8 Spectral density . . . . . . . . . . . . . . . . .
10.9 Histogram, estimated density and distribution .
10.10 Regression lines and smooths . . . . . . . . .
10.10.1 Kernel smooth . . . . . . . . . . . . .
10.10.2 Spline smooth . . . . . . . . . . . . .
10.11 QQ plot . . . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
141
141
141
142
142
142
143
143
144
144
145
146
147
148
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
ix
CONTENTS
10.12 Box plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.13 Exponentially-weighted moving average (EWMA) . . . . . . . .
10.14 Exponentially-weighted moving correlation . . . . . . . . . . . .
149
149
149
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
151
151
151
153
154
154
154
154
157
158
158
159
159
160
160
160
160
160
160
161
161
161
163
163
165
166
166
12 Algebra Language
12.1 Introduction . . . . . . . . . . . . . . . . . . . .
12.2 Executing Algebra code . . . . . . . . . . . . .
12.2.1 Calculator (Alt+c) . . . . . . . . . . . .
12.2.2 Algebra Editor (Alt+a) . . . . . . . . .
12.2.3 Algebra from Results windows (Ctrl+a)
12.2.4 Algebra from a Batch file . . . . . . . .
12.3 Syntax of Algebra language . . . . . . . . . . .
12.3.1 Variables and variable names . . . . . .
12.3.2 Comment . . . . . . . . . . . . . . . .
12.3.3 Constants . . . . . . . . . . . . . . . .
12.3.4 Algebra operators . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
167
167
167
167
168
168
168
168
168
168
169
169
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
CONTENTS
12.3.4.1 Arithmetic operators . . . . . . . . . . . . . .
12.3.4.2 Relational and logical operators . . . . . . . .
12.3.4.3 Algebra operator precedence . . . . . . . . . .
12.3.5 Assignment statements . . . . . . . . . . . . . . . . . .
12.3.6 Conditional assignment statements . . . . . . . . . . . .
12.3.7 Indexing . . . . . . . . . . . . . . . . . . . . . . . . . .
12.3.8 Keywords . . . . . . . . . . . . . . . . . . . . . . . . .
Algebra implementation . . . . . . . . . . . . . . . . . . . . . .
Algebra Functions . . . . . . . . . . . . . . . . . . . . . . . . .
12.5.1 Differencing and lag functions . . . . . . . . . . . . . .
12.5.2 ACF and periodogram functions . . . . . . . . . . . . .
12.5.3 Sorting functions . . . . . . . . . . . . . . . . . . . . .
12.5.4 Smoothing functions . . . . . . . . . . . . . . . . . . .
12.5.4.1 HodrickPrescott filter . . . . . . . . . . . . .
12.5.4.2 Kernel and spline smoothing . . . . . . . . . .
12.5.4.3 Exponentially-weighted moving average and correlation . . . . . . . . . . . . . . . . . . . . .
12.5.4.4 Date and time functions . . . . . . . . . . . .
Algebra function summary . . . . . . . . . . . . . . . . . . . . .
169
169
169
169
170
171
171
172
173
173
173
174
175
175
175
13 Batch Language
13.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.2 Executing Batch commands . . . . . . . . . . . . . . . . . . . .
13.2.1 Batch Editor (Alt+b) . . . . . . . . . . . . . . . . . . .
13.2.2 Batch from Results windows (Ctrl+b) . . . . . . . . . .
13.2.3 Batch from the File/Open command . . . . . . . . . . .
13.2.4 Batch from the Windows Explorer . . . . . . . . . . . .
13.2.5 Batch from a Batch file . . . . . . . . . . . . . . . . . .
13.3 Batch files and default folders . . . . . . . . . . . . . . . . . . .
13.4 General Batch command summary . . . . . . . . . . . . . . . . .
13.4.1 Comment . . . . . . . . . . . . . . . . . . . . . . . . .
13.4.2 Command types . . . . . . . . . . . . . . . . . . . . . .
13.4.3 Default arguments . . . . . . . . . . . . . . . . . . . . .
13.5 Batch commands . . . . . . . . . . . . . . . . . . . . . . . . . .
13.5.1 algebra { . . . } . . . . . . . . . . . . . . . . . . . . . .
13.5.2 appenddata("filename", "group"=""); . . . . . . . . .
13.5.3 appresults("filename"); . . . . . . . . . . . . . . . .
13.5.4 break; . . . . . . . . . . . . . . . . . . . . . . . . . .
13.5.5 chdir("path"); . . . . . . . . . . . . . . . . . . . . . .
13.5.6 closedata("databasename"); . . . . . . . . . . . . . .
13.5.7 command("command line"); . . . . . . . . . . . . . . .
13.5.8 database("name", year1, period1, year2, period2, freq);
13.5.9 draw(area, "y", "mode"=""); . . . . . . . . . . . . .
13.5.10 drawf(area, "y", "function", d1=0, d2=0); . . . . . .
180
180
180
180
180
181
181
181
181
181
181
181
182
182
183
183
183
183
183
183
184
184
184
184
12.4
12.5
12.6
176
176
177
xi
CONTENTS
13.6
14 OxMetrics Graphics
14.1 Graphics paper . . . . . . . . . . . . . . . . . . . . .
14.2 Creating graphs . . . . . . . . . . . . . . . . . . . . .
14.2.1 Actual series with optional transformations .
14.2.2 Multiple series with optional transformations
14.2.3 Scatter plots . . . . . . . . . . . . . . . . . .
14.2.4 Distribution . . . . . . . . . . . . . . . . . .
14.2.5 Time-series: ACF etc. . . . . . . . . . . . . .
14.2.6 QQ plots . . . . . . . . . . . . . . . . . . . .
14.2.7 Two series by a third . . . . . . . . . . . . .
14.2.8 3-dimensional plots . . . . . . . . . . . . . .
14.3 Printing graphs . . . . . . . . . . . . . . . . . . . . .
14.4 Graphics formats . . . . . . . . . . . . . . . . . . . .
14.5 Saving and loading graphs . . . . . . . . . . . . . . .
14.6 Editing graphs . . . . . . . . . . . . . . . . . . . . .
14.6.1 Graph layout . . . . . . . . . . . . . . . . .
14.6.2 Area layout . . . . . . . . . . . . . . . . . .
14.6.3 Variable against time, scatter, or 3D . . . . .
14.6.3.1 Error bars . . . . . . . . . . . . . .
14.6.3.2 Regression, Scale . . . . . . . . . .
14.6.4 Axes . . . . . . . . . . . . . . . . . . . . . .
14.6.4.1 Settings for non-default labelling .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
185
185
185
186
186
186
186
186
186
186
186
186
187
187
187
187
187
188
188
189
189
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
192
192
193
193
194
194
194
195
195
196
196
197
197
198
198
198
199
199
200
200
201
201
xii
CONTENTS
14.7
14.8
14.9
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
201
202
202
202
203
203
203
203
203
203
204
204
204
204
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
207
207
207
207
207
208
208
208
208
209
209
209
209
209
210
210
210
210
References
213
Author Index
215
Subject Index
217
Figures
2.1
2.2
18
20
3.1
3.2
35
37
4.1
4.2
53
55
5.1
5.2
66
72
6.1
6.2
6.3
82
83
6.4
6.5
6.6
6.7
6.8
6.9
6.10
6.11
6.12
6.13
6.14
6.15
7.1
7.2
7.3
7.4
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
84
86
88
89
90
91
91
92
93
95
95
97
99
101
106
109
111
xiv
LIST OF FIGURES
8.1
117
9.1
9.2
9.3
9.4
9.5
9.6
9.7
9.8
.
.
.
.
.
.
.
.
132
133
134
134
135
136
137
138
11.1
A simple graph . . . . . . . . . . . . . . . . . . . . . . . . . . .
162
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Tables
8.1
113
11.1
151
12.1
12.2
12.3
170
172
178
13.1
182
14.1
14.2
14.3
14.4
14.5
14.6
14.7
14.8
Greek symbols . . . . . . . . .
Arrows . . . . . . . . . . . . .
Mathematics accents . . . . . .
Foreign and accented characters
Mathematical symbols . . . . .
Log-like symbols . . . . . . . .
Miscellaneous symbols . . . . .
Fonts and sizes . . . . . . . . .
205
205
205
205
206
206
206
206
xv
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Preface
The OxMetrics front-end binds all the components of the OxMetrics system together.
Versions 7 and 6 follows on from version 5. Version 5 in turn was a thorough rewrite of
its predecessor, GiveWin 2. wxWidgets is used for the interface implementation from
version 4 onwards. This makes it possible for all the interactive software to be available
on Linux and Mac OS-X, as well as Windows. OxMetrics also uses Unicode, thus
supporting most languages. As a consequence Windows NT, 9x and ME are no longer
supported.
OxMetrics builds on many of GiveWins achievements, such as the complete separation of the front-end (for data manipulation and visualization) and the econometric
and statistical modules. However the current version presents a better integrated system
to the user, while maintaining the benefits of being able to develop the many components separately.
Ox, an object-oriented matrix programming language, is one of the modules which
can interface with the OxMetrics front-end. Indeed, almost all modules (such as PcGive) now do their computations in Ox, rather than in lower level C or C++. In many
cases, OxMetrics now also offers to generate Ox code, as a more flexible alternative to
Batch code.
Although OxMetrics 6 represents a new generation, it builds on earlier versions of
GiveWin and PcGive, and we wish to reiterate our thanks to all those who have helped
in its development.
OxMetrics
xvii
Chapter 1
Introduction and Overview
The OxMetricstm system presents an interactive menu-driven graphics-oriented system for econometric, statistic, and financial analysis. Here we describe the core OxMetrics program, which acts as the front-end to a series of integrated software modules. These modules obtain their data from OxMetrics and return output and graphics
to it. OxMetrics is the component that allows you to load, edit, and save data; transform
that data using the calculator or algebra; create a wide variety of graphs, which can be
edited, amended and saved in various formats; provide the data for other modules to
analyze; receive their text output, results, and graphics; and lets you edit, amend, and
save any or all of these as desired. As such, the OxMetrics front-end can be seen as the
desktop for econometric and statistical modelling.
OxMetrics databases can have a fixed frequency, or dated, which allows for daily
or timed data. Aggregation facilities are provided, e.g. to convert daily data into
monthly. OxMetrics is multilingual, in that names of database variables and text in
reports and graphics can be from a wide range of languages, including Chinese and
Japanese.
This introductory chapter notes the OxMetrics languages (Algebra and Batch), describes the Help system, notes the data storage format and how results (both text and
graphics) are saved, including a brief explanation of the various filenames and extensions used. Finally it explains the conventions of the documentation. The Ox language
is treated in separate books.
1.1
Supported platforms
Linux
Installation is to /usr/share/OxMetrics7/.
A separate installation document describes the supported platforms in more detail,
and shows how to install the software.
OxMetrics 7 operates independently from version 6.
1.1.1
Folder structure
1.2
What is new?
This documentation refers to OxMetrics 7. OxMetrics 6 users will find much that is
familar. There are a number of small fixes in this version, which are documented on the
online help.
The most important new features in OxMetrics 6 are:
Output handling is faster under Linux, and very much faster under OS X.
Normal QQ plots can now include pointwise asymptotic 95% standard error bands,
as derived in Engler and Nielsen (2009). See Figure 6.11 for an example.
A variable can be used to add Shading to a graph: shading is switched on when the
variable has value 1. This allows for recession shading, and is used in particular for
the output from regime-switching models. See Figure 6.2 for an example.
Legends can be transparent or not. Transparent legends are not transparent to shading or separate symbols. Opaque legends are drawn on top of everything else.
Added context menu (graph, sort, ...) when right-clicking on the variable name in a
database.
1.3 Availability
1.3
Availability
1.4
Citation
To facilitate replication and validation of empirical findings, the module used to generate the results should be cited in all reports and publications involving its application.
1.5
Help
1.6
Modular structure
OxMetrics maintains the modular structure that was introduced in previous generations
of the software. An increasing number of modules interacts with OxMetrics. In that
case, the OxMetrics front-end is the server, while the modules (TSP, STAMP, etc.)
are the clients. The communication is implemented via DDE.
While it is possible to write clients that interface directly with the server (such as
TSP, OxPack, and OxRun), it is much easier to develop Ox packages which do this. This
requires the use of the Modelbase class, which provides the necessary functionality.
Examples of this are PcGets, PcGive, G@rch, etc.
1.7
Registration
A licensing code is required for the software to work properly. This code will have been
supplied with your copy, and, under normal circumstances, the licence that is entered
during installation is automatically used by the software.
Additional licences can be entered under the Help/Registration menu option (a dialog will automatically appear when OxMetrics is not registered). In the subsequent
dialog you can enter your code as well as your name and affiliation. Help/Registration
can be also used to check the available licences for using client modules.
1.8
Upgrades
1.9
Algebra
The Algebra language enables you to transform database variables by writing mathematical formulae. Algebra code can be written interactively in the Calculator, or directly in the Algebra editor. Such algebra code can be saved, reloaded, and edited.
The Calculator writes its operations as algebra code to the Results window, from
where it can be cut and pasted into the algebra editor. Algebra can also be run directly
from the results window, by highlighting the block of algebra code, and then pressing
Ctrl+A.
Algebra is a simple vector language, operating on the variables in the database. The
operation is applied to each observation in turn, although it is possible to limit access to
a subsample. The syntax is described in Chapter 12.
1.10 Batch
1.10
Batch
OxMetrics is a menu-driven program for ease of use, but some operations can be implemented by entering commands. These commands are parts of simple computer
language which allow some control of OxMetrics through Batch operations. A Batch
program may contain sections of Algebra code.
Batch files allow you to load data, append results, implement algebra and save current PcGive (or STAMP etc.) models. Later, these can be run from the Model/Batch
menu or by clicking on the OxMetrics icon on the toolbar. Thus, when a complicated
model has been created interactively, it can be saved as a batch file for further editing,
or easy recall in a later session. This is also the most convenient way to create a batch
file. Like Algebra, batch code can be run directly by highlighting the block of text, and
then pressing Ctrl+B.
Once saved to disk, a batch file can also be run directly using File/Open, or even
by double clicking on the batch file in the Windows Explorer. Batch files have the
.fl extension, which originally stood for Fiml Language. The syntax is described in
Chapter 13.
1.11
Data storage
The primary mode of data storage is a pair of files with extensions .in7 and .bn7. The
latter is a binary file containing the actual data, whereas the former holds the information on the contents of the binary file such as variable names, sample periods, frequencies etc. The information file is a human-readable file, the .bn7 is binary and is not
human-readable. One artificial data set is supplied in the OxMetrics7\data folder, in
the files called data.in7 and data.bn7. The tutorials use this data set. If you want to
load your own data, you must begin by inputting the observations; however, follow the
relevant tutorial first.
OxMetrics checks for potential overwriting of files and if such is likely to occur,
allows selecting another file name. The data options facilitate easy archiving of data.
Please be careful not to overwrite precious data sets. It is always wise to make regular
backups of important files: hard disks may break down, accidental deletion occur or
viruses could strike.
OxMetrics can read and write human-readable files and Excel spreadsheet files.
OxMetrics can also read comma-separated, GAUSS and Stata files. See Chapter 11 for
detailed lists on the file formats supported by OxMetrics.
1.12
All file names have automatic default extensions which need not be input: a detailed
discussion is provided in Chapter 11. Say the basic data set is called m1ukq, then the
information file might be m1ukq.in7, the associated binary file (of actual data) will
be m1ukq.bn7, the OxMetrics Results window storage file could be m1ukq.out, the
algebra storage file m1ukq.alg, and batch files m1ukq.fl. A human-readable base
data file generally uses the .dat extension. Graph files allow saving in encapsulated
PostScript (.eps), PDF (.pdf), PostScript (.ps), Windows metafiles (.wmf), enhanced
metafiles (.emf), and OxMetrics graphics (.gwg, for GiveWin graphics), of which the
last can be re-read by OxMetrics for further editing.
Note that by default Windows does not show the file extension in the Explorer window only the icon shows what the file type is. If you wish, you can switch the display
of file extensions on in the Folder Options entry in the Explorer.
1.13
Output storage
All text output are shown in the Results window as calculations proceed but are not
stored on disk or diskette unless specifically requested. On long runs, a large amount
of information can be generated. This can be edited to eliminate redundant records: the
Edit menu allows copying, cutting and pasting, deleting, finding and replacing.
The storage facility allows rapid interactive modelling to proceed while any useful
results can be printed as a batch job when the computer is otherwise idle.
Since much of the output is graphical, graphs can be easily edited. Graphs can be
saved in a variety of formats as noted in the next section.
1.14
Sample periods
For data samples, reference is by the absolute date in the form Year(Period) to
Year(Period), for example: 1965(1) to 1985(3). Whenever a sample choice has to be
made, OxMetrics will show the maximum available and will not allow choices outside
that range.
When the data is dated, for example consisting of daily data, the choice is made
by entering dates in ISO format of yyyy-mm-dd. The year is always four digits, the
month one or two digits (1=January) and the date also one or two digits. For example:
1965-1-31 to 1985-9-5.
Time is written as hh:mm:ss.uuu where hour is two digits on the 24-hour clock
(so 22:00 is 10 PM), mm is minutes, the seconds and hundreds are optional. When
combined with a date, the ISO standard uses a T to glue the parts together: 1980-11T12:05:05.
1.15
Status bar
The status bar is displayed at the bottom of the OxMetrics window and consists of four
areas:
1. The left area of the status bar describes actions of menu items as you use the arrow
keys to navigate through menus. This area similarly shows messages that describe
the actions of toolbar buttons as you depress them, before releasing them. If after
viewing the description of the toolbar button command you wish not to execute the
command, then release the mouse button while the pointer is off the toolbar button.
2. If a tool is running, this is indicated on a yellow background in the second panel.
3. The third panel shows the location of the current document. The content is different
for text, data and graphics.
For text it is the position in the document of the caret.
For example: L 113 C 14 indicates that the caret is at Line 113, Column 14. In
binary/hexadecimal viewing mode this shows the position of the caret in decimal
(the first character of the document is at byte 0). This field will also indicate if
the document is read-only, or when the editor is in overwrite mode.
For data it is the position in the database of the caret. If there is an active
selection, it shows the selected variables.
For graphics it is the X coordinate of the mouse cursor.
4. The right area of the status bar also depends on the document type:
For text it indicates the document encoding properties:
End-of-line marker
One of: Win, Lnx, Mac for Windows (\r\n), Linux (\n) or Mac (\r).
Multilingual file format
If the file format is different from the default (ASCII) encoding, this is indicated by one of UTF8, UTF16, or UTF32. The can be followed by BE or
LE to indicated big-endian or little-endian encoding.
These properties can be changed using Edit/Text properties.
For data it is the value of the observation which has the caret. If there is an
active selection, it shows the selected sample.
For graphics it is the Y coordinate of the mouse cursor.
1.16
Tool bars
Three tool bars are displayed across the top of OxMetrics, below the menu bar. The tool
bars can be customized from a right click on the bar. Customization allows adding or
removing icons, and choosing small medium or large icon size (medium is the default).
The Find/Replace tool bar, by default on the second row, replicates most commands
of the Find/Replace dialog. The two are actively linked, and the Find/Replace bar is
often a convenient way to quickly search for text or execute search/replace actions. The
default layout consists of:
Find text Specify the text to search for. The drop down list box holds previously used
search texts. You can use a context menu (right click) to insert text from the clipboard.
Find down Finds the next occurrence of the search text downwards from the current
location of the caret.
Find up Finds the next occurrence of the search text upwards from the current location
of the caret.
10
Case sensitive Toggle case sensitive searching on or off (if the button is down, the
search is case sensitive).
Whole word Toggle word matching on or off (if the button is down, the search will only
find whole words).
Goto next instance Finds the next instance of the currently selected text downwards
from the current location. The selected text will become the default for subsequent
searches.
Goto previous instance Finds the previous instance of the currently selected text upwards from the current location. The selected text will become the default for subsequent searches.
Show Find dialog Open the Find dialog.
Show Replace dialog Open the Find/Replace dialog.
Find in Files Open a dialog that allows searching for text strings in disk files.
1.17
Documentation conventions
The convention for instructions that you should type is that they are shown in
Typewriter font. Capitals and lower case are only distinguished as the names of
variables in the program and the mathematical formulae you type. Once OxMetrics
has started, then from the keyboard, the Alt key accesses line menus (at the top of the
screen); from a mouse, click on the item to be selected using the left button. Common
commands have a shortcut on the toolbar, the purpose of which can be ascertained by
placing the mouse on the relevant icon. Icons that can currently operate are highlighted.
Commands on menus, toolbar buttons, and dialog items (buttons, checkboxes etc.) are
shown in the text in a Sans Serif font.
We assume that you have the basic skills to operate programs under the Windows
operating system. Generally, we assume a mouse is used for operations: substitute
Alt+key otherwise.
Equations are numbered as (chapter.number); for example, (8.1) refers to equation
8.1, which is the first equation in Chapter 8. References to sections have the form
chapter.section, for example, 8.1 is Section 8.1 in Chapter 8. Tables and Figures are
shown as Figure chapter.number such as Figure 5.2 for the second figure in Chapter 5.
Multiple graphs are numbered from left to right and top to bottom, so b is the top-right
graph of four, and c the bottom left.
Chapter 2
Getting Started: Windows
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!
11
12
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 13 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
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.
13
We trust that you use a legal copy of OxMetrics and client modules. That will allow
us to keep developing the programs.
2.3
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:
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:
By default, all files are displayed, but you can refine the files listed from the Files of
14
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:
If more than one database is open, this toolbar box can be used to switch active database:
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:
15
On the bottom right of the OxMetrics window, in the status bar, the observation
under the cursor is shown with full accuracy:
Double clicking on the variable name shows the name and documentation of the
variable, both of which can be changed. For the CONS variable:
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).
16
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:
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:
17
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:
single click to select one variable;
hold the Ctrl key down and click to select additional variables;
hold the Shift key down and click to extend the selection range.
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:
Press Actual series. Now the graph appears, which looks very much like Figure 2.1.
The only difference is the position of the legend. You can pick that up with the mouse,
18
CONS
INC
900
890
880
870
860
1955
1960
1965
Figure 2.1
1970
1975
1980
1985
1990
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:
19
Alternatively, choose Graphics from the Model/Preferences menu, and activate Box
all areas:
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 14).
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.
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:
20
CONS
INC
900
880
860
1955
900
1960
1965
1970
1975
1980
1985
1990
CONS INC
890
880
870
860
870
875
880
885
Figure 2.2
890
895
900
905
910
Multiple graphs
The final result is in Figure 2.2. The editing possibilities are manifold: Chapter 7
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
21
will remove the graphics line again. Graph saving clears the undo/redo buffer, to avoid
excessive memory use.
2.4.3
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:
Enhanced metafile (.emf); These can easily be inserted into Microsoft Word or
newer using Insert/Picture/From File.
Encapsulated PostScript (.eps), which is the format used to produce all the graphs
in this book;
OxMetrics Graphics File (.gwg);
PostScript (.ps), this is like EPS, but defaulting to a full page print.
Portable Network Graphics (.png), which is a bitmap format that may be useful for
insertion in web pages;
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
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.1
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).
1
We use LATEX for our typesetting system, and save all graphs as .eps files.
22
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:
prefixes of D for differences, e.g. DCONS;
prefixes of L for logarithms, e.g. LCONS;
suffix n for n-period lags, e.g. CONS 1.
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).
The first transformation is to take the first difference of CONS. Click on the CONS
variable just to highlight it (dont double click), and then on the diff button, accept a lag
length of one, to see in the top part of the dialog:
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.
2.5 Calculator
23
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:
Delete a variable: select and press the button labelled Del, or the Delete key; you
will have to confirm the deletion as the variable is eliminated from the database.
Move variables: use the < or > button to move (groups of) variables up or down.
This changes the order in the database.
Rename a variable: select and press the Ren button; you will be prompted for a new
name.
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);
24
2.6
Algebra
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,
25
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 12.
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
26
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.
Right clicking on the document category (Data, Graphics, Code, or Text) gives a
context menu. For Data it is:
27
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
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
28
29
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
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 31 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.
30
3.2
Registering OxMetrics
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
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.
31
We shall load this tutorial data set here. Access the File menu in OxMetrics, and
choose Open:
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:
By default, all files are displayed, but you can refine the files listed from the Enable
pop-up list:
32
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:
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:
On the bottom right of the OxMetrics window, in the status bar, the observation
under the cursor is shown with full accuracy:
Double clicking on the variable name shows the name and documentation of the
variable, both of which can be changed. For the CONS variable:
33
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:
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):
34
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:
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:
single click to select one variable;
hold the Cmd key down and click to select additional variables;
hold the Shift key down and click to extend the selection range.
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 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.
35
910
CONS
INC
900
890
880
870
860
1955
1960
1965
Figure 3.1
1970
1975
1980
1985
1990
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 14).
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:
36
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.
37
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.
CONS
INC
900
880
860
1955
900
1960
1965
1970
1975
1980
1985
1990
CONS INC
890
880
870
860
870
875
880
885
Figure 3.2
890
895
900
905
910
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:
The final result is in Figure 3.2. The editing possibilities are manifold: Chapter 7
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
38
will remove the graphics line again. Graph saving clears the undo/redo buffer, to avoid
excessive memory use.
3.4.3
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):
Encapsulated PostScript (.eps), which is the vector format used to produce all the
graphs in this book;
OxMetrics Graphics File (.gwg);
PostScript (.ps), this is like EPS, but defaulting to a full page print.
Portable Network Graphics (.png), which is a bitmap format that may be useful for
insertion in web pages;
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
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:
Copy Metafile to Clipboard
This is a vector format, so better quality.
Copy Bitmap to Clipboard
This is a bitmap format, so does not scale as well.
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
3.5 Calculator
39
commands that were used to draw the graph, and thus scales well. The alternative is to
copy the bitmap to the clipboard.1
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).
In several cases OxMetrics will offer a default name for a newly created variable:
prefixes of D for differences, e.g. DCONS;
prefixes of L for logarithms, e.g. LCONS;
suffix n for n-period lags, e.g. CONS 1.
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 (dont double click), and then on the diff
button, accept a lag length of one, to see in the top part of the dialog:
1
We use LATEX for our typesetting system, and save all graphs as .eps files.
40
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: INCCONS. Double click on INC, click on the
minus button, and then double click on CONS. The expression now reads INCCONS,
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:
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:
Delete a variable: select and press the button labelled Del, or the Delete key; you
will have to confirm the deletion as the variable is eliminated from the database.
Move variables: use the < or > button to move (groups of) variables up or down.
This changes the order in the database.
3.6 Algebra
41
Rename a variable: select and press the Ren button; you will be prompted for a new
name.
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);
3.6
Algebra
42
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 12.
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
43
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:
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:
44
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
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.
45
46
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
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 48 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
47
Registering OxMetrics
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
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 indi-
48
cates 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:
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:
By default, all files are displayed, but you can refine the files listed from the All files
pop-up list:
49
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:
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:
On the bottom right of the OxMetrics window, in the status bar, the observation
under the cursor is shown with full accuracy:
Double clicking on the variable name shows the name and documentation of the
variable, both of which can be changed. For the CONS variable:
50
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:
The data can be manipulated, much like in a spreadsheet program. Pressing the left
51
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):
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:
single click to select one variable;
hold the Ctrl key down and click to select additional variables;
hold the Shift key down and click to extend the selection range.
52
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:
Press Actual series. Now the graph appears, which looks very much like Figure 4.1.
The only difference is the position of the legend. You can pick that up with the mouse,
53
910
CONS
INC
900
890
880
870
860
1955
1960
1965
Figure 4.1
1970
1975
1980
1985
1990
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 14).
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.
54
The second method will change the default for all future graphs that are made with
OxMetrics.
55
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.
CONS
INC
900
880
860
1955
900
1960
1965
1970
1975
1980
1985
1990
CONS INC
890
880
870
860
870
875
880
885
Figure 4.2
890
895
900
905
910
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:
56
The final result is in Figure 4.2. The editing possibilities are manifold: Chapter 7
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.
4.4.3
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):
Encapsulated PostScript (.eps), which is the vector format used to produce all the
graphs in this book;
OxMetrics Graphics File (.gwg);
PostScript (.ps), this is like EPS, but defaulting to a full page print.
Portable Network Graphics (.png), which is a bitmap format that may be useful for
insertion in web pages;
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
4.5 Calculator
57
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
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:
prefixes of D for differences, e.g. DCONS;
prefixes of L for logarithms, e.g. LCONS;
suffix n for n-period lags, e.g. CONS 1.
So can you guess what DLCONS 1 is likely to be?
58
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 (dont double click), and then on the diff
button, accept a lag length of one, to see in the top part of the dialog:
4.5 Calculator
59
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: INCCONS. Double click on INC, click on the
minus button, and then double click on CONS. The expression now reads INCCONS,
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:
Delete a variable: select and press the button labelled Del, or the Delete key; you
will have to confirm the deletion as the variable is eliminated from the database.
Move variables: use the < or > button to move (groups of) variables up or down.
This changes the order in the database.
Rename a variable: select and press the Ren button; you will be prompted for a new
name.
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:
60
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);
4.6
Algebra
4.6 Algebra
61
62
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 12.
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:
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:
63
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:
to receive the data for analysis;
to store the text output from the analysis;
to display the graphical output.
At the time of writing, the OxMetrics compatible modules include:
G@RCH (Laurent, 2013)
Ox Professional: OxRun and OxPack (Doornik, 2013)
PcGive (Hendry and Doornik, 2013), including PcNaive (Doornik and Hendry,
2013)
STAMP (Koopman, Harvey, Doornik, and Shephard, 2013)
TSP (Hall and Cummins, 2005)
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
The figures are for Wednesday, or Tuesday if the stock market was closed on Wednesday.
The data are from www.djindexes.com.
64
65
We are interested in the returns, log Yt log Yt1 , 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:
The outcomes are given in the top panel of 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 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 5.1 (remember to reset the transformation back to none).
This plot suggests that there is indeed some persistence in volatility.
66
DLDOWJONES
0.0
-0.1
1980
1
1982
1984
1986
1988
1990
1992
1994
ACF-DLDOWJONES
0
1
10
15
20
25
30
35
40
45
50
15
20
25
30
35
40
45
50
ACF-sqrReturns
Figure 5.1
10
5.3
67
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:
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:
the first column must be of type Date,
the first column holds date values (there are several Algebra functions to help creating these),
the optional fractional part of this indicates time,
the first and last observation must be valid, i.e. cannot be missing.
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.
68
5.4
PcGive
PcGive is an interactive program for dynamic econometric modelling. Like other interactive modelling packages, it can be started in three ways:
By clicking on the Model entry under Modules in the workspace on the left-hand
side:
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.
5.4 PcGive
5.4.1
69
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:
Change the default lag length when selecting. The choices are: lag 0 to a specified
lag, just the specified lag, or none.
Empty the entire model formulation by pressing Clear>>.
The box immediately below the database contains the so-called special variables.
These are made available even when not present in the database, and may be treated
in a special way.
Below that, still on the database side, is the option to change databases, if more than
one are open in OxMetrics. But the model only works on one database.
On the left-hand side, below the selection (the model formulation), is a drop-down
box to change the status of selected variables. It currently reads Use default status,
70
which means that variables are added to the model as such: the first addition to an
empty model is the dependent variable, the rest are regressors in the mean.
For the GARCH model there are three types:
Y the endogenous (dependent) variable, by default the first,
X regressor, the default for all other variables,
H a regressor that enters the conditional variance equation.
If another status is selected in the drop down box, that will be used for the added
variables instead of the default (but lagged variables can never be the dependent
variable).
To change status of variables that are already in the model: highlight the variables
in the selection box, choose a status, and press the Set button. Note that it is also
possible to change status by right-clicking on a variable.
Finally, the last drop-down box below the selection allows the recall of a previously
formulated model.
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:
5.4 PcGive
71
The final step is the estimation period, where we can accept the default again:
Click on OK and the output appears in the results window. To end this section, click
on the Test button:
72
and accept the default choice. The figure is as in 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
(Doornik and Ooms, 2008 and Doornik and Ooms, 2005).
DLDOWJONES
Fitted
1982
1984
0.0
-0.1
1980
2.5
1986
1988
1990
1992
1994
r:DLDOWJONES (scaled)
-2.5
1987-7
0.075
1982
1984
10
11
12
1988-1
CondSD
0.050
0.025
1980
Figure 5.2
1986
1988
1990
1992
1994
5.5 TSP
5.5
73
TSP
TSPtm is a complete language for the estimation and simulation of econometric models.
It works in two modes:
TSP Session Interactive mode
Commands are entered and executed directly.
TSP Batch mode
A complete program is executed.
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
This starts the TSP launcher, which allows for the selection of a default working folder
(here still shown in its OxMetrics 5 implementation):
1949:1 to 1960:12
74
5.5 TSP
75
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
76
5.5.3
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:
1
2
3
4
5
6
smpl 1 100;
random eps;
random(uniform) x;
y = 1 + 2 * x + eps;
graph y x;
olsq y c x;
?
?
?
?
?
?
Now, when tutreg.tsp as the active window, the file can be run directly using one of
the following:
Modules/Run Default Module,
Ctrl+R,
click on the Run button on the toolbar,
right click on the file name in the workspace, and select TSP.
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:
Open opens the TSP file in OxMetrics; this is the default action when double clicking on a TSP file.
Run runs the TSP file in OxMetrics.
OxMetrics Tutorials
Chapter 6
Tutorial on Graphics
This chapter discusses the various types of graphs which are available for (exploratory)
data analysis. Chapter 5 already gave some examples using weekly Dow Jones data;
Ch. 7 is mainly concerned with the mechanics of changing the appearance of graphs.
If youre not inside OxMetrics at the moment, restart and load the tutorial data set
data.in7/data.bn7. Note that recently loaded files are listed at on the File menu. Recent data files can also be accessed by right clicking on the Data folder in the workspace.
Create DCONS as the first difference of CONS, as shown in the Getting Started chapters
for your platform (the remaining screen captures are all made under Windows).
6.1
Descriptive graphics
79
80
Activate the Graphics choice on the Model menu, select CONS and DCONS, by
marking them in the Database list box (remember: to select two (or more) variables,
click on CONS, then hold the Ctrl key down and click on DCONS), then press the <<
button to move them into the selection list (the list on the left-hand side). The screen
capture is shown on the previous page.
Next press All plot types >. Select Actual series at the top, and at the left, and tick
the Create separate plots box on the right:
Then press Plot, to create the graph, and Cancel to exit the dialog. The output
should correspond to the top two graphs of Figure 6.1.
To add some graphs of the time-series properties, restart Graphics (note that CONS
and DCONS are still selected), press All plot types >, and choose Time-series properties as the graph type.
Click Next to choose both ACF for the sample autocorrelation function (or covariogram; you can also choose to plot the correlogram instead, which uses running means
and variances, see 10.5) and PACF for the partial autocorrelation function. You can
also change the length of the ACF and PACF if you wish. Tick both ACF and PACF. If
necessary, mark Create separate plots and set the lag length to 20:
Click on Plot, now selecting Distribution as the plot type. Mark Normal:
81
82
The options we used for each variable correspond to a time-plot showing its historical behaviour, a correlogram and partial correlogram which reflect its autocorrelation,
and a histogram, with estimated density and the normal distribution for reference to
evaluate the distributional shape. This generates six graphs in total: see Figure 6.1. A
detailed description of the formulae underlying these graphs is given in Chapter 10.
900
CONS
880
860
-5
1960
1970
1980
1990
1960
0
ACF-CONS
5
CONS
10
15
20
0
5
Density
0.2
N(s=13.5)
DCONS
1980
1990
15
20
PACF-DCONS
10
N(s=2.2)
0.1
0.02
850
860
870
880
Figure 6.1
6.2
1970
ACF-DCONS
PACF-CONS
Density
0.04
DCONS
890
900
910
-7.5
-5.0
-2.5
0.0
2.5
5.0
7.5
Plots the actual values of all selected variables against time (or the observation index
for undated series), together or each in a separate graph. If there are missing values,
these show up as gaps in the line.
Create separate Plots
This creates as many graphs as there are series.
Style
Lines
Symbols
Lines and symbols
Index line: plot first series as index
Index line and symbols: plot first series as index
Bars: plot all series as bars
Shading: use shading where this variable is 1, no shading otherwise
First as bar: plot only the first as bar chart
Transformation:
83
Next, starting from a new Data Plot window (closing the existing one first), select CONS
and INC in the Graphics dialog, and press Actual series. Then, right-click on the graph,
choosing Add Graph from the context menu (also see 7.9). This brings up the Graphics
dialog again, now with title Graphics - data.in7 - Add to area 1. Remove CONS and
INC from the selection, and add the just created recession variable. Next, click on All
plot types, select Actual series, and change the style to shading:
Click on Plot, then cancel the Graphics dialog. The shading is done in the next available
color, and a lighter would be better (see 7.7), see Figure 6.2.
CONS
recession
900
INC
875
1955
Figure 6.2
1960
1965
1970
1975
1980
1985
1990
84
6.3
Match series by
None: no matching is done
Mean & range matched to first series
Second series on right scale
Start = 100
Style: as above
Transformation: as above
Use log scale
You can try to replicate Figure 6.3 (make sure that Shading is changed back to
Line). The first graph shows that graphing INFLAT and OUTPUT together is not very
informative. To maximize the visual correlation between them, we can match the mean
and range of OUTPUT to that of INFLAT, as shown in the middle graph. This has the
same effect of plotting each on their own scale, also see 7.13.
1250
No matching
INFLAT
OUTPUT
INFLAT
OUTPUT
OUTPUT
1000
5.0
5.0
2.5
2.5
0.0
0.0
750
1200
500
250
1175
0
1960
Figure 6.3
6.4
1980
1960
1980
1960
1980
Scatter plots
85
If DINC is not yet in your database, create it as the first difference of INC, using
Algebra or the Calculator. Then click on the graph icon and select DCONS as the first
(Y ) and DINC as the second (X) variable, then on All plot types >, Scatter plots/Add
regression line, expanding the Regression section:
Mark With projections, and Reverse regression, as shown in the previous capture. Click
Finish to see the graph, shown in Figure 6.4a (we changed the symbols from the default
plus symbol to a box). It shows the lines of best fit, minimizing vertical squared deviations of points from the line for the normal regression, and horizontal for the reverse
regression. The steeper line corresponds to horizontal minimization: can you see
why? To check, double click on the graph and expand the Regression, Scale sections:
Remove the regression by setting the number of lines to zero. This just leaves
the reverse regression line. Click on Undo to restore the normal regression line, as in
Figure 6.4a below.
Return to the Scatter plot dialog, keep the selection of DCONS as Y and DINC as
X, but now select Add smoothed line. Deselect the regression options, and expand the
86
5.0
DCONS DINC
2.5
2.5
0.0
0.0
-2.5
-2.5
-5.0
Spline k=12.00
-5.0
-7.5
5.0
DCONS DINC
-5.0
-2.5
DCONS DINC
Spline k=12.00
0.0
2.5
5.0
7.5
-7.5
5.0
Kernel k=12.00
2.5
2.5
0.0
0.0
-2.5
-2.5
-5.0
-5.0
-2.5
DCONS DINC
Spline k=12.00
0.0
2.5
5.0
7.5
5.0
7.5
Kernel k=12.00
-5.0
-7.5
-5.0
-2.5
0.0
Figure 6.4
2.5
5.0
7.5
-7.5
-5.0
-2.5
0.0
2.5
Smoothing section:
Set the Bandwidth method to Parameters and create the plot as in Figure 6.4b.
The cubic spline is one of two ways of fitting smoothed lines that nevertheless
track the general movements in scatter plots; the other is Kernel smooth so draw
another plot withe both the ernel and spline smooths (Figure 6.4b).
These are actually quite close to a straight line. You can fit a straight line as well
for comparison, or be more enterprising as follows. Click on the scatter plot with both
kernel and spline lines (then shown by the fuzzy outline) and copy it to the clipboard
(two pages icon); next, click outside any graph area ensure that there is no selection,
6.5 Distribution
87
then paste to make a block of four graphs. Note that if an area is selected when pasting,
the paste will be added to the selected graph. Then add a regression line to this graph.
The direct comparison is clear: they are close approximations. And for all their wiggles, both are nearly straight lines. Setting the number of parameters to (say) 3 will
produce a fairly smooth fit.
All scatter plots involving the selected variables, each in a separate graph. If CONS,
INC, INFLAT and OUTPUT are marked, for example, the scatter plots are: CONS
on INC, on INFLAT and on OUTPUT; INC on INFLAT and OUTPUT; and finally
INFLAT on OUTPUT. If there are missing values, these are omitted from the graphs.
6.5
Distribution
6.5.1
The histogram is a simple graph: the range of xt is divided into intervals, and the
number of observations in each interval is counted. The height of each bar records the
number of entries in that interval. In OxMetrics, these are divided by the total number
of observations to show the relative frequency (use bar to keep the count). OxMetrics
sets a default number of intervals dependent on the sample size, but this can be changed
by the user by clicking on Smoothing and Use custom bar count to set a different
value.
The bimodal curved line in Figure 6.1 is a smoothed version of the histogram. Because we divided the histogram by T , the heights of the bars add up to unity. Correspondingly, the area underneath the smoothed histogram is unity, and the curve is called
a (non-parametric) density estimate. The familiar bell shape of the normal distribution is added for comparison. It is clear that CONS does not look very normal. DCONS
is much closer to a normal distribution: at least it is symmetric, but could still be too
narrow, or too wide (i.e., have excess kurtosis relative to the normal).
Tip If you want to test for normality, use Data/Descriptive Statistics in PcGive and
select the Normality option. Or regress on a constant in either PcGive or TSP, and
get the residual tests.
6.5.2
Distribution
Start with an empty Data Plot window, and return to Graphics, select CONS and
DCONS, and use the Destribution option, this time marking Distribution, Frequency
and Cumulative frequencies, and Box plot:
88
We obtain eight graphs for CONS and DCONS, as shown in Figure 6.5.
Distribution
40
30
20
10
CONS
900
850
850
CONS
860
870
880
890
900
950
150
850
860
CONS
870
880
890
900
900
100
850
50
10
5
0
-5
910
CONS
850
860
Distribution
-7.5
870
880
890
900
30
DCONS
DCONS
20
10
-5.0
DCONS
-2.5
0.0
2.5
5.0
150
-5.0
DCONS
-2.5
0.0
2.5
5.0
100
50
-5
-5.0
-2.5
Figure 6.5
0.0
2.5
5.0
Figure 6.5a shows the cumulative distribution of the variable, integrating the estimated density. The result is presented in the form of a QQ plot against the normal
distribution, see 6.7.
If you double click on a graph with a histogram, you can fill the histogram bars in
any desired colour. By default, the inside colour is white, here we made it grey:
89
6.5 Distribution
6.5.3
Frequencies
Figure 6.5b,f are just unscaled histograms, and the cumulative versions (Figure 6.5c,g)
literally add up the total numbers below or inside the current interval (CONS has 159
observations, DCONS 158).
6.5.4
Box plot
A box plot shows the distribution of a variable in a more condensed form. Refer to
Figure 6.6, which shows the total range of a variable and the concentration in a central
region, using the quartiles of the distribution, and the inter-quartile range (IQR).
Box plot of INFLAT
6
Q3 + IQR
maximum inside (Q1 - IQR, Q3 + IQR)
4
Q3
Third quartile
Q2
Median
Q1
First quartile
Figure 6.6
90
6.6
6.6.1
ACF-CONS
Correlogram-CONS
0.5
1
ACF-DCONS
Correlogram-DCONS
Figure 6.7
10
15
20
10
15
20
91
The partial autocorrelation coefficients correct the autocorrelation for the effects of previous lags. So the first partial autocorrelation coefficient equals the first normal autocorrelation coefficient. The sample PACF of CONS shows that after the first, the remaining
partial autocorrelations are close to zero.
6.6.3
Cross-correlation function
The sample cross-correlation function (CCF) graphs the correlation between a series
and the lags of another series. Figure 6.8 shows that the CCF between CONS and
DCONS is different between that of DCONS and CONS.
1
CCF-CONS x DCONS
CCF-DCONS x CONS
Figure 6.8
6.6.4
10
15
The periodogram and the spectrum (or more accurately here: spectral density) graph the
series in the frequency domain. The sample periodogram is based on the coefficients
of the Fourier decomposition of the sample autocorrelations (that is, the correlations
{rj } in 6.6.1 between xt and xtj ). Figure 6.9 graphs the periodograms of CONS and
DCONS using a lag length of 20.
Spectral density
Periodogram
CONS
Spectral density
Periodogram
DCONS
CONS
1500
0.3
1000
0.2
500
0.1
DCONS
0.0
0.5
1.0
Figure 6.9
0.0
0.5
1.0
0.0
0.5
1.0
0.0
0.5
1.0
The sample spectral density is a smoothed (and scaled) function of the periodogram.
It is symmetric between and , and so is only graphed for [0, ]; 1 on the horizontal
axis stands for , 0.5 for 0.5, etc. Peaks at certain frequencies can indicate regular
92
(cyclical or seasonal) behaviour in the series. The spectrum of CONS shows the typical spectral shape (a term introduced by Granger, 1966), which many macroeconomic
variables appear to have: a pronounced peak at the lowest frequencies. Like the correlogram, this indicates that successive values of CONS are strongly correlated. Figure 6.9
shows that spectrum of DCONS is much flatter, indicating a series which is closer to
white noise. More information is in 10.8.
Tip You may wonder how graphs such as Figure 6.8 are made smaller. In this case,
that is done using Graph layout/Aspect ratio (Y scale)/Half size (50%):
6.7
QQ plots
1.00
0.4
distribution
normal
0.75
0.3
0.50
0.2
t(3)
0.1
0.25
t(3)
-5.0
-2.5
0.0
Figure 6.10
2.5
5.0
-5.0
-2.5
normal
0.0
2.5
5.0
93
6.7 QQ plots
QQ plot
CONS normal
920
INC normal
900
900
875
880
850
860
850
860
QQ plot
870
880
890
900
910
DCONS normal
870
QQ plot
10
880
890
900
910
920
DINC normal
5
5
0
0
-5
-5
-10
-5.0
-2.5
0.0
2.5
5.0
Figure 6.11
-7.5
-5.0
QQ plots
-2.5
0.0
2.5
5.0
7.5
94
6.8
The result is in panel a of Figure 6.12, with a similar graph for the first differences in
panel b. Note that we also choose to have the labels along the axes, instead of a legend.
In the top-left panel (levels), the fourth (Christmas) quarter is uniformly highest, and
the first lowest; in the lower panel (first differences), the first-quarter points are grouped
far below all other quarters, the second are scattered along the X-axis, and the last two
quarters are bunched together. Thus, plotting reveals distinct patterns in this instance.
The remaining panels show the seasonal sub-plots, which essentially reveal the same
information.
There are more cross-plot options. One is a so-called bubble chart. It consists of
a scatter plot, where the symbols are circles, and the size of the circle indicates a third
dimension (e.g. market share). Return to the data.in7 tutorial data set, and use Algebra
95
8.7
8.8
8.9
9.0
9.1
9.2
0.1
DLC
0.05
LC
44 4
43 3
3
4 4 32 21212 1
1
4 4233
4
423233 2 1
4323324 211 1
4 32 1 1
434 2 1
4 3 223 1
21
44 32 11
3 232 1
1
11
LY
-0.1 -0.05
8.6
8.8
9.0
9.3
11
2
24 442442 2424 2 2 2 22
2
2
2 22 24 4 4444444 2
3 3334 43
3
3 3 333 3 33 3333
1 1
11 1 111 1
11 1 1
11 1 1
DLY
0.025
0.050
0.075
0.10
9.25
0.05
0.00
9.00
-0.05
8.75
-0.10
LC
Figure 6.12
DLC
DLY
LY
860
CONS
880
900
870
1250
875
880
885
890
INC
895
900
905
910
CONS seas2
750
1955
1250
1960
1965
1970
1975
1980
1985
1990
1965
1970
1975
1980
1985
1990
CONS seas2
750
1955
1960
Figure 6.13
96
The final graph of this section illustrates error bars/bands. Select CONS as the first
variable, and seas2 as the second, and choose Two series by a third/Error bars at the
second stage. Note that, when only two variables are selected, the horizontal (X) axis
is automatically set to time. See Figure 6.13b.
Afterwards, the colour and size of the error bars can be changed in the section
related to the error bars, see the capture on the next page. It is also possible to switch
between bars and bands. For example, changing to error fans as shown in Figure 6.13c.
6.9
3-dimensional plots
With 3-dimensional plots there are two ways of presenting the data: as a scatter
of points in three-dimensional space, or as a table with the X and Y values along the
side, and the Z values in the cells. The tabular format specifies the 3D surface directly,
whereas for the scatter it is left to OxMetrics to work out the surface. Although the
tabular format leads to better results, the scatter is easier to use, as it requires only three
variables.
6.9.1
To create a surface from a scatter, OxMetrics derives a triangulation, and from the
triangulation a smooth surface. This method works best when the surface is smooth. To
illustrate this, create a new database with 1000 observations. Create a random X and
Y value, uniformly distributed between 3 and 3. Create Z as the independent normal
density (without the normalizing constant):
97
1.0
Z
0.5
Z
0.5
1.0
Select Y , X and Z in the graphics dialog (in that order), select Triangulation from
scatter. Repeat this, but selecting Surface from scatter. The result can be seen in the
first two panels of Figure 6.14.
0.0
Y
-2.5
0.0
X
-2.5
-2.5
0.0
X
-2.5
0.0
Y
2.5
2.5
0.0
X
-2.5
-2.5
0.0
Y
0.0
X
-2.5
-2.5
0.0
Y
2.5
-2.5
-5
Z1
0
Z2
0.0
2.5
10
2.5
2.5
Figure 6.14
2.5
2.5
2.5
There are a few additional edit actions available for 3-dimensional graphs:
Rotation
The Edit menu has an entry for rotation: left/right (azimuth, keyboard short-cuts
are left-arrow, right-arrow), up/down (elevation, keyboard short-cuts are up-arrow,
down-arrow) and side ways (twist). This can be done from the menu for the currently selected 3-d area, or for all graphs. The keyboard short-cuts only work when
a 3D area is selected.
Palette
The Style entry for the 3D graph on Edit Graphs allows for a choice of palette:
98
Tables are harder to work with, because OxMetrics essentially only recognizes vectors,
not matrices (unlike Ox).
Create a new database with only seven observations. Let X be 3, 2, . . . , 3, and
Y the same. The Algebra code then defines Z1 = f (X1 , Y ), Z2 = f (X2 , Y ), etc.:
X = trend() - 4;
Y = X;
Z1 = exp(-0.5*(X[1(1)]^2+Y^2));
Z2 = exp(-0.5*(X[2(1)]^2+Y^2));
Z3 = exp(-0.5*(X[3(1)]^2+Y^2));
Z4 = exp(-0.5*(X[4(1)]^2+Y^2));
Z5 = exp(-0.5*(X[5(1)]^2+Y^2));
Z6 = exp(-0.5*(X[6(1)]^2+Y^2));
Z7 = exp(-0.5*(X[7(1)]^2+Y^2));
Note the indexing of the form year[period], which is explained in 12.3.7. The
dataset looks like:
X
3
2
1
0
1
2
3
Y
3
2
1
0
1
2
3
Z1
Z2
0.00012341 0.00150344
0.00150344
0.0183156
0.00673795
0.082085
0.011109
0.135335
0.00673795
0.082085
0.00150344
0.018315
0.00012341 0.00150344
...
...
...
...
...
...
...
...
Z7
0.00012341
0.00150344
0.00673795
0.011109
0.00673795
0.00150344
0.00012341
99
1.0
Z1
0.5
Z1
0.5
1.0
6.10 Conclusions
2.5
0.0
Y
-2.5
-2.5
Figure 6.15
0.0
X
2.5
2.5
0.0
Y
-2.5
-2.5
0.0
X
2.5
Paste X from the previous database, so X is 3, 2, . . . , 3, with missing values for the
remaining observations. Create Y as:
Y = (trend()/20 - 0.5) * 6;
and Z as before. Select X, Y, Z1, . . . Z7, and 3-dimensional plots/Surface from table:
Z,Y columns match to see Figure 6.15b.
6.10
Conclusions
Many different types of plots are available. New ones can be derived by editing or
copying and pasting, as discussed in the next chapter.
For a quick example of the plotting capabilities, open the batch file plots.fl (in
the OxMetrics7\batch folder) and run it.
Chapter 7
Tutorial on Graph Editing
The prologue introduced the basics of using OxMetrics, accessing its menus and dialogs, loading, saving and transforming data, using graphics, including saving, printing and pasting them, and described the Calculator and Algebra. Chapter 6 gave an
overview of the many different types of graphs. Now we consider the facilities for
editing graphs in more detail. Chapter 14 discusses various graphics options more systematically.
If youre not inside OxMetrics at the moment, restart and load the tutorial data set
data.in7/data.bn7.
7.1
Multiple graphs
Create DCONS and DINC as the first differences of CONS and INC, then activate the
Graphics choice on tools which defaults to the Variables options as shown in Chapter 2.
Select CONS and INC, then click Actual series, at which point the graph will appear;
restart the graphics dialog, mark and select CONS and INC again, but now click on the
YX (Scatter plot) button, then Apply; and repeat both of these operations for the pairs
DCONS and DINC, clicking OK after the fourth, to see Figure 7.1. We number the four
graphs from left to right and top to bottom as:
a
c
7.2
b
d
To understand the editing facilities, it is easiest to see the graphics window as a piece
of graphics paper, consisting of 15 000 pixels along the x-axis, and 10 000 along the
y-axis (this is very much higher than the actual screen resolution). The four graphs in
Figure 7.1 all have an area attached to them. By default, these areas are evenly spread
100
101
INC
890
CONS
900
INC
870 880
900
860
880
860
DCONS
1970
1980
1990
1980
1990
870
880
5.0
1960
DINC
900
910
DINC
0.0
2.5
890
CONS
-2.5
-5.0
-5
1960
Figure 7.1
1970
-7.5
-5.0
-2.5
0.0
DCONS
2.5
5.0
7.5
out on the paper. An area has pixel coordinates to fix it on the paper, and real world
coordinates to draw variables, axes, etc. inside the area.
An area can be selected with the mouse by clicking on it. Then it is shown selected
(in a fuzzy rectangle), and you can pick it up and move it around on the paper, or
102
resize it. Once moved around, the pixel coordinates switch from automatic to manual.
To see this, click on the first area to select it, then move it with the mouse. Next, use
a double click on the area (or use Edit/Edit Graph) to activate the Edit Gaphics dialog
and select the Area Layout page for Area 1.
Expand the Pixel coordinates section, and uncheck Set to reset to the default paper
location. Similarly, it is possible to redefine the world coordinates of the area (e.g.
to zoom in on a part of the graph). This is done by deselecting the Set check box in
the World coordinates section. To apply the new settings to all areas, use the Copy
properties to other areas section on the page.
The Graph Layout entry in the left-hand column gives access to the properties that
apply to the whole graph. For example, there is a drop-down box that allows for changing the area matrix. With four graphs on paper, various ways of layout can be chosen.
Select Box all areas to get the graphs boxed as in Figure 7.1.
7.3
Graphics view
When resizing a Graphics window, the content automatically grows or shrinks accordingly. However the aspect ratio of the graph paper (the size along the x-axis relative
to that along the y-axis) remains constant. To change this, see 14.6.1.
7.4
The default graphics window is called Data Plot. By default, OxMetrics keeps on
adding graphs to this window. If you wish to keep the current window, and start with a
clean piece of paper, use New Data Plot Window on the File menu.
To restart with a clean sheet: close the graphics window; a new one will be opened
automatically when required.
7.5
103
7.6
Lines in a graph can have different colours and styles (solid, dotted, dashed, etc.). This
is implemented in two levels:
There is a palette of 16 line types, defining colour, style and symbol type.
Each line is defined through an index in that palette.
So, for example, when a line has type 3, it is drawn in whatever colour and style is
defined for that type. When editing a graph on screen, it is possible to change its line
type (see 7.7). In addition, and separately, the global palette settings can be modified
(7.8).
Line type 0 refers to the background colour (white), and type 1 to the foreground
(normally black). Therefore, the first index used in drawing variables is 2.
7.7
By default, all graphs use the automatic selections offered by OxMetrics: these are
usually fine for immediate usage, but are open to many possible amendments depending
on their purpose. We begin with Figure 7.1a. Double click on it to bring up the Edit
Graphics dialog (a single click makes it become the focus, shown by the fuzzy boxed
outline mentioned before). Almost any aspect can be changed in the Edit Graphics
dialog.
Lines are chosen from a set of predefined line types, which define colour, pattern,
width and default symbol type. Model/Preferences/Graphics Setup defines the line
definitions. Here we start by changing the line type to index line (as shown below in
Figure 7.2 on page 106) after double clicking on the first area:
104
Next, select the INC x (time) section, and under Regression, Scale, and set the
number of regression line to one (as in 2.4.2), as well as Seq. with projections:
105
Click on Regression, and mark 4 lines, and Seq. with projections. This page also
allows for renaming the labels of variables in graphs by clicking on Y or X label, in this
case to income:
For graph c, select X-axis on Edit Graphics, and click Grid, as shown in the next
capture. Repeat for the Y-axis, then close: on the graph, grab the legend and move it
to a more convenient location (click with the mouse and holding the button, drag it to
the place required) as shown. Changing Style alters the line colour or style: we have
done that for DCONS in c to a thicker line as explained in the next section.
106
Finally for graph d, mark 20 (sequential) regression lines. The final result is in
Figure 7.2. This is a very different picture from our first figure, and such facilities can
be used to reveal hidden features of data.
CONS
900
INC
900
CONS income
890
880
880
870
860
860
1960
1970
1980
1990
870
5.0
880
890
900
910
DCONS DINC
2.5
0.0
-2.5
-5
DCONS
1960
1970
Figure 7.2
DINC
1980
1990
-5.0
-7.5
-5.0
-2.5
0.0
2.5
5.0
7.5
7.8
107
Graphics setup
There are many default graphics settings that can be generically controlled by the user,
and are persistent between runs of OxMetrics.
Lines (Tools/Graphics Setup):
define the default line attributes;
Layout:
define defaults for margins, boxing and font size;
Axes:
define defaults for axes, grids, axis labels and grids;
Legend style
Histogram
Cross-plot style
Palettes (Tools/Graphics Setup):
for three-dimensional surfaces and error fans;
Display style for color mode:
Line colours, types, symbol style, palettes, etc.
Display style for black, white & gray mode:
Line colours, types, symbol style, palettes, etc.
Click on Model, Preferences, Graphics Setup to bring up the dialog shown below.
The colours, types and thickness of all lines can be set as wished: for example,
much thicker lines are more useful for live demonstrations than printed graphs; some
108
7.9
Close the current graphics windows, and create a scatter plot of INFLAT against OUTPUT. It is possible to add further graphs to this area. The default graphics command
will always create new areas, but the Add Graph command from the Edit menu or the
context menu:
adds to a selected area. You can try this by adding a scatter of INFLAT against INC
to the graph. Similar results can be achieved by copying one area to the clipboard,
selecting another, and pasting into that area.
The simplest way to remove it again is to use Undo. An alternative is to delete the
second scatter. Select Delete From Graph:
109
7.10 Drawing
7.10
Drawing
Change the line type of the INFLAT x OUTPUT scatter plot to symbol and line to link
the points. Next, access Draw on the context menu (right click):
Use Draw a Filled Rectangle to highlight the two clusters on the graph. Click on Draw
Symbol/Draw Filled Rectangle the mouse point becomes like a pencil, as indeed
it can now draw a rectangle. Put the mouse down near the top left of the first cluster.
while holding the mouse down, continue the expansion till the cluster of points around
the low OUTPUT equilibrium is highlighted as in Figure 7.3a. Next double click on
the rectangle and a Lines and symbols section will appear:
5.0
2.5
0.0
1165
1170
1175
Figure 7.3
1180
1185
1190
1195
1200
1205
1210
110
7.11
To add text, proceed as in the previous section: use the edit menu or click with the right
button, and select Add text. The mouse cursor becomes a letter. Now click where you
wish the text to appear. A dialog pops up in which the text is entered:
You may note from the dialog that graphics text can use a LATEX-style of formatting,
more information is given in 14.9.
Another simple way to add text is to start typing a letter, which will become the first
letter in the dialog box. The text will be added at the location of the mouse (but can be
picked up and moved). When adding text just above the graph, it becomes the title.
7.12
Legends
Legends are created for all the variables in each graph, located in the top left corner of
the graph. The legend can be picked up with the mouse and moved around the graph.
They are automatically resized as the graph gets smaller. When the graph is very small
(usually with more than sixteen graphs in one window) the legend is omitted altogether.
Another way of removing the legend is by hiding it. The Legend style section on
the Edit Graphics dialog allows hiding and unhiding the legend:
Legends are transparent by default. In that case, they are drawn below data plots,
111
with the exception of shading and separately drawn symbols. Opaque legends, on the
other hand, are drawn on top of everything else.
7.13
Scaling variables
Often it is useful to draw two or more variables in the same graph to allow easy comparison. However, when the variables have widely differing magnitude, all visual information will disappear. For example, graph CONS and OUTPUT (after closing the
existing graph). They appear as two nearly straight lines, one at the top and one at the
bottom of the graph: most visual information is lost.
900
CONS
OUTPUT
860
1955
1960
1965
1970
1975
1980
1985
1990
900
OUTPUT
1200
CONS
880
1180
1960
Figure 7.4
1965
1970
1975
1980
1985
1990
OUTPUT 233.52
.
1.093
112
The second method involves more extensive editing. Add separate graphs of CONS
and OUTPUT (there are three areas now). Both already have the same time axis, but
when put on top of each other, the y axes will clash. Double click on the OUTPUT
graph, and select the X-axis section. Check Hide:
Then expand the Y-axis section, and, under location and (log)scale or dates, set the
Anchor to Maximum. To get the labels and tick marks on the other side, select Labels
above.
Change the line type of OUTPUT to number 3. Figure 7.4b shows the result. Note
that the labels along the y-axis have been rotated using Rotate labels on each y-axis.
To put the areas exactly on top of each other, it is necessary to set the pixel coordinates of the areas.
Chapter 8
Tutorial on Data Input and Output
In this tutorial, we turn to what can be one of the more tedious operations: inputting
new data. Fortunately, OxMetrics can load a wide range of formats to allow for easy
exchange with other programs; and can do so from disk files or by copy and paste.
Table 8.1 summarizes the available options.
Table 8.1 OxMetrics data input/output options
Disk OxMetrics
OxMetrics disk
OxMetrics paper
Paper OxMetrics
OxMetrics clipboard
clipboard OxMetrics
8.4.1
8.4.2
8.4.3
8.4.3
8.3
8.3
8.3
8.2.2
8.2.1
8.2.2
8.2.2
p.120
Many other formats can be loaded, after conversion to any of the supported formats at
source.
The order in the tutorials below is somewhat different from the table: first we enter
a small data set into OxMetrics (16 observations from the tutorial data set variables
113
114
CONS and INFLAT, from the first quarter of 1955 up to the last quarter of 1958). Next
we save this in various formats, which we shall reload. After all, we do not want to
spend too much time typing in data.
From now on, we will abbreviate menu selections; e.g., File/Save as/Data (*.in7)
will mean: select the File menu, then select Save as, and then the file type data (*.in7).
8.1
The file type entry on the dialog when using File/Open specifies which types of file
OxMetrics can load:
8.2
OxMetrics allows you to type data directly into a database, or to enter the data into a
file, and then load the file. Remember: this is for tutorial practice modern scanners
offer a fast route from paper to disk.
8.2.1
Start OxMetrics without loading any database yet. One of the available options on the
File menu is New: click on it then select OxMetrics (Data: *.in7):
In the current situation, this brings up the Create a new database dialog to ask you for
the information needed to create the database. Fill in the information as shown in the
115
screen capture: Quarterly frequency, start date 19551, add 6 observations (the database
already has 10:
Press OK to accept the dialog: the empty database appears on screen. It could be
convenient here to maximize the database window.
To add variables to the database, keep the focus on it and click on Edit, New variable
and type Cons; repeat to create Inflat so there are two variables in the database.
Alternatively, double click on the empty grey box at the column head, then enter the
name of the variable to be created in the Variable description dialog:
All the observations of Cons and Inflat are set to missing. (NaN, not a number, is
used internally on computers for the missing value). OxMetrics takes account of this
when determining sample sizes for operations, but just leaves gaps when graphing.
There are three ways of entering a value:
1. double click to get a pop-up editor to enter values:
116
2. type a first digit, and the inline editor for the current field is entered.
3. click to select and single click (or press the Enter key) to get the inline editor:
To document each variable, position the cursor on the variable name and press -, or
double-click on the variable name. To return to the Results window, click on Windows
and select Results: you may wish to minimize the database window first.
Tip After conversion or entering new data, it is useful to do a graphic inspection
which can help to find mistakes. See Figure 8.1 for the two variables created in this
tutorial.
The next important task is to save the database to disk. Losing data can be disastrous, and it is best to save it as soon as possible (and make backup copies!). But before
117
Cons
Inflat
2
895
1
890
0
1955
1956
1957
1958
Figure 8.1
1959
1955
1956
1957
1958
1959
moving to 8.3 to see how to save the results of your efforts, we consider data entry by
another way. We suggest that you read the next section, but there is no need at this stage
to enter the numbers again: you can highlight them in the database and use Edit/copy
to put them on the clipboard, then paste to the results window if you wish: the next
section explains.
8.2.2
To get data into a human-readable file we need the services of an editor: the Results
window will do that job. First change the 1956(3) value for Cons to a missing value.
To avoid typing the data again, select all observations in the database: put the mouse
down on the first observation of Cons, then, while keeping the left mouse button down,
move to the last observation of Inflat. Or more quickly: select all by starting selection
on the first variable label, finishing on the last. Quicker still: click on the top-left empty
cell. The screen should look like the capture below.
The bottom left of the status bar gives the current selection. The right panel still
gives the data value under the cursor. Click on the copy icon (shown as two pages on
the toolbar) to copy the data to the clipboard.
118
Next, set focus to the Results window, and click on the paste icon, as shown here
with some comment (this capture was made after saving to testobs.dat):
Note that we kept the names, and that the data is ordered by observation (the variables
are in columns), with the assumption of one observation per line.
Note that, while we entered 0.46 in the database, the pasted value is actually .46000000000000002. This no mistake, but a consequence of the finite
precision with which the computer hardware works. Some experimentation of
entering values in the database and pasting into Results, shows that the next
number up is .45999999999999996. So .46000000000000002 is as close to
0.46 as we can get. In general, there are about 15 to 16 significant digits available. However, because internal storage is in binary format, the exact numbers
tend not to be the ones ending in lots of zeros.
Precisely the same copy and paste operations would have worked between Excel
and OxMetrics. Of course it is also possible to copy and paste directly between an
Excel spreadsheet and a OxMetrics database.
See the note regarding copying from Excel on page 120.
Comment can be added to the data by putting double forward slashes (//) at the start
of each comment line. When reading a human-readable data file, OxMetrics skips all
the lines starting with // or a semicolon. Here we commented out the variable names,
and removed all previous text from the Results window.
The next step is to save the contents of the Results window. Type Alt+f and
then a to execute Save as on the File menu using the Text (*.out) file type. Enter
testobs.dat for the filename. If the file already exists you can choose between renaming or overwriting. The human-readable data file has been created. Loading the
created file is considered in 8.4.3, after we have learned how to save the database.
8.3
119
With new data entered as in 8.2.1, it is most convenient to save the database in the
OxMetrics format. OxMetrics uses two files for its data storage. The first is an information file, which has the .in7 extension. The second holds the data in binary (not
human-readable) form, and has the .bn7 extension.
Activate the database, currently called something like new08.in7, but not corresponding to a disk file. Select File/Save As/Default (*.in7). Enter test in the Save
File dialog. This results in the disk files test.in7 and test.bn7 being created. The
OxMetrics format preserves data documentation entered in the database, and the file
documentation. These can be modified in a later run of OxMetrics.
For completeness, we also save the data in the Excel spreadsheet format, and in
plain ASCII (text) format. Select File/Save As/Data (*.xlsx); type test in the Save
File dialog, the remainder is the same. This creates test.xlsx.
Next repeat the process for File/Save as/Data (*.dat) creating test.dat. This is a
text file with load information: a line is added for each variable giving the name, sample
period and frequency, very similar to the information that is contained in an .in7 file:
>Cons 1955 1 1958 4 4
887
890
891
894
897
895
894
892
...
This is different from testobs.dat created before: now the data is ordered by
variable.
8.4
This section discusses the three main types of file which can be loaded directly into OxMetrics. Consult Chapter 11 for additional information on the file formats and further
examples.
8.4.1
This is the simplest way of getting data into OxMetrics. So once you have your data
from another format loaded into OxMetrics, you might wish to save it in the OxMetrics
format, and use that from then onwards. An example was given in the first tutorial,
where we loaded the tutorial data file data.in7/data.bn7. Try loading the test.in7
file which was created earlier.
8.4.2
A test file called test.xlsx was created above. To load it in OxMetrics, select
File/Open, and select the file. The spreadsheet is loaded directly into OxMetrics.
This is what test.xlsx looks like in Excel (try to load it if you own a copy), for
the first few observations:
120
Two human-readable data files were created in this chapter, one by copying to the results
window, and saving as testobs.dat (ordered by observations), and test.dat at the
end of 8.3 (ordered by variable, with load info).
To load test.dat into OxMetrics, use File/Open/Human readable. After selecting
the correct file (test.dat), we note that the file is loaded automatically as desired (with
the help of the load info that is embedded in the file). View the database or graph the
data to check the results.
Finally, load testobs.dat. This is read with variable names, but there is no sample
information. Activate the database and use Edit/Change Sample to set the frequency to
quarterly and the start date to 19551.
8.5
Often one wishes to lift variables out of other data files, and add them to the current
database. OxMetrics supports this operation through copy and paste. You can select
individual variables from an .in7/.bn7 data set, or add them from a human-readable
file. Once created, the frequency of the database is fixed, but the sample period will be
121
8.6
8.6.1
It is possible to add observations prior to the current sample start, or after the sample
end. Such an operation is required when new data are collected, or ex-ante forecasts
are to be stored for further analysis. When storing forecasts, or pasting data, the sample
end is extended automatically.
Suppose we wish to add a year of data at the beginning of the test data created
in 8.3. Remember that the data in test.in7 (and corresponding test.bn7) have a
sample period of 1955 (1) to 1958 (4). Focus on the database and select Edit/Change
Sample. Fill this in as shown: 4 observations at the start, then press OK to accept:
The same procedure can be used to add observations, but a simpler way is just to
double click beyond the end of the database: the editor pops up, and the database is
automatically extended.
8.6.2
This was done in 8.4.3: the number of observations remained unchanged, and no data
will be lost or changed.
8.7
Appending data
It is possible to append a database from disk to an open database, using Append Data
File on the context menu in the workspace:
122
Append will only work if the frequencies match. OxMetrics will make additional
adjustments when these are required:
the sample of the open database will be extended to encompass that of the appended
database;
if a variable from the appended database already exists in the open database (remember that this requires the names to be identical, including upper/lower case),
then the existing variable is updated, except where the appended variable has missing values (for those observations the existing variable is not changed).
In this case, a message will warn you about the update: Found duplicate variables
in appended database: existing variables adjusted.
For example:
existing
Cons
887
890
891
894
897
8.8
appended
Cons
880
missing
900
missing
910
resulting
Cons
880
890
900
894
910
In 5.3 we gave an introduction to dated data, loading the weekly Dow Jones index. In
this section we illustrate how an undated database can be converted to a dated database.
First we contrast the two methods for dating observations:
Fixed frequency Denoted by a start year, start period and frequency. From this, the
date of any subsequent observation can be worked out. For example, if the start
year is 2005, the start period 1, and the frequency 4 (quarterly), then the sixth observations is for 2006(2), the second quarter. This works well for monthly, quarterly
and annual data. For undated data we simply set the start year and period to one,
and the frequency as well.
Dated The fixed frequency method does not work for weekly or daily data: not every
year has the same numbers of observations. The solution adopted in OxMetrics is
as follows: an integer value represents a date. A database variable can be classified
123
as of type date, in which case the date is displayed, rather than the underlying value.
For example 2005-1-1 (1st January 2005 OxMetrics uses the ISO representation
year-month-day) corresponds to 2453372. To check this, just enter 2005-1-1 as an
observation value in a database: this is automatically translated to 2453372. It is
not necessary to work with these large numbers directly, there are several Algebra
functions to help.
The following criteria must be satisfied for a database to be dated:
1. the first column must be of type Date,
2. the first column holds date values,
3. the optional fractional part of this indicates time as a fraction of 24 hours; e.g.
2453372.75 is 18:00 on 2005-1-1 (2005-1-1T18:00 in ISO notation),
4. the first and last observation must be valid, i.e. cannot be missing.
Note that the fixed sample period is still available for a dated database, but this is
usually set as for an undated database (start year, start period, frequency all set to one).
8.8.1
Our next step is to create a database that is dated. We continue with the Cons, Inflat test
database that was constructed, but any will do.
The simplest way is to use the Change Sample command, set a daily frequency with
5 days per week and set the start date to 2005-1-3 (the first Monday in January, as can
be seen from the dialog:
This is a variable as any other: it can be renamed, transformed, moved, deleted, etc.
Although some of these will make the database undated again. Double clicking on the
124
Click on Undo to reset the database. Renaming the variable does not make the database
undated, because the name is not really used elsewhere.
8.8.2
The following Algebra code creates separate variables with the year, month and day:
If we now delete the Date variable, the database becomes undated:
This is the format in which some data sets come. To make it dated, use makedate to
create a date variable:
date = makedate(y, m, d);
Then move the variable to the first position in the database using the Move Up button
in the Algebra editor (or in the Calculator):
125
Finally, double click on the new date variable, and change the type to Date. And
the database is dated again.
8.9
A third type of variable is that called Choice, which has text labels attached to values.
Normally the values of such a variable are integers, ranging from zero upwards. Then
each zero has the same label, each one etc. An example would be a country panel,
where we find labels such as UK, USA etc. more informative than 14, 15 (say). Another
example is tick-by-tick data, where it can denote a stock exchange. Within OxMetrics,
there is fairly limited benefit of this variable type. Ox programs, however, can also
access this aspect in the Database class, which can make output more readable.
To illustrate the creation of a choice variable, continue with one of the small test
databases, say test.in7. (It doesnt matter if it is dated or undated.) Add a variable
called Var4 which at first is all missing values. Then set the first third of obesrvations
to zero (select the block, right-click on the selection, choose Edit Value, and set it to
0). Set the second block to one, and the final block to two:
126
Double click on the variable name, and change the type to Choice:
Then press Add to add the next value, label pair. Finally, also add cc:
Now the Var4 variable is displayed with labels instead of numbers. It is still a
numerical variable though, which can be used in modelling as any other variable.
127
Not all file types can preserve the choice labels correctly. For saving you can use
.in7/.bn7, .xlsx or .dta. Other formats will either loose the labels completely, or
are unable to guarantee that the labelvalue association stays intact.
This completes our treatment of data input and output. The remainder of the tutorials will use either data that is provided with OxMetrics, or artificial data created inside
OxMetrics. After that you will have your own data to analyze; we hope that OxMetricss ample facilities allow you to enter, edit, save and document your data easily and
quickly.
Chapter 9
Tutorial on Data Transformation
We briefly described the Calculator and Algebra in Chapter 2. Here we explore the
transformation and data generation possibilities. Along the way, we round off the options in the Model menu by looking at the Tail probabilities dialog.
If you are not inside OxMetrics at the moment, restart and load the tutorial data set
data.in7/data.bn7.
9.1
Calculator
The calculator enables easy manipulation of the variables in the database, and is a convenient way to write algebra expressions.
The aim is to build a valid algebra expression in the expression window (without
the assignment part and the terminating semi-colon). All successful transformations are
logged in the Results window, from where they can be cut and pasted into an algebra
file for later use if desired. Advanced algebra is discussed in the next section, whereas
Chapter 12 has a more formal description of the language.
Suppose, for example, that you have selected the variable called CONS (we use
the artificial data set again), and then pressed the log button. Then the expression will
read log(CONS). When pressing evaluate (the = sign), the logarithm of CONS will
be computed. Now you have to assign the new variable a name, with LCONS as the
suggestion made by OxMetrics. If you accept this suggestion, LCONS will be added
to the database. If LCONS already exists, OxMetrics will ask whether you wish to
overwrite the existing variable.
If you have ticked the Sub-sample evaluation check box, you can also select a
sample period over which you wish to compute log(CONS). If you create a new variable
in this way, it will be set to the missing value outside the sample. If you overwrite an
existing variable, it will be left untouched outside the sample period.
Examples using the calculator were given in Chapter 2. Some additional examples
follow here.
128
129
9.1 Calculator
First, creating a lag: select CONS, click on lag, specify 4 (to create a four-period
lag) in the lag length dialog, OK to accept, and click on the button with the = symbol at
which point a suggested name (CONS 4) appears in a small window, to accept and the
created variable is added to the database. In general, lags for modelling should not be
created this way, although it can be useful for (e.g.) graphing.
Next, to create a step dummy of the 0-1 variety for the oil crisis: click on dummy,
then enter 1973 3 in the Sample start part (leave the Sample end edit field unchanged,
so the 1 extends to the end of the sample; a capture of the dialog was shown on page 23),
press OK and click on = (or C to clear the expression) and specify the name s1973p3.
Third, a complex example: to create the five-period moving average of CONS:
4
1X
CONSti .
5 i=0
Select CONS in the database, locate movingavg in the function list, double click on
it to see movingavg(CONS, LAG, LEAD). Replace LAG by 4 and LEAD by 0. Click
on =, and specify the name MA40CONS. To create the moving average centred around
the current observation (i.e. using two lags, the current value and two leads), specify
movingavg(CONS, 2, 2). Note that this variable lagged two periods is the same as
MA40CONS.
Other operations are equally simple. To create an Almon polynomial in INC of 2nd
order over eight lags (producing three terms): Click on INC, and then double click on
almon, to get the expression almon(INC, LAG, POWER). Change this to almon(INC,
8, 0) to create the first Almon variable. Call this A0INC. Repeat this to create A1INC
as almon(INC, 8, 1) and A2INC as almon(INC, 8, 2). They are computed using
8
8
X
X
(9 i)j x(t i)/
(9 i)j
i=0
for j = 0, 1, 2,
i=0
and eight initial observations are lost. Graph these to see how collinear they are.
To create the price level from INFLAT as our final example, we need to integrate
(cumulate) INFLAT. This is easily done using the cum or stock function. First highlight
INFLAT, then double click on the cum function to cumulate. Press = to accept the
expression cum(INFLAT), call it P, so that Pt = Pt1 +INFLAT is created (graph it and
see). Another way to create this is selecting INFLAT, but clicking on the stock function
instead. Replace ARVAL (one minus the autoregressive coefficient) by 0, and INIT (the
initial value) by 0. Call this SINFLAT, and check that P and SINFLAT are identical.
If you wanted P equal to 100 in 1970(1), say, when it is 86.28879985, select the same
options but replace the INIT argument of stock with 13.71120015, which will set
P = 100 in 1970(1). Alternatively, return to the Results window where SINFLAT =
stock(INFLAT,0,0); is shown, copy the observation for P in 1970(1) to the clip board
and paste to the Results window, create c=100-86.2887998521328; and SINFLAT =
stock(INFLAT,0,c);, highlight these two algebra statements and press Ctrl+A to
execute.
130
9.2
Advanced algebra
9.2.1
Introduction
Select File/New to create a database with 600 observations, using frequency one.
9.2.3
Statistical distributions
We shall first look at some graphs of densities and corresponding distribution functions.
Most often we work with continuous density functions, and it is assumed that you are
familiar with the basic principles (Volume I of the PcGive books discusses statistical
theory). For example, the standard normal density is defined as:
1 2
1
fx (x) = e 2 x ,
2
131
This integral cannot be written explicitly for the normal distribution. F is a nondecreasing function and:
Fx () = 0, Fx () = 1.
If X has a continuous distribution, then the expectation of X is:
Z
E [X] =
ufx (u) du.
We write X N(0, 1) to say that the random variable X follows a standard normal
distribution. Three other distributions of interest are the student-t, the F and the 2
distribution:
k/21/2
x2
1
k = 1, 2, . . .
1
+
t(k)
fx = (k/2+1/2)
(k/2)
k
k
F(m, n) fx =
(m/2+n/2)
(m/2)(n/2)
2 (k)
1
(k/2)
fx =
1 k/2
2
m m/2
n
xm/21 1 +
m/2n/2
m
nx
xk/21 ex/2
x > 0,
m, n = 1, . . .
x > 0,
k = 1, 2, . . .
xu1 ex dx
for u > 0.
Run the code from tutdist.alg, and do a scatter plot of each of the four variables
against i, as in Figure 9.1. This shows the four densities.
It is also possible to evaluate the densities directly, instead of using the built-in
functions. Note in the second line that we write -(i^2); -i^2 would be equivalent
132
0.4
0.25
normal
0.3
0.20
0.2
0.15
0.1
0.10
chi
0.05
0
100
200
300
400
500
600
student
100
200
300
400
500
600
400
450
500
550
600
0.6
0.3
0.2
0.4
0.1
0.2
100
200
300
400
Figure 9.1
500
600
300
350
to (-i)^2, as the unary minus operator has a higher precedence than power (see Table 12.1 on page 170). The () function is not available in the algebra, but the log ()
is and we use the fact that () = exp(log ()).
normal = exp(-(i^2) / 2) / sqrt(2 * PI);
chi = (i > 0) ? 1 / exp(loggamma(1.5)) * 0.5 ^ 1.5
* i ^ 0.5 * exp(-i / 2);
student = exp(loggamma(1.5) - loggamma(1)) /
(sqrt(2 * PI) * (1 + i^2 / 2) ^ 1.5);
F = (i > 0) ? exp(loggamma(2.5) - loggamma(1.5)
- loggamma(1)) * 1.5 ^ 1.5 * i ^ 0.5
/ (1 + 1.5 * i) ^ 2.5;
To translate the densities into approximate CDFs, the following code is used in
tutdist.alg to cumulate and scale the outcomes (which are in increasing order given
our choice of i for the densities):
cnormal = cum(normal) / (NOBS/12);
cchi = cum(chi) / (NOBS/12);
cstudent = cum(student) / (NOBS/12);
cF = cum(F) / (NOBS/12);
133
cnormal
cstudent
normal
cchi
cF
t(2)
F(3,2)
2(3)
0.5
50
100
150
Figure 9.2
200
250
300
350
400
450
500
550
600
The approximate 75% critical values as read from the database are:
N(0, 1) .66
t(2)
.86
2 (3)
4.1
F(3, 2) 3.16
The accuracy turns out to be quite good. If we compute the p-values using Tools/Tail
probability we find:
N(0,1,1-sided)
t(2,1-sided)
Chi^2(3)
F(3, 2)
=
=
=
=
0.66
0.86
4.1
3.16
[0.2546]
[0.2402]
[0.2509]
[0.2496]
This dialog gives P (X > x) when 2-sided is not marked, in which case we would
ideally get p-values of 25%.
9.2.4
The random number generators in OxMetrics can be used to illustrate statistical concepts, and to give examples of a wide range of commonly used processes. The main
generators are for the uniform distribution (all other distributions can be derived from
this), and the standard normal distribution. In addition, OxMetrics provides functions
to draw from the t, 2 , and F distributions. Other distributions could be derived if desired. An alternative way to draw from a 2 (k), for example, is to compute the sum of k
squared standard normals. Doornik (2006) discusses recent aspects of random number
generation.
The following experiments use 10 000 observations, but you could keep on using
the database with 600 observations. Otherwise create a new database with 10 thousand
annual observations. Draw from the N(0, 1), t(100), 2 (3), and F(3, 100) distributions,
and compute the probabilities (using the correct distributions) to get a value less than
the observed numbers:
phi
stu
chi
fdi
=
=
=
=
rann();
rant(100);
ranchi(3);
ranf(3, 100);
134
1.0
1.0
p_phi phi
0.5
0.5
-3
1.0
p_chi chi
-2
-1
p_stu stu
0.5
0
1.0
10
15
20
0.5
p_fdi fdi
-2
Figure 9.3
p_phi
p_stu
p_chi
p_fdi
=
=
=
=
1
1
1
1
tailn(phi);
tailt(stu, 100);
tailchi(chi, 3);
tailf(fdi, 3, 100);
The algebra code is in the file tutran1.alg. When using 10 000 observations, the
computations may take a little while.
Using these data, we can draw the cumulative distribution functions, see Figure 9.3,
and compare with Figure 9.2. In this case we used a t and F distribution with finite
variance. You could try the distributions of 9.2.3: there will be some large outliers,
extending the scale of the graphs.
A check of the random number generators can be based on the probabilities. Sort
each vector of probabilities, and corresponding random numbers with it:
_sortby(p_phi,
_sortby(p_stu,
_sortby(p_chi,
_sortby(p_fdi,
phi);
stu);
chi);
fdi);
Figure 9.4 shows that the probabilities form a straight line. A plot of the sorted random
numbers look like a mirror image of Figure 9.3. Alternatively, graph the histogram and
densities of phi, stu, chi and fdi to see sample analogues of the distributions.
1.0
p_phi
p_chi
p_stu
p_fdi
20
0.5
phi
chi
stu
fdi
1450
2900
10
0
0
1450
2900
4350
5800
7250
8700
Figure 9.4
Check on CDFs
4350
5800
7250
8700
135
Generating data
Finally, we shall generate data on various autoregressive and related processes. The
database is assumed to consist of 600 annual observations, as in 9.2.3. The file
tutran2.alg contains the algebra code used in this section.
Consider the following examples (note that the roots in the MA(2) process are
0.87 and 0.23):
white noise
AR(1)
AR(2)
MA(2)
ARMA(2, 2)
ARCH
5.0
t N(0, 1),
yt = 0.6yt1 + t ,
yt = 0.4yt1 0.7yt2 + t ,
yt = t + 1.1t1 + 0.2t2 ,
yt = 1.4yt1 0.5yt2 + t 0.2t1 0.1t2 ,
2
yt = t t , t2 = 1 + 0.6yt1
.
eps
ar1
2.5
0
0.0
-2.5
0
5
100
200
300
400
500
600
0
5
ar2
100
200
300
400
500
600
200
300
400
500
600
200
300
400
500
600
ma2
-5
0
10
100
200
300
400
500
600
arma22
arch
10
5
0
100
-5
-10
0
100
200
300
400
Figure 9.5
500
600
100
The middle four processes are used as examples in Priestley (1981). For the
ARCH (autoregressive conditional heteroscedasticity) process, see, for example, Harvey (1993). The following algebra code generates a sample from the six processes:
ranseed(-1);
eps = rann();
ar1 = year() >= 3 ? .6 * lag(ar1,1) + eps : 0;
ar2 = year() >= 3 ? .4 * lag(ar2,1) - .7*lag(ar2,2) + eps : 0;
ma2 = eps + 1.1 * lag(eps,1) + .2 * lag(eps,2);
arma22 = year() >= 3 ? -1.4 * lag(arma22,1)
- .5 * lag(arma22,2) + eps
- .2 * lag(eps,1) - .1 * lag(eps,2) : 0;
arch = year() >= 3 ? sqrt(1 + 0.6 * lag(arch,1)^2) * eps : 0;
136
The ranseed() function sets the seed of the random number generator, an argument of 1 resets the seed to the default value. The variable eps is N(0, 1) and is
reused in each process. The autoregressive parts use conditional statements. If the
year is 3 (we use annual data, so this corresponds to an observation index 3), the
part following the ? is executed. For the first two observations the value zero is used.
In this way a variable can be integrated safely (without the conditional statement all
observations would have the missing value). The test year() >= 3 could also be written as insample(3,1,600,1) or lag(eps,2) != MISSING. Try to understand and
compare these alternatives.
Figure 9.5 graphs the results, after adjusting the axes to give the same vertical range.
The correlograms and spectral densities are given in Figure 9.6.
1
ACF-eps
0
1
10
20
0
1
ACF-ma2
0
0.2
10
Spectral density
20
eps
0.50
0.4
10
20
0
1
ACF-arma22
1.0
ma2
0.0
1.0
10
Spectral density
20
ar1
0.50
0.0
0.5
1.0
Figure 9.6
0.0
20
10
Spectral density
20
ar2
0.25
0.5
Spectral density
1.0
arma22
0.0
0.2
0.5
0.2
10
ACF-arch
0.25
0.5
Spectral density
ACF-ar2
0.1
0.0
ACF-ar1
0.5
Spectral density
1.0
arch
0.1
0.5
1.0
0.0
0.5
1.0
t N(0, 1),
z2: = 0, = .9, = 0
m2: = .1, = .9, = 0
t2: = .1, = .9, = .001
z3: = 0, = .5, = 0
m3: = .1, = .5, = 0
t3: = .1, = .5, = .001
=
=
=
=
year()
year()
year()
year()
>=
>=
>=
>=
3
3
3
3
? 1 * lag(z1,1) + eps
? .9 * lag(z2,1) + eps
? .5 * lag(z3,1) + eps
? .1 + 1 * lag(m1,1) +
: 0;
: 0;
: 0;
eps : 0;
137
=
=
=
=
=
year()
year()
year()
year()
year()
>=
>=
>=
>=
>=
3
3
3
3
3
?
?
?
?
?
z1
.1
.1
.1
.1
.1
z2
0
0
0.0
-10
-5
-2.5
-20
0
40
200
400
600
200
400
600
0
5
m2
200
400
600
200
400
600
200
400
600
m3
5
0
20
-5
0
0
200
m1
z3
2.5
200
400
600
t1
0
10
200
400
600
t2
0
5
t3
5
100
0
0
0
200
400
600
Figure 9.7
200
400
600
Figure 9.7 clearly shows the impact of the different parameter values on the behaviour
of the functions.
9.2.6
Smoothing data
As our last tutorial example, we show how the natural cubic spline function can be used
to fit missing values. Load the tutorial data set DATA.IN7.
First edit the CONS variable to set the observations for the years 1958, 1968 and
1978 to missing values (for each year: select the four observations, press Enter, set to
Missing value, press Enter again, and apply to the whole selection). Afterwards, make
sure that you do not save this modified database. An alternative way to set the missing
values is to run the following algebra code:
CONS = insample(1958,1,1958,4) || insample(1968,1,1968,4)
|| insample(1978,1,1978,4) ? MISSING;
Select the Scatter plot graphics dialog, and do a cross plot of CONS against time
(so there is no need to choose an X variable), adding a Cubic spline smooth using all
three bandwidth settings. The results should be similar to Figure 9.8. The label of
the spline line gives the equivalent number of parameters (comparable to the number of
variables used in a linear regression). So we see that a bandwidth of 1600 corresponds to
nearly 10 parameters (it also corresponds to the HodrickPrescott filter, see 10.10.2),
138
880
CONS
sp1CONS (k=12.00)
860
1955
1960
1965
1970
1975
1980
1985
1990
1970
1975
1980
1985
1990
1970
1975
1980
1985
1990
900
880
CONS
sp2CONS (k=-1600)
860
1955
1960
1965
900
880
CONS
sp3CONS (automatic)
860
1955
1960
Figure 9.8
1965
The following algebra code creates the three smooths in the database (see 12.5.4):
sp1CONS = smooth_sp(CONS,
12, sp1CONS);
sp2CONS = smooth_sp(CONS, -1600, sp2CONS);
sp3CONS = smooth_sp(CONS,
0, sp3CONS);
The first line sets the bandwidth implicitly by specifying an equivalent number of parameters (12), the next sets the bandwidth directly to 1600, and the last uses automatic
bandwidth selection. You could try to add the appropriate variable to each graph by selecting the area (left mouse button), and then using Add Variable. When done correctly,
each added variable should exactly cover the pre-existing spline.
To add the shading, first create the shading variable:
shading = CONS == MISSING;
Then add this variable to each graph, changing the line type to shading, and removing
the Y label so that it doesnt show in the legend.
OxMetrics Reference
Chapter 10
OxMetrics Statistics
OxMetrics provides many convenient graphical options for prior data analysis. For simplicity, we denote the selected variable by xt , t = 1, . . . , T . This chapter summarizes
the underlying formulae, discussing each available graph type in turn.
10.1
Actual series gives a graph for each selected variable, showing the variable over time.
The All scatter plots option gives scatter plots between all selected variables (omitting
redundant scatter plots).
10.2
These are relevant for the statistics described below. For a series xt , t = . . . , T :
x
=
sample mean
1
T
PT
x2 = T1
sample variance
t=1
T
X
xt ,
2
(xt x
) ,
(10.1)
t=1
T
X
t=1
(xt x
) ,
(10.2)
x .
The maximum likelihood estimate for a linear model gives 1/T , while regression on a constant using OLS produces an unbiased estimate of the variance using 1/(T 1).
141
142
10.3
T
1 X
(xt x
) (xtj x
) ,
T t=j+1
j = 0, . . . , T 1,
(10.3)
PT
x2 corresponds to b
c0 , see
using the full sample mean x
= T1 t=1 xt . The variance
(10.1).
The sample autocorrelation function (ACF) is the series {brj } where brj is the sample
correlation coefficient between xt and xtj . The length of the correlogram is specified
by the user, leading to a figure which shows (br1 ,br2 , . . . ,brs ) plotted against (1, 2, . . . , s)
where for any j when x is any chosen variable:
brj = b
cj /b
c0 ,
j = 0, . . . , T 1.
(10.4)
The first autocorrelation, {br0 }, is equal to one, and omitted from the graphs.
The asymptotic variance of the autocorrelations is 1/T , so approximate 95% error
bars are indicated at 2T 1/2 (see e.g. Harvey, 1993, p.42).
If there are missing values in the data series, the correlogram uses all valid observation as follows: the mean is computed for all valid observations; terms where xt or
xtj are missing are omitted from the summation in (10.3). Consequently, the same
procedure is used in (10.4) and any other derived functions such as the spectrum and
periodogram.
10.4
Given the sample autocorrelation function {brj } the partial autocorrelations are computed using Durbins method as described in Golub and Van Loan (1989, 4.7.2). This
corresponds to recursively solving the YuleWalker equations. For example, with autocorrelations, br0 ,br1 ,br2 , . . ., the first partial correlation is
b0 = 1 (omitted from the
graphs). The second,
b1 , is the solution from
br0
br1
=
br0 br1
br1 br0
b0
1
,
et cetera.
10.5
Correlogram
The sample correlogram plots the series {rj } where rj is the correlation coefficient
between xt and xtj . The length of the correlogram is specified by the user, leading to
143
a figure which shows (r1 ,r2 , . . . ,rs ) plotted against (1, 2, . . . , s) where for any j when
x is any chosen variable:
PT
0 ) (xtj x
j )
t=j+1 (xt x
rj = qP
.
(10.5)
T
2 PT
2
0 )
j )
t=j+1 (xt x
t=j+1 (xtj x
Here x
0 =
PT
1
1
T j
PT
t=j+1
rj corresponds to a correlation
t=j+1 xtj is the sample mean of xtj , so that
T j
coefficient proper.
Note the difference with the definition of the sample autocorrelations {rj } in (10.4)
above. This difference tends to be small, and vanishes asymptotically, provided the
series are stationary. But, as argued in Nielsen (2006), the correlogram provides a better
discrimination between stationary and non-stationary variables: for an autoregressive
value of one (or higher), the correlogram declines more slowly than the ACF.
When the correlogram is selected for plotting, the PACF is based on the correlogram
values, rather than the ACF. Handling of missing values is the same as for the ACF.
10.6
The sample cross-correlation function (CCF) graphs the correlation between a series xt
and the lags of another series yt :
PT
) (ytj y)
bcxy
j
t=j+1 (xt x
xy
brj = PT
=
, j = 0, . . . , T 1,
(10.6)
PT
1/2
x
) t=1 (yt y)
(bc0 b
cy0 )
t=1 (xt x
using the full sample means x
and y.
The CCF between xt and yt is different from that between yt and xt : brjxy 6= brjyx .
Both are plotted in the same graph.
10.7
Periodogram
=
=
1 PT 1
1 PT 1
ij
= 2
c|j| cos (j)
j=T +1
2 j=T +1 c|j| e
P
c0 T 1
2 j=T +1 r|j| cos (j) ,
(10.7)
144
10.8
Spectral density
1
2
T
1
X
0 ,
(10.8)
j=(T 1)
where || takes the absolute value, so that, for example, br|1| = br1 . The K () function
is called the lag window. OxMetrics uses the Parzen window:
j
j 3
j 2
0.5,
,
K (j) = 1 6 m
+ 6 m
j 3
m
j
(10.9)
= 2 1 m ,
0.5 m
j
1.0,
= 0,
m > 1.
We have that K(j) = K(j), so that the sign of j does not matter (cos(x) = cos(x)).
The brj s are based on fewer observations as j increases. The window function attaches
decreasing weights to the autocorrelations, with zero weight for j > m. The parameter
m is called the lag truncation parameter. In OxMetrics, this is taken to be the same as
the chosen length of the correlogram. For example, selecting s = 12 (the with length
setting in the dialog) results in m = 12. The larger m, the less smooth the spectrum
becomes, but the lower the bias. The spectrum is evaluated at 128 points between 0 and
. For more information see Priestley (1981) and Granger and Newbold (1986).
10.9
Given a data set {xt } = (x1 . . . xT ) which are observations on a random variable X.
The range of {xt } is divided into N intervals of length h with h defined below. Then the
proportion of xt in each interval constitutes the histogram; the sum of the proportions
is unity on the scaling in OxMetrics. The density can be estimated as a smoothed
function of the histogram using a normal or Gaussian kernel. This can then be summed
(integrated) to obtain the estimated cumulative distribution function (CDF).
Denote the actual density of X at x by fx (x). A non-parametric estimate of the
density is obtained from the sample by:
T
1 X
K
f\
x (x) =
T h t=1
x xt
h
,
(10.10)
145
where h is the window width or smoothing parameter, and K () is a kernel such that:
Z
K (z) dz = 1.
OxMetrics sets:
h = 1.06
x /T 0.2
as a default, and uses the standard normal density for K ():
K
x xt
h
"
2 #
1
x
x
t
= exp 12
.
h
2
(10.11)
The default window width is used when the dialog option is set to Default bars.
Alternatively, it is possible to directly choose the number of bars, in which case, the
more bars, the less smooth the density estimate will be. The histogram uses the whole
sample, skipping over missing values.
f[
x (x) is usually calculated for 128 values of x, but since direct evaluation can be
somewhat expensive in computer time, a fast Fourier transform is used (we are grateful
to Dr. Silverman for permission to use his algorithm). The estimated CDF of X can
be derived from f[
x (x); this is shown with a standard normal CDF for comparison. An
excellent reference on density function estimation is Silverman (1986).
10.10
The scatter plots option allows for various types of regression lines to be drawn. A
single regression line draws the fitted values from the OLS estimates
b and b in
b t,
ybt =
b + x
t = 1, . . . T,
assuming that yt and xt are the selected variables. The distinction between sequential
and recursive regression lines is easily explained using three lines. Divide the sample
in three parts: 1, . . . , T /3, T /3 + 1, . . . , 2T /3 and 2T /3 + 1, . . . , T , then:
sequential
line 1
line 2
line 3
ybt =
b1 + b1 xt ,
ybt =
b2 + b2 xt ,
ybt =
b3 + b3 xt ,
t = 1, . . . T /3,
t = T /3 + 1, . . . , 2T /3,
t = 2T /3 + 1, . . . , T ,
recursive
line 1
line 2
line 3
ybt =
b1 + b1 xt ,
ybt =
b4 + b4 xt ,
b t,
ybt =
b + x
t = 1, . . . T /3,
t = 1, . . . , 2T /3,
t = 1, . . . , T .
Some examples were given in Chapter 7. The regression line is fitted over the whole
sample, skipping over missing values inside sample.
146
10.10.1
As a first step towards non-parametric regression, we start with a scatter plot of yt and
xt , with xt along the horizontal axis. Divide the x-axis in N intervals, and compute the
average y-value in each interval. The resulting step function provides a non-parametric
regression line: to compute yb(x0 ) we locate the interval on which x0 falls, and use the
mean of y in that interval as yb. An obvious drawback is that, if x0 is towards the edge
of an interval, most of the observations are on the other side. Solve this by centring the
interval in x0 . This still gives as much weight to points far away as to points nearby. In
line with the smoothing functions (kernels) in the spectrum and density estimates, we
use a density function to take a weighted average.
The non-parametric estimate of y is obtained from
!1 X
!
T
T
X
x xt
x xt
K
yt ,
(10.12)
K
ybh (x) =
h
h
t=1
t=1
where, as for (10.10), h is the window width, bandwidth or smoothing parameter, and
K () is a kernel which integrates to 1. OxMetrics uses the Epanechnikov kernel:
K (u) = 43 1 u2 , |u| 1,
(10.13)
= 0,
|u| > 1,
which is optimal in a certain sense. The optimal bandwidth, equivalent to the default
chosen for the non-parametric density estimate is:
h = 0.75
x /T 0.2 .
The function ybh () is computed at 128 points. As h 0, ybh () y: the sample
mean is the fitted value for any x. On the other hand, if h the interval goes
to zero, and we fit the nearest corresponding y-value so that each data point is picked
up exactly. Note, however, that the yb () function is evaluated at the T data points xt
(which is time in the absence of x). Hardle (1990) is a general reference on the subject
of non-parametric regression.
There are three ways of specifying the bandwidth:
Number of parameters
This specifies the equivalent number of parameters (approximately comparable to
the number of regressors used in a linear regression). The default is
1/2
3 (T 1)
T 0.2 .
4
12
Set
Sets the bandwidth directly.
Automatic
Chooses the bandwidth by generalized cross validation (GCV). We find that choosing bandwidth using GCV or cross validation (CV) tends to undersmooth.
Equation (10.14) below indicates how GCV is computed.
147
The kernel smooth is not computed using a Fourier transform, but directly, so can
be slow for large T . The smooth is fitted over the whole sample skipping over missing
values inside sample, which are estimated by the fit from the smooth.
One drawback of this smooth is that, for trending lines, it behaves counter intuitively
at the edges. Consider, for example, the left edge of the kernel smooth of a variable
which is upwardly trending. Since the smooth starts as a moving average of points
which are only to the right, and hence mainly higher, the left edge will have a J shape,
starting above what would be fitted by eye.
10.10.2
Spline smooth
A spline is another method for smoothing a scatter plot. Consider a plot of yt , against
xt , and sort the data according to x: a < x[1] < . . . < x[T ] < b. In a spline model,
the sum of squared deviations from a function g is minimized, subject to a roughness
penalty:
Z b
T
X
2
2
+
[g 00 (x)] dx.
min
yt g x[t]
a
t=1
OxMetrics uses a natural cubic spline, which is cubic because the function g is
chosen as a third degree polynomial, and natural because the smooth is a straight line
between a and x[1] and between x[T ] and b. This avoids the end-point problem of the
kernel smooth of the previous section. Two good references on splines and nonparametric regression are Green and Silverman (1994) and Hastie and Tibshirani (1994).
The parameter is the bandwidth: the smaller , the lower the roughness penalty,
and hence the closer the smooth will track the actual data.
The spline is evaluated at all the data points, where missing y values are estimated
by the fit from the smooth. The spline procedure handles ties in the x variable. The
algorithm used to compute the spline is of order T , and discussed extensively in Green
and Silverman (1994, Chs.2,3).
For evenly-spaced data (e.g. scatter plot against time), the algorithm involves a
Toeplitz matrix. This illustrates the closeness of a natural cubic spline to the Hodrick
Prescott filter which is popular in macro-economics:
HodrickPrescott
spline
diagonal
6 + 1
6 + 2/3
2nd diag
4
4 + 1/6
3rd diag
remainder
0
0
The only difference is in this Toeplitz matrix. Since the HodrickPrescott filter uses
= 1600 (for quarterly data), the smoothers from both methods are virtually identical.2
There are three ways of specifying the bandwidth:
2
148
Number of parameters
This specifies the equivalent number of parameters, ke , (approximately comparable
to the number of regressors used in a linear regression). The default is
1/2
3 (T 1)
T 0.2 .
4
12
Set
Sets the bandwidth directly, with the default of 1600 corresponding to the Hodrick
Prescott filter for quarterly data (see 12.5.4.1 for other frequencies).
Automatic
Chooses the bandwidth by generalized cross validation (GCV). We find that choosing bandwidth using GCV or cross validation (CV) tends to undersmooth. The GCV
criterion is computed as:
RSS
.
(10.14)
GCV () = T
T 1.25ke + 0.5
We have adopted GCV instead of CV because a very good fit at one point could
dominate the CV criterion.
10.11
QQ plot
Draws a QQ plot. The variable would normally hold critical values which are hypothesized to come from a certain distribution. This function then draws a cross plot of these
observed values (sorted), against the theoretical quantiles (the horizontal axis). The 45o
line is drawn for reference (the closer the cross plot to this line, the better the match).
The QQ plot line is drawn over the whole sample, skipping over missing values.
The following distributions are supported:
2 (df1 ),
F(df1 , df2 ),
N(0, 1),
t(df1 ),
Uniform(0, 1), resulting in a Quantile plot.
The normal QQ plot includes the pointwise asymptotic 95% standard error bands,
as derived in Engler and Nielsen (2009) for residuals of regression models (possibly autoregressive) with an intercept. Here the normal QQ plot is created for the standardized
data, but drawn on the original scale. The standard errors are given by the square root
of:
(z)(1 (z))
2
z
/2
1
,
T 1
(z)2
where z denotes the coordinates of the reference distribution (the standard normal),
is the standard normal cdf, and the density.
149
10.12
Box plot
A box plot shows the distribution of a variable in terms of its quartiles, labelled Q1 ,
Q2 , Q3 (the 25%, 50% and 75% quartiles). Define the interquartile range as IQR =
1.5(Q3 Q1 ). The box plot consists of the following elements:
a box, with horizontal lines at Q1 , Q2 (the median) and Q3 ;
a vertical line from Q1 IQR to Q3 + IQR (omitted inside the box);
individual observations: all observations outside the (Q1 IQR, Q3 +IQR) range,
plus the two observations on either end which just fall inside this range.
For an example see Figure 6.6 on page 89. The box plot uses the whole sample,
skipping over missing values.
10.13
mt = (1 )
m1 +
t1
X
(1 ) yts .
s=0
See e.g. Harvey (1993, Ch. 5), or Makridakis, Wheelwright, and Hyndman (1998,
Ch. 4).
10.14
The exponentially weighted moving sample correlation of two series yt and xt , both
having expectation zero, is defined as:
rt =
pt (x, y)
1/2
t = 3, . . . , T
150
where
pt (x, y) =
t1
X
s xts yts ,
t = 1, . . . , T,
s=0
and r1 , r2 are set to missing values. When any yt+h or xt+h is missing rt+h is set to rt .
Premultiplying the numerator and denominator of rt by 1 , shows that mt =
(1 )pt (x, y) is the EWMA of the cross-product with = 1 and m1 = 0. This
does not work for = 1.
Chapter 11
OxMetrics file formats
11.1
The most convenient way of storing data on disk when using OxMetrics is the combination of the information (.in7) and binary (.bn7) data file.
The information file, with the .in7 extension, holds the information about the data
set. The information file is accompanied by a binary data file. The binary data file holds
the actual data, and has the .bn7 extension. The .in7/.bn7 combination is convenient
because information on sample size etc. is automatically stored.
Loading of very large .in7/.bn7 files is significantly faster than loading .xlsx or
.csv files.
Note OxMetrics uses the same format as PcGive versions 7 and 8. (The difference is
that spaces are allowed in variable names, and the introduction of date and choice
variables.)
11.1.1
The .in7 file is a text file that stores the metadata. As an example, see Table 11.1,
which lists the data.in7 file.
Table 11.1
pcgive 700
data data.bn7
;Tutorial Data Set:4 equation model with oil shock for PcGive
;October 1985
>CONS
1953 1 1992 3 4 32 data
10-04-1992 13:20:38.33
; Artificial consumption variable
>INC
1953 1 1992 3 4 1336 data 10-04-1992 13:20:38.33
; Artificial income variable
>INFLAT 1953 1 1992 3 4 2640 data 10-04-1992 13:20:38.33
; Artificial inflation variable
>OUTPUT 1953 1 1992 3 4 3944 data 10-04-1992 13:20:38.33
; Artificial output variable
151
152
1953 1 1992 3
4
32
sample period
frequency address
name, preceded by status: active (>) or deleted (-)
data
group
10-04-1992 13:20
type
Status If the status is a minus sign, the variable is deleted (but physically still present).
A deleted variable will not be loaded into OxMetrics.
Variable name Maximum length is 64 characters. The variable name is enclosed in
double quotes if it has a space, but leading and trailing spaces, as well as double
quotes in the name are removed. So a name like CONSINC, which would not be a
valid variable name in any programming language, is allowed.
Generation The generation is not explicitly stored in the information file, but derived
from the variable name. If there is more than one entry with an identical name (also
written in identical case, since Cons and CONS are different), then the first one has
generation 0, the second generation 1, etc. Only the highest generation (most recent
version) will be loaded into OxMetrics.
Sample period The sample period consists of four numbers: startyear, startperiod,
endyear and endperiod. Each variable in the data file can have a different sample
period. When reading such a file into OxMetrics with a still empty database, the
sample containing all data will be used (missing observations will get the missing
153
value).
Frequency Variables with different frequencies can be stored, but only one frequency
at a time can be loaded into OxMetrics (although several databases can be open
simultaneously with different frequencies).
Address Gives the physical address of the variable in the binary data file. So the first
observation of CONS starts at byte 32 in data.bn7, the second at byte 40 etc. (data
is stored in double precision, taking eight bytes per observation). The 32 bytes preceding every variable are a separate information block, from which a rudimentary
information file can be reconstructed. If necessary, this is a 64-bit integer.
Group Variables in a file can be grouped together by the group name. No spaces are
allowed in the group name.
Date and time fields These give the date and time at which the variable was written.
No spaces are allowed in either field.
Variable type The optional entry after the date and time fields gives the variable type:
(empty) By default the type field is empty, indicating a normal numerical variable.
date Indicates that this is a variable of type Date.
choice[#] Signals a choice variable. The # is an integer that specifies the number
of labels. The next line enumerates the labels, starting with |, and also using |
as a separator. The choice list can be written over multiple lines, but each line
must start with a |. As a consequence, the | character should not be used in the
choice label.
11.1.2
The .bn7 file is a binary file, and thus not human readable. It holds the actual data.
Each variable starts with a 32 bit signature, followed by the data in the form of 8
byte doubles. The doubles have the standard IEEE form and are stored in little endian
format (the default on PC platforms).
The 32 bit signature consists of:
bytes
0-7
8-11
12-23
24-25
26-27
28-29
30-31
C type
double
int
char[12]
short int
short int
short int
short int
description
marker (double: 9999E99)
number of observations (T )
variable name (truncated or padded with null characters)
frequency
starting period
starting year
not used
This signature is followed by 8 T bytes. The signature is always written, but never
read, because all the relevant information is obtained from the .in7 file, including the
starting address of each variable. Note that int is a 32-bit signed integer, and short int a
16-bit signed integer.
Missing values are encoded as a IEEE defined NaN (not a number); 9999.99 is
not recognized as missing (but was used for this purpose in early versions of PC-GIVE).
154
11.1.3
The amount of data in the .in7/.bn7 files is limited by available disk space, and, more
strictly, by available memory. In a 32-bit operating system, the maximum database size
is about 22 8 2.68 108 elements, equivalent to 2 Gigabyte of memory space. For
a 64-bit operating system, the maximum number of observations in a variable is 23 1
2.1 109 . This is usually much more than can be loaded at one time in OxMetrics. C
source code and object files to read .in7/.bn7 files are available on request. Ox can
read and write .in7/.bn7 on all computer platforms.
11.1.4
An information file may describe a human-readable data file which is ordered by variable. This option is especially useful for the situation where OxMetrics is routinely
used to process output generated by another program which cannot write binary data
files. When saving data, OxMetrics will always create a binary data file with accompanying information file. To attach a human-readable file to an information file, the
filename following the data statement in the .in7 file should have the .dat extension
(and the .bn7 file must not exist, otherwise that file is read instead). In the example of
Table 11.1 the second line would read data data.dat. Then OxMetrics will assume
that the data is stored in the human-readable (ASCII) data file data.dat. The data
must be ordered by variable, and offending words are treated as missing values (see
11.3). Apart from the data statement, the organization of the .in7 file is the same as
in 11.1. The value in the address field will be ignored, the date and time field may be
missing.
11.2
Support for .wks and .wk1 files will be dropped in OxMetrics 8; .xls files are under consideration for removal with OxMetrics 9.
155
The data matrix is a rectangular array, structured in one of the following formats:
1. Unlabelled first column with dates, followed by labelled columns, one for each
variable.
The first column either consists of proper calendar dates, or strings that represent
a date. In the latter case, it should be of the form yearperiod, where the can
be any single character: for example, 19801 (or: 1980Q1 1980P1 1980:1 etc.;
this character is ignored).
If the date column can be read as fixed frequency dating of observations, the
sample will be set appropriately, and the date column will not appear as a variable.
If the first column cannot be interpreted as defining a fixed-frequency database,
the column will be loaded with default variable name Svar1.
2. All columns are labelled.
An attempt will be made to read the first column as the dates. Regardless of the
result, the column will appear as a variable in the database.
If string-based dates were used, the date variable is of type choice. Otherwise it
will be of type date, in which case the database will appear as dated.
3. No column is labelled.
This is the same as if all columns are labelled with Svar1, Svar2, ....
If no dates are present, the database will have a fixed frequency of unity, starting
from year 1.
If these conventions are not adopted the file can still be read, but you might have
to provide some additional information, such as frequency, start date and row of first
observation. In the example, these are respectively 4, 1980 1, 2.
Variable types are determined automatically:
1. If a variable contains text fields, it will be interpreted as a choice variable. The
ordering of the choice labels is determined from the comment field, see the example
below.
If there is no comment field, numbers will be assigned consecutively to unique text
fields. This means that these observations with be assigned an integer value that is
not yet used in the variable. Identical text fields will have the same integer value.
Fields that have no label associated show their value, while missing values are
shown with a dot.
When saving as .xlsx, the choice labels are saved to the comment field of the
variable name.
2. A variable with dates will become a date variable. A date variable will interpret all
observations as dates.
3. Otherwise, the variable has only numerical values (the default).
You can use #N/A, #NA, .NaN, ., missing or leave gaps for missing observations
in the input spreadsheet file. When saving as a spreadsheet file, missing values are
written as #N/A.
156
For example, the format for writing is (this is also the optimal format for reading):
A
1
2
3
4
5
6
1980(1)
1980(2)
1980(3)
1980(4)
1981(1)
B
CONS
883
884
885
889
900
C
INFL
2.7
3.5
3.9
2.6
3.4
D
DUM
3
5
1
9
2
We shall give some examples to show what happens with slightly different files. The
spreadsheet displayed on the left was created in Excel, and then subsequently loaded
into OxMetrics, with the result displayed on the right.
In the first example the first column has dates, rather than text. There is also text
in the third variable. OxMetrics detects that the dates correspond to a fixed frequency
sequence (monthly in this case), and sets the sample correctly. Text fields are assigned
unused integers, starting from zero, in the order they are found (separately for each
variable). So text gets value 0, and abcd value 3.
A
1
2
3
4
5
5
Jan-80
Feb-80
Mar-80
Apr-80
May-80
B
aap
1
2.3
9
4.125
1
C
D
noot mies
#N/A
1
12.436
2
13.786 text
9.456 abcd
#N/A #N/A
OxMetrics database
aap
noot
1980( 1)
1 missing
1980( 2)
2.3
12.436
1980( 3)
9
13.786
1980( 4) 4.125
9.456
1980( 5)
1 missing
mies
1
2
text
abcd
.
While this method of reading text works, it doesnt guarantee that the labels always
appear in a user-defined order (so that text always corresponds to value 0). When
saving this database from OxMetrics as .xlsx file, the choice labels are saved in the
comment field of the variable. The description of the variable created in OxMetrics is
also preserved there. Using Choice Variable for the description and saving, the file
appears as follows in Excel:
In the second example the dates are valid, but column labels (that is, variable names)
are missing. Also note that any non-numeric fields are converted to missing values.
1
2
3
4
A
1980(1)
1981(1)
1982(1)
1983(1)
B
1
2.3
9
4.125
C
missing
13.786
9.456
D
1
2
3
4
1980
1981
1982
1983
157
OxMetrics database
Svar1 Svar2 Svar3 Svar4
1980(1)
1 missing
1
1981(1)
2.3 missing
2
1982(1)
9 13.786
3
1983(1) 4.125 9.456
4
A
1
2.3
9
4.125
B
#N/A
12.436
13.786
9.456
C
1
2
3
4
1-1
2-1
3-1
4-1
OxMetrics database
Svar1
Svar2 Svar3
1 missing
1
2.3
12.436
2
9
13.786
3
4.125
9.456
4
158
first column, with other columns labelled, is loaded if it contains numerical data (even
when recoginized as defining a fixed frequency).
When reading, variables with non-numerical fields are converted to a choice variable, with the text as choice label. A choice variable is not properly preserved in the
saved csv file: the label is written, but the numerical value is reconstructed from the
order when loading. This may not correspond to the original order.
11.2.3
OxMetrics can use spreadsheet files for econometric modelling, because it imposes
structure on the spreadsheet to define variables, their names, and the sample period.
Dates are mapped to OxMetrics dates. Text fields, apart from variable names or date
labels in the first column, are interpreted as labels for specific values, defining a choice
variable. Because the underlying value of a choice is still numerical, it can be used to
select an estimation sample by, create dummy variables, or use in a regression.
Another benefit of the adopted handling of choice variables is that they can be easily
manipulated in Ox using the Database class. Database::GetVarChoices gets the list
of choices as an array, while Database::GetObsLabel gets the label of an observation
on a variable.
The Ox loadsheet function can be used to read an entire spreadsheet (.xlsx or
.csv) into an array, without the interpretation that OxMetrics and Ox apply by default.
The Ox loadmat function can be used to read an entire numerical spreadsheet
(.xlsx or .csv) into a matrix, either with or without the interpretation that OxMetrics and Ox apply to dates and strings. Without the interpretation all the strings are
treated as missing values, and variables that only have missing values are dropped.
11.2.4 .xls files
OxMetrics can read the following types of Excel files:
.xls: Excel 5.0, 95, 97, 2000, XP, 2003, 2007 workbooks.
.xls: Excel 2.1, 3.0, 4.0 worksheets;
Workbooks are compound files, and only the first sheet in the file is read.
When reading, variables with non-numerical fields are converted to a choice variable, with the text as choice label. A choice variable is not properly preserved in the
saved csv file: the label is written, but the numerical value is reconstructed from the
order when loading. This may not correspond to the original order.
When saving a database as an .xls Excel file, it is written as an Excel 2.1 worksheet. The maximum size of spreadsheet files is 65 536 rows by 256 columns, and
a warning is given if that maximum is exceeded (OxMetrics can handle much larger
datasets). OxMetrics does not enforce the maximum number of columns, allowing up
to 65 536 instead; rows and columns in excess of 65 536 are not written. There are no
such restrictions with Office Open XML .xlsx files.
11.3
159
As the name suggests, a human-readable (or text) data file is a file that can be read using
a file viewer or editor. (A binary file cannot be read in this way.) Initial input of data
to OxMetrics is often in this form, and then saved in the OxMetrics format (see 11.1).
The default extension is .dat.
In this format, there is no information on sample size nor on data frequency. There
may be information on variable names at the beginning of the file. The data set will be
loaded as undated, which can be changed subsequently inside the program.
Each variable must have the same number of observations. Variables that have too
short a sample have to be padded by missing values. Text following ; or // up to the
end of the line is considered to be comment, and skipped. Data files must be ordered
by observation (first observation on all variables, second observation on all variables,
etc.) with one observation per line. The file may start with listing the variable names.
Examples are:
//by observation
891 2.8 //1953 (1)
883 2.7 //1953 (2)
884 3.5 // etc.
891 2.8
885 3.9
. 2.6
891 2.8
//with names
Cons Inflat
891 2.8 //1953 (1)
883 2.7 //1953 (2)
884 3.5 // etc.
891 2.8
885 3.9
889 2.6
11.4
This data type can be read without intervention, unlike data by observation, which is
unstructured. An example is:
>CONS 1953 1 1954 1 4
890.449584960938
.
884.884704589844
885.254089355469
886.328796386719
899.795288085938
900.678527832031
895.776916503906
The variable description starts with a >, followed by the variable name (no spaces
are allowed), the sample and finally the frequency. This is similar to the description in
the .in7 file. The description is followed by the actual data (so the data are always
ordered by variable here). As before, text following ; or // up to the end of the line is
considered to be comment, and skipped.
When loading a .dat file, OxMetrics will first see if it is a Gauss data file. If not,
it will try to read it as a data file with load information. Finally, it will try a data file by
observation.
160
11.5
The .dht/.dat combination is a format written by Gauss. The .dht part is a binary
file which specifies the size of the data. The .dat file holds the actual data in binary
form. OxMetrics can read both 16 and 32 bit .dht files (called small data set v89 and
extended data set v89), but only reads the .dat file if it holds 8 or 4 byte doubles. Any
complex part of the data is ignored. There is no sample information in the .dht file,
the frequency will be set to one, and the first observation will be at year 1. This can
be changed after loading the data, see 8.6.2.
OxMetrics can write a 32-bit .dht/.dat file, but dates, choice labels, variable comments, database comment and sample information is lost.
11.6
The .dta file is a format written by Stata. OxMetrics can read files written by Stata
versions 46 as well as those defined as formats 113 to 115. There is no sample information read from the .dta file, so the frequency will be set to one, and the first
observation will be at year 1. This can be changed after loading the data, see 8.6.2.
OxMetrics can write a .dta file as a format-114 file, but dates, database comment
and sample information is lost. Choice labels and variable comments are preserved.
11.7
The contents of text windows are written to the results file, using the default extension
.OUT when saving the window content to disk.
11.8
The batch file stores a set of batch commands, and has the .FL extension. It is a normal
text file. The batch language is explained in Chapter 13.
11.9
An algebra file holds the algebra code, and will normally have the .ALG extension. It
is a text file and can be edited. The algebra syntax is explained in Chapter 12.
11.10
Ox file (.ox)
Is used to store Ox programs (Doornik, 2013). When loaded in OxMetrics, with the
Windows version of Ox installed, the file can be run by clicking on the Run button on
the toolbar, or using the Modules/Run Default Module command (Ctrl+r).
11.11
161
Is used to store TSP programs. When loaded in OxMetrics, with the OxMetrics compatible version of TSP installed, the file can be run by clicking on the Run button on the
toolbar, or using the Modules/Run Default Module command (Ctrl+r).
11.12
A matrix file holds a matrix in human readable form. The actual matrix contents is
preceded by two integers which specify the matrix dimensions (number of rows and
columns). A matrix file normally has the .mat extension. Lines starting with ; or // are
treated as comments. An example of a matrix file is:
2 3
//comment
1 0 0
0 1 .5
11.13
//<-//<-//<-//<--
dimensions, a 2 by 3 matrix
a line of comment
first row of the matrix
second row of the matrix
This is the only graphics storage which can be read back into OxMetrics. The file
is text, but direct editing will rarely be necessary because all graphics objects can be
manipulated on screen. Figure 11.1 corresponds to the following .gwg file:
OxMetrics 11 1 1
paper(15000,7500)
box(1,640)
mode(1,0)
xvec(0,2,2)
{
"CONS" 8
< 890.4495849609375
885.2540893554688
>
"" 0
1953.75 0.25;
freq:4;
symbol:1 4 160;
}
xvec(0,3,3)
{
"INC" 8
< 908.2122802734375
895.7769165039063
>
"" 0
1953.75 0.25;
freq:4;
symbol:0 1 90;
}
axis(0,1)
162
{
x;
anchor2: 0;
label:300 1000 60;
grid:0 8 1;
set:0 1 0 0 0 0 0;
rot:0;
}
axis(0,1)
{
y;
anchor2: 0;
label:300 1000 60;
grid:0 8 1;
set:0 1 0 0 0 0 0;
rot:0;
}
area(0,0)
{
}
legend(0,1)
{
365 46 0;
set:300 1 2 1;
}
line(0,11,11)
{
wset:1954.502949852507 884.0768348623853 1954.99133480826
905.3899082568807 0;
}
text(0,1)
{
9128 5619 10$$\theta_i$;
set:0 390 0;
wset: 1955.03558259587 904.0137614678901;
}
CONS
INC
905
900
895
890
885
1954
1955
Figure 11.1
A simple graph
1956
11.14
163
A PDF file is a (partially) compressed binary file which can be handled by many PDF
compatible programs.
11.15
A PostScript file is an ASCII file which can be printed on any PostScript compatible printer, or on other printers using GhostScript. GhostScript (and its companion,
GhostView for viewing files) can be obtained from the internet.
Direct printing can be achieved simply by copying the file to the PostScript printer.
However, since the file is Encapsulated PostScript (EPS), it will not be centred on the
page. Most popular word-processors can load EPS files.
Figure 11.1 corresponds to the following .EPS file (part of the actual graph is deleted
from the listing):
%!PS-Adobe-2.0 EPSF-2.0
%%BoundingBox: 0 0 432 216
%%Creator: Ox (C) J.A. Doornik, 1994-2006.
%%Pages: 0
%%EndComments
%functions deleted ...
%lines
/Linetype0 [ ] def /Linewidth0 10 def
/Linetype1 [ ] def /Linewidth1 6 def
/Linetype2 [ ] def /Linewidth2 10 def
/Linetype3 [50 20] def /Linewidth3 10 def
/Linetype4 [ ] def /Linewidth4 10 def
/Linetype5 [35 35] def /Linewidth5 10 def
/Linetype6 [35 35] def /Linewidth6 20 def
/Linetype7 [35 35] def /Linewidth7 30 def
/Linetype8 [160 80] def /Linewidth8 10 def
/Linetype9 [160 80] def /Linewidth9 20 def
/Linetype10 [160 80] def /Linewidth10 30 def
/Linetype11 [ ] def /Linewidth11 20 def
/Linetype12 [ ] def /Linewidth12 30 def
/Linetype13 [ ] def /Linewidth13 50 def
/Linetype14 [ ] def /Linewidth14 10 def
/Linetype15 [ ] def /Linewidth15 10 def
%fonts
/F0 /Times-Roman ISOLatin1
/F1 /Symbol findfont definefont pop
/F2 /Times-Bold ISOLatin1
/F3 /Times-Italic ISOLatin1
/F4 /Times-BoldItalic ISOLatin1
/F5 /Helvetica ISOLatin1
/F6 /Courier ISOLatin1
/F7 /Times-Roman ISOLatin1
/F8 /Times-Roman ISOLatin1
/F9 /Times-Roman ISOLatin1
164
%colors
/BWG 16 array def
/Gray 16 array def
/RGB 16 array def
% first set all to black
0 1 15 { dup Gray exch 0 put RGB exch [0 0 0] put } for
% color 0: white
% color 1: black
BWG 0 0.00 put
BWG 1 0.00 put
BWG 2 0.00 put
BWG 3 0.00 put
BWG 4 0.00 put
BWG 5 0.00 put
BWG 6 0.00 put
BWG 7 0.00 put
BWG 8 0.20 put
BWG 9 0.95 put
BWG 10 0.79 put
BWG 11 0.85 put
BWG 12 0.70 put
BWG 13 0.25 put
BWG 14 0.50 put
BWG 15 0.75 put
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[1.00
[0.00
[1.00
[0.00
[0.00
[1.00
[0.00
[0.50
[0.50
[1.00
[0.50
[0.50
[0.00
[0.25
[0.50
[0.75
1.00
0.00
0.00
0.00
0.50
0.00
0.75
0.50
0.00
1.00
1.00
1.00
1.00
0.25
0.50
0.75
1.00]
0.00]
0.00]
1.00]
0.50]
1.00]
0.00]
0.00]
0.50]
0.50]
0.50]
1.00]
1.00]
0.25]
0.50]
0.75]
put
put
put
put
put
put
put
put
put
put
put
put
put
put
put
put
FullPage
%Graph start
% rest deleted ...
%Graph end
restore
showpage
%%EOF
Sometimes minor changes need be made after saving the file, e.g.:
Changing colour model.
165
11.16
The difference with the .EPS file of the previous section is that the default size is full
page, with settings controlled via the PostScript Setup dialog.
166
11.17
The Windows metafile format is used for storing the graph as displayed on screen.
Since the graphs are drawn in vector form, the metafile will be a vector graph. EMF
files can be read by many programs, for example Microsoft Word and Scientific Word,
and edited further.
11.18
Chapter 12
Algebra Language
12.1
Introduction
OxMetrics is mostly menu-driven for ease of use. To add flexibility, certain functions
can be accessed through entering commands. The syntax of these commands, which
can be seen as small computer languages, is described in this and the next chapter. In
addition, there is the Ox language, which is a more serious computer language, and
described in a separate book.
12.2
Algebra is a simple vector language, operating on only one type of object: the variables in the database. This object is manipulated as a whole, although it is possible to
limit access to a subsample. The only valid statements are assignments and conditional
assignments. Statements have to be terminated with a semicolon.
If an error occurs while executing the algebra code, the processing will be aborted,
and control returned to OxMetrics. All successful statements up to that point will have
been executed, with corresponding changes to the database. Take this into account when
rerunning the corrected code.
There are three ways of running Algebra code, as discussed in the next three sections.
12.2.1
Calculator (Alt+c)
The calculator enables easy manipulation of the variables in the database, and is a convenient way to write algebra expressions.
The aim is to build a valid algebra expression in the expression window (without
the assignment part and the terminating semi-colon). All successful transformations are
logged in the Results window as Algebra code.
167
168
12.2.2
The Tools/Algebra Editor command enables you to transform the database variables
by typing mathematical formulae into an editor. The algebra code can be saved and
reloaded. The Algebra editor also allows for choosing the database to which the code
is applied.
12.2.3
A text selection containing Algebra code can be run directly from that window using
the Edit/Run as Algebra command (or Ctrl+a as short cut). The code is applied to
the currently active database. The current database is changed by setting focus to that
database, or using any of the drop down boxes (calculator, algebra editor, graphics), or
using the usedata() batch command.
12.2.4
Algebra code can be specified in a Batch program, see Ch. 13, and specifically 13.5.1.
An Algebra file can also be loaded into a batch file (13.5.14).
12.3
12.3.1
Names are made up of letters and digits. The first character must be a letter. Underscores ( ) count as a letter. Valid names are CONS, cons, cons 1, a 1 b, etc. Examples
of invalid names are CONS, 1CONS, log(X), etc. Invalid names may be used in
Algebra when enclosed in double quotes, so
"log(X)" = log(X);
is valid as long as the variable called X exists. Algebra is case-sensitive: CONS and
cons refer to different variables. When you create a new variable through an assignment
operation, it is immediately added to the database, and initialized to missing values. If
necessary the database name will be truncated (longer names are allowed in algebra
than in the database).
12.3.2
Comment
Anything between /* and */ is considered comment. Note that this comment cannot
be nested. So
aap = CONS + 1; /* comment /* nested comment */ */
leads to a syntax error. Everything following // up to the end of the line is also comment.
169
Constants
Algebra operators
Arithmetic operators
The relational operators are <, <=, >, >=, standing for less, less or equal,
greater, greater or equal. The equality operators are == and !=, is equal to and is
not equal to. These are ranked below the relational operators in precedence. Ranked
yet lower are logical AND (&&) and logical OR (||). The unary negation operator !
has the highest precedence. An example of unary negation is:
new = !season();
new will have a 0 where the season function returns a 1, and vice versa. Boolean
arithmetic is also done in floating point. The numeric result is 1. for an expression
that evaluates to true, and 0. for one that is false. An expression with value 0 is false,
whereas a value that is not 0 is true.
Missing values are treated as follows:
a op b
<, <=, >, >=
==
!=
&&, ||
12.3.4.3
Table 12.1 lists the operator precedence, with the highest precedence at the top of the
table.
12.3.5
Assignment statements
170
Logical NOT
Unary minus
Unary plus
Right to left
*
/
Multiply
Divide
Left to right
+
-
Add
Subtract
Left to right
<
<=
>
>=
Less than
Less than or equal to
Greater than
Greater than or equal to
Left to right
==
!=
Equal
Not equal
Left to right
&&
Logical AND
Left to right
||
Logical OR
Left to right
(it is possible to restrict assignment to a subsample using the insample function). Some
valid assignment statements are:
cons2 = 2 * CONS - 1;
cons3 = CONS / 3 - (cons2 + 5) * 1.55;
Seasonal = season();
The last statement constructs a variable called Seasonal, which is 1 in period 1, and 0
otherwise. This variable will be used in further examples in this chapter.
Take care not to confuse the = and == symbols: = assigns, while == compares.
Parentheses may be used in expressions in the usual way; in the example above (cons2
+ 5) * 1.55 evaluates to cons2 * 1.55 + 5 * 1.55.
12.3.6
can be read as follows: the variable new will get the value of CONS when Seasonal is
true (that is, when Seasonal is not 0., so in the first quarter of each year), else it will
171
get the value 0. In this case, the same result could have been reached with:
new = Seasonal * CONS;
However, if we had used a seasonal with the value 2 in the first quarter, and the rest
zeros, then only the conditional assignment would have given the desired result (since
2 is not false, and hence true).
Note that the : FalseExpression part is optional. For example:
new = Seasonal ? CONS;
is a valid conditional assignment statement. Now the variable will have the value of
CONS for the first quarter, but the other observations of new are not touched (so if new is
created by this expression, it will contain missing values for quarters 2, 3 and 4, making
the variable unusable for modelling purposes). Another example:
new = (CONS == MISSING) ? 0 : CONS;
This new variable takes the values of CONS, replacing missing values by zeros.
12.3.7
Indexing
By absolute date
In this case the index has the form year(period), for example
X = INC + CONS[1980(1)];
y[1955(1)] = 12;
12.3.8
Keywords
172
Table 12.2
keyword
FALSE
TRUE
FREQUENCY
MISSING
PI
NOBS
12.4
value
0.
!FALSE
data frequency
the missing value
Pi (3.1415..)
number of observations
Algebra implementation
Each Algebra statement has an implicit loop over the sample size around it. E.g.
LCONS = log(CONS);
meanLCONS = mean(LCONS);
Note that the mean of a vector is just a single number, so creating a vector which has
this value for every observation is implemented with the constant function in Ox (and
adding this to the database is not very useful).
12.5
173
Algebra Functions
A large set of functions is provided by algebra. Most of these take both variables and
constants as arguments. A function name must be followed by parentheses, even if it
does not take any arguments. See the Algebra function list of Table 12.3 for function
definitions. Some examples of statements involving functions are:
lcons = log (CONS);
// takes the natural logarithm of CONS
cons_1 = lag(CONS, 1);
// lag CONS one period
ccons = exp(log(CONS));
// gives back original CONS
dummy = insample(1979, 1, 1983, 4) ? log(CONS) : 0;
// Dummy will be log(CONS) for the period 1979(1)
// to 1983(4), and 0 outside it.
trough = (lag(trough,1) == MISSING || CONS < lag(trough,1))
? CONS : lag(trough,1);
// a trough can also be created with the built in
// algebra function trough()
dummy = (year() == 1979) ? 1 : 0; // creates a dummy variable
12.5.1
A variable is lagged using the lag function,1 and differenced using the diff function.
For example, for first lag and difference respectively, as well as second lag and difference:
Y_1 = lag(Y, 1);
DY = diff(Y, 1);
Y_2 = lag(Y, 2);
D2Y = diff(Y, 2);
This code adopts the naming convention which is used by OxMetrics: append an underscore followed by lag length for a lagged variable, and a prefix D for differenced
variables.
When taking a first difference or lag, the first observation becomes missing; for a
second difference or lag, the first two observations are missing, etc.
Neither function can have an expression as the argument for differencing. So you
cannot write diff(diff(Y,1),1) but must write:
DY = diff(Y, 1);
DDY = diff(DY, 1);
The sample autocorrelation function can easily be plotted, see 6.6.1. To compute the
exact values of the ACF, use the following algebra code:
1
In most cases it is better to avoid storing lags in the database: most estimation modules
handle lags explicitly, allowing for dynamic analysis of the model.
174
acf_lag = MISSING;
acf_dcons = MISSING;
acf(DCONS, acf_dcons, acf_lag);
The first two lines are required to create the output variables for the acf function. The
output from acf is the actual ACF values (here stored in ACF DCONS), and the lag length
(in ACF LAG).
The periodogram function has a similar syntax, returning the sample periodogram
in the second argument, and the frequencies at which it was computed in the third.
Section 10.7 describes this in more detail.
12.5.3
Sorting functions
The sort functions change the order of observations in the database and must be handled
with care. Note that the trend() function can be used to create a variable which
corresponds to the original observation index of the data. So if that variable is sorted
together with the variable we wish to sort, it can be used to unsort the variable.
sort(arg1)
Sorts the variable arg1 in increasing order (arg1 must be a variable, and cannot be
an expression). Returns the value of arg1 after sorting. Suppose the residuals of a
regression have been saved in the variable called Residual, then a sorted copy is
created as follows:
res = Residual;
sort(res);
sortby(arg1, arg2)
Sorts the variable arg1 in increasing order, and sorts arg2 accordingly. Returns the
value of arg1 after sorting. Both arg1 and arg2 must be variables. Suppose the
residuals of a regression have been saved in the variable called Residual, then a
sorted residual is created as follows:
index = trend();
tmp = _sortby(Residual, index);
/* Residual is sorted, and index accordingly
/* tmp is a dummy variable,
/* at this stage identical to Residual.
/* Now it is easy to locate outliers in Residual
*/
*/
*/
*/
The following statement will reset the old ordering (do not rerun the index =
trend(); statement, because that will overwrite the index and lose the information on the original ordering):
tmp = _sortby(index, Residual);
/* Restores index and Residual, */
/* at this stage index is equal to Trend. */
sortallby(arg1)
Sorts the variable arg1 in increasing order, and sorts the whole database accordingly. Returns the value of arg1 after sorting. This function will be most useful
with cross-section data; for example, to push missing values to the end:
exclude =
(Var1 == MISSING || Var2 == MISSING || Var3 == MISSING);
/* exclude is 1 for each observation where any of the
175
12.5.4
Smoothing functions
The smoothing functions which are available in scatter plots can also be accessed from
algebra. Chapter 10 briefly reviews the mathematics underlying the smoothers.
12.5.4.1
HodrickPrescott filter
which creates hpCONS through the assignment statement, and uses it as the destination
for the fitted values from the filter.
If there are missing values in the data series, smooth hp uses data starting from the
first valid observation, and stopping at the first missing value thereafter (this is unlike
the smoothing functions of the next section, which will skip over missing values, using
the maximum sample). The sample used can be restricted using the insample function.
The bandwidth parameter associated with the HodrickPrescott filter is 100(freq)2 :
annual data
quarterly data
monthly data
12.5.4.2
100
1600
14400
The kernel based smoother (using the Epanechnikov kernel, 10.10.1), and the natural
cubic spline (10.10.2) are computed respectively by:
var dest = smooth np(var,alpha,var dest);
var dest = smooth sp(var,alpha,var dest);
where var is the variable to be smoothed, var dest is the destination variable (must be
different from var), and alpha is the bandwith, used as follows:
0
use automatic bandwidth selection based on generalized cross validation;
< 0 the absolute value is used for the bandwidth;
> 0 specifies the equivalent number of parameters to be used.
176
These functions will use all available observations (unless restricted by the
insample function), and will fill in missing values using the fit from the smoother.
Some examples were given in 9.2.6.
12.5.4.3
Here = 0.5. An extended version introduces a slope coefficient , and is also called
Holts method, e.g. with = 0.1:
ysmo = ewma(y, 0.5, 0.1, ysmo);
When a database is dated, there are functions to return components of the current date
and time for each observation: day, month, week, hours, minutes, seconds.
The makedate and maketime functions translate year, month, day and hours, minutes, seconds to date and time respectively. These can be added together to create a date
with a time.
The dayofweek, isdayofmonth and iseaster functions are needed when determining holidays, for example to delete all holidays and weekends from a database. The
following code, supplied as holiday us.alg in the algebra folder, determines all the
official US holidays:
hol_us_fix =
/* official US holidays: fixed dates
(month()==1 && day()==1)
/* New Years Day
|| (month()==7 && day()==4)
/* Independence Day
|| (month()==11 && day()==11)
/* Veterans Day
|| (month()==12 && day()==25);
/* Christmas Day
hol_us_fix = hol_us_fix
/* fixed dates moved to Fri
|| (month()==12 && day()==31 && dayofweek()==6)
|| (month()==7 && day()==3 && dayofweek()==6)
|| (month()==11 && day()==10 && dayofweek()==6)
|| (month()==12 && day()==24 && dayofweek()==6);
hol_us_fix = hol_us_fix
/* fixed dates moved to Mon
|| (month()==1 && day()==2 && dayofweek()==2)
|| (month()==7 && day()==5 && dayofweek()==2)
|| (month()==11 && day()==12 && dayofweek()==2)
|| (month()==12 && day()==26 && dayofweek()==2);
*/
*/
*/
*/
*/
*/
*/
hol_us_flt =
/* official US holidays: floating dates */
isdayofmonth(1,2,3) /* 3rd Mon in Jan: Martin Luther King day*/
|| isdayofmonth(2,2,3) /* 3rd Mon in Feb: Washingtons Birthday */
|| isdayofmonth(5,2,-1)/*last Mon in May: Memorial Day
*/
|| isdayofmonth(9,2,1) /* 1st Mon in Sep: Labor Day
*/
177
*/
*/
12.6
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
Available functions are listed in Table 12.3. Any function operating on missing values returns a missing value. Any function which fails also returns a missing value.
Where the argument is var, it must be just a variable name, e.g. one = 1; cum(one);
is allowed, but cum(1) is not. Similarly: lag(CONS+1,1) is not allowed, while
lag(CONS,1)+1 is.
Several examples of Algebra code were given above; for convenience these are
summarized here:
LX = log(X);
DX = diff(X, 1);
"log(X)" = log(X);
aap = CONS + 1; /* comment /* nested comment */ */
new1 = !season();
cons2 = 2 * CONS - 1;
cons3 = CONS / 3 - (cons2 + 5) * 1.55;
Seasonal = season();
new2 = Seasonal ? CONS : 0;
new3 = Seasonal * CONS;
new4 = Seasonal ? CONS;
new5 = (CONS == MISSING) ? 0 : CONS;
CONSlag1 = CONS[-1];
X = INC + CONS[1980(1)];
y[1955(1)] = 12;
X = INC + CONS[0(0)];
// add first CONS value
178
asin(arg)
atan(arg)
ceil(arg)
cos(arg)
cum(var)
date()
day()
dayofweek()
delete(var,. . . )
denschi(arg)
densf(arg1,arg2)
densn()
denst(arg1)
diff(var,arg)
Returns
absolute value of arg (same as fabs)
autocorrelation function (all arguments must be a variable)
arccosine of arg, or 0 if |arg| > 1
almon lag of var P
P1
1
(c1 + 1 i)c2 xti / ck=0
(c1 +
almon(x, c1 , c2 )= ck=0
1 i)c2
arcsine of arg, or 0 if |arg| > 1
arctangent of arg
ceiling of arg (the smallest integer arg)
cosine of arg
cumulative sum of var
date value (dated database) or the observation index
day (dated database)
day of the week (dated database, 1=Sunday,. . . ,7=Saturday)
delete the list of variables when this Algebra run completes
2 (arg) density
F(arg1, arg2) density
N(0, 1) density
student-t(arg) density
argth difference of var, or the missing value if var is not a
variable, or the difference cannot be taken
returns the result of the (32 bit) integer division
first difference of natural logrithm of var
1 inside the sample yr1 (per1) yr2 (per2), 0 outside it
as dummy for a dated database
see 12.5.4.3, 10.13
see 12.5.4.3, 10.14
exponential function of arg
absolute value of arg
floor of arg (the largest integer arg )
floating point remainder of arg1/arg2
div(arg1,arg2)
dlog(var)
dummy(yr1,per1,yr2,per2)
dummydates(date1,date2)
ewma(var,alpha,beta,dest)
ewmc0(varx,vary,lambda,dest)
exp(arg)
fabs(arg)
floor(arg)
fmod(arg1,arg2)
hours()
indates(date1,date2)
as insample for a dated database
insample(yr1,per1,yr2,per2)
true if inside the sample yr1(per1) to yr2(per2), false outside
isdayofmonth(month,dow,nth) returns 1 for nth day of week in month; dow: 1=Sunday, etc.
nth< 0: from end
iseaster(daysafter)
returns 1 for daysafter easter
lag(var,arg)
argth lag of var, or the missing value if arg1 is not a variable,
or the lag cannot be taken; use arg < 0 for leads
log(var)
natural logarithm of var
log10(var)
base 10 logarithm of var
loggamma(var)
logarithm of the gamma function at var)
makedate(year,month,day)
make date values
maketime(hour,min,sec)
make time values
max(arg1, arg2)
maximum of arg1 and arg2
(Continued on next page)
179
Returns
(Continued)
mean of var
minimum of arg1 and arg2
minutes (dated database)
month (dated database)
the moving average of var
P 2
MAV(x, c1 , c2 ) = t+c
k=tc1 xk /(c2 + c1 + 1)
movingSD(var,lag,lead,mvar) the moving standard deviation of var around mvar
hP
i1/2
(xk zk )2
t+c2
MSD(x, c1 , c2 , z) =
k=tc1 (c2 +c1 +1)
pacf(var,dest,lag)
peak(var)
period()
periodogram(var,dest,freq)
probn(arg1)
quanchi(p,arg)
quanf(p,arg1,arg2)
quann(p)
quant(p,arg1)
ranu()
ranchi(arg)
ranf(arg1,arg2)
rann()
rant(arg1)
ranseed(arg)
round(arg)
season()
seconds()
sin(arg)
smooth hp(var,alpha,dest)
smooth np(var,alpha,dest)
smooth sp(var,alpha,dest)
sort(var)
sortallby(var1)
sortby(var1, var2)
sqrt(arg)
stock(var,arvalue,init)
stockv(var,arvar,init)
tailchi(arg1,arg2)
tailf(arg1,arg2,arg3)
tailn(arg1)
tailt(arg1,arg2)
tan(arg)
time()
trend()
trough(var)
variance(var)
year()
Chapter 13
Batch Language
13.1
Introduction
The Batch language gives some control over OxMetrics through a command language.
This allows for automating repetitive tasks, or as a quick way to get to a certain point
in your analysis. Other programs (such as PcGive, STAMP and X12arima) extend this
batch language with their own module-specific commands.
OxMetrics allows you to save the most recent model from the current module as a
batch file (if supported by the module). If a model has been created interactively, it can
be saved as a batch file for further editing or easy recall in a later session. This is also
the most convenient way to create a batch file.
13.2
If an error occurs while executing the Batch commands, the processing will be aborted,
and control returned to OxMetrics. All successful statements up to that point will have
been executed.
There are five ways of running Batch commands, as discussed in the next four sections.
13.2.1
The Tools/Batch Editor command activates the edit window in which you can
edit/load/save a set of batch commands. The file extension used for batch files is .FL.
13.2.2
A text selection containing Batch commands can be run directly from that window using
the Edit/Run as Batch command (or Ctrl+b as short cut).
180
181
If you use File/Open, and set the file type to Run Batch file (*.fl), then the batch file
is run immediately.
13.2.4
You can double click on a .FL file in the Windows Explorer to run the file directly. If
OxMetrics is not active yet, it will be started automatically.
13.2.5
A batch file can be called from another batch file, see 13.5.15.
13.3
When a batch file is run, the working folder is set to that of the batch file. This allows
data and algebra files which reside in the folder of the batch file to be found, even
if the batch file is run from somewhere else. In addition the chdir command allows
specifying a new default directory. Finally, paths to data files can be hard coded, but
that is to be avoided if possible.
When a batch file is loaded in the batch editor, and then run, there will not be an
associated default folder. However, the process of opening the batch file would set the
default folder to that of the batch file.
13.4
Table 13.1 gives an alphabetical list of the OxMetrics batch language statements.
13.4.1
Comment
Anything between /* and */ is considered comment. Note that this comment cannot
be nested. Everything following // up to the end of the line is also comment.
13.4.2
Command types
182
13.4.3
Default arguments
Table 13.1 shows two instances of default arguments, in the appenddata command,
and in the setdraw command. For example, when omitting the last argument as in
appenddata("data.in7");
13.5
Batch commands
In the following list, function arguments are indicated by words, whereas the areas
where statement blocks are expected are indicated by . . . . Examples follow the list
183
of descriptions. For terms in double quotes, the desired term must be substituted and
provided together with the quotes. A command summary is given in Table 13.1. Module
specific commands are documented with each module (so, for PcGive batch commands
consult Volume I of the PcGive books).
13.5.1 algebra { . . . }
Contains the algebra code to execute. The block of algebra should be enclosed in curly
braces, for example:
algebra
{
// Create SAVINGSL in database test
SAVINGSL = lag(INC,1) - lag(CONS, 1);
y = log(Y);
}
184
13.5.10
Graphs a function of the variable y from the current database in the requested area (the
first area has number 0). The mode argument can be one of:
"acf"
autocorrelation function with specified lag length
"boxplot"
boxplot
"cdf"
estimated distribution (QQ plot against normal)
"chisq"
QQ plot against Chi2 (d1)
"cumfreq"
cumulative frequency count (for non-standard bars, specify the
bar count)
"density"
estimated density (for non-standard bars, specify the bar count)
185
Graphs variable y against x from the current database in the requested area (the first area
has number 0). This is a standard scatter plot, but if the second argument equals "", the
graph is a standard time-series plot. For other types of graphs, mode can be one of:
"alt"
use alternate style: x,y labels along axes
"project"
add regression line with projections
"regression" add a regression line
"smooth"
add a cubic spline (automatic bandwidth)
13.5.12
Graphs variable y against x by z from the current database in the requested area (the first
area has number 0). This is a standard scatter plot, but the second argument may equal
"" for a time-series plot. The mode argument can be one of:
"bar"
z is error bar
"band"
z is error band
"fan"
z is error fan
"hilo"
high-low
"symbol"
z is symbol size
"value"
print values of z
For 3-dimensional graphs, the mode argument can be one of:
"contour"
"contourx"
"contoury"
"points"
"surface"
"surfacex"
"surfacey"
"trisurface"
13.5.13
exit;
186
13.5.14 loadalgebra("filename");
Loads and executes the algebra code from the named .ALG file. The extension must be
provided. See 13.3 on the default folder.
13.5.15 loadbatch("filename");
Loads and executes the batch code from the named .FL file. The extension must be
provided. See 13.3 on the default folder.
13.5.16 loadcommand("filename");
Sends the contents of the named file to the active module. The module must be able to
accept commands (either via batch, or as an input console module).
13.5.17 loaddata("filename");
Load the data from the named .IN7 file. To load, a full pathname would sometimes have
to be specified, e.g. "c:\mydata\data.in7". The extension indicates the data type
and must be provided. Inside OxMetrics, the database will then be known as data.in7,
and will be the current default database. See 13.3 on the default folder.
If the database is already opened, the command works as usedata().
13.5.18 loadgraph("filename");
Load the graph from the named file. To load, a full pathname would sometimes have to
be specified, e.g. "c:\mydata\data.in7". The extension indicates the file type and
must be provided (but OxMetrics will always require the .gwg file for loading, so when
using loadgraph(fig1.eps), OxMetrics will look for fig1.gwg.
13.5.19 module("name");
Starts the specified module. When the module is already active, it becomes the focus
for subsequent module-specific batch commands. Otherwise the module is started first.
13.5.20 package("packagename", "modeltype"="");
Used to specify the package and model type for modelling:
package("PcGive", "Single-equation");
13.5.21 print("text");
13.5.22 println("text");
Prints the specified text in the Results window. This can be useful to introduce explanatory notes. The println commands adds a new line after printing the text.
187
Prints the current date and time in the Results window. The date and time are pasted
into the text in ISO format yyyy-mm-dd hh:mm:ss, so putting the year first and using a
24-hour clock.
13.5.24 savedata("filename");
Save the current database to the named .IN7 file. The .BN7 file will get the same base
name. If files with these names already exist, they will be overwritten!
13.5.25 savedrawwindow("filename", "window"="");
If no window is specified, the command saves the current Batch Graphics window to
the named file (or gives an error message Cannot save to if there is no Batch Graphics
window or the file cannot be saved). Otherwise it saves the named graphics window.
13.5.26 saveresults("filename");
Save the contents of the results to the named file and clear the Results window. If a file
with that name already exists, it will be overwritten!
13.5.27 setdraw("option", i1=0, i2=0, i3=0, i4=0, i5=0);
This command changes the default settings used in graphics. The easiest way to use
this command is to design the layout using the interactive dialogs (Graphics Setup
and Postscript Setup). Then use the Write as batch command on both pages of the
Graphics Setup dialog to record the batch code in the results window. This can then
be pasted to the batch editor, and saved to a file. Or edited, and run directly from the
results window.
option
"axis"
"axisline"
"axisformat"
"box"
"bw"
"color"
"colormodel"
"default"
"font"
changes
axis fonts/ticks
axis options
format of labels
box and grid
black&white settings
colour settings
PostScript model
reset default
font
option
"legendfontsize"
"legendhide"
"legendresize"
"line"
"linebw"
"margin"
"palette max"
"palette min"
"papercolor"
changes
legend font size
legend hiding
legend resizing
colour line settings
b&w line settings
paper margins
palette light colour
palette dark colour
Paper colour
"grid"
"histogram"
"legend"
grid style
bar colours
legend style
"printpage"
"symbol"
"xystyle"
PostScript paper
symbol settings
cross-plot style
188
The following table lists the integer arguments for each option, with the range of
possible values. If no range is given, the argument is a size in pixel coordinates (see
Ch. 14). The default width and precision for axisformat is 8 and 6 respectively.
option
i1
"axis"
fontsize
"axisline"
no X-line:01
"axisformat"
width
"box"
box:01
"bw"
lineno:015
"color"
lineno:015
"colormodel"
model:03
"default"
0,1,2
"font"
fontno:03
"grid"
color:015
"histogram"
inside:015
"legend"
boxed:01
"legendfontsize" fontsize
"legendhide"
hide:01
"legendresize"
resize:01
"line"
lineno:015
"linebw"
lineno:015
"margin"
left
index:07
"palette max"
"palette min"
index:07
"papercolor"
red:0255
"printpage"
orientation:01
"symbol"
lineno:015
"xystyle"
2d along axes:01
linetype
solid
dotted
dashed
long dashes
user defined
symboltype
0 solid box
1 open box
2 plus
3 dash
4 circle
i2
i3
i4
i5
step
tick
no Y-line:01 center dates:01 no small Y:01
precision same precision:01 leading zeros:01
X-grid:01
Y-grid:01
red:0255
green:0255
blue:0255
red:0255
green:0255
blue:0255
fontsize
type:015
outside:015
columns
linetype:04
linetype:04
top
red:0255
red:0255
green:0255
papertype:02
symtype:04
3d along axes:01
papertype
0 A4
1 Letter
2 user defined
5
6
7
8
9
none
line
solid circle
triangle
solid triangle
0
1
2
3
10
11
12
width
width
on
on
green:0255
green:0255
blue:0255
X-size
size
blue:0255
blue:0255
off
off
Y-size
colormodel
black & white
black, white, gray
gray
color
diamond
solid diamond
cross
13.5.28 setdrawwindow("name");
Sets the name of the graphics window in which the graphs appear. The default is
"Batch Graphics".
13.5.29 show;
Shows the graph created in batch. Note that graphs from draw/drawf/drawx/drawz
commands are not displayed until the show command is issued.
13.6 Examples
189
13.6
Examples
We finish with two example batch files. The first uses most non-graphics Batch commands, as well as some commands from the PcGive module.
database("test", 1950, 1, 2000, 4, 4);
// Create the database
// Append the tutorial data set to test
// note that test has a longer sample then data.in7
chdir("C:\Program Files\OxMetrics7"); // default install folder
// it is better to use chdir("#home");
appenddata("data.in7");
loaddata("data.in7"); // Load the tutorial data. Now there are
// two databases, with data.in7 the default database
usedata("test");
// make test the default database
algebra
{
// Create SAVINGSL in database test
SAVINGSL = lag(INC,1) - lag(CONS, 1);
}
package("PcGive", "Single-equation");
system
{
Y = CONS;
// The endogenous variable
Z = Constant, CONS_1, CONS_2;
// the regressors
}
estimate("OLS", 1953, 3, 1992, 3, 8);
// Estimate the system by OLS over 1953(2)-1992(3)
// withhold 8 forecasts
println("Saving results to test.out");
saveresults("test.out");
// Save the contents of the Results
// window to test.out and clear the window
testsummary;
// Do the test summary
println("Appending results to test.out");
appresults("test.out");
// Append the contents of the Results
// window to test.out, and clear the window
break;
The final example uses many graphics batch commands, and is supplied as plots.fl
with OxMetrics:
190
13.6 Examples
setdrawwindow("3D surface plots");
drawz(0, "x","y","z", "surface");
drawz(1, "x","y","z", "trisurface");
show;
191
Chapter 14
OxMetrics Graphics
14.1
Graphics paper
(700,3200)
(0,0)
These pixels are virtual and different from screen pixels: the paper is always
10 000 15 000, regardless of the screen resolution or the size on screen.
Positions can be specified in pixel coordinates, as for example (px , py )
= (700, 3200). More often it is convenient to use real-world coordinates to map
the pixel coordinates into real data values. This is done by specifying an area on the
graphics worksheet, and attaching real-world coordinates to it. These areas are allowed
to overlap, but need not:
(15 000, 10 000)
0
(0,0)
192
193
The areas are numbered from left to right and top to bottom, counting starts at zero.
Suppose we have set up all areas as being from (x, y) = (0.0, 0.0) to (x, y) = (1.0, 1.0)
(again within each area the origin is the lower left corner). Then we can draw a line
through area 2 in two ways:
1. in real coordinates within an area
step 1: select area 2;
step 2: move to (0.0, 0.0);
step 3: draw a line to (1.0,1.0).
2. using pixel coordinates on the worksheet
step 1: move to pixel coordinates (600,600);
step 2: draw a line to pixel coordinates (3600, 3600).
where we assume that (600,600) to (3600,3600) are the pixel coordinates chosen for
area 2. Drawing in real-world coordinates has the advantage that it corresponds more
closely to our data.
14.2
Creating graphs
A graph is created from data in a database using the Graphics toolbar button, or
Model/Graphics. These graphs appear in the window labelled OxMetrics Graphics.
Subsequent graphs are added to this window. To start from scratch, close the window,
or select and delete each area. To keep the existing OxMetrics graphics window and
open a new one for subsequent graphs, use File/New Data Plot Window (note that the
menu contents change according to the type of window which is active).
Modules such as PcGive will put their graphs in a window with a different name.
Examples of the various types of OxMetrics graphs are given in Chapter 6.
14.2.1
plots the actual values of all selected variables against time (or the observation index
for undated series), together or each in a separate graph. If there are missing values,
these show up as gaps in the line.
Create separate Plots
This creates as many graphs as there are series.
Style
Lines
Symbols
Lines and symbols
Index line: plot first series as index
Index line and symbols: plot first series as index
Bars: plot all series as bars
Shading: use shading where this variable is 1, no shading otherwise
First as bar: plot only the first as bar chart
Transformation:
Logarithms: natural logs of the series: log(yt )
194
Match series by
None: no matching is done
Mean & range matched to first series
Second series on right scale
Start = 100
Style: as above
Transformation: as above
Use log scale
14.2.3
Scatter plots
Distribution
195
Autocorrelation function
The sample autocorrelation function (ACF), or correlogram, plots the correlations
rj between xt and successive xtj , Also see 10.3. The length of the ACF can be
set by the user. Since the correlation between xt and xt is always unity, it is not
drawn in the graphs.
Partial autocorrelation function
The partial autocorrelation coefficients correct the autocorrelation for the effects of
previous lags. So the first partial autocorrelation coefficient equals the first normal
autocorrelation coefficient.
Cross-correlation function
The sample cross-correlation function (CCF) graphs the correlation between a series
and the lags of another series.
Periodogram
The periodogram and the spectrum (or more accurately here: spectral density) graph
the series in the frequency domain. The sample periodogram is based on the coefficients of the Fourier decomposition of the sample autocorrelations (that is, the
correlations {rj } in 6.6.1 between xt and xtj ).
Spectral density
The sample spectral density is a smoothed (and scaled) function of the periodogram.
It is symmetric between and , and so is only graphed for [0, ]; 1 on the
horizontal axis stands for , 0.5 for 0.5, etc. Peaks at certain frequencies can
indicate regular (cyclical or seasonal) behaviour in the series.
Seasonal sub-plot
In a seasonal sub-plot, the data are displayed by season. For example, for quarterly
data, first the quarter 1 data are graphed, then quarter 2, etc. This helps detecting
changing seasonal patterns.
14.2.6
QQ plots
196
When X has a uniform distribution over (0, 1), if Px () is plotted against x in a unit
square, the result is a straight line. A similar idea applies to all distributions and QQ
plots can be selected so some reference distribution is a straight line with the empirical
distribution compared to it.
The QQ plot options page on the Graphics dialog allows for a choice of reference
distributions. For the t, F and 2 distribution it is necessary to also supply the degrees of
freedom arguments. Drawing a variable against a uniform results in a so-called quantile
plot.
14.2.7
Error bars
Error bands
Error fans
High-low
Show Z values
As symbol size: Bubble chart
A bubble chart consists of a scatter plot, where the symbols are circles, and the size
of the circle indicates a third dimension (e.g. market share).
14.2.8
3-dimensional plots
197
The Style entry for the 3D graph on Edit Graphs allows for a choice of palette.
Contour lines
The same page allows for the addition of contour lines to a surface (but not a triangulation).
14.3
Printing graphs
Select File/Print to print to an attached printer and File/Print Preview to first view the
results. The following control of headers and footers is available for printing from
File/Print Page Setup:
Orientation: portrait or landscape;
Column and scale are ignored, as the graph will fill the page;
Draw a box;
The size of margin to use;
Draw a header for the graph. This is controlled via the Header and Footer boxes.
There are five specials:
&[date] prints the date,
&[time] prints the time,
&[page] prints the page number,
&[pages] prints the total number of pages,
&[file] prints the file name.
Other text in the edit field is printed directly.
Other print setup options are printer specific.
Use File/Print Preview to view the result before printing. Note that colours are
shown in the preview, but will come out in grey levels (unless you have a colour printer
of course).
14.4
Graphics formats
198
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.
Graphics file formats are discussed in more detail in 11.1311.17.
14.5
Use File/Save As or the diskette toolbar button to save the graph to a file. At the bottom
of the dialog is a dropdown listbox in which you select the type of file.
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.
Choose File/Open, to open a previously saved graphics file type.
14.6
Editing graphs
Each graph consists of a collection of objects, which in most cases can be manipulated,
moved or deleted. The main one, the area, was introduced in 14.1.
14.6.1
Graph layout
An area defines a rectangle on the paper which has world coordinates attached to it.
The concept of areas enables multiple graphs on the paper, up to 36. Areas are allowed
to overlap.
The Graph Layout page of the Edit Graphics dialog allows for making adjustments
that are relevant for the whole graph. Activate this through Edit/Edit Graph, or by
double clicking in an area. You can:
Change the Areas layout, e.g. for example from 2 1 to 1 2.
Box all areas in the current graphics window.
Change the aspect ratio, for example to half-height graphs as used occasionally in
this book.
The aspect ratio of the graph paper defaults to 1.5 (15 000 along the x-axis and
10 000 along the y-axis). This usually works very well, but occasionally it may
need changing, for example to make the graphs square on paper. Half-size graphs
can also look good in publications. Examples are in Figures 6.9 and 6.8.
Change margins.
Adjust all styles to make all lines in all the areas thicker or thinner, or
to Increase all font sizes.
Set the PostScript mode: usually plots on screen are colour, but required in gray
levels for publication purposes.
Display mode can be changed from colour to black & white. Occasionally, this can
be useful when pasting to another application for printing. OxMetrics always starts
in colour mode.
199
Paper colour allows the colour to be set for the (normally) white space around the
graphics areas, e.g. to a light grey.
14.6.2
Area layout
By default, an area has automatic pixel coordinates, which means that, when an area
is added, the pre-existing area will automatically shrink to make space. An area can be
selected with the mouse, and moved around the paper. This changes the automatic paper
positioning into a fixed position. Real world coordinates are also selected automatically,
but can be set to fixed values.
The Area Layout page of the Edit Graphics dialog contains the settings that relate
to positioning and layout of each individual area. You can:
change world coordinates: select the desired area and select the Set checkbox for
the X or Y coordinates, then adjust the settings. Press All to apply this to all areas.
reset pixel coordinates to automatic or set specific pixel coordinates.
change layout, e.g. for example from 2 1 to 1 2.
Box the current area, or all areas in the current graphics window.
The Edit menu allows you to rotate 3-dimensional graphs. This applies to the currently
selected 3D area, or all 3D areas if none is selected:
Rotate left or right (from the keyboard use Alt< or Alt>; this does not require the
shift key, so just hold Alt pressed while typing the < or > key). This canges the
azimuth.
Rotate up or down (from the keyboard use Alt- or Alt+). This canges the elevation.
Twist left or right.
Reset the rotation and twist back to the original values.
14.6.3
The title of this section is derived from the variables being plotted, such as CONS x
(time) x z or INC x (time).
The variable (or vector) is the main graphics object: it consists of a sequence of
observations, graphed against time or another variable. A variable cannot be moved,
nor can observations be moved on screen. There are essentially four types of vectors:
variable against time;
variable against another variable;
variable against another variable by a third variable. The third variable can indicate
symbol size, have its value printed, or specify error bars.
3D graphs: surface, contour or scatter.
The Lines page of the Graphics Property dialog controls how the vector is displayed.
The line type joining the observations can be:
Line: linked,
Symbols: not linked, but showing symbols,
Line and symbols,
200
Index: this draws a line from the point to the zero axis (if part of the area), or the
edge of the area (towards zero). A non zero base can be specified in the Base for
index/bars edit field.
Index and symbols,
Bars: this draws a bar to the zero axis (if part of the area), or the edge of the area
(towards zero), with the bar centred on the current point. A non zero base can be
specified in the Base for index/bars edit field.
Style allows a choice of the colour or pattern for the currently selected entry; the
type choice is repeated in the drop-down box. The colour with which lines and symbols
are drawn is set in the first column; the line width and pattern is set in the second combo
box. In both cases an entry is selected from one of the 16 defined line types. These can
be changed in Model/Preferences/Graphics Setup
The observations can be marked by a symbol, and the style and size of that symbol
can be set in the third column.
For 3D graphs it is possible to change the colour palette, or add contour lines (but
not for a triangulation). The global palette definition is set in Model/Graphics Setup
The entries used in the legend can be changed by renaming the labels of the variables
in the X, Y, Z label boxes. If there is no name, that component will be omitted from
the legend label for the vector: if all labels are empty, the legend entry will be omitted
alltogether.
14.6.3.1
Error bars
Error bar options are only shown if the line object has error bars. Then you can switch
between bars, bands and fans, choose a color for the bars/bands. A multiplication factor
may also be set for error bars and bands. For example, if the data in the Z variable are
standard errors, then a factor 2 will show the data plus/minus 2 standard errors (which
would be a 95confidence interval if the data come from a normal distribution).
To rename a label for the selected vector, click on Rename, or double-click on the
vector in the list box.
14.6.3.2
Regression, Scale
The Regression, Scale page of the Edit Graphics dialog allows adding regression lines
to variables, and adjustment of the scaling (relative to the selected variable):
None removes all scaling.
Means matches the means of all variables to that of the selected variable: the shift
factor will be set to make the means of the variables equal.
Ranges: the scale factor will be set to give all the variables the same range. Maximum minimum will now be the same for every variable. Adjustment is made
relative to the selected variable.
Means and Ranges matches means and ranges. Both the shift and scale factors are
set.
The scale and shift factor can also be set directly.
The regression options in this page are:
201
Axes
An X and Y axis (and Z for 3D graphs) is added automatically to each graph. Usually
the default suffices, but a large number of adjustments can be made in the Axis entries
of the Edit Graphics dialog.
14.6.4.1
The location and transformation settings further position and define the axis:
Anchor: determines where the axis is anchored, e.g. for an X-axis this is a Y value
(changing the anchor would move the X-axis up or down). Minimum anchors at the
left (bottom) of an area, Maximum at the right (top). Use specified anchor allows
anchoring anywhere in the graph. For 3D graphs, the X axis is anchored at an Y
and Z value, Y at X, Z and Z at X, Y .
Transformation
The Axis type:
Normal the default axis without transformation;
Log (data is in logs) when the data is in natural logarithms, use this to show the
original values on the axis;
Log10 (data is in log10) when the data is in logarithms of base 10, use this to show
the original values on the axis;
Use specified shift and scale allows the shift and scale factors to be set;
Dates when the values on the axis are to be interpreted as date values.
202
14.6.4.3
The following adjustments can be made to an axis (all adjustments apply to the current
axis only):
hide an axis by checking Hide. (Axes can also be deleted, but when an area has no
X or Y axis and is redrawn, that axis will be added.)
No base line removes the line, leaving only tick marks.
No small ticks removes the small tick marks.
Line at y=0 is only for X-axes, and uses the same line colour and type as the grid.
By default a line showing zero is added when both negative and positive data occur.
Grid attaches a grid, perpendicular to the selected axis. The grid is at the large tick
marks. The grid colour and type is set in Graphics Setup, the default is that of line
colour and type 14.
The Tick Size. This sets the small tick size, the large tick size is twice the small tick
size.
The Font Size sets the size of the axis labels.
14.6.4.4
Label style
Labels other side puts the labels on the other side of the axis.
Rotate labels writes text of labels along the Y -axis (Y axis), see e.g. Figure 7.4, or
at a right angle (X-axis).
Centre dates puts the labels in between the tick marks. For example for annual
data, the label 1960 is centred at 1960 by default. With Centre dates it is set half
way between 1960 and 1961. This option is for X axes only. This does not work
when the axis is dated.
Note that you may have as many axes as you wish. Axes can be selected on screen with
the mouse.
14.6.5
Legend style
Legends are added automatically in an appropriate size, unless the legend font gets too
small. In that case (normally with more than sixteen areas), the legend will be omitted.
In addition, a legend can be hidden, and subsequently unhidden.
Legends can be selected with the mouse, and moved around. Deleting the legend
results in it being hidden. The available options in the Legend style page of the Edit
Graphics dialog are:
Hide, legends are never completely deleted.
Auto resize, by default, legends are reduced when the area gets smaller. When the
text gets too small, the legend is hidden.
Boxed draws a box around the legends.
Default box size will be unchecked if the box is resized with the mouse. When it is
checked, the box size is left to OxMetrics.
Columns sets the number of columns for the labels; the default is two.
203
Font size determines the size of the label. This is reduced further when Auto resize
is set.
Transparent is the default. In that case, legends are drawn below data plots, with
the exception of shading and separately drawn symbols. Opaque legends, on the
other hand, are drawn on top of everything else.
14.6.6
Histogram
The only available options for histograms is to select a line color/pattern for the outside
line and for the area inside the boxes.
14.6.7
Some aspects of one area can be copied to all other areas in the graph:
Pixel coordinates: width and height or reset the default;
World coordinates: X or Y;
Axes: labelling, scale tyle or label style;
Legend style;
Histogram style.
14.6.8
Text
Text can be added from the Edit menu using Add Text. Text belongs to an area, in
which case it is deleted if the area is deleted (or copied when the area is copied). Text
entered outside any area will be part of area 0. More than one line of text can be entered
at a time. Text can also be rotated, by specifying the angle in degrees. This does not
work so well for multiple line text blocks. Text entered immediately above the graph
will have the title property, which means that it is moved with the area when the area is
moved.
Text uses a LATEX-style of formatting, see 14.9.
14.6.9
Lines can be added from the Edit menu using Draw. Line coordinates may be specified
in world coordinates (the default when the line is drawn inside an area), in which case
the line is deleted if the area is deleted (or copied when the area is copied). Alternatively,
lines may be specified in pixel coordinates. The appearance of a line can be changed to
a box or a solid box.
14.6.10
Objects are added from the Edit menu. Most objects can be selected with the mouse,
and moved and deleted subsequently.
14.6.11
Pointing
The status bar shows the graphics coordinates of the the mouse.
204
14.6.12
Persistent setup for graphics is set through the Model/Preferences/Graphics Setup dialog.
14.7
There is a distinction between use of the clipboard inside OxMetrics, and that for external use. There are three copy commands:
1. Copy is for internal use.
When no area is selected, the whole graphics window is copied. When an area is selected, only that is copied to the clipboard. These clipboard items are not recognized
by other programs.
When a OxMetrics graphics format is on the clipboard, it can be added to an existing
graph (no area selected) or to an existing area (which must be selected). Copying
in the internal format is delayed, which means that the full copying is not actually
performed until a paste is requested. This implies that when a graphics window is
closed it is not available for pasting anymore.
2. Copy Bitmap to Clipboard copies the whole graphics window in bitmap format.
This can be pasted into other programs that recognize bitmaps.
3. Copy Metafile to Clipboard copies the whole graphics window in EMF format,
from which is a vector format that can be pasted into other programs.
It is not possible to paste from other programs into OxMetrics graphs, with the
exception of text.
14.8
All types of graphs will use all valid observations, just skipping over missing values.
14.9
Text formatting
Text uses a LATEX-style of formatting, which allows for complex mathematics be used to
annotate graphs. OxMetrics implements a subset of the normal LATEX commands, and
mathematics is typeset using the Symbol font.
Mathematics is enclosed in $ . . . $; superscripts and subscripts are only allowed in
math mode. A superscript is written as ^{...}, a subscript as _{...}. For example,
$\hat \epsilon _{i-1}^{k+1}$ gives k+1
i1 . Tables 14.1 to 14.6 list the mathematics symbols which are available in OxMetrics.
The entries in Tables 14.7 to 14.8 do not require math mode. Note that, to write
$ \ _ { } % you must enter \$ \\ \_ \{ \} \% respectively (\\ for a backslash is not standard in LATEX, where it denotes a line break).
205
Table 14.1
Greek symbols
\alpha
\beta
\gamma
\delta
\epsilon
\varepsilon
\zeta
\eta
\theta
\vartheta
\iota
\kappa
\lambda
\mu
\nu
\xi
o
\pi
\varpi
\rho
\varrho
\sigma
\varsigma
\tau
\upsilon
\phi
\varphi
\chi
\psi
\omega
\Gamma
\Delta
\Theta
\Lambda
\Xi
\Pi
\Sigma
\Upsilon
\Phi
\Psi
\Omega
Table 14.2
\arrowext
\downarrow
\Downarrow
\Leftarrow
\leftarrow
\Leftrightarrow
\leftrightarrow
\leftarrow\arrowext
\acute a
\bar a
\Rightarrow
\rightarrow
\uparrow
\Uparrow
Table 14.3
a
Arrows
a
a
Mathematics accents
\dot a
\ddot a
a
`
a
\grave a
\hat a
\tilde a
\aa
\AA
\ae
\AE
\o
\O
\ss
a
a`
\a
\a
a
a
\^a
\"a
a
a
\~a
\=a
\.a
206
\aleph
\angle
\approx
\ast
\bullet
\cap
\cdot
\clubsuit
\cong
\cup
\degree
3 \Diamond
\diamondsuit
\div
\emptyset
\equiv
Mathematical symbols
\exists
\forall
\geq
>
\gt or >
\heartsuit
=
\Im
\in
\infty
R
\int
h
\langle
d
\lceil
. . . \ldots
\leq
b
\lfloor
<
\lt or <
\arccos
\arcsin
\arctan
\arg
\cos
\cosh
\cot
\coth
csc
deg
det
dim
exp
gcd
hom
inf
\copyright
\euro
\florin
\$
\{
\rfloor
\sim
\spadesuit
\subset
\subseteq
\sum
\supset
\supseteq
\surd
\therefore
\times
\triangledown
\vee
\wedge
\wp
r
\
}
ker
lg
lim
lim inf
lim sup
ln
log
max
\ker
\lg
\lim
\liminf
\limsup
\ln
\log
\max
min
Pr
sec
sin
sinh
sup
tan
tanh
\min
\Pr
\sec
\sin
\sinh
\sup
\tan
\tanh
Miscellaneous symbols
\P
\pounds
\registered
\\
\}
tm
\S
\trademark
\_
\%
Table 14.8
bold
bold italic
font 0 to 9
italic
Log-like symbols
\csc
\deg
\det
\dim
\exp
\gcd
\hom
\inf
Table 14.7
c
Euro
f
$
{
i
e
<
\mid
\neg
\neq
\ni
\oplus
\otimes
\partial
\perp
\pm
\prime
\prod
\propto
\rangle
\rceil
\Re
Table 14.6
arccos
arcsin
arctan
arg
cos
cosh
cot
coth
6
=
3
0Q
\bf
\bi
\f0 \f9
\it
roman
sans serif
typewriter
\rm
\sf
\tt
small
large
normalsize
\small
\large
\normalsize
Chapter 15
OxMetrics Data Management
15.1
Creating data
File/New allows for the creation of a new database. All variables in a database have the
same frequency. A sample period is required, but can be extended or changed later.
15.2
Database font
View/Increase Text Size and View/Decrease Text Size are useful to select a smaller or
larger font size for displaying the database on screen.
15.3
Database description
A database can have a description for documentation purposes, and separate from the
variable description. Only .in7/.bn7 data files can preserve the description.
15.4
Printing data
Use File/Print when a database has the focus to print the database. File/Print Preview
is available to view the result before printing.
Select File/Print to print to an attached printer and File/Print Preview to first view
the results. The following control of headers and footers is available for printing from
File/Print Page Setup:
Orientation: portrait or landscape;
Number of columns on the printed page;
Scale for printing: 100 is full scale, 90 smaller, etc.;
Draw a box;
The size of margin to use;
207
208
Write a header and footer. This is controlled via the Header and Footer boxes.
There are five specials:
&[date] prints the date,
&[time] prints the time,
&[page] prints the page number,
&[pages] prints the total number of pages,
&[file] prints the file name.
Other text in the edit field is printed directly.
15.5
Data formats
The data format specific to OxMetrics consists of a pair of files with extensions .in7 and
.bn7. The latter is a binary file containing the actual data, whereas the .in7 file holds the
information on the contents of the binary file such as variable names, sample periods,
frequencies etc. The information file is a human-readable file, the .bn7 is binary and is
not human-readable.
In addition, OxMetrics can read and write human-readable files, Excel spreadsheet
files, comma-separated files, and GAUSS and Stata files.
See Chapter 11 for detailed information on the file formats supported by OxMetrics.
15.6
Summary statistics
This command prints the name of the database, the sample period and number of variables to the Results window. For each variable in the database the name is printed as
well as:
leading sample the first valid sample period without missing values,
#obs number of valid observations,
#miss number of observations with missing values,
minimum minimum value,
mean mean of valid observations, see (10.1),
maximum maximum value,
std.dev standard deviation of valid observations, see (10.1).
15.7
Saving data
Use File/Save As or the diskette toolbar button to save the data to a disk file. At the
bottom of the dialog is a dropdown listbox in which you select the type of file.
15.8
A database cursor indicates which is the current observation. The cursor can be moved
from the keyboard or using the mouse. A block of observations can be selected (high-
209
lighted) for:
copying to the clipboard;
as a destination for a block from the clipboard;
to set to a single value: press Enter to specify the value, whence you will be
prompted whether the value should be applied to the whole selection.
Press Enter or double click on an observation to edit the value. Single click on
a cell with the cursor will give access to the inline editor. Algebra and the Calculator
allows manipulation of variables through mathematical expressions.
15.9
Renaming variables
Press Enter or double click on the variable name in the database to change the name
or documentation. When in the Calculator or the Algebra Editor, click Ren when a
variable is selected in the list box to rename.
15.10
Deleting variables
Click on the variable name in the database to select the variable (or a group of variables),
then press the Del key to delete (confirmation of the deletion will be required). When in
the Calculator, press the Del buttonwhen a variable is selected in the list box to delete,
confirmation will be required again.
15.11
Reordering variables
The variables listbox in the Calculator and Algebra Editor allows variables to be picked
up with the mouse and moved down or up in the listbox.
15.12
Adding variables
Double click on an empty field in the database next to an existing variable to create a
new variable. Alternatively use Edit/New Variable.
15.13
Double click on an empty field in the database below an existing variable to activate
the Extend Database sample dialog. Alternatively use Edit/Extend sample. Enter a
negative value to reduce the sample size.
The Change Sample option on the Edit menu allows the following actions:
Add observations at the start;
Add observations at the end;
Delete observations at the start;
Delete observations at the end.
210
15.13.1
The Change Sample option on the Edit menu allows changing the start year and period,
as well as the frequency. The number of observations remains unchanged, and no data
will be lost.
15.14
The standard copy and paste facilities are available, also see 15.8.
15.15
Appending data
A database can be appended from disk to an open database, using Append Data File
when right clicking on a database in the workspace. This requires the frequencies to
match. OxMetrics will make additional adjustments when these are required:
the sample of the open database will be extended to encompass that of the appended
database;
if a variable from the appended database already exists in the open database, then
the existing variable is updated, except where the appended variable has missing
values (for those observations the existing variable is not changed).
15.16
The calendar1 index used by OxMetrics is the Julian day number. For example, Julian day 2453402 corresponds to 2005-01-31. An optional fractional part specifies the
fraction of the day: 2453402.75 corresponds to 2005-01-01T18:00. If the day number
is zero, it is interpreted as a time only, so 0.75 is just 18:00 (6 PM).2 OxMetrics uses
the ISO representation yyyy-mm-dd, and the 24 hour clock for time, hh:mm:ss:.hhh. A
date with a time are joined by the letter T, as shown above.
In many fields it is possible to enter a date or time, which is then automatically translated to the internal representation. Years with week number are then also recognised,
e.g. 1976-W3 returns the calendar index for the Monday of week 3 in 1976. (Week 1 is
the first week that contains the first Thursday; or equivalently, the week that contains 4
January.)
OxMetrics uses two methods for dating a database:
Fixed frequency Denoted by a start year, start period and frequency. From this, the
date of any subsequent observation can be worked out. For example, if the start
year is 2005, the start period 1, and the frequency 4 (quarterly), then the sixth observations is for 2006(2), the second quarter. This works well for monthly, quarterly
1
The calendar is Gregorian from 15 October 1582 onwards, and Julian before (so there is no
year 0: year 1 precedes year 1; day 0 is on Julian date 1 January -4713).
2
This is similar to how Excel stores dates and times.
211
and annual data. For undated data we simply set the start year and period to one,
and the frequency as well.
Dated The fixed frequency method does not work for weekly or daily data: not every
year has the same numbers of observations. The solution adopted in OxMetrics is
as follows: an integer value represents a date. A database variable can be classified
as of type date, in which case the date is displayed, rather than the underlying value.
The following criteria must be satisfied for a database to be dated:
the first column must be of type Date,
the first column holds date values,
the optional fractional part of this indicates time as a fraction of 24 hours; e.g.
2453372.75 is 18:00 on 2005-1-1 (2005-1-1T18:00 in ISO notation),
the first and last observation must be valid, i.e. cannot be missing.
Note that the fixed sample period is still available for a dated database, but this is
usually set as for an undated database (start year, start period, frequency all set to one).
Also note that the first variable in a dated database (which defines the calendar dates
of the observations) is a variable as any other: it can be renamed, transformed, moved,
deleted, etc. But some of these will make the database undated again.
See 5.3 and 8.8 for more examples.
References
Davidson, J. E. H., D. F. Hendry, F. Srba, and J. S. Yeo (1978). Econometric modelling of
the aggregate time-series relationship between consumers expenditure and income in the
United Kingdom. Economic Journal 88, 661692. Reprinted in Hendry, D. F., Econometrics: Alchemy or Science? Oxford: Blackwell Publishers, 1993, and Oxford University
Press, 2000; and in Campos, J., Ericsson, N.R. and Hendry, D.F. (eds.), General to Specific
Modelling. Edward Elgar, 2005. [94]
Doornik, J. A. (2006). The role of simulation in econometrics. In T. Mills and K. Patterson (Eds.), Palgrave Handbook of Econometrics, pp. 787811. Basingstoke: Palgrave
MacMillan. [133]
Doornik, J. A. (2013). Object-Oriented Matrix Programming using Ox (7th ed.). London:
Timberlake Consultants Press. [64, 160]
Doornik, J. A. and D. F. Hendry (2013). Interactive Monte Carlo Experimentation in Econometrics Using PcNaive (3rd ed.). London: Timberlake Consultants Press. [64]
Doornik, J. A. and M. Ooms (2005). Outlier detection in GARCH models. Discussion paper
2005-w24, Nuffield College. [72]
Doornik, J. A. and M. Ooms (2008). Multimodality in the GARCH regression model. International Journal of Forecasting 24, 432448. [72]
Engler, E. and B. Nielsen (2009). The empirical process of autoregressive residuals. Econometrics Journal 12, 367381. [4, 148]
Golub, G. H. and C. F. Van Loan (1989). Matrix Computations. Baltimore: The Johns Hopkins
University Press. [142]
Granger, C. W. J. (1966). The typical spectral shape of an economic variable. Econometrica 34, 150161. [92]
Granger, C. W. J. and P. Newbold (1986). Forecasting Economic Time Series, (2nd ed.). New
York: Academic Press. [144]
Green, P. J. and B. W. Silverman (1994). Nonparametric Regression and Generalized Linear
Models. A Roughness Penalty Approach. London: Chapman and Hall. [147]
Hall, B. H. and C. Cummins (2005). Time Series Processor 5.0 Users Guide. Palo Alto, CA:
TSP International. [64]
Hardle, W. (1990). Applied Nonparametric Regression. Cambridge: Cambridge University
Press. [146]
Harvey, A. C. (1993). Time Series Models, (2nd ed.). Hemel Hempstead: Harvester Wheatsheaf. [135, 142, 149]
Hastie, T. J. and R. J. Tibshirani (1994). Generalized Additive Models. London: Chapman and
Hall. [147]
Hendry, D. F. and J. A. Doornik (2013). Empirical Econometric Modelling using PcGive:
Volume I (7th ed.). London: Timberlake Consultants Press. [64]
213
214
REFERENCES
Koopman, S. J., A. C. Harvey, J. A. Doornik, and N. Shephard (2013). Structural Time Series Analysis, Modelling, and Prediction using STAMP (5th ed.). London: Timberlake
Consultants Press. [64, 147]
Laurent, S. (2013). G@RCH Professional 7 (5th ed.). London: Timberlake Consultants Press.
[64]
Makridakis, S., S. C. Wheelwright, and R. C. Hyndman (1998). Forecasting: Methods and
Applications (3rd ed.). New York: John Wiley and Sons. [149]
Nielsen, B. (2006). Correlograms for non-stationary autoregressions. Journal of the Royal
Statistical Society B 68, 707720. [90, 143]
Priestley, M. B. (1981). Spectral Analysis and Time Series. London: Academic Press. [135,
144]
Silverman, B. W. (1986). Density Estimation for Statistics and Data Analysis. London: Chapman and Hall. [145]
Author Index
Cummins, C.
64
Davidson, J. E. H. 94
Doornik, J. A. 64, 72, 133, 147, 160
Engler, E.
4, 148
Golub, G. H. 142
Granger, C. W. J. 92, 144
Green, P. J. 147
Hall, B. H. 64
Harvey, A. C. 64, 135, 142, 147, 149
Hastie, T. J. 147
Hendry, D. F. 64, 94
Hyndman, R. C. 149
Hardle, W. 146
Koopman, S. J.
Laurent, S.
64, 147
64
Makridakis, S.
149
Newbold, P. 144
Nielsen, B. 4, 90, 143, 148
Ooms, M.
72
Priestley, M. B.
135, 144
147
Van Loan, C. F.
142
Wheelwright, S. C.
Yeo, J. S.
149
94
215
Subject Index
3-dimensional plots 96, 196
3D
contour 98, 197, 200
palette 97, 196, 200
217
218
SUBJECT INDEX
Azimuth
Bandwidth 147
selection 138, 145147, 175
Batch 7, 180191
editor 7
file (.fl) 7, 160
running 7
syntax 180
Executing code 180, 186
Graphics settings 108, 187
Batch Commands
appenddata 183
appresults 183
break 183
chdir 183
closedata 183
command 184
database 184
draw 184
drawf 184
drawx 185
drawz 185
exit 185
loadalgebra 186
loadbatch 186
loadcommand 186
loaddata 186
loadgraph 186
module 186
package 186
print 186
printdate 187
println 186
savedata 187
savedrawwindow 187
saveresults 187
setdraw 108, 187
setdrawwindow 188
show 188
usedata 189
Black and white 165
Black, white, gray 165
Box plot 89, 149
Boxed 197, 202, 207
Boxed graph 18, 35, 53
Bubble chart 94, 196
Calculator 22, 39, 57, 128, 167, 209
Changing sample 120, 121, 210
2 -distribution 131, 148
2 -random numbers 134
Choice variables 125
SUBJECT INDEX
Clipboard
219
estimation 144
Density estimation 87
DHSY 94
Dialogs
Algebra 24, 41, 60, 130
Calculator 22, 39, 57, 128, 209
Dummy 23, 40, 59
Create a New Database 114
Edit Graphics 103
Area Layout 101, 199
Aspect ratio 92
Axes 106, 201
Copy properties to other areas 203
Error bars 200
Graph Layout 102, 198
Hide axis 112
Histogram 89, 203
Label 200
Legend style 202
Legends 110
Lines (Error Bar) 96
Match by 112
Regression 104
Regression, Scale 85, 200
Rename 105
Scaling 111
Style 98, 104, 105, 200
Type 104, 199
Formulate 70
Graphics 17, 34, 51, 80
Autocorrelation function (ACF) 81
Distribution 81, 83
Distribution Options 88
Scatter Plot 137
Scatter Plot Options 85, 86
Select type of graph 80
Two series by a third 94
Graphics Setup 107, 203
Write as batch 187
Graphics Text 110, 203
Lines and symbols 109
Modelling
Formulate 70
New 114
Open 114
Open File 114, 119, 120
Settings GARCH 70
Tail Probability 133
Test 71
Variable Description 15, 32, 49, 115
Directory structure 4
Documentation conventions 10
Dummy variable 23, 40, 59, 129, 173
220
Durbins method
SUBJECT INDEX
142
Editor
Algebra 130
Batch 7
Elevation 97, 196, 199
Enhanced meta file (.emf) 166, 204
Error
bands 200
bars 200
fans 96, 200
Error messages 130
Exponentially-weighted moving average
(EWMA) 149, 176
Exponentially-weighted moving correlation
149, 176
Extending sample 121, 209
F-distribution 131, 148
F-random numbers 134
File
extensions 7
extensions and Open 114
extensions in Windows Explorer
names 7
Folder structure 4
Font 165, 202, 203, 207
Fourier decomposition 91, 195
Frequencies 89
Frequency 153, 172
8, 14
129, 179
221
SUBJECT INDEX
Lotus
154
Matching
means 200
means and ranges 84, 111
Matrix file (.mat) 161
Menus
Edit menu
Add Text 110, 203
Change Sample 120, 121
Change sample 209
Copy 120
Database Description 207
Draw 109
Draw Line 109
Edit Field 208
Edit Graph 198, 199
Lines and symbols 203
New Variable 115, 209
Reset Starting Date 121, 210
File menu 13, 30, 48
New 114, 207
New Data Plot Window 84, 102, 193
Open 114, 119, 120, 198
Print 197, 207
Print Page Setup 197, 207
Print Preview 197, 207
Save As 118, 119, 198, 208
Model menu
Algebra 130
Calculator 22, 39, 57, 128
Graphics 16, 34, 51, 193
Model 68
Preferences 107, 200, 203
Tail probability 133
Test 71
View menu
Increase Text Size 207
Point 203
Summary statistics 208
Microsoft Excel 113, 118, 119
data file 119, 154
Copying from 120
Microsoft Word 21, 38, 166, 197
Missing value 82, 87, 115, 142, 145,
147149, 153, 155, 159, 168, 169,
172, 175, 193, 194, 204
Module 6476, 186
Modules
Model 68
Moving
average 129, 179
standard deviation 179
Multiple series
84, 194
222
SUBJECT INDEX
Toolbar
Model 68
Transformed series 82, 193
Trend 174, 179
TSP 73, 87, 90
WWW address 5
file (.tsp) 161
Tutorial data set (data.in7/data.bn7)
47
Twist 97, 196, 199
Two series by a third 94, 196
13, 30,
Uniform
distribution 148
random numbers 134
Upgrades 6
Value labels 125
Variable
creation 115
names 152
names in algebra 168
Sorting a 174
Variables
Adding 120, 209
Copying 120, 210
Deleting 23, 40, 59, 209
Renaming 15, 23, 32, 41, 49, 59, 209
Reordering 23, 40, 59, 209
Vector 199
Weekly data 67, 122, 210
Windows bitmap 204
Windows Explorer 7, 8, 14, 76
Windows meta file (.wmf) 166
Windows XP 14
WKS,WK1 files 154
Workspace 25, 43, 62
World coordinates 192, 199, 203
WWW 5
XLS files 154
XLSX files 119, 154
YuleWalker equations
142