TUG Model Basics

Embed Size (px)

DESCRIPTION

Some notes on modeling using GAMS

Citation preview

PAGE 1

Tools for UnderGraduates

Exercises to use with TUG-CGE.gms

Karen Thierfelder and Mary Burfisher

Economics Department, U.S. Naval Academy

September 2009This material is based upon activities supported by the National Science Foundation under Agreement No DUE-0632836. Any opinions, findings, and conclusions or recommendations expressed are those of the authors and do not necessarily reflect the views of the National Science Foundation.Exercise 1: Getting started in GAMS

Concepts: Download GAMS software; introduction to basic commands needed to run TUG-CGE.gms using the GAMS software; open and run data program for the US economy.GAMS software

To install GAMS on your computer, go to: http://download.gams-software.com/ You may download the latest version compatible with your computer. The course model is small enough for GAMS to solve without a license. IntroductionThe TUG-CGE.gms is written in General Algebraic Modeling System (GAMS) programming language. The model code is derived from the file ERSMCP.gms, found in the GAMS Model library. The model used in this course updates the ERSMCP.gms model to make it compatible with the free GTAP summary v7 country databases in a Social Accounting Matrix (SAM) format. The model code can be used with any country data set available from the GTAP website. The user can easily swap out one country file for another to change the country analyzed with TUG-CGE.gms.In this exercise, you will create a directory on your computer in which you store the files used in the course and for your research project. You will learn basic commands in GAMS to run the course CGE model, TUG-CGE.gms. Note, the emphasis of the course is on interpreting results and understanding economic concepts through model simulations. It is not a course on GAMS computer programming so only the basic skills will be addressed. The simulation file is also written in GAMS. Simulation results are reported in an excel spreadsheet called results.xls to make it easy for the user to analyze the information.

The US is used for the exercises in this course, taken from the GTAP version 7 summary matrix program. You may substitute another country of interest in the model. Directions to do so are given in exercise 2.Basic GAMS commands:

Create a PROJECT FILE1. Before you execute a GAMS program, you must create a project file this is where you will keep all files used in the course; as GAMS solves, it will look in this directory for any files called in the main GAMS model program. YOU MUST FIRST OPEN THE PROJECT FILE BEFORE DOING WORK IN GAMS.2. Create a course directory and store all files in that directory. The files you will need can be found at http://www.usna.edu/users/Econ/thier. Copy the following files to your course directory: TUG-CGE1d.gms, TUG-DATA1b.gms, GTAP_SUM_v7.xls, Experiment.inc, results.xls

3. Open GAMSIDE (Use the Windows icon. If it is not available, explore your computer to locate the GAMS directory. Find the GAMSIDE icon and pin it to your start menu.)

4. Create a GAMSIDE project:(GAMS needs to know where you have stored your files. A Project is a GAMS file folder.)

a. On the menu bar at the top, select: >File >Project >New Project if it is the first time you are identifying the folder.

b. In the box, look in, type in the name of the directory in which you placed your model and database

c. At to the bottom of your screen, fill in the file name with the name the of project: YOURNAME, (the file will be assigned a suffix gpr and the file YOURNAME.gpr will appear in the directory in the future).d. You will be in the GAMS program with access to the files in your project directory.

-- To REOPEN your GAMS project:

e. >File >Project >Open Project >Your project name (called YOURNAME.gpr, in the example above).5. If you do not open a project file at the beginning of a GAMS session, you will get an error message because GAMS cannot find the working file it needs to run the program.

Execute GAMS:1. Open your project file.

2. Click on File >open

3. Highlight the file TUG-CGE1d.gms and hit open.

4. Hit either F9 or the red arrow at the top of the menu bar to execute the program.

5. When you run the mode, GAMS generates a list file called TUG-CGE1d.lst. The list file is a report of the model solution. It reprints the model and prints the results of all model calculations. When you run the base model, the TUG-CGE1d.lst file displays all parameters and the solution values for all model variables. The TUG-CGE1d.lst file should appear automatically on your screen after the model is run.

6. When you run TUG-CGE1d.gms, the program will export a file, TUG-CGE.xls to your directory. This file has the database for the US economy, in a SAM format compatible with TUG-CGE1.gms.

