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
Loading Data and
Date Formats
Program Flow and
Functions Saving Data and
Screen Output
Example Clip
Discussion Discussion
Example Code
Example Clip

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

Intermediate Programming

Arrays and
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
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
Time Series
Unit Root and
Stationarity Testing
Example Code
coming soon Discussion
Methods of Moments
Example Code
coming soon Discussion
Example Code
Simulation Techniques
Binary Response
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]