Você está na página 1de 43

Economic Trade Analysis Tool (Gravity Model of Bilateral Trade)

Isaac A. Asiamah

Project Oriented Computer Science Dowling College

Presentation Breakdown

Aims & Objectives of Project Background Phases Tasks & Dependencies User Externals System Design Input/Output Documentation Future Objectives Q&A Acknowledgements

Aims & Objectives of Project


The main objective of this project was to write an application based on the gravity model of bilateral trade that will ease the process of analyzing the flow of Trade between trading nations. TARGET AUDIENCE This tool is targeted towards an academic audience such as people who might be doing graduate level work in economics and applied mathematics .

We believe this tool ,with further polishing ,will be very useful mainly to economists who need access to analyzed Trade Flow information between specific countries based on a wide variety of factors which are within their choice . This will allow the user to improve and better predict the volume of trade between specific countries by adding and removing several factors in order to improve the Model.

Background

The gravity equation is a popular formulation for statistical analyses of bilateral flows between different geographical entities or regions. It was adapted from Newtons law of gravitation.

In 1962 Jan Tinbergen proposed that roughly the same functional form could be applied to international trade flows. However, it has since been applied to a whole range of what we might call social interactions including migration, tourism, and foreign direct investment.

Background
Newtons Law of Gravitation has an application in terms of the flow of trade and Import/Export between two countries F = Gm1m2 r2 F = The force of attraction m1 = mass of object 1 m2 = mass of object 2 r = the distance G = is a constant. G is a gravitational constant depending on the units of measurement for mass and force.

Background

F = KGDPi GDPj d F = The Flow of Trade GDPi = GDP of country i GDPj = GDP of country j d = distance between economic capitals of countries i and j. K = is a constant.

F = Gm1m2 r2 F = The force of attraction m1 = mass of object 1 m2 = mass of object 2 r = the distance G = is a constant.

The economics version can linearized and due to the additive nature of Logarithms we convert it to the formula Ln(F) = ln(GDPi) + ln(GDPj) ln(d) +ln(k)

Before we start .

While working on this project I realized most of my course mates had a problem understanding what I was doing. And very recently I heard a comment like I dont even know what Bilateral means". So I took these comments to heart and in order not to confuse anyone I put a few terms and their definitions together to make this presentation a little clearer. Some Keywords

Bilateral - pertaining to, involving, or affecting two or both sides, factions, parties Model - Model (abstract), an abstraction or conceptual object used in the creation of a predictive formula Time invariant factors Factors that are not expected to change with time Dummy variable - An extra variable we include in regression analysis to improve the predictive output of the model by allowing us to include subgroups such male /female ,married /single etc. Regression - examines the relation of a dependent variable (response variable) to specified independent variables (explanatory variables).

Proposed Features /Functionality


I. II.

III. IV.

Java based although originally started in java script Calculate the flow of trade between two given countries based on factors such as balance of trade Gross Domestic Product(GDP) geographical location Political regime and diplomatic ties Must plot a chart to represent the calculated Trade flow data over the number of years based on the users input The data must be analyzed using Regression in order to predict future trade patterns based on the users input.

Phases
PHASE I: CODING: - Graphical User Interface - Data Analysis and Prediction Functions - Code to Link input and Output - Code to Polish Output PHASE II: TESTING AND DEBUGGING: GUI related Testing and Fixing Code functionality related Fixes Output and I/O link related fixes -Input -Error Handling -Output PHASE III: DOCUMENTATION: - Help - Download Instructions

Design Breakdown
The project was divided into the following phases in order to expedite the completion. However ,from hindsight the project would have started differently had I been aware of some of the dependencies.
Design Process Breakdown 1. Input - GUI 2. Data - IMF/World bank ,BEA,Dept of Commerce,Econstat sourced data for import/export, balance of trade, and distances 3. Computation - implementing the algorithm & regression analysis 4. Output - Output Generation

System Design
FLOW CHART OF SYSTEM DESIGN
DATA

OUTPUT CODE

GUI