7. When you run the TUG-CGE1.gms, it will also calibrate model parameters. After the model executes you can run simulations (more details about the steps in a later exercise). If you run the base model successfully (which should be the case with the course CGE model), the program will end with a display of exit solution found. In addition, GAMS will print solution diagnostics which are helpful if the file does not solve. If you have an error, the error message will appear in red.

Search the program for a particular variable name 1. When you have opened a file, enter the variable name in the search window (the box directly to the right of the symbol with a flashlight and the letter A) and hit F3, this will search down from the location of the cursor. Alternatively, you can go to the bottom of the code (control end) and search up using shift F3.Turn off a section of code (so the GAMS software does not execute that command)1. Put a * in the far left corner of the code. The line should turn to a light grey color. To turn on a section of code, remove the * and the code should return to normal print. This command will be useful when setting up experiments the file has many different options and you can choose which option you would like to analyze by removing the * from before the relevant line of code.Exercise 2: Download your country database from GTAPConcepts: Download GTAP summary matrix for a country, create a SAM compatible with TUG-CGE.In this exercise, you will learn how to download the free GTAP summary matrices from the GTAP website. You will convert this Social Accounting Matrix (SAM) to a version compatible with TUG-CGE. You will view your country SAM in Excel. At the end of this exercise, your 10 sector, 5 factor database and model will be ready to use for analysis. Create a Directory in Your Computer for Your Project (such as CGE-PROJECT)You will download and save files for your project into this directory. Download a GTAP Summary matrix

1. go to www.GTAP.org1. go to login box at the top of the screen and create an account under New Member Registration, (for subsequent interaction with GTAP, use the account you have created)2. From the menu bar, select:

> Data Bases

> GTAP 7 Summary Matrices

> In section on Country-Specific Data, under the heading SAM, pull the drop down menu and select a country. If your computer blocks file download as part of internet security, disable the feature (you should get a pop-up box on your machine to notify you of the problem). Once you allow the download, repeat the selection from the SAM drop down menu. Save the excel file in your project directory.3. The downloaded file will be named ???_SAM.xls file where ??? is a three letter country code used by GTAP. (If you click on the tab Table Description 2 you will find a listing of country codes.) For example if you use the United States as your country, your file will be USA_SAM.xls

4. When you open the excel file, you should be on the tab with your country name, United States of America for the US example. This tab has the country data we will use in the course. The other tabs provide background information. The tab Sector Mapping is particularly useful because it shows how the 57 sectors available in GTAP are mapped to the 10 sector aggregates used in the Summary matrices. Note that for which ever country you choose, your data will have the same 10 sectors.

Create a Social Accounting Matrix (SAM) compatible with TUG-CGE

1. Copy the excel file, GTAP_SUM_V7.xls from http://www.usna.edu/Users/econ/thierOpen the tab GTAP-SAM

2. Open your GTAP summary matrix, such as USA_SAM.xls and open the tab with the country name, here it is United States of America

3. In USA_SAM.xls, copy from cell A1 to cell BV80 and paste in cell A1 in the tab GTAP-SAM in the file GTAP_SUM_V7.xls 4. SAVE the GTAP_SUM_V7.xls DO NOT CHANGE THE FILE NAME. DO NOT OPEN or MOVE or EDIT any other TABS in that file. The excel sheet is set up to interface with the GAMS program to aggregate the data into a format compatible with TUG-CGE and the exercises that follow

5. Open the GAMS fileTUG-DATA1b.gms. Hit the key F9 to run the data program. You should create a file in your directory TUG-SAM.xls. This is the file you will use to understand the structure of your economy.

6. To view the SAM and move around the data file easily, use View > Freeze Pane in excel to lock the row and column titles.

