Está en la página 1de 84

Introduction to OxMetrics

7 June 2010

J. James Reade

Outline
Introduction to OxMetrics. Pre-modelling: Data management. Modelling: Using the packages. Post-modelling: Misspecication and further analyses. Purpose of slides: Cannot cover all material in slides! Slides provide information to start using OxMetrics and PcGive.

j.j.reade@bham.ac.uk

Introduction: What is OxMetrics?


Formerly GiveWin: Front-end for doing econometric analysis. Front-end: Menu driven, not code-based. Easier to use. But: Front-ends constrain you to do what it thinks you want to do. But: Not restricted to menus: All underwritten by Ox Programming language. Learning underlying code grants exibility at a cost: Learning the language. OxMetrics acts as an umbrella for many packages: E.g. PcGive, G@RCH, PcNaive, . . . Packages are for doing econometrics analysis: Single/multiple-equation modelling. Limited-dependent variable modelling. GARCH modelling. Panel data analysis. Etc. Packages often written by others: Experts in their own elds.
j.j.reade@bham.ac.uk 3

OxMetrics vs Other Packages


Historical development of econometric software fascinating.1 Stata, Eviews, PcGive (now OxMetrics), RATS, Limdep, Microt... Stata: Historical perception: Stata for non-time series, OxMetrics for time series. Both now cross into each others territories extensively. Time series still considerably easier in OxMetrics than Stata. Eviews: Traditionally more general than Stata but less popular. OxMetrics faster, more accurate than Eviews, developed by leading minds: David Hendry, Siem Jan Koopman, Steve Bond, Andrew Harvey... Renfro: User inertia is an important aspect of the software experience.
See Renfro, C.G., Econometric Software: The rst Fifty Years in Perspective, Journal of Economic and Social Measurement, 29 (2004).
j.j.reade@bham.ac.uk 4 1

OxMetrics: Context
Contrary to belief, OxMetrics is used widely and not just in Oxford. More than other packages, OxMetrics reects an econometric methodology. The Hendry, or LSE approach: General-to-specic. Advantage: Thorough and rigorous econometric methodology. Disadvantage: Not everyones cup of tea. Practically: Some tests unavailable (KPSS and other unit root/cointegration tests). Automated General-to-specic algorithm built in: Autometrics (previous incarnation PcGets). Little else dierent.

j.j.reade@bham.ac.uk

The Methodology Behind OxMetrics


Various parts of Hendry (1995) express it probably best: General-to-specic. Model misspecication is the fundamental problem in econometrics: Manifests itself in unexpected ways, and many solutions out there are inappropriate. E.g.: Wrong signs on coecients: Omitted variable bias and other biases caused by misspecication. You are not modelling what you think you are modelling! But sometimes commercial pressures dictate: E.g.: HACSE, correlograms.

j.j.reade@bham.ac.uk

Doing Economics and Econometrics: The Way Forward


Programming ability essential: Even for pure economic theory: Models complicated and programs like Matlab help solving. OxMetrics or Stata useful tools, but limited. Complicated and exotic likelihood models may not be included. Learn a programming language. Statas own code: .do and .ado les. Ox: Underlies OxMetrics and its modules. But has much wider range of modules/sub-routines itself. Developed specically with econometric needs in mind. Matlab, Mathematica, R, Gauss,. . .

j.j.reade@bham.ac.uk

Getting Started
Open by locating OxMetrics on your system. Disambiguating: OxMetrics (in Economics Software?) is what you want, not OxEdit.2 OxMetrics is the software package, or front-end. PcGive, G@RCH etc are modules within. Getting OxMetrics on your computer: Licence on the way: All sta can have OxMetrics, as can students.

A OxEdit is a text editor developed specically for Ox, but many people write and compile L TEX and other languages using

it.
j.j.reade@bham.ac.uk 8

Getting to grips with OxMetrics: Tasks


1. Open OxMetrics. 2. Go to File, New, and select: OxMetrics (Graphics:

.gwg)

3. Right click on the white area, select Draw and Draw a Freehand Line. 4. Sign your name. 5. Double click on plot area, select Regression/Scale. In Regression bit set number of lines to 1. You have successfully regressed your signature.

j.j.reade@bham.ac.uk

The OxMetrics Interface


Now have experience of Graphics in OxMetrics: Very powerful and exibly tool for plotting data. Vastly superior and more elegant than Excel, more exible than Stata.3 Graphics is a central part of the OxMetrics interface. Econometric analysis carried out using Modules. Pre-estimation mainly OxMetrics: Loading data. Organising data: Checking summary statistics. Checking for holes or other problems. Data transformations and data creation. Plotting data.
3

I think!
10

j.j.reade@bham.ac.uk

Nice Features of OxMetrics Interface


Can open many documents at once of dierent types: All in LHS toolbar. Can easily view data les unlike in Stata (and open many data les). Help very easy and convenient to nd: Press F1 or go to Help menu.4 Can do most things via icons on toolbar along top: More later. . . Text editing: Right clicking: Highlight by column. Right click on that: Can sort and sum. Pasting from history: Can paste up to nine items: From Ctrl+1 to Ctrl+9. Searching for next/previous incidence: Highlight word or set of characters you want to nd and hit: Find in les: Very useful for nding les with certain text in them.5
4 5

Admittedly this is more useful when Ox programming than using OxMetrics more generally. But manuals are online. For non-Mac users, that is. . .
11

j.j.reade@bham.ac.uk

Loading Data
First task: Opening data. OxMetrics has own datale format: .in7 and .bn7. But can load .xls and .csv les directly.6 Can also copy and paste data. But: Must be careful about format of csv/xls le: Need date in rst column (with no column title) in form 1957-1 or 1957-12-24. Keep names simple, ensure no holes in data.7 Important for time series: PcGive treats sample as up to rst .NaN entry.
Can load most types of data le in OxMetrics, including Stata .dta les. 7 I.e. no variables without names. OxMetrics will generally change any blank data cells to .NaN but better to be on safe side and do this yourself (or enter N/A in blank cells).
j.j.reade@bham.ac.uk 12 6