DESIGNING THE GUI


The Graphical User Interface was designed using Net beans.

FEATURES OF THE GUI


DROP DOWN MENUS To allow selection of countries, years, and time invariant variables from a list CHECK BOXES: To select options for time invariant variable effect on output format desired by the user. BUTTONS: To compute Trade flow or Trade potential for a region or to compute trade flow data for future analysis. TEXTFIELD There is one main text field labeled Output .Its main purpose is to display the computed data for trade flows and regression.

DATA
Datasets Needed: Distances between capitals based on great circle method Real GDP values for countries Export/Import Data for countries Balance of Trade Data for countries
Distances were obtained from Raymond Robertson and Jon Haveman of Macalester Colleges Economics Department. http://www.macalester.edu/research/economics/PAGE/HAVEMAN/Trade.ResourcesTradeData.ht ml#Gravity US Economic data U.S. Department of Commerce Bureau of Economic Analysis www.bea.gov

Non US Economic data www.econstat.com

Code

The code was written in java and the GUI was also written using Netbeans. It Calculates the trade flow for each pair of selected countries based on the GDP,balance of trade between trading partners ,and other factors such as distance, common borders, language and diplomatic ties. A lot of good ideas on how to compute the trade flows was also learned from some of the papers I read. I also learned a lot on how to implement the regression analysis .I decided to adopt the Java Matrix library .i.e. JAMA and used the included the regression code using JAMAs library. I also wrote a little library of functions for performing calculations such as standard deviation ,covariance ,variance etc.This is also included as part of the source folder

Algorithm
case = 2 countries only variable declaration:
Fij Flow of Trade from i to j,
GDPi ,GDP of country i, GDPj ,GDP of country j, Balance of trade between country i and country j Distance - proxy for time taken to travel from i to j

Z Time Invariant factors causing -/+ bilateral effect - common language -- value of either 1 or 0 - colonial links -- value of either 1 or 0 - tariffs -- value of either 1 or 0 eij the normal random error term.

ln(Fij) = Bo +B1 ln(GDPi) + B2 ln(GDPj)- B3 ln(Distance) +B4 (language) + eij The Betas are the regression coefficients obtained after performing regression analysis.

Input /Output
In designing the I/O aspect of this program we tried as much as possible to emphasize these three principles and we will strive to stick to them as other advanced versions of the program is released.

Simplicity Ease of use Clear, readable output

Elements of Input

Country Selection examples :


Ghana United States Nigeria China

This choice is based on the relative availability and ease of access to data for calculations Performed

Mode of Input
The four countries are selected from a combo-list, or drop down list of countries.

Elements of Input

Date Range Selection


The selected range of dates is limited to years between 1980 and 1990 due to the availability of data for those countries. Further expansions will be made to this range of dates in future releases.

Mode of Input

The range of years is input by selecting the desired dates from two combo lists of dates The dates are selected from two lists from which the begin year chosen MUST be lower than the end year chosen.

Elements of Input

Time Invariant Variable Selection

The dummy variables are selected by choosing from a variable list. All dummy variables included will have to be assigned an effect by the user in order to be considered as valid for input in the program.
This part has already been coded so the effect of a time invariant variable is automatically updated when a variable is selected.
Positive effect = 1 Negative effect = 0

Variable Effects

Elements of Input

Compute Trade Flow

The user must click this button to compute the trade flow values for the selected input It will be invalid to click this push button when no values have been entered.
The user must click this button to generate trade flow predictions from the selected input It will also be considered invalid input if the same countries are clicked or the years are the same since we dont have month to month data on balance of trade.

Predict Trade Flow


Elements of Output
Graphing
The graphing system employed by this program is used for both the computations and predictions of the trade flow values given the years specified. The output can be displayed currently as a Line Graph We hope we can extend the program to plot other types of charts in the future .

The button Plot Graph just displays the ordinary line Graph with actual trade flow values

The data analysis button also plots two line graphs which show the actual and predicted values of the model along side each other.