EXERCISE 3: Explore the Structure of your Country The database of a CGE model can be displayed in a table format called a Social Accounting Matrix XE "Social Accounting Matrix" (SAM XE "SAM" \t "See Social Accounting Matrix" ). A SAM is a square matrix whose columns and rows describe the circular flow of income and expenditures in an economy at a particular point in time. It is a square matrix because every economic agent in the economy (firms, households, government and investors) has both a column account, which records each of the agents expenditure items, and a row account, which records each source of its income thus, the number of columns in a SAM is equal to the number of rows. Each cell in the SAM matrix describes a single transaction that is simultaneously an expenditure by one agent and the receipt of income by another agent. Each cell tells the expenditure by the column account to the row account. In a balanced SAM, each agents total income (the row sum) is equal to the agents total expenditure (the column sum). Each account is described below. See table 3.3 for a conceptual SAM with an explanation of each income flow in the matrix.In this exercise, we will explore the properties of the country SAM that you downloaded from the GTAP Summary Matrix database. Note that the GAMS program used in Exercise 2 combines some of the accounts from the GTAP Summary Matrix to the accounts used in TUG-CGE.gms. In particular, the data for this course: (1) combines the imported and domestic purchases by agent to have each agent purchasing a composite commodity; (2) combines the sales taxes by agent and computes a single tax rate paid by all agents who purchase the composite commodity; (3) eliminates the regional household by allocating income to households and government directly; and (4) combines trade margins with commodities traded.Note that the names for the accounts follow the names from the GTAP summary matrices. When imported and domestic purchases are combined to create the single commodity account used in the CGE model, the accounts have the prefix c rather than m or d. The account names are described in the text below.

1. Open the file, TUG-CGE.xls, that you created in Exercise 2. Use the Freeze Pane option in Excel to lock the row and column headings in the spread sheet. To understand the income flows in the SAM, remember that for any account, the values in the column for that account record expenditures by the column heading on the row heading. For example SAM(c_agr, a_agr) reports payment from the activity agriculture (a_agr) to the commodity agriculture (c_agr) as expenditures on intermediate inputs. A description of the entry in each cell is given below.Accounts in the SAM, TUG-CGE.xls Activities. XE "activities" Activities are the accounts of domestic industries or firms that engage in the production of goods or services. In the GTAP Summary matrices, there are 10 activities. Each activity column account describes the industrys production expenditures on factors, intermediate inputs to production and taxes; it provides insight into the production technology used. Each activity row account reports where the firms sell their output. In the SAMs from the GTAP summary matrices, each activity output goes to a commodity account for that industry. For example, output produced by the activity agriculture is sold only to the commodity agriculture. This specification is not a necessity in CGE models, but rather a feature of the data set used; intuitively it means that each marketed commodity is produced using a single production technology as described in the activity account for that good. With a more detailed data set, one could allow for different production technologies to produce the same commodity for example agriculture could be produced on family farms and on large commercial farms, each with a different spending pattern on inputs.

The activities from the GTAP summary matrices, which are aggregates of the 57 sectors available in the full database, are:Table 3.1 Activities

A_agrAgriculture

A_Mng_ExtrMining & Extraction

A_PcfProcessed Food

A_LMnfLabor-Intensive Manufactures

A_CMnfCapital-Intensive Manufactures

A_Util_CnsUtilitites & Construction

A_Trans_CommTransportation & Communication

A_SvcesPrivate, Financial, & Other Services

A_OsgPublic Services

A_DweDwelling

Commodities. These are the goods and services that an economy demands for consumption, investment and trade. A commodity is an economys total supply of a good XE "commodities" or service from domestic production and imports, combined. It is a composite of the domestic and imported varieties. The column account for a commodity shows the sources of its supply from domestic firms and imports. The column also reports payments of taxes on in the imported commodity and payment of sales taxes on the composite good. The row account for the commodity shows to whom the good has been sold other producers as intermediate inputs, households, government, investors and exports to foreign markets.

Commodities in the GTAP Summary matrices are as follows:

Table 3.2: Commodities

C_agrAgriculture

C_Mng_ExtrMining & Extraction

C_PcfProcessed Food

C_LMnfLabor-Intensive Manufactures

C_CMnfCapital-Intensive Manufactures

C_Util_CnsUtilitites & Construction

C_Trans_CommTransportation & Communication

C_SvcesPrivate, Financial, & Other Services

C_OsgPublic Services

C_DweDwelling

Factors of production. Factors are the primary resources used to produce goods and services. The factors from the GTAP Summary matrices are: Land, UnSklab (unskilled labor), SkLab (skilled labor), Capital and NatRes (natural resources).The factor account row shows the income received by factors from the activities that employ them. This factor income is sometimes called value added because it is the value of the factors services which are combined with intermediate inputs to generate firms output. The factor column accounts report factor expenditure. In the SAM used in this course, all factor income flows to households. (Note that in the GTAP Summary matrices, factors also pay taxes such as payroll taxes, and some proportion of capital is depreciated. To be consistent with the CGE model used for this course, depreciation (payment to the savings-investment account) and factor taxes are paid out of the household account and the household account receives all factor income.)