Data Management
Assuming you have loaded your data le: What is there and what does it look like? OxMetrics has plenty of tools for analysing data pre-estimation. Summary Statistics: Right click and Data Description or View and Summary Statistics.8
Database: US_China_1m_IB.csv Sample: 2002-01-01 Tue - 2010-01-06 Wed (2092 observations) Variables: 5 Variable leading sample #obs #miss minimum mean Svar1 1 to 2092 2092 0 2.4523e+06 2.4537e+06 China 1 to 2079 2078 14 0 2.6621 US 1 to 2079 2078 14 0.2325 2.6609 ExchangeRate 1 to 2092 2092 0 6.8109 7.8442 1MFWDExchangeRate 29 to 2092 2063 29 6.7834 7.7727

maximum 2.4552e+06 9.9 5.8238 8.7129 8.2841

std.dev 845.47 0.95229 1.7371 0.62651 0.57096

Provided the active window within OxMetrics is the data le.


13

j.j.reade@bham.ac.uk

Pre-Estimation: Hocus-pocus?
May come across those who claim looking at data pre-estimation wrong: Contaminates later ndings. OxMetrics pre-estimation tools artefact of econometric methodology: You need to know what data looks like before you model it. Helps determine correct model for data: Stationarity, structural breaks, lag length, data transformations (e.g. logs). . .

j.j.reade@bham.ac.uk

14

Plotting data
OxMetrics has great exibility for plotting data. Huge range of possible types of plot. Easy to access. Multiple series on a set of axes, multiple sets of axes. Manipulation of axes and series much more intuitive than Excel. Copy and paste works in wonderful ways. . .
A Can save in eps format, ideal for including in LTEX documents.9

PDF les are easy to create from eps: Type eps2pdf into Google and download the relevant program for your operating system.
j.j.reade@bham.ac.uk 15

Plotting Data: An Example


8.75 8.50 8.25 8.00 7.75 7.50 7.25 7.00 8.2 8.1 2005 2006 Spot Exchange Rate 1month Forward Exchange Rate 7.0 6.9 6.8 2009 2010

2002

2003

2004

2005

2006

2007

2008

2009

2010

j.j.reade@bham.ac.uk

16

Plotting Data

Hit the Graphics button:

.10

Double click on series to plot.

Click OK then select type of graph to plot.

10

Or Model, Graphics, or Alt+G.


17

j.j.reade@bham.ac.uk

Plotting: Big Picture


General intent is to present econometric results. Credibility enhanced if clear and intuitive plots of data provided. What plots will best help your story? Will they just take up space?11 Thus likely you will return to pre-estimation graphics later. Important to ensure plot labels and numbering visible and make sense.

Double clicking on a plotted graph, selecting the Graph layout tab, and changing the Aspect ratio (Y scale) to Half height 50% will provide a graph half as high as it is wide, very useful for including in papers without taking up too much space.
j.j.reade@bham.ac.uk 18

11

Another Data Manipulation Tool: Aggregation


Data may be of dierent frequency: Matching manually tedious. May also wish to estimate model over dierent frequencies: Robustness. ARCH big problem at high frequency: Noice vs signal. With your dataset as active window, select Edit -> Aggregate. Resulting menu allows aggregation to many dierent frequencies. Weekly, 4-week periods, monthly, quarterly, bi-annually, annually. Also allows dierent aggregation methods: End-period, mid-period, average, sum, peak, trough. Incredibly exible and useful tool.

j.j.reade@bham.ac.uk

19

Plotting Data: Tasks


1. Plot Actual series of all four variables. Give plot name of your choice.12 2. Try plotting data transformations, would a log scale help? 3. Investigate the kinds of plots possible do they make sense? Correlation: Auto, Partial Auto, Cross. Distributions and scatter plots. 3D plots. 4. Manipulate your plots. How many axes do you want in each le? Lines or dots? Double click on your plot and explore the possibilities.13 5. Annotate your plot in helpful ways. Just start writing with cursor over plot.14
Try the Rename option in the File menu if you dont really want to save just yet. For putting plots into papers, increasing font size and line thickness useful. Also saving an viewing modes in colour, grayscale or black and white. Colour for slides, grayscale for papers. 14 A Note that by using $ signs, you can include L TEX maths in your plots.
13 j.j.reade@bham.ac.uk 20 12

Post-Plotting and Summarising


Data plots and summarising help in deciding appropriate model. May also reveal need for extra variables: Dummy variables for events in time or characteristics in cross-section. Interaction terms and transformations of variables: A quadratic term perhaps for eect of education? Ination instead of the price level (CPI)? Debt as a percentage of GDP?

Create and manipulate variables using Calculator:

j.j.reade@bham.ac.uk

21

The Calculator Tool

Data transformations: Lags, logs, dierences, percentage changes,. . . Creating variables: Dummies, quadratic trends, interaction terms,. . . Other...: Extensive list of data transformations.

j.j.reade@bham.ac.uk

22

Creating New Variables: Tasks


1. Create a variable for the daily change in the exchange rate. 2. Create a variable for the monthly change in the US interest rate. 3. Create a variable for log(1 + rt) and check how similar to rt it is.15 4. Create the log ratio of the forward and spot exchange rates. 5. Plot all the variables you create. Do they look as you expected? 6. In mid-June 2005 the forward rate drops sharply and the spot rate drops at the start of August 2005. Try to work out when the changes took place exactly and create dummy variables.16
Note the need to convert the rst six observations of the Chinese interest rate, which as NA entries cause issues when taking logs. Right click on these observations and select Edit Value... and check the box for Missing Value. 16 Hovering over the break in a plot will tell you roughly what date the shift took place. Then look at the data and work exactly when it happened.
j.j.reade@bham.ac.uk 23 15

Manipulating your Data: Batch Files


Transforming data easy via calculator in PcGive. . . But if doing empirical work, need to document what you did. Integrity. Good method: Write an algebra le. Calculator simply generates algebra code look at Results. Algebra le (.alg) is code to create variables:
Inflation = diff(CPI, 4)/lag(CPI, 4);

Task: Create your own algebra le. Go to File and New... or hit Ctrl+N.

j.j.reade@bham.ac.uk

24

Post Data Manipulation


Pre-estimation carried out in OxMetrics, the Front-End.

