gravity model final
TRANSCRIPT
-
8/4/2019 Gravity Model Final
1/43
Economic Trade Analysis Tool(Gravity Model of Bilateral Trade)
Isaac A. Asiamah
Project Oriented Computer ScienceDowling College
-
8/4/2019 Gravity Model Final
2/43
Presentation Breakdown
Aims & Objectives of Project Background Phases Tasks & Dependencies
User Externals System Design Input/Output Documentation
Future Objectives Q&A Acknowledgements
-
8/4/2019 Gravity Model Final
3/43
Aims & Objectives of Project
The main objective of this project was to write an application based onthe gravity model of bilateral trade that will ease the process of analyzingthe flow of Trade between trading nations.
TARGET AUDIENCE
This tool is targeted towards an academic audience such as people whomight be doing graduate level work in economics and appliedmathematics .
We believe this tool ,with further polishing ,will be very useful mainly toeconomists who need access to analyzed Trade Flow informationbetween 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 tradebetween specific countries by adding and removing several factors inorder to improve the Model.
-
8/4/2019 Gravity Model Final
4/43
Background
The gravity equation is a popular formulation forstatistical analyses of bilateral flows between differentgeographical entities or regions.
It was adapted from Newtons law of gravitation.
In 1962 Jan Tinbergen proposed that roughly thesame functional form could be applied to international
trade flows. However, it has since been applied to awhole range of what we might call social interactionsincluding migration, tourism, and foreign directinvestment.
-
8/4/2019 Gravity Model Final
5/43
Background
Newtons Law of Gravitation has an application interms of the flow of trade and Import/Export betweentwo countries
F = Gm1m2
r2F = The force of attractionm1 = mass of object 1m2 = mass of object 2r = the distance
G = is a constant.G is a gravitational constant depending on the units of
measurement for mass and force.
-
8/4/2019 Gravity Model Final
6/43
Background
F = KGDPiGDPj
d
F = The Flow of TradeGDPi = GDP of country i
GDPj = GDP of country j
d = distance between economiccapitals of countries i and j.
K = is a constant.
F = Gm1m2
r2
F = The force of attractionm1 = 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 ofLogarithms we convert it to the formulaLn(F) = ln(GDPi) + ln(GDPj) ln(d) +ln(k)
-
8/4/2019 Gravity Model Final
7/43
Before we start .
While working on this project I realized most of my course mates had aproblem understanding what I was doing. And very recently I heard acomment like I dont even know what Bilateral means".
So I took these comments to heart and in order not to confuse anyone Iput 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 thecreation 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 toimprove the predictive output of the model by allowing us to include subgroupssuch male /female ,married /single etc.
Regression - examines the relation of a dependent variable (response variable)to specified independent variables (explanatory variables).
-
8/4/2019 Gravity Model Final
8/43
Proposed Features /Functionality
I. Java based although originally started in java script
II. Calculate the flow of trade between two given countriesbased on factors such as
balance of trade
Gross Domestic Product(GDP) geographical location
Political regime and diplomatic ties
III. Must plot a chart to represent the calculated Trade flow dataover the number of years based on the users input
IV. The data must be analyzed using Regression in order topredict future trade patterns based on the users input.
-
8/4/2019 Gravity Model Final
9/43
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 FixingCode functionality related FixesOutput and I/O link related fixes-Input-Error Handling
-OutputPHASE III:
DOCUMENTATION:- Help- Download Instructions
-
8/4/2019 Gravity Model Final
10/43
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
-
8/4/2019 Gravity Model Final
11/43
System Design
GUI
FLOW CHART OF SYSTEM DESIGN
DATA
CODE
OUTPUT
-
8/4/2019 Gravity Model Final
12/43
DESIGNING THE GUI
The Graphical User Interface was designed using Net beans.
-
8/4/2019 Gravity Model Final
13/43
FEATURES OF THE GUI
DROP DOWN MENUSTo allow selection of countries, years, and time invariantvariables from a list
CHECK BOXES:
To select options for time invariant variable effect on outputformat desired by the user.
BUTTONS:To compute Trade flow or Trade potential for a region or tocompute trade flow data for future analysis.
TEXTFIELDThere is one main text field labeled Output .Its main purpose is todisplay the computed data for trade flows and regression.
-
8/4/2019 Gravity Model Final
14/43
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 CollegesEconomics 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
http://www.macalester.edu/research/economics/PAGE/HAVEMAN/Trade.ResourcesTradeData.htmlhttp://www.macalester.edu/research/economics/PAGE/HAVEMAN/Trade.ResourcesTradeData.htmlhttp://www.bea.gov/http://www.econstat.com/http://www.econstat.com/http://www.bea.gov/http://www.macalester.edu/research/economics/PAGE/HAVEMAN/Trade.ResourcesTradeData.htmlhttp://www.macalester.edu/research/economics/PAGE/HAVEMAN/Trade.ResourcesTradeData.html -
8/4/2019 Gravity Model Final
15/43
Code
The code was written in java and the GUI was also written usingNetbeans.
It Calculates the trade flow for each pair of selected countries based onthe GDP,balance of trade between trading partners ,and other factorssuch as distance, common borders, language and diplomatic ties.
A lot of good ideas on how to compute the trade flows was also learnedfrom some of the papers I read.
I also learned a lot on how to implement the regression analysis .Idecided to adopt the Java Matrix library .i.e. JAMA and used theincluded the regression code using JAMAs library.
I also wrote a little library of functions for performing calculations such asstandard deviation ,covariance ,variance etc.This is also included as partof the source folder
-
8/4/2019 Gravity Model Final
16/43
Algorithm
case = 2 countries onlyvariable 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 jZ 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.
-
8/4/2019 Gravity Model Final
17/43
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
-
8/4/2019 Gravity Model Final
18/43
Elements of Input
CountrySelectionexamples :
Ghana United States Nigeria China
This choice is based on the relative availabilityand ease of access to data for calculationsPerformed
Mode of InputThe four countries are selected from a combo-list, or drop downlist of countries.
-
8/4/2019 Gravity Model Final
19/43
Elements of Input
Date Range SelectionThe selected range of dates is limited to years
between 1980 and 1990 due to the availability ofdata 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 desireddates from two combo lists of dates
The dates are selected from two lists from whichthe begin year chosen MUST be lower than the end
year chosen.
-
8/4/2019 Gravity Model Final
20/43
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 beconsidered as valid for input in the program.
Variable Effects This part has already been coded so the effect of a
time invariant variable is automatically updated
when a variable is selected.Positive effect = 1Negative effect = 0
-
8/4/2019 Gravity Model Final
21/43
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. Predict Trade Flow
The user must click this button to generate tradeflow predictions from the selected input
It will also be considered invalid input if the same
countries are clicked or the years are the samesince we dont have month to month data onbalance of trade.
-
8/4/2019 Gravity Model Final
22/43
Elements of Output
GraphingThe 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.
-
8/4/2019 Gravity Model Final
23/43
Elements of Output
Regression Output
When performing regression analysis the followingterms are displayed in the Output text field. Thesevalues 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 atable and also the
Correlation coefficients
-
8/4/2019 Gravity Model Final
24/43
Documentation
The documentation for this project includes
System Design
User Manual
This presentation features- Readme
- User Manual :Step by Step guide to usingthis product.
This presentation will be available in the docs
Tab on blondie.dowling.edu and sourceforge.net
-
8/4/2019 Gravity Model Final
25/43
User Manual - Readme
1. 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 youunzipped 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.
-
8/4/2019 Gravity Model Final
26/43
Step 1- Country Selection
-
8/4/2019 Gravity Model Final
27/43
Step 2 Year Selection
-
8/4/2019 Gravity Model Final
28/43
-
8/4/2019 Gravity Model Final
29/43
Step 4 Calculate Trade Flow
-
8/4/2019 Gravity Model Final
30/43
Step 5 -- Saving Data
-
8/4/2019 Gravity Model Final
31/43
Step 6 Graphical Output 1
-
8/4/2019 Gravity Model Final
32/43
-
8/4/2019 Gravity Model Final
33/43
Step 8 -- Graphical Output 2
-
8/4/2019 Gravity Model Final
34/43
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 toHandle that error.
So far Ive come up with a few Input Errors and how theyre handled
in the problem.
-
8/4/2019 Gravity Model Final
35/43
Invalid Country Selection
-
8/4/2019 Gravity Model Final
36/43
Invalid Date Range Selection
-
8/4/2019 Gravity Model Final
37/43
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
-
8/4/2019 Gravity Model Final
38/43
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 thissoftware will also be affected by the GPLLicense and the subsequent products will
also be infected by the conditions of
the GPL.
F Obj i /O I
-
8/4/2019 Gravity Model Final
39/43
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 yearoutlook data for trade
I just started learning about Qt and since this current version iswritten in java ,I believe a more light weight Qt version will be agood idea
Extend the list of countries and integrate sql in order to store all
data for GDP,balance of trade etc in a database .
-
8/4/2019 Gravity Model Final
40/43
Downloads
This project is available on two main web pagesi) 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 suchcorrespondence to [email protected]
http://blondie.dowling.edu/gravmod2/http://sourceforge.net/projects/gravmodeq/http://sourceforge.net/projects/gravmodeq/mailto:[email protected]:[email protected]://sourceforge.net/projects/gravmodeq/http://sourceforge.net/projects/gravmodeq/http://blondie.dowling.edu/gravmod2/ -
8/4/2019 Gravity Model Final
41/43
Q&A
Any Questions or Comments ?
-
8/4/2019 Gravity Model Final
42/43
References
1. Macalester College Department of Economics, Western Hemispheric Research.http://www.macalester.edu/research/economics/PAGE/HAVEMAN/Trade.Resources/Data/Gravity/dist.txt
2. Bureau of Economic Analysis, Department of Commerce. 2006. Current-dollar and real grossdomestic product. Washington, DC: BEA. March 30 http://www.bea.gov/bea/dn/gdplev.xls.
3. 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, contemporaryphysics.November 1998.
6. Helga Kristjnsdttir. A gravity model for exports from iceland. 2005.
7. Population Potentials and Development Levels : Empirical Findings in the European Union byJ. Andres Fanaa,* and J. Lopez-Rodrguez
8. A SUR-EC-AR System Gravity Model of Trade by Jaya Krishnakumar9. The Java Matrix Package http://math.nist.gov/javanumerics/jama/
A k l d t
http://www.macalester.edu/research/economics/PAGE/HAVEMAN/Trade.Resources/Data/Gravity/dist.txthttp://www.macalester.edu/research/economics/PAGE/HAVEMAN/Trade.Resources/Data/Gravity/dist.txthttp://www.macalester.edu/research/economics/PAGE/HAVEMAN/Trade.Resources/Data/Gravity/dist.txthttp://www.bea.gov/bea/dn/gdplev.xls.http://www.usatradeonline.gov/http://www.usatradeonline.gov/http://www.bea.gov/bea/dn/gdplev.xls.http://www.macalester.edu/research/economics/PAGE/HAVEMAN/Trade.Resources/Data/Gravity/dist.txthttp://www.macalester.edu/research/economics/PAGE/HAVEMAN/Trade.Resources/Data/Gravity/dist.txt -
8/4/2019 Gravity Model Final
43/43
Acknowledgements
First of all Ill like to thank God for keeping mealive and giving me the strength and health tobring this phase of the project to completion.Prof. Bernstein for his Insight and his supervision
and guidance.My classmates Jon Ihm,Mike Fiero ,NikolayDarakev, Georgi Jones Darakev and Gregory
Mcquillan for their support and making it easierfor me to work with them although Im not a
computer science major.And lastly ,the Economics , Math and ComputerScience faculty