Accelerating the pace of engineering and science

 User Stories

# MATLAB Used to Predict Financial Crises in Emerging Markets

View PDF

“Because MATLAB is both powerful and easy to use, I felt confident that the Bank of Indonesia would be able to implement the MATLAB programs and use them as an early warning system for financial distress.”

Dr. Paul McNelis, Georgetown University

Prompted by the financial crisis that began in the Asian Tiger economies and quickly spread to much of the world, economist Paul McNelis set out to see if modern tools and research techniques could help predict such crises and thereby lessen their impact.

He focused on Indonesia, where, in the fall of 1997, the value of the Indonesian rupiah fell precipitously and domestic demand for dollars reached panic levels even after the government had received a \$23 billion loan from the IMF.

McNelis conducted his research at Bank Indonesia under a technical assistance grant from the United States Agency on International Development in Indonesia. Throughout this ambitious project he relied on MATLAB® and his repertoire of personal MATLAB files, in combination with Spreadsheet Link™ EX, Statistics Toolbox™, Optimization Toolbox™, and Neural Network Toolbox™.

## Challenge

McNelis set out to analyze the monthly demand for both currency and broad, or quasi, money in Indonesia for a 13-year period up to and including the crisis. He needed to determine the most effective way to analyze the vast amounts of data that would accumulate. He also needed to reduce the risk of forecasting errors that large fluctuations in the data, such as peaks in the demand for dollars at the height of the crisis, could produce. He knew that the linear or error-correction models that economists traditionally use would not be adequate for this task.

## Solution

McNelis chose to work in MATLAB because of its programming facility, ease of use, and ability to handle vast data sets. As for methodology, he believed that he would achieve more accurate results by combining linear models and neural network analysis. An advantage of using neural networks, he explains, is that “the estimation involves not only sequential processing of the data, using inputs x to forecast the output y, but also simultaneous parallel processing, since the inputs are processed by several neurons in the hidden layer.”

Central to his analysis was a genetic algorithm that he developed jointly with Professor John Duffy of the University of Pittsburgh. In developing the algorithm, McNelis and Duffy used Statistics Toolbox extensively. They also used the vectorization functions in MATLAB for faster processing. “The coefficients that are obtained by the algorithm,” McNelis explains, “can be used as the starting values for the more common local search methods.” For his search method, he used the nonlinear minimization function in Optimization Toolbox.

After completing the data collection, McNelis set out to produce the best results he could obtain with a traditional linear model. He then used the input from this model to build the neural network.

In defining a neural network, McNelis says that he likes to “start with a simple network, such as three or four neurons in one hidden layer. I train the model with a hybrid method, first using a genetic algorithm to find a set of coefficients for the neural network, and then switch, with these coefficients, to a nonlinear gradient descent method.”

McNelis used the feed-forward architecture in Neural Network Toolbox to relate input to output. He explains, “Though I have experimented with different neural network architectures in a variety of economic applications, I have found that the best one is the feed-forward model with one hidden layer.” He used the toolbox’s log sigmoid activation function for the hidden layer for each of the neurons. The input was transmitted to the hidden layer and squashed by the log sigmoid function. Finally, the neurons were transmitted to the output layer as linear combinations.

He was able to increase the forecasting power of neural networks even further by using a time-varying GARCH model to proxy exchange rate risk for the dramatic Indonesian currency declines during November and December 1997.

He used Spreadsheet Link EX for getting in-sample and out-of-sample performance. Spreadsheet Link EX allowed him to take out-of-sample predictions and import them into Microsoft® Excel® and calculate the errors in the out-of-sample predictions. It was then easy to transfer the results from MATLAB into a presentation spreadsheet format.

## Results

• Models with greater predictive capacity. The neural network models developed by McNelis showed far greater accuracy overall than could have been obtained with linear models, and the GARCH model improved forecasting even further.
• A program for averting financial disaster. The Bank of Indonesia is now using McNelis’s models extensively to forecast money demand and predict the core inflation rate. This improves their ability to resist the main inflationary pressures that they have to contend with. McNelis believes that close monitoring of exchange rate fluctuations “may be an effective early warning system for financial distress” that other banks can use to predict a crisis.
• New research tools for the next generation. McNelis is a professor at Georgetown University. He brings leading-edge economic technology, which is based on MATLAB, to the central banking and financial communities of Asia and South America. He also teaches his MATLAB based methods, with a view to helping his students mitigate the hardship that fiscal instability can bring to populations in economic transition.

### Challenge

Develop an econometric model that would help predict—and avert—financial crises in emerging economies

### Solution

Use MathWorks tools to develop a model that applies both linear methods and neural networks to the analysis of trends in currency demand over a selected period

### Results

• Models with greater predictive capacity
• A program for averting financial disaster
• New research tools for the next generation