Estimation carried out using Module: Select module via PcGive is the Module we will use, but PcGive has many possibilities. Select Models for time-series data and Single-equation Dynamic Modelling using PcGive.

j.j.reade@bham.ac.uk

25

Autometrics?
Clicking OK leads to the next menu: Autometrics options. Autometrics is PcGives automatic model selection algorithm. Based on Hendry (1995) Ch. 9, the General-to-specic modelling methodology. Start with most general model possible: All variables that might be relevant. Omit variables if t- and F-tests permit, and also if misspecication tests allow. Find most parsimonious/simple model possible satisfying misspecication tests. Takes specied model as the general unrestricted model (GUM). Massively useful modelling tool. But leave for now.

j.j.reade@bham.ac.uk

26

Modelling Using PcGive


Having selected type of modelling using PcGive, must specify regression model. Variables in dataset on RHS, double clicking will select them.17 Constant will be automatically included. Double click it if you dont want it.18

17 18

As will highlighting them and hitting the double arrow buttons. Double clicking in the Selection window de-selects a variable.
27

j.j.reade@bham.ac.uk

Modelling Using PcGive


Check variable status is appropriate: Automatically rst variable is dependent variable: Denoted Y for endogenous. Rest are given default Regressor status (but not marked with Z). Change status using Use default status drop-down menu and hitting set. Multiple endogenous variables possible: Must instrument extra Ys. Change status to A: instrument/fixed and hit set.

Bottom right: Can select which dataset to choose variables from. Handy when more than one dataset open. But cannot select variables from dierent datasets for a model. Bottom left: Recall a previous model: Lists all previous models estimated using PcGive. Can reselect previous model if need to.

j.j.reade@bham.ac.uk

28

Our Model
Interested in Covered Interest Parity between US and China: iU S,t = (ft st) + iCh,t. Hence dependent variable (Y) is US interest rate (recall log approximation). Explanatory variables: Log forward, spot exchange rates, Chinese interest rate. Estimation methodology: General-to-specic. So estimate rst unrestricted version and then test model restrictions. iU S,t = 0 + 1ft + 2st + 3iCh,t + t, t iidN 0, 2 . (2) (1)

Test 0 = 0, 2 = 1, 1 = 3 = 1 and that t iid Normal.19


19

Absence of Normality (autocorrelation, heteroskedasticity) implies important explanatory power left out of model.
29

j.j.reade@bham.ac.uk

Cross Section Modelling Using PcGive


Can choose to estimate over full sample or some subset. In time series sometimes we only care about particular time period. Estimation method in Cross Section is only OLS. IV possible: Need to specify extra endogenous variable when selecting variables. Reects methodology behind PcGive again: Other methods non-robust.20 Can also select type of standard errors (robust or not).

20

E.g. Least Absolute Deviations.


30

j.j.reade@bham.ac.uk

Post-Estimation: Interpreting Model Output


Clicking OK should yield the model output:
EQ( 7) Modelling US by OLS-CS The dataset is: /Users/jamesreade/Documents/Data/Mon Ind/US_China_1m_IB_jr.csv The estimation sample is: 2002-02-08 - 2009-12-17 Coefficient -3.56565 0.597886 -8.44612 10.7424 1.64242 0.116922 0.115628 2050 2.67242 Std.Error 1.038 0.03835 2.599 2.801 t-value -3.44 15.6 -3.25 3.84 t-prob Part.R2 0.0006 0.0057 0.0000 0.1062 0.0012 0.0051 0.0001 0.0071

Constant China LExchangeRate L1MFWDExchangeRate sigma R2 Adj.R2 no. of observations mean(US)

RSS 5519.1801 F(3,2046) = 90.3 [0.000]** log-likelihood -3923.97 no. of parameters 4 se(US) 1.74649

Important but not yet appropriate to scrutinise in detail: Not checked if residuals are Normally distributed: Is model well specied?

j.j.reade@bham.ac.uk

31

Automatic Graphical Model Output


Check the Graphics part of Documents bar (LHS) for Model.
US Fitted

2002

2003
r:US (scaled)

2004

2005

2006

2007

2008

2009

2010

2002

2003

2004

2005

2006

2007

2008

2009

2010

j.j.reade@bham.ac.uk

32

Post-Estimation: Misspecication Testing Output

To carry out post-estimation testing hit Test button:21 Resulting menu gives post-estimation options we will explore. For now, select Test Summary:
Normality test: Hetero test: Hetero-X test: RESET23 test: Chi2(2) F(6,2043) F(9,2040) F(2,2044) = = = = 637.54 384.85 394.87 104.14 [0.0000]** [0.0000]** [0.0000]** [0.0000]**

Output: Type of test, test statistic distribution, test statistic, p-value, signicance. Standard:

is rejection at 5% level,

rejection at 1% level.

21

Or Model and Test, or Alt+T.


33

j.j.reade@bham.ac.uk

What are these tests?


Normality: Test for skewness and excess kurtosis. Both should be zero if distribution Normal. Sample variants have Chi-square distribution hence can make test. Combine two stats for Normality test statistic. Test reported is Doornik-Hansen variant: Small-sample correction.

Heteroskedasticity: White test: Regress squared residuals on regressors and squared regressors. X test also includes cross-products. Signicance of any regressors of combinations of heteroskedasticity. RESET test: Test of functional form: Include squares and cubes of tted values in original regression model. Signicance of squares and cubes implies wrong functional form assumed.

j.j.reade@bham.ac.uk

34

More Detail: Test in the Test Menu


To help diagnose a problem, may be helpful to get more details. Choose Test... in the Test menu: Further menu containing summarised tests. Heteroskedasticity tests will provide coecients: Can possibly identify source of heteroskedasticity.22 Normality test contains details on skewness and excess kurtosis: Skewness more harmful than excess kurtosis. RESET tests provide coecient estimates also. Index test removes variables that are identical after squaring/cubing.
22

However, more likely omitted variables or structural form problems cause heteroskedasticity rather than anything in model.
35

j.j.reade@bham.ac.uk

Post-Estimation: Misspecication Graphical Output


Model looks very badly specied. Testing only gives so much information. Graphical analysis can sometimes be illuminating: E.g. What does residual distribution look like? Check Graphical Analysis... from Test Menu. Options:
23 24