Households XE "final demand" . The single household, HOUS, in the SAM for this course gets income from factors, as reported in the row of the household account. The households column account reports expenditures by commodity as well as taxes (payment to DIRPAY) and savings (payment to CGDS).

Taxes. There are five different tax instruments used in the CGE model for this

course. Each has a separate account in the SAM. For each tax instrument, a negative value indicates a subsidy rather than a tax.Indirect taxes

Tmm_world reports the tariff revenue paid. The row of the tmm_world account reports payment by commodity to the tariff account. The column of the tmm_world account reports the payment of total tariff revenue to the government.

Tee_world reports the revenue from export taxes. The row of the tee_world account reports payment by commodity to the export tax account. The column of the tee_world account reports the payment of total export tax revenue to the government.

SALTAX reports the revenue from sales taxes against a commodity. The row of the SALTAX account reports payment by commodity to the SALTAX account. The column of the SALTAX account reports the payment of sales tax revenue to the government.

PRODTAX reports revenue from production taxes paid by an activity. The row of the PRODTAX account reports payments by activity to the PRODTAX account. The column of the PRODTAX account reports the payment of production tax revenue to the government.

Direct taxes

DIRTAX reports the taxes paid by households; the row of the DIRTAX account has a single entry from the household account. The DIRTAX column reports payment of direct tax revenues to the government. Government. In the SAM for this course, the government column, GOVT, shows its spending on goods and services. The government row account shows government revenue from various types of taxes in the economy. The difference between government revenue and government expenditure is government savings and it is the amount reported as a payment from the GOVT to CGDS. Savings- investment. This account, with the heading CGDS, shows the balance between savings and investment in an economy. The accounts column records investment expenditures on capital equipment that will be used in future production activities. The column sum reports an economys total investment expenditures. Investment is made possible by an economys savings. The row for CGDS describes the sources of an economys savings. Total savings consists of foreign and domestic savings, which, in turn, consists of household and government savings.

Rest of World. This account, with the heading ww_world, describes trade and investment flows between a country, such as the United States, and the rest of the world. The row account shows the countrys foreign exchange outflows, or expenditures on imports, valued in world prices in the domestic currency. The column account reports the countrys foreign exchange inflow, or export sales, also valued in world prices in the domestic currency. The difference between the value of exports and imports is the balance of trade. When a country runs a trade surplus (the value of its exports exceed the value of its imports), its foreign savings flow is negative. When a country runs a trade deficit (its imports exceed its exports) its foreign savings flow is positive. In either case, the value of the foreign savings flow is recorded in the SAM as a payment from the rest of the world (ww_world) to the savings-investment account (CGDS)Table 3.3 Conceptual Social Accounting Matrix XE "Social Accounting Matrix"

ActivitiesCommoditiesFactors HouseholdsGovernmentSavings-InvestmentROWTotal

ActivitiesDomestic supplyDomestic production revenue

CommoditiesIntermediate inputsHousehold consumptionGovernment consumptionInvestmentExportsDemand

FactorsFactor income (or Value added)

Factor income

HouseholdsNet factor incomeGovernment transfersHousehold income

GovernmentProduction taxesImport tariffs

Export subsidies

Sales taxesFactor taxIncome taxGovernment income

Savings-InvestmentPrivate savingsGovernment savingsForeign savingsSavings

ROWImportsForeign exchange outflow

TotalDomestic production costsAggregate supplyFactor expenditureHousehold expenditureGovernment expenditureInvestment expenditureForeign exchange inflow

Macroeconomic Identities in SAM Data from the SAM can be used to calculate national income accounting identities. GDP from the income side

Factor income + Indirect business taxes + Commodity taxes = GDP

GDP from the expenditure side

C + I + G + E M = GDP

Using TUG-CGE.xls, the SAM data sheet for your country, calculate your countrys GDP from both the income and expenditure side. You should get the same number for each calculation of GDP.