Elements of Output
Regression Output When performing regression analysis the following terms are displayed in the Output text field. These values and table can be saved and imported to be used in other programs .

Standard error term The residual values i.e.. Difference between predicted and actual trade flow values in a table and also the Correlation coefficients

Documentation
The documentation for this project includes System Design User Manual This presentation features - Readme - User Manual :Step by Step guide to using this product. This presentation will be available in the docs Tab on blondie.dowling.edu and sourceforge.net

User Manual - Readme


Go to Download Page and Download Current Version 2. Unzip package and save to a desired folder on your machine NB: There isnt a gzipped version on blondie currently. It will be uploaded soon . 3. Windows Users : Go to start -> Click Run ->Navigate to Directory where you unzipped the package -> Type java jar GravModel.jar Linux Users : Open a terminal -> Navigate to directory where you unzipped the package -> Type java jar GravModel.jar 4. The following visuals will show you how to use some of the current features of the program.
1.

Step 1- Country Selection

Step 2 Year Selection

Step 3 Selection of TI variables

Step 4 Calculate Trade Flow

Step 5 -- Saving Data

Step 6 Graphical Output 1

Step 7 -- Regression Output

Step 8 -- Graphical Output 2

Error Handling
Since this is the first public release its fairly pragmatic to assume that this program is chocked full with logical errors .

So the debugging process never stops Im continually thinking of new cases the program can crash and finding a way to Handle that error.

So far Ive come up with a few Input Errors and how theyre handled in the problem.

Invalid Country Selection

Invalid Date Range Selection

More on Error Handling

Youll receive these same error messages if you attempt to perform regression analysis with An invalid combination of countries An invalid selection of years

License
This product is released under the GNU Product license .It is freely available to everyone to download ,copy and revise. Be Aware that all revisions that you make to this software will also be affected by the GPL License and the subsequent products will also be infected by the conditions of the GPL.

Future Objectives /Open Issues

Adding functionality to extend prediction of future trade patterns ,this would allow the user to generate values of 3,5 and 10 year outlook data for trade I just started learning about Qt and since this current version is written in java ,I believe a more light weight Qt version will be a good idea Extend the list of countries and integrate sql in order to store all data for GDP,balance of trade etc in a database .

Downloads
This project is available on two main web pages
i) Blondie @ http://blondie.dowling.edu/gravmod2/

ii) Source forge @ http://sourceforge.net/projects/gravmodeq/

If you want to join this project as a developer or have any helpful suggestions and constructive criticisms you can forward all such correspondence to ixa2@dowling.edu

Q&A
Any Questions or Comments ?

References
1. 2. 3.

Macalester College Department of Economics, Western Hemispheric Research. http://www.macalester.edu/research/economics/PAGE/HAVEMAN/Trade.Resources/Data/Gr avity/dist.txt Bureau of Economic Analysis, Department of Commerce. 2006. Current-dollar and real gross domestic product. Washington, DC: BEA. March 30 http://www.bea.gov/bea/dn/gdplev.xls. United States Census Bureau http://www.usatradeonline.gov/

4.

Keith Head. Gravity for beginners. February 2003.

5.

R.G Keesing. The history of Newton's apple tree, contemporary physics.November 1998.
Helga Kristjnsdttir. A gravity model for exports from iceland. 2005.
Population Potentials and Development Levels : Empirical Findings in the European Union by J. Andres Fanaa,* and J. Lopez-Rodrguez A SUR-EC-AR System Gravity Model of Trade by Jaya Krishnakumar The Java Matrix Package http://math.nist.gov/javanumerics/jama/

6.
7.

8. 9.

Acknowledgements
First of all Ill like to thank God for keeping me alive and giving me the strength and health to bring this phase of the project to completion. Prof. Bernstein for his Insight and his supervision and guidance. My classmates Jon Ihm,Mike Fiero ,Nikolay Darakev, Georgi Jones Darakev and Gregory Mcquillan for their support and making it easier for me to work with them although Im not a computer science major. And lastly ,the Economics , Math and Computer Science faculty

Você também pode gostar