Actual and tted values: Plots both how well does model t data? Cross plot of actual and tted: Scatter plot high correlation = good model.23 Residuals (scaled): Plot of all residuals, scaled by standard deviation.24 Residual density and histogram: Distribution of residuals: Is it Normal/symmetric?

Since tted similar to actual. Hence if Normally distributed and model has constant, scaled versions are standard Normally distributed.
36

j.j.reade@bham.ac.uk

Post-Estimation: Graphical Output


6
US Fitted

US Fitted

2002 2003 2004 2005 2006 2007 2008 2009


r:US (scaled)

2.5 Density
r:US

3.0
N(0,1)

3.5

4.0

1 0 1

1.00 0.75 0.50 0.25

2 2002 2003 2004 2005 2006 2007 2008 2009 3 2 1 0 1 2

j.j.reade@bham.ac.uk

37

Post-Estimation: Predictions
Two reasons for modelling: 1. To understand an economic phenomenon better. How have China and the US interacted nancially? 2. To predict something. How will they interact nancially? PcGive allows forecasting or prediction. Forecasting a time-series concept, prediction more cross-section. But in C-S, need observations on explanatory variables to predict. Well return to Prediction in its more natural context: Time series modelling.

j.j.reade@bham.ac.uk

38

Post-Estimation: Further Output


More information available for diagnosing problems or supporting results. Correlations between regressors, robust standard errors, information criteria. Printing of residuals can be useful: Which ones are big? Outliers? Writing model results: Equation format: Written intuitively in text form. A LTEX format: For copying and pasting into your tex document. Non-linear model format: Batch code for non-linear modelling.

j.j.reade@bham.ac.uk

39

Post-Estimation: Interpreting Model Output


Now checked for misspecication, can start to consider results. . . . . . if model well specied! Ours isnt but well look anyway. . .
EQ( 9) Modelling US by OLS-CS The dataset is: /Users/jamesreade/Documents/Data/Mon Ind/US_China_1m_IB.csv The estimation sample is: 2002-02-08 - 2009-12-17 Coefficient -3.56565 0.597886 -8.44612 10.7424 1.64242 0.116922 0.115628 2050 2.67242 Std.Error 1.038 0.03835 2.599 2.801 t-value -3.44 15.6 -3.25 3.84 t-prob Part.R2 0.0006 0.0057 0.0000 0.1062 0.0012 0.0051 0.0001 0.0071

Constant China LExchangeRate L1MFWDExchangeRate sigma R2 Adj.R2 no. of observations mean(US)

RSS 5519.1801 F(3,2046) = 90.3 [0.000]** log-likelihood -3923.97 no. of parameters 4 se(US) 1.74649

se standard error, Part.R2 partial R2, Adj.R2 is R2.

j.j.reade@bham.ac.uk

40

Post-Estimation: Testing Economic Theory Hypotheses


We want to test whether Covered Interest Parity is upheld in our model. Test Menu: Select Linear Restrictions or General Restrictions. Linear Restrictions: Recall: R = r where R is restrictions, coecients and r sum of restrictions. E.g. R = (1, 0, 0, 0), = (0, 1, 2, 3) , r = 0. Tests constant 0 equal to zero. Each column of R a restriction. Need 4.

Test for linear restrictions (Rb=r): R matrix Constant ChinaLExchangeRateL1MFWDExchangeRate 1.0000 0.0000 0.0000 0.0000 0.0000 1.0000 0.0000 0.0000 0.0000 0.0000 1.0000 0.0000 0.0000 0.0000 0.0000 1.0000 r vector 0.0000 1.0000 -1.0000 1.0000 LinRes F(4,2046) = 32.670 [0.0000]**

j.j.reade@bham.ac.uk

41

General Restrictions
Linear restrictions requires you to recall econometrics. General restrictions requires to you write some code: Each variable denoted by ampersand (&) and number: Key beneath. RHS of code line must be zero. Each restriction is line of code; must be ended with semi-colon ;. Code gives exibility: Could write &2+&3=0.
Test for general restrictions: &0=0; &1-1=0; &2+1=0; &3-1=0; GenRes Chi2(4) = 130.68 [0.0000]**

Dierent test statistics; same test result. Heavy rejection of theory.

j.j.reade@bham.ac.uk

42

Batch File
As before, want to document what you do: Especially useful if you take break! Estimate model then hit batch button. Produces new window with Batch code in. Better to hit Save Save As... than work in window. Tasks: 1. Estimate your model and create Batch le. 2. Change sample size and re-estimate.

j.j.reade@bham.ac.uk

43

Ox Batch Code
New to recent versions of OxMetrics: Can generate Ox code. Ox is programming language OxMetrics written in. Model and Ox Batch Code..., or Alt+O opens Ox le. File contains Ox code used by OxMetrics to generate output you found. Taking a look, and amending code highly recommended: Programming languages are the future.

j.j.reade@bham.ac.uk

44

Post-Estimation: Many Other Options


The Test Menu has many possibilities for post-estimation activity. Test... contains more detailed versions of summary tests. E.g. Normality test gives 2 stat for skewness and kurtosis: Numbers always useful when writing up results. Testing for omitted variables (no dierent to including them though). Test exclusion restrictions: More than one variable and not all of them.25 Store Residuals etc. in Database:

Very useful feature: Can append dataset with residuals t and tted values rU S,t. Can manually run tests on residuals/tted values and create various plots.
25

Test for all variables is given in model output. You can check this. . .
45

j.j.reade@bham.ac.uk

Improving on the Model


Important part of econometric modelling: Taking stock and improving. Hendry: Progressive modelling strategy. Although: Should start as general as possible. . . OxMetrics allows tracking of model development: Hit Progress... on Module. Checking a number of models produces comparative statics between models: Log-likelihoods, sample sizes, number of parameters, information criteria. Can also Recall a previous model from Formulate window: Useful if want to re-estimate a model. More fundamental potential improvement: Adopt dierent model specication: OxMetrics houses many Modules for dierent model types. . .

j.j.reade@bham.ac.uk

46

Modelling Time Series Data