Recall that you can rearrange the expression for GDP from the expenditure side, to derive the relationship between a nations domestic savings (S) and investment (I), and its trade balance, where E is exports and M is imports.

S - I = E M

Verify this identity is true, using your country SAM data.

As a result of this exercise, you can be confident that the base data used in the model satisfy the market equilibrium constraints implied by national income accounting identities. These identities will also hold following a policy shock to the base model.Economic Structure in the SAMThe SAM can also be used to describe the underlying structure of your economy. This knowledge is helpful for understanding and explaining model results. Use the following information to compute the components of the structure table below for your country. Industry GDP and industry share in GDP

The GDP for industry a is calculated as:

Factor payments + indirect business taxes + commodity (sales and export) taxes

The share of industry a in GDP is calculated as:

Industry GDP / GDP

The size of an industry is among its most important economic characteristics. The larger the size of a sector in an economy, the greater is the impact of a shock to that sector on the rest of the economy. Factor-intensity by industry

The activity columns of the SAM show the inputs required by each industry. The factor-intensity of an industry refers to the shares of each type of factor in its technology. A labor-intensive technology means that the industry requires proportionally more labor than capital. Calculate the factor-intensity for each activity, as:

Payment to factor f in activity a/ Total factor payments in activity a Industry shares in employment by factor

Data from the SAM can also be used to calculate the shares of each industry in factor employment.

Employment of factor f in industry a / total employment of f by all activities

Together, the factor-intensity and employment shares of an industry can help us to understand the effects of economic shocks on factor markets.

Import share of domestic consumption

The share of imports in domestic consumption of a commodity will influence the size of the domestic impacts of an economic shock in world markets. The larger the share of imports in consumption, the greater the effect on the domestic consumers when there is an import shock. Since import tariffs are a component of the price paid by consumers, they must be included in any consideration of the cost of imports.

(Imports of commodity c plus tariff paid for commodity c) / (Intermediate demand for commodity c + household demand for commodity c + government demand for commodity c + investment demand for commodity c)

Export share of production

(Exports plus export tax) / Production

Similar to the case of imports, the share of exports in the domestic supply of a commodity determines an industrys vulnerability to shocks in world markets. Since the revenue that producers get from export sales includes export taxes (or subsidies), the values of exports to producers must include that payment.

Consumption shares in final demandFinal demand refers to demand for commodities by agents: households, government, investors and foreign demand (exports.) These agents tend to demand different types of goods and services. (Spending by agent on commodity c)/(Total commodity spending by agent)

Tax rates

Import tariffs and taxes on exports, retail sales and production all drive a wedge between the prices received by sellers and the prices paid by consumers. Direct taxes on income effectively reduce earnings. It is important to know the initial sizes of tariffs and taxes in the model before you analyze the effects of reforming or eliminating them. If the tariff or tax is small, then removing it is likely to have only small effects on an industry, or the economy as a whole.

Tariffs (tax on imports) by commodity = (tariff payment by commodity)/(payment to Rest of World for imported commodity)Tax on exports by commodity = (payment of export taxes by commodity)/(payment by ROW for the commodity)Sales tax by commodity = (payment of sales taxes by commodity)/(payment for the commodity from intermediates + household+government+investors payment of sales taxes by commodity)Production tax by activity = (payment of production taxes by activity)/ (value of eactivity output)Household income tax rate = (payment of direct taxes by household)/(total household income)SectorGDPFactor-intensity, by industryIndustry shares in factor employment, by factorImport shr. of

consumption

Industry GDPIndustry shares in GDPLandCapitalLandLandLaborCapital

Agr

Mng_Extr

Pcf

LMnf

CMnf

Util_Cns

Trans_Comm

Svces

Osg

Dwe

Total1.00NaNana1.001.001.00na

SectorCommodity share of final demandImport tariff rateExport tax rateSales tax rateIndirect business tax rateExport share of production

HouseholdsGovt.InvestmentExports

Agr

Mng_Extr

Pcf

LMnf

CMnf

Util_Cns

Trans_Comm

Svces

Osg

Dwe

Total1.001.001.001.00nananaNaNa

Source: GTAP Summary Matrix, v. 7 as adapted to use in TUG-CGE.gms.

PAGE United States Naval Academy Capstone Seminar: Introduction to CGE Modeling