MATLAB

From ECLR
Jump to: navigation, search

The Essential MATLAB Programming Techniques

In this section we will introduce a number of basic and intermediate programming techniques. Whatever language you program in you will encounter these techniques, although the details will, of course, vary. We recommend that you ensure that you are familiar with these before you progress to Special Econometric Topics .

Basic Programming

Basics and
Matrices
Loading Data and
Date Formats
Program Flow and
Logicals
Functions Saving Data and
Screen Output
Discussion
Example Clip
Discussion
ExampleClip
Discussion Discussion
Example Code
OLSexample.xls
Example Clip
Discussion

After having gone through these basic techniques you may want to test your newly acquired skills with the following examples.

Example 1 Example 2
Example 1 Example2a
Example2b

Intermediate Programming

Statistical
Functions
Arrays and
Structures
Debugging Graphing Data Function Handlers
Anonymous Functions
Discussion Discussion coming soon Discussion Discussion

Advanced Programming

Sorry, but this cannot be taught! It will come with experience. Find someone who has experience in MATLAB programming and let him or her look over your code.

Nonlinear Optimisation

The optimal parameters in a linear econometric model (assuming certain assumptions) can be found analytically. We call them the Ordinary Least Squares (OLS) estimates and they are easily calculated with a certain formula (see the OLSest.m function). When econometric models do not have such an analytical solution, an alternative parameter estimation strategy is required. In essence it is a clever "trial and error" strategy. This is often called nonlinear optimisation.

Nonlinear optimisation is a very important, but also a very tricky area of econometric computing. It certainly helps to understand some of the underlying theory and therefore we have below separate sections on the theory and implementation.

Theory Implementation Constrained
Optimisation
Discussion Discussion Discussion

Special Econometric Topics

Topics in this Section will assume that you have mastered all the techniques covered in the Essential Programming Section

Robust standard
errors
Univariate
Time Series
Unit Root and
Stationarity Testing
Forecasting
Discussion
Example Code
Discussion
FXrateUSEU.xls
USGDP.xls
coming soon Discussion
Maximum
Likelihood
Generalized
Methods of Moments
Instrumental
Variables
Bayesian
Estimation
Discussion
Example Code
coming soon Discussion
Example Code
Discussion
Monte-Carlo/
Simulation Techniques
Binary Response
Models
Handling High
Frequency Data
coming soon coming soon coming soon

Other useful MATLAB resources

The MATLAB Software

The software is available on University of Manchester Computer Labs. If you make regular use of MATLAB you should consider purchasing your own software. The Student Version of MATLAB is available, for instance, from Amazon for £66. This is a real bargain, considering that the equivalent non-discounted package would come in at about £4,000.

Freely available toolboxes

The following toolboxes are freely available and contain extremely useful procedures

  • Spatial Econometrics by James P. LeSage [1]. This toolbox contains a wide variety of useful econometrics functions. It also contains an excellent documentation. In addition to quite general econometric functions you will, as the name suggests, find a huge list of functions relevant if you are working with spatial data.
  • Oxford MFE toolbox by Kevin Sheppard [2]. Use the download link in the box on the right that starts with "Owner: Kevin Sheppard". This toolbox contains many useful functions for uni- and multivariate volatility models.

You need to copy these toolboxes into your MATLAB toolbox folder and add the respective path to the MATLAB list of folders it searches for functions. (In the main menu select FILE and then SET PATH where you can add the folders you added.) If you work on a computer for which you have no administrator rights, this strategy may not work. This Example Clip demonstrates what to do in that case. It is just a matter of adding one line into your code! Piece of cake.

Literature and other learning resources

  • Kevin Sheppard's MATLAB introduction.
  • Martin V., Hurn S. and Harris D. (2012) Econometric Modelling with Time Series: Specification, Estimation and Testing (Themes in Modern Econometrics).[3] This book contains an extensive library of relevant MATLAB codes.
  • Higham, D.J. and Higham, N.J. (2005) MATLAB Guide, Society for Industrial and Applied Mathematics [4]

This website does not cover any theoretical ground and is no substitute for any Econometric Textbook. There is a wide range of very good Econometric Textbooks available. If you are concerned about programming in MATLAB than you are likely to appreciate textbooks that use matrix notation. Here are two very good books that fit that bill:

  • Heij C., de Boer P., Franses P.H., Kloek T. and van Dijk H.K (2004) Econometric Methods with Applications in Business and Economics, Oxford University Press, New York.[5]
  • Greene W.H. (2012) Econometric Analysis, Pearson, Harlow.[6]