This term with Bent Nielsen you will cover time-series econometrics: Neil and Steve should have provided you with brief intro. Essence: Data through time usually displays persistence. Model persistence by including lags of dependent (and independent) variables. PcGive has huge capacity for dealing with time series. Pre-estimation: Graphing, data manipulation (e.g. aggregation). Estimation: PcGive developed as a time-series package. Adding lags, dierences, coping with non-standard distributions. Calculating long-run solutions and error-correction terms. VAR modelling, Johansen cointegration procedures.26 Post-estimation: Recursive analysis, Impulse response analysis.
26

In multi-variate modelling.
47

j.j.reade@bham.ac.uk

Getting Going With Time Series


Graphing: Time-series properties helps model choices: Autocorrelation function (ACF): Gently declining implies autoregressive series. Partial ACF (PACF): Helps to determine lag length.27 Cross-correlation function (CCF): Correlation between series and lags of another. Spectral density plots. Seasonal sub-plots: Plots for each season to help detect patterns.

Modelling: Models for time-series data, Single-equation Dynamic Modelling using PcGive.

27

Choose as many lags as there are signicant PACF lags.


48

j.j.reade@bham.ac.uk

Improving Our Model


7.5 2.5 2002 2004 2006 2008 2010 2002 2004 2006 2008 2010

rCh,t

5.0 2.5

rUS,t

2.2 2.1 2.0 2002

st
2004 2006 2008 2010

2.0 2002

ft
2004 2006 2008 2010

Cursory glance at data series above tells us they display persistence. We model such time persistence using lagged dependent variables: Recall AR(K) model for home interest rate:
2 t N 0, .

rU S,t = 0 + 1rU S,t1 + + K rU S,tK + t, 1 will likely be highly signicant for all series in our model.

(3)

j.j.reade@bham.ac.uk

49

Modelling Time Series Data: Non-Stationarity


Big problem with time series is non-stationarity: If time series non-stationary (unit-root processes), regressions may be spurious. Hence for our interest rates and exchange rates: Check for time dependence. Test for non-stationarity. Amend model accordingly (and make use of Autometrics).

j.j.reade@bham.ac.uk

50

Time Dependence
It is standard to report the time-series properties of data being modelled. Unit root tests and ideally plots of data series also.28 Also important: Aects distributions of test statistics. Tomorrow: Can investigate eects using PcNaive in OxMetrics. PcGive allows unit-root testing. Generic time series xt: xt = 0 + 1xt1 + K xtK + et, Unit root test is hypothesis that 1 = 1. Unit root test output tells us what 1 coecient is, if not unity. But test dependent on correct lag specication: Too short: Omitted variable bias. Too long less important.
28

2 et N 0, r .

(4)

Unit-root tests are usually criticised for a lack of power and hence other information is vital for characterising data series.
51

j.j.reade@bham.ac.uk

Choosing Lag Length


Choose via PACF: Number of signicant lags. Investigate via Information Criteria. Use Autometrics: Start with large number of lags and reduce. Can also use unit root test: Test output provides information. In Model: Other Models, Descriptive Statistics using PcGive.

j.j.reade@bham.ac.uk

52

Unit-Root Testing
In resulting menu, choose variables of interest (can test many variables), click OK. In next menu, check the Unit-root tests box at the top. Then access the drop down menu for Unit-root test settings if desired.29 Rearrange AR(1) model to:
K1

xt = 0 + xt1 +
k=1

k xtk + et.

(5)

Either: Test = 0 using standard t-test (but not t-distribution). Test = 0 and 0 = 0 using standard F-test (but not F-distribution). Strategy: Start general and reduce if trend/constant insignicant.
29

Have a play around with the dierent options; most important is inclusion of constant and/or trend.
53

j.j.reade@bham.ac.uk

Unit-Root Test Output


Appropriate Dickey-Fuller distribution critical values above each variable. D-lag: Number of lags of rst dierences k=1 k xtk so K 1. t-adf: t-test statistic for , stars based on DF distribution. beta Y 1: . T sigma: = t=1 e2/T (K + 1). t t-DY lag: t-statistic of longest lagged dierence coecient: K1.
K1

Table for each variable: Can get more lags, and more detail (non-summary table).
Unit-root tests The dataset is: /Users/jamesreade/Documents/Data/Mon Ind/US_China_1m_IB_jr.csv The sample is: 2002-02-13 - 2009-12-17 China: ADF tests (T=2047, Constant; 5%=-2.86 1%=-3.44) D-lag t-adf beta Y_1 sigma t-DY_lag t-prob 2 -7.591** 0.92512 0.4052 -2.613 0.0090 1 -8.167** 0.92058 0.4058 -10.35 0.0000 0 -10.50** 0.89793 0.4162 US: ADF tests (T=2047, Constant; 5%=-2.86 1%=-3.44) D-lag t-adf beta Y_1 sigma t-DY_lag t-prob 2 -0.4669 0.99982 0.03064 5.537 0.0000 1 -0.2998 0.99988 0.03086 27.16 0.0000 0 0.4596 1.0002 0.03599

AIC -1.805 -1.802 -1.752

F-prob 0.0090 0.0000

AIC -6.969 -6.955 -6.648

F-prob 0.0000 0.0000

j.j.reade@bham.ac.uk

54

Time Series Modelling Using PcGive


Time-series modelling provides more options than cross-section. When selecting variables, extra option for number of lags. Useful but can also be annoying. Can have None, specic lag length Lag or all lags up to that length. Also got option for adding time trend automatically to model. Type of variables begins to get important now. Change type by either: Right clicking on variable and selecting from menu. Highlighting (click once) in Selection window, selecting desired status in Use default status menu and hitting Set.30
30

Last step can easily be forgotten and wrong choices made.


55

j.j.reade@bham.ac.uk

Time Series Modelling Using PcGive


Additional options for estimation: Usual OLS (equivalent to MLE if errors normal). Instrumental variables: Standard IV estimation: Specify instruments back at Variable Selection stage. Must specify additional variable as Engogenous.31 Estimation method: Only 2SLS. Autoregressive least squares: Iterative method of estimating an autoregressive error structure. E.g. xt = 1xt1 + ut, where ut = ut1 + et. Generally advisable to model autocorrelation in residuals. Autometrics options: Available for OLS and IV but not Autoregressive Least Squares. Caution: By default next model at Formulate window is specic model.
31

Second endogenous regressor treated as variable to be instrumented.


56

j.j.reade@bham.ac.uk

Post-Estimation: What Does Time Series Add?


Test for residual autocorrelation and ARCH:32 Part of Test Summary, can also go more detailed. Forecasting: Can construct and assess dierent types of forecast easily. Recursive analysis: Extensive range of recursive statistics and graphics.

32

ARCH: Autoregressive Conditional Heteroskedasticity for the uninitiated.


57

j.j.reade@bham.ac.uk

Interpreting Model Output


Nothing altered from cross-section output:
EQ(27) Modelling US by OLS The dataset is: /Users/jamesreade/Documents/Data/Mon Ind/US_China_1m_IB_jr.csv The estimation sample is: 2002-02-12 - 2009-12-17 Coefficient -3.56730 0.600000 -8.15856 10.4526 1.64258 0.117418 0.116122 2048 2.67324 Std.Error 1.038 0.03839 2.609 2.811 t-value -3.44 15.6 -3.13 3.72 t-prob Part.R2 0.0006 0.0057 0.0000 0.1067 0.0018 0.0048 0.0002 0.0067

Constant China LExchangeRate L1MFWDExchangeRate sigma R2 Adj.R2 no. of observations mean(US)

RSS 5514.85552 F(3,2044) = 90.64 [0.000]** log-likelihood -3920.34 no. of parameters 4 se(US) 1.74715

j.j.reade@bham.ac.uk

58

The Test Summary


Test summary includes residual autocorrelation and ARCH:
AR 1-2 test: ARCH 1-1 test: Normality test: Hetero test: Hetero-X test: RESET23 test: F(2,2042) F(1,2046) Chi2(2) F(6,2041) F(9,2038) F(2,2042) = = = = = = 45492. 19589. 637.64 383.77 393.44 103.37 [0.0000]** [0.0000]** [0.0000]** [0.0000]** [0.0000]** [0.0000]**

Model terrible. Should add lagged dependent variable at minimum. Spurious signicance possible: Already established unit-root behaviour. Autoregressive Distributed Lag (ADL) model: Distributed lag of explanatory variables. Eect of variable spread over number of time periods.

j.j.reade@bham.ac.uk

59

Autoregressive Distributed Lag Model


Consider xt with one lag and add yt to model: xt = + 1xt1 + 0yt + 1yt1 + t. Model easy to estimate in PcGive: But is it appropriate/sucient? Mechanics: AR(1) model only estimable over T 1 observations. PcGive deducts observation automatically in Selection Sample if add lag. Care when removing lags: Need to add back in observations (if want them). PcGive not restricted to set time series models: But some post-estimation time-series functionality is. (6)

j.j.reade@bham.ac.uk

60

ADL for Covered Interest Parity


Add contemporaneous level and lag of other variables: iU S,t = + 1iU S,t1 + 0iCh,t + 1iCh,t1 + 0ft + 1ft1 + 0st + 1st1 + t.

Remember to check recursive estimation and save some observations for forecasting.

j.j.reade@bham.ac.uk

61

EQ(28) Modelling US by OLS The dataset is: /Users/jamesreade/Documents/Data/Mon Ind/US_China_1m_IB_jr.csv The estimation sample is: 2002-02-12 - 2009-12-03 Coefficient 1.00048 -0.117155 0.000177891 -0.00203798 0.815535 -0.882411 2.88309 -2.75721 0.035644 0.999583 0.999582 2038 2.68521 Std.Error 0.0004840 0.02279 0.001901 0.001899 0.5628 0.5607 0.7046 0.7064 t-value 2067. -5.14 0.0936 -1.07 1.45 -1.57 4.09 -3.90 t-prob Part.R2 0.0000 0.9995 0.0000 0.0128 0.9254 0.0000 0.2834 0.0006 0.1475 0.0010 0.1157 0.0012 0.0000 0.0082 0.0001 0.0074

The ADL Model Output

US_1 Constant China China_1 LExchangeRate LExchangeRate_1 L1MFWDExchangeRate L1MFWDExchangeRate_1 sigma R2 Adj.R2 no. of observations mean(US)

RSS 2.57911023 F(7,2030) = 6.956e+05 [0.000]** log-likelihood 3907.26 no. of parameters 8 se(US) 1.74303

1-step (ex post) forecast analysis 2009-12-04 - 2009-12-17 Parameter constancy forecast tests: Forecast Chi2(10) = 0.34950 [1.0000] Chow F(10,2030)= 0.033968 [1.0000] CUSUM t(9) = 0.5808 [0.5756] (zero forecast innovation mean)

Additional forecast analysis provided as standard.

j.j.reade@bham.ac.uk

62

Post-Estimation: Test Summary


AR 1-2 test: ARCH 1-1 test: Normality test: Hetero test: Hetero-X test: RESET23 test: F(2,2038) = F(1,2046) = Chi2(2) = F(14,2033)= F(35,2012)= F(2,2038) = 353.63 98.824 14958. 15.293 8.3928 5.4855 [0.0000]** [0.0000]** [0.0000]** [0.0000]** [0.0000]** [0.0042]**

Better but still not good. Tasks: Use Test... in Test menu to investigate test failures. Use Post-estimation graphics to investigate: Autocorrelation. Normality. Heteroskedasticity. How might you reformulate model?

j.j.reade@bham.ac.uk

63

Post-Estimation: The Long-Run Solution


From your undergraduate degree recall we can rearrange ADL model:33 iU S,t = 0iCh,t + 0ft + 0st + [iU S,t1 0 1iCh,t1 2ft1 3st] + t. This is the equilibrium-, or error-correction form of our model: Contains long-run solution: iU S,t1 0 1iCh,t1 2ft1 3st. Where = (1 1), 0 = /(1 1), 1 = (0 + 1)/(1 1),. . . Variables non-stationary, but CIP relationship exists: Expect cointegration. Linear combination of I(1) variables that is I(0). CIP is stationary, steady-state relationship amongst I(1) variables? We can test this. . .
33

See PcGive Vol. 1, Ch. 12.


64

j.j.reade@bham.ac.uk

Post-Estimation: Dynamic Analysis


Select Dynamic Analysis... in the Test Menu.34 Static long-run solution: Yields: iU S,t1 0 1iCh,t1 2ft1 3st. Requires model be of ADL form. Provides standard errors of ECM terms, and Wald test of joint signicance.
Solved static long-run equation for US Coefficient Std.Error Constant 251.079 271.0 China 4.08618 4.072 LExchangeRate 145.122 202.4 L1MFWDExchangeRate -271.774 324.0 Long-run sigma = 77.2275 t-value 0.927 1.00 0.717 -0.839 t-prob 0.3543 0.3158 0.4734 0.4017

ECM = US - 251.079 - 4.08618*China - 145.122*LExchangeRate + 271.774*L1MFWDExchangeRate; WALD test: Chi2(3) = 1.01629 [0.7973]

Does not test for cointegration however. . .


34

See PcGive Vol. 1, Sec. 18.3, especially for graphing lag weights.
65

j.j.reade@bham.ac.uk

Cointegration Testing
Cointegration testing makes use of other useful features of OxMetrics. Cointegration theory: xt I(1), yt I(1) but linear combination yt xt I(0). Hence regress yt on xt and save residuals since t = yt xt in regression. Carry out unit root testing on residuals t. If residuals stationary, implies xy and yt cointegrated.35 Tasks: 1. Regress iU S,t on iCh,t, ft and st. 2. Save the residuals from the regression. 3. Carry out unit root testing on the residuals.
35

Subject to the caveat that Dickey-Fuller unit root tests are known to have low power hence conclude in favour of null (unit root) too often. Most cointegration is now done using VAR models: Come back tomorrow for that.
j.j.reade@bham.ac.uk 66

Post-Estimation: Dynamic Analysis


Lag structure analysis:
Analysis of lag structure, coefficients: Lag 0 Lag 1 Sum SE(Sum) US -1 1 0.00046 0.000482 Constant -0.116 0 -0.116 0.0226 China 0.000167 -0.00205 -0.00188 0.000907 LExchangeRate 0.817 -0.884 -0.0668 0.0568 L1MFWDExchangeRate 2.88 -2.76 0.125 0.0612 Tests on the significance of each variable Variable F-test Value [ Prob] Unit-root t-test US F(1,2040) =4.3141e+06 [0.0000]** 0.95593 Constant F(1,2040) = 26.205 [0.0000]** China F(2,2040) = 2.3366 [0.0969] -2.0751 LExchangeRate F(2,2040) = 1.9184 [0.1471] -1.1774 L1MFWDExchangeRate F(2,2040) = 10.391 [0.0000]** 2.0442 Tests on the significance of each lag Lag 1 F(4,2040) =1.0898e+06 [0.0000]**

Unit-root tests based on (1 1), (0 + 1), etc.

j.j.reade@bham.ac.uk

67

Post-Estimation: Dynamic Analysis


Roots of lag polynomials: Lag operator L s.t. Lxt = xt1. AR(1): xt = xt1 + et (1 L)xt = et. (1 L) = a(L) is lag polynomial, here root is 1. < 1 for stability.
Roots of US lag polynomial: real imag modulus 1.0005 0.0000 1.0005 Roots of China lag polynomial: real imag modulus 12.250 0.0000 12.250 Roots of LExchangeRate lag polynomial: real imag modulus 1.0818 0.0000 1.0818 Roots of L1MFWDExchangeRate lag polynomial: real imag modulus 0.95661 0.0000 0.95661

Roots of other variables for model reduction purposes: ADL for xt, yt: (1 1L)xt = 0(1 + 1/0)yt + t. If 1 = 1/0, divide thru by (1 1L) for: yt = + 0xt + ut. ut = t/(1 1L) ut = 1ut1 + t, hence autoregressive errors.
j.j.reade@bham.ac.uk 68

Post-Estimation: Common Factors


Test for common factors: Can formally test whether lag polynomials equal: 1 = 1/0. Idea: Autocorrelated residuals often assumed in econometric modelling. Common factors: Residual autocorrelation indicative of richer structure of model. But not necessarily: AR test failure common factors.
COMFAC Wald test table, COMFAC F(3,2040) = 3.84376 [0.0093] ** Order Cumulative tests Incremental tests 1 Chi2(3) = 11.531 [0.0092]** Chi2(3) = 11.531 [0.0092]**

j.j.reade@bham.ac.uk

69

Post-Estimation: Graphics
As in Cross-Section, Graphics may help determine problems. Many additions in time series: Residual density options, ACFs and PACFs: May want to trick PcGive into thinking your cross section is time series. Graphic possibilities: Actual/tted values: Does model do well? Residuals: Scaled, unscaled, pickled, roasted,. . . 36 Residual density/actual plots: Distribution looks normal/iid? Skewed? Heteroskedastic? Use these graphics to shape model re-specications.
36

See Further graphs


70

j.j.reade@bham.ac.uk

Post-Estimation: Graphics
6
US Fitted r:US (scaled)

10 4 0 2

10 2002 2004 Density 2.0 r:US N(0,1) 1.5 1.0 0.5 2006 2008 2010 2002 1.0 0.5 0.0 0.5 2004
ACFr:US

2006
PACFr:US

2008

2010

10

10

15

10

j.j.reade@bham.ac.uk

71

Thoughts Based on Graphics


Appears to be some under/overshooting eect as US rate rises. Much greater volatility since nancial crisis. Deterministic terms (dummy variables) to cope with diculties? Or extra variables? E.g. VIX index, daily volatility of Dow Jones? Tasks: Consider reformulating model using Datastream.37 Consider modelling over weekly, monthly or quarterly frequency. Does it make a dierence?
37

Assuming your computers have it!


72

j.j.reade@bham.ac.uk

Post-Estimation: Forecasts
To forecast, must re-estimate and estimate over reduced sample size. At sample size selection (Estimate) menu, Change Less forecasts to 10. Shortens estimation sample by 10 most recent observations. Can then forecast over these 10 observations. Evaluating model via forecast performance very common. But may not be indicative of model quality, esp. if data non-stationary. Hendry (1995): Forecast performance of naive simple devices hard to beat. Post-estimation, go to the Test menu and select Forecast...

j.j.reade@bham.ac.uk

73

Two Types of Forecasting


Denote forecast of variable xt at T + h made at T as xT +h|T Dynamic or h-step (static) forecasts? Assume model: xt = xt1 + t. h-step forecast is xT +h = xT . Forecasts further ahead (e.g. T + h + 1) require knowledge of xT +1. Dynamic forecast is: xT +h = xT +h1, where xT +h1 = xT +h2 and so on. Each forecast is fed back in: May lead to cumulation of errors.

j.j.reade@bham.ac.uk

74

Forecasting: Tasks
Select a dierent length of Forecasts to hold back. Evaluate the forecast performance of the model by both types of forecast. What is the forecast performance as h is increased? Compare the forecast performance of your model against a random walk model. Recall random walk model is xt = xt1 + t, or xt = t. Remember you can copy and paste particular sets of plots in OxMetrics.

j.j.reade@bham.ac.uk

75

Recursive Estimation
Recursive estimation is a method of model evaluation: Are coecient estimates stable over the entire sample? Or are they averages over structural breaks? Generally expected in any regression analysis submitted to a journal. Estimate over observations 1, 2, . . . , TI , where TI < T is the Initialisation. Evaluate all model parameters: , , etc. Estimate over observations 1, 2, . . . , TI , TI + 1 and evaluate parameters. Keep going until reach full sample. Analysis: Plot parameters for dierent sample lengths. Calculate test statistics to detect structural change.
j.j.reade@bham.ac.uk 76

The Doing of Recursive Analysis


Must select recursive estimation at Estimate window.

Need to also select Initialization: What is TI ? Smaller TI , analysis covers more of sample. Smaller TI , earlier estimates less stable as sample size tiny. Then estimate as usual: Will take fractionally longer to produce results.
j.j.reade@bham.ac.uk 77

Recursive Analysis Post-Estimation


Recursive analysis is all post-estimation. Hit Test menu. Recursive analysis option now possible. Range of graphics possible in resulting menu. Choosing all will result in very small plots, hard to see.38 First plot regression coecients: Beta coefficient +/- 2 SE. t-stats can be inferred from this plot via SEs so dont clutter by plotting ts also.

38

Can always copy and paste some to a new graphics le though (Using Ctrl+N).
78

j.j.reade@bham.ac.uk

1.5 1.0 0.5

Plotting Recursive Regression Coecients 10


Constant
0

US lag
2004 2006 2008 2010 2002 0.01 0.00 0.01 2004 2006 2008 0.02 2010 2002 5.0 2.5 2004 2006 2008 2010

0.0 2002 0.02 0.01 0.00 0.01 2002 5 0

China

China lag
2004 2006 2008 2010

Spot ExchangeRate (log)

Spot Exchange Rate lag (log)

0.0 2002 10 0 2004 2010 2002 1Month Forward Exchange Rate 10 0 2006 2008 2004 2006 2008 2010

1Month Forward Exchange Rate lag (log)

2002

2004

2006

2008

2010 2002

2004

2006

2008

2010

Need to change axes to make plots useful: Much structural instability.39 Be careful in changing axes: Comparability between plots impaired. t-stat signicant if both green lines do not include zero.
39

Make use of Apply button when changing the Y axis values here. To aid visibility, delete Z label also, and relabel.
79

j.j.reade@bham.ac.uk

More Recursive Plots


Residual sum of squares:
2 t=1 t ,

= TI , TI + 1, . . . , T .

If model stable expect this to rise steadily: By 2 each period. Jumps indicative of something changing: Residual very large that period. 1-step Residuals +/- 2 SE: Final observation residuals: y x , = TI , TI + 1, . . . , T . Points outside standard error bounds ( ) associated with structural change. Standardized innovations: Residuals calculated using last period estimates: y 1x , = TI , TI + 1, . . . , T . Standardised by . Large observations suggest structural instability.
3 2 1 2002 2004 2006 2008
RSS

0.50 0.25 0.00 0.25 2010 2002

Res1Step

0.50 0.25 0.00 0.25 2006 2008 2010 2002

Innovs

2004

2004

2006

2008

2010

j.j.reade@bham.ac.uk

80

What are the Chow tests?


All plots: test statistic scaled by critical value at 1% level. 1-step Chow test: Estimate 1, . . . , m 1, forecast m. D RSSm RSSm1 Test statistic: FChow1 = 2. 1 RSSm1/ [(m 1) 2] Break-point Chow test: Estimate 1, . . . , m 1, forecast m, . . . , T . D RSST RSSm1 Test statistic: FBreakChow = 2 m+1. T RSSm1/ [(T 1) 2]

(7)

(8)

Forecast Chow test: Estimate 1, . . . , M 1, forecast {M }, {M, M + 1}, ..., {M, M + 1, . . . , T }. (RSSm RSSM 1)(M k 1) D 2 Test statistic: FForcChow = mM +1. (9) RSSM 1 (m M 1) Tests all very likely to fail if structural change hence useful.
j.j.reade@bham.ac.uk 81

Chow Test Outputs


150
1up CHOWs 5%

50 2002 75 50 25 2003
Ndn CHOWs

2004
5%

2005

2006

2007

2008

2009

2010

2002 15 10 5 2002

2003
Nup CHOWs

2004
5%

2005

2006

2007

2008

2009

2010

2003

2004

2005

2006

2007

2008

2009

2010

j.j.reade@bham.ac.uk

82

Deterministic Terms
Already covered creating them in Calculator. What about using them? Chow tests suggest something happened in 2003 and 2007. Can work out date by hovering cursor over graph. Can also write results instead of graphing in Recursives. Can also print out largest residuals: See Further output... Tasks: Determine the dates of structural changes and create dummy variables. Re-run your model including these structural break terms. Do they have any eect? If not how might you alter them/the model?

j.j.reade@bham.ac.uk

83

Enough for Today


Introduction to OxMetrics: Keep playing: Cant include every facet of software. Single-equation modelling using PcGive. Tomorrow: Many of the other possibilities within OxMetrics. . .

j.j.reade@bham.ac.uk

84

También podría gustarte