Using GAMS For Agricultural Policy Analysis
Using GAMS For Agricultural Policy Analysis
net/publication/266466336
CITATIONS READS
2 488
1 author:
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Nicholas William Minot on 16 January 2015.
Nicholas Minot
International Food Policy Research Institute
July 2009
Table of Contents
Objectives
The objective of this training module is to explain how to use GAMS to construct, calibrate, and modify
agricultural sector models in order to simulate the effect of alternative policies or other events affecting
agricultural markets. In particular, the course aims to train the participants in the following skills:
determining whether an agricultural sector model is appropriate for a given research question;
selecting the scale of the model in terms of commodities, markets, and time periods;
constructing the model in GAMS using available data ;
running simulations of alternative policies and events;
revising the model in response to new information; and
documenting and describing the results of simulations.
Although the course does not attempt to cover agricultural economics and international trade in depth, it does
provide a quick review of concepts to explain the logic behind the components of agricultural sector models.
It should be noted that this course is not a lecture course, but rather it is a semi-structured hands-on workshop
in which trainees will use computers to learn different methods of analyzing data. The course starts out with
very simple models and gradually introduces new concepts and new commands to develop a multimarket
spatial equilibrium model that represents four commodities and six regions, as well as internal trade and
international trade. This model is called SDP4 and is shown in Annex 1 of this guide.
1 For convenience, we use the term “agricultural models” to refer to economic models of the agricultural sector,
excluding non-economic models such as those relating climate to crop production.
2 Mathematically, there is little difference between parameters and exogenous variables, but parameters represent
relationships between variables, while exogenous variables are economically relevant concepts. Parameters are
assumed to be fixed over time, while exogenous variables vary in real life, but are assumed constant in the model.
Finally, parameters are estimated econometrically, while exogenous variables are typically measured directly.
3 This rule is complicated by the fact that the number of equations in a model varies depending on how it is expressed.
A single market can be expressed as three equations (S = a + bP; D = c + dP; and S=D) or as two equations (Q = a +
bP; Q = c + dP) or even as one equation (a + bP = c + dP). Fortunately, the number of endogenous variables declines
from 3 to 2 to 1 at the same time, maintaining the equality between equations and endogenous variables.
4 In a recursive dynamic model, events at time t influence events in time t+1, but not the reverse. This type of model
can be solved using a programming loop, where the solutions for each period feeds into the information used to solve
the next period. A non-recursive dynamic model, events in time t+1 influence events in time t. This could be used to
represent rational expectations regarding prices by farmers. These models are more difficult to program and rare in
applied policy analysis.
5 The distinction between the two types of models is somewhat artificial because many optimization models can be
expressed as an equilbrium model and vice versa. For example, the objective function in an optimization model can
be replaced by a set of first- and second-order conditions, which are equalities and inequalities.
Key Words
GAMS, parameters, variables, equations, program files, input, output, and the GAMS commands
PARAMETERS, VARIABLES, EQUATIONS, MODEL, and SOLVE.
.
What is GAMS?
GAMS is a software package for designing and solving various types of models. GAMS stands for General
Algebraic Modeling System. It was developed by economists at the World Bank for economic models, but
it can be used to solve systems of equations from any field of study. GAMS takes a program file as input and
sends the results to an output file.
There are two parts to GAMS.
First, the core of GAMS is just a language for defining the variables and equations in a model. This
“language” has ways of describing any equation, even very complicated equations, in an ordinary text
file (ASCII format).
Second, there is a set of solvers, each of which is a complex program for finding the solution to a specific
type of problem. Some solvers only do linear programming, some will do non-linear programming, and
others will solve different types of equilibrium models.
To create and run a model, we need to learn how to use the language to describe our model, and we need to
know which solver will work with our model. In this manual, we will be using equilibrium models with both
equalities and inequalities.
Starting GAMS
To open GAMS, double-click on the GAMS IDE icon. The opening screen is shown in
Box 1. The menu bar is relatively simple with just six options:
Menu headings Function
File For opening and saving files, running programs, printing, and setting options.
Edit For cutting and pasting text and for undoing a mistake.
Search For searching and replacing text within GAMS files.
Windows For arranging the windows in different ways on the screen.
Utilities For making macros, importing and exporting spreadsheets, and other tasks.
Help For getting assistance in how to use GAMS
There are also seven buttons to carry out frequent tasks. In most cases, the buttons are just an alternative way
of carrying out functions that the menu options. The buttons are :
Button Function
Open folder For opening files
Diskette For saving files
Three flashlight buttons For different types of searches
{a} For checking to make sure parentheses are balanced
Printer For printing a file
Red arrow For running a GAMS program
When you first start on a new model, you will need to create a project, which tells GAMS where to find the
files you will be working with. To create a project, click File/Project/New Project, select a folder, and type
in the name of the project. The name can be anything that will help you remember what you are working on.
When you create and name a project, GAMS puts a file with that name and extension prj in the folder you
have chosen. This makes it easier to go back to this folder and find your files in the future.
Writing or editing a GAMS program
You can start writing a new GAMS program from scratch by clicking on File/New. A blank window will
open and you can begin writing commands to compose a program. But you will probably never need to start
writing a GAMS program from scratch. It is almost always easier to start with an existing program and
modify it to meet your needs.
To open an existing GAMS program, click on File/Open and select the program file. For example, if you
select “SD1 simple.gms”, you will see a window appear with the GAMS program. Alternatively, from the
Windows Explorer you can double-click on the file “SD1 simple.gms.” Because Windows knows that
the .gms extension is for a GAMS program, it will open GAMS and then open the program. In either case,
you will see the program on the left side of the screen.
PARAMETERS
<parameter name> <parameter description>
<parameter name> <parameter description>
<parameter name> <parameter description> ;
An example from the SDP4.gms program (see Annex 1) is given below, along with the line numbers of each
command (note that the line numbers were added to the text; they are not part of a GAMS program).
164 PARAMETERS
246 NER Nominal exchange rate (1000 LC per US$)
247 POP(R) Population in 1995 (inhabitants)
268 NER = 11 ;
269 POP(R) = POP94(R)*1.0225 ;
VARIABLES
This command defines the variables used in the model. You list the variables with a short description of each.
VARIABLES
<variable name> <variable description>
<variable name> <variable description>
<variable name> <variable description> ;
EQUATIONS
This command defines the equations that describe the relationships among the variables and parameters in
the model. Every equation has a name. First, you list the names of the equations with a brief description of
each one. Then, you list the equations themselves. Notice that the equations use =E= to represent the equals
sign.
EQUATIONS
<equation name> <equation description>
<equation name> <equation description>
<equation name> <equation description> ;
Part of the EQUATIONS command from SDP4.gms (shown in Annex 1) is given below:
176 EQUATIONS
177 DEMAND Demand equation
178 SUPPLY Supply equation ;
186 DEMAND(C,R)..
187 D(C,R) =E= DA(C,R) + DB(C,R)*P(C,R) + DC(C,R)*Y0(R) ;
188
189 SUPPLY(C,R)..
190 S(C,R) =E= SA(C,R) + SB(C,R)*P(C,R) ;
MODEL
This command names the model and the equations that are part of the model. Usually, all the equations listed
are part of the model, but not always. The format is as follows:
You can put two equation names on the same line, but they must be separated by a comma. The MODEL
command in the model SDP4 (see Annex 1) is:
213 MODEL MARKET / DEMAND
214 SUPPLY
215 IN_OUT
216 DOM_TRADE.TQ
217 EXPORTS.X
218 IMPORTS.M
219 XQUOTA.IXT
220 MQUOTA.IMT / ;
SOLVE
This command tells GAMS the method to use to solve the model. Solving the model means finding the
values of the variables that make all the equations true. The format is as follows:
The SOLVE command in the model SDP4 (see Annex 1) is given below.
EXERCISE #2
This exercise uses a simple model with one equation (demand for rice) and one variable (the quantity of rice
demanded). The price is fixed (exogenous). The exercise involves editing and running the program DEM1
and looking at the output.
1. Open GAMS, then open the GAMS program DEM1 by clicking on File/Open and then clicking on
DEM1.
Notice that the program is divided into sections for the parameters, the variables, and the equations.
In the parameter section, find the line that defines price.
What is the price of rice in this model?
Is price a parameter or a variable in this model?
Is quantity demanded a parameter or variable?
3. Open the program DEM1 again by clicking on the tab for DEM1.gms.
Change the price of rice from 3000 LC/kg to 2500 LC/kg.
Run the model (same command as in Step 2).
Look at the output file (same command as in Step 2).
What is the new quantity demanded?
Why did the quantity demanded change? (circle a letter)
a) People decided they liked rice and wanted more.
b) The price rose so consumers decided to buy less.
c) The price fell so consumers could afford more.
d) The income of consumers rose so consumers could afford more.
4. Suppose we want to write a simple model to calculate the distance a car can go if it is traveling 53
kilometers per hour for 4.5 hours. The parameters are speed and time and the variable is distance. Open a
new GAMS file and write a GAMS parameter command that defines the values of the two parameters
(SPEED and TIME). Do not use line numbers.
5. In the same file, write a GAMS variable command for the distance variable. Give it the name DIST.
Write a GAMS equation command to say that distance is equal to speed multiplied by time. Use the
equation name SPEEDEQ.
6. Write a GAMS model command that says that SPEED is the name of the model and it contains the
equation SPEEDEQ. Write the GAMS solve command so that the model SPEED is solved using MCP.
7. Now save the file calling it SPEED. Run the program SPEED. Look at the results in the file
SPEED.LST. What is the distance traveled? Use a calculator to confirm that this is the correct answer.
Key Words
Income and price coefficients, income and price elasticities, set, and index. GAMS commands
SETS, PARAMETERS (with one index), * (for comments), INCLUDE, TABLES, and
DISPLAY.
Economics of demand
In economics, “demand” refers to the amount that consumers are willing to purchase of a given product over
a certain period of time. There are four main factors that affect consumer demand:
the price of the product
the price of related goods
the income of consumers
the preferences of consumers.
Not surprisingly, the higher the price of the product, the less consumers are willing to buy it. The
relationship between price and demand is described by the own-price elasticity of demand, defined as the
percentage change in the quantity demanded given a 1% increase in the price. Own-price elasticities of
demand are almost always negative, often between -0.4 and -3.0. Products are classified according to their
price elasticity:
The demand for a certain product is also affected by the price of related products. For example, if the price
of rice rises, consumers may shift to wheat or maize so the demand for these commodities rises. Similarly,
if the price of apples rises, the demand for oranges may increase. Two products are called substitutes in
consumption if an increase in the price of one causes an increase in the demand for the other.
Alternatively, an increase in the price of one product may cause a decrease in the demand for a related
product, particularly if the two are normally consumed together. For example, an increase in the price of
hamburgers would probably cause a reduction in the demand for hamburger rolls. Similarly, a large increase
in the price of petrole might cause a reduction in the demand for cars. Two products are called complements
in consumption if an increase in the price of one causes a decrease in the demand for the other.
The relationship between the price of one product and the demand for a different product is described by the
cross-price elasticity of demand. Generally, cross-price elasticities of demand are much smaller than
The demand for a product is also affected by preferences and tastes. Even if prices and income are the same,
two households may differ in their demand due to different preferences, perhaps related to religion, culture,
education, family background, or individual experiences. For example, the demand for pork is much less in
countries with a large Muslim population. Similarly, in India, the demand for meat is lower and the demand
for dairy products is higher than in other countries with similar prices and income.
When simulating the demand for a product by large groups of people, we normally limit the factors to price
and income. For example, a demand equation might be:
In this equation and in GAMS, the asterisk (*) indicates multiplication. The demand intercept is 7500, the
price coefficient is 2, and the income coefficient is 3. The income coefficient determines how changes in
income affect demand. In this example, if the income rises by 100, demand rises by 300. For a normal good,
a higher income increases demand, so the income coefficient is positive. For an inferior good, a higher
income reduces demand, so the income coefficient is negative.
Often, we want to represent more than one market in GAMS. For example, we may want to create a model
One way to represent more than one market is to create separate variables, parameters, and equations. For
example, suppose we want to represent the demand for rice in the north and south of A country. We could
write a model like this:
PARAMETERS
AN Intercept in the north
AS Intercept in the south
BN Price coefficient in the north
BS Price coefficient in the south
PNOR Price in the north
PSOU Price in the south ;
AN = 7500 ;
AS = 9500 ;
BN = -1 ;
BS = -2 ;
PNOR = 3500 ;
PSOU = 2000 ;
VARIABLES
DNOR Demand for rice in the north
DSOU Demand for rice in the south
EQUATIONS
DEMANDN Demand in the north
DEMANDS Demand in the south ;
DEMANDN..
DNOR =E= AN + BN*PNOR ;
DEMANDS..
DSOU =E= AS + BS*PSOU ;
However, It is more convenient to write this model using sets and indexes, as follows:
SETS
R Region /North
South /;
PARAMETERS
A(R) Intercept of demand function
/North 7500
South 9500 /
B(R) Price coefficient of demand function
/North -1
South -2 /
P(R) Fixed price (LC per kg)
/North 3500
South 2000/
VARIABLES
D(R) Quantity demanded (thousand tons) ;
EQUATIONS
DEMAND Demand equation ;
DEMAND(R)..
D(R) =E= A(R) + B(R)*P(R) + C(R)*Y(R) ;
The SET command defines the set of regions (North and South) and a variable to represent regions (R). On
paper, indexes are often written as subscripts, so that PR might refer to the regional price, PNorth might be the
price in the north, and PSouth is the price in the south. Since not all computers can write subscripts, GAMS
uses parentheses instead of subscripts. In this example, P(R) would refer to the regional price in general,
The model still has two equations: one for the north and one for the south. However, now it is written in the
GAMS program as one command. We say there is one block of equations and two equations. Similarly, the
model SDP4 has 8 blocks of equations, but 248 equations.
SETS
The SETS command is used to define sets of parameters and variables to simplify the presentation of the
equations. The general format is as follows:
SETS <name of set> <label for set> / <1st item> <1st label>
<2d item> <2d label>
<3d item> <3d label> /
12 SET
13 C Crops /Rice
14 Maize
15 Mustard
16 Citrus /
17 RW Region including world
18 /WEST
19 CENTRAL
20 EAST
21 S_WEST
22 S_CENT
23 S_EAST
24 WORLD /
25 R(RW) Region
26 /WEST
27 CENTRAL
28 EAST
29 S_WEST
30 S_CENT
31 S_EAST /;
We have already discussed the PARAMETER command, but the format is different when we have
parameters with indexes. If a parameter has just one index, such as A(R), then the PARAMETERS
command can list the values of the parameter as follows:
PARAMETERS
<parameter name with index> <parameter description>
/ <#1 in index> <value>
<#2 in index> <value>
<#3 in index> <value> / ;
The list may have any number of elements (not just three as above). The SDP4 model does not use this
command, but below is an example of the use of the PARAMETER command to give the population for each
PARAMETERS
POP(R) Population
/WEST 150000
CENTRAL 100000
EAST 95000
S_WEST 120000
S_CENT 98000
S_EAST 72000 /;
In this example, WEST through S_EAST are elements in the set of regions that is named R. The semi-colon
must go at the end of the last list, not after each list.
If a parameter is defined by an equation, then the format for the command is the same with or without an
index. This is shown in the following example from the SDP4 model. The import and export price in LC for
each commodity (index C) are defined in terms of the world price in dollars, the exchange rate, and the tax.
529 PARAMETERS
530
531 PM(C) Import price after tariffs (D per kg)
532 PX(C) Export price after taxes (D per kg)
538
539 PM(C) = PW(C,'M')*NER*(1+TAX(C,'M')) ;
540 PX(C) = PW(C,'X')*NER*(1-TAX(C,'X')) ;
* (for comments)
Sometimes it is useful to include text in a program that does not run any command. There are several reasons
for this: 1) it is useful to explain what each section is designed to do, 2) it is a good idea to give the source
of data found in a program, and 3) you may want to turn off some commands without erasing them. If you
put an asterisk (*) in the first column of a line, GAMS will ignore that line. In the following example, lines
227 and 228 are ignored by GAMS.:
Notice that you must put an asterisk at the beginning of each line that is part of the comment.
Until now, all the equations we have used have been linear. In other words, they all have had the form:
However, it is not necessary to use linear equations. GAMS can solve models with non-linear equations also.
As discussed earlier in this module, one of the more common types of demand equations is the Almost Ideal
Demand System (AIDS). In this demand equation, the budget share (s) is a function of the log of prices (p)
and the log of real income (Y/P).
si = Di pi /Y = ai + bi log(pi) + c log(Y/P)
This equation is more flexible than the linear equation in representing demand. In this section, we will show
Until now, all the examples we have looked at have had just one product. However, GAMS can solve models
that have more than one region and more than one product. For example, the SDP4 model has six regions
and four commodities.
In order to have multiple products and multiple regions, some variables such as demand need two indexes:
one for the region and one for the product. Demand is represented by D(C,R), where C represents the
commodity and R the region. In addition, some parameters such as price need two indexes. Price is
represented by P(C,R). In this module, we show how to write models with two indexes in GAMS, and we
introduce some new GAMS commands.
TABLE
The TABLE command is used to define parameters with more than one index. The values are described in
a table with the different values of the indexes in the first row and in the first column.
TABLE <parameter name with indexes> <parameter description>
Note that the first index (C for the crop) identifies the different rows in the table, while the second index (R
for region) identifies the different columns.
When a parameter is defined by an equation, then the format for the command is the same with or without
an index. This is shown in the following example from the SDP4.
The INCLUDE command is used to insert the commands from one program file into another program file.
This is useful for dividing a long program into several modules that can be tested and modified separately.
The format is as follows:
Note that the $ must be in the first column. When GAMS comes to this command, it goes to the other
program file and runs all the commands in that file, then returns to run the commands after the INCLUDE
command in the original program file.
$INCLUDE DEM5a ;
At this point in the program, GAMS runs the commands in the file DEM5a before continuing with the
commands in DEM5 after the INCLUDE command.
DISPLAY
The DISPLAY command is used to specify the type of output generated by the GAMS program. This
command can be used to show the values of parameters and variables. In the case of variables, you must
attach .L to the end of the variable name. The L stands for level. The general format is as follows:
This command will print any number of parameters and variables in any order. The list can continue over
various lines.
1046 DISPLAY CALIB3, PD0, PD.L, PS0, PS.L, PW, S0, S.L, D0,
1047 BS0, BS.L, NFYPC0, YPC0, YPC.L, FOODPCT,
1048 DYE, DPE2, SPE, SBETA, TP, ITX, MARGD, MARGX, MARGM ;
DEM2 is a model of two markets, each of which has a fixed price. It has two demand equations and two
variables. The SETS command defines the index R (region) and its two values N (North) and S (South). The
index allows the same type of equation to describe demand in different regions or for different products.
4. Suppose income in the north rose from 1.5 to 2.0 million LC per capita. Open the file DEM2 and
change the income parameter in DEM2 to reflect this new situation. Now exit DEM2 and run it.
Look at the output file (DEM2.LST).
What is the quantity consumed in the north?
What is the quantity consumed in the south?
Why did the quantity consumed change in the north?
DEM3 is a model of demand for two goods in two regions with fixed prices. It uses linear demand equations
with income terms. The TABLE command is used to give the values of parameters with two indexes.
Notice that the income coefficient is now called GAMMA instead of C. This is because we have called the
commodity index C and GAMS does not allow an index and a variable to have the same name.
4. Open the program file again. Increase the income in both north and south by 500. Run the model and
look at the results.
Key Words
Economics of supply
Supply equations are used to represent the response of producers of a product to changes in the price of the
product and other factors. If the price of a product increases, the producers are likely to increase output by
switching resources to the production of that good or by using more resources. In agriculture, resources
include land, labor, fertilizer, and water. A farmer may respond to higher rice prices by switching land from
maize production to rice production. The farmer may also increase the total amount of land or apply fertilizer
more intensively than before. In any case, the level of rice production will generally rise following an
increase in the price of rice.
The supply response is measured using the price elasticity of supply, defined as the percentage change in
output in response to a one percent change in price. Supply elasticities in agriculture are generally between
0 and 2, with a majority of the estimates being between 0 and 1. Various factors affect the size of these
supply elasticities:
Length of time: In the very short run (less than 3 months), supply elasticities are close zero because it
takes time for farmer decisions to affect output.
Type of crop: In the medium term (1-3 years), annual crops such as rice and maize have higher supply
elasticities than tree crops such as coffee, tea, and rubber. This is due to the delay between the
planting of new tree crops and the increase in supply.
Cropping intensity: Crops that are planted and harvested more than once per year will respond to price
changes more quickly than crops that are planted and harvested annually.
Existence of substitutes in production: If a crop competes closely with other crops (eg maize), its
supply will be more sensitive to price. Crops that are grown on land that is not useful for other crops
(eg cassava) tend to be sensitive to changes in price.
Type of technology: Crops that are grown with modern technology, including fertilizer and other
chemical inputs, tend to be more price elastic because farmers can adjust the yield depending on price.
The simplest supply equation is a linear relationship between the level of output and the price:
S = a + b*p
A somewhat more complicated supply equation is the double-log function. This equation can be expressed
as follows:
log(S) = a + b*log(p)
One advantage of this equation is that the price coefficient (b) is the supply elasticity. In other words:
Supply equations often include terms to reflect the effect of other prices on supply.
The logarithm of x is the power to which e (a number approximately equal to 2.7) needs to be raised to get
x. In other words, elog(x) = x. One peculiarity of logarithms is that the logarithm (or log ) of zero or a
negative number is not defined. GAMS will give an error message and stop the run if it comes to a step
involving the log of a negative number.
Normally this would not be a problem since neither S (supply) nor p (price) in the supply equation are zero
or negative. However, GAMS solves models by doing a complex search of possible values of the
endogenous variables. It starts this search by setting the variable(s) to zero. This starting point generates an
error message in GAMS. The solution to this problem is simple: we need to tell GAMS to start the search
with a positive number. For example, the format of this command is as follows:
<variable name>.L = 1 ;
The SDP4 does not need to set initial values, but here are some examples from another model. These
commands serve to avoid the error message and they also help GAMS find the solution by providing a
starting point for the search. The starting points are the values of the variables in the base scenario, indicated
by the 0' at the end of the name.
GAMS automatically produces a results file with the values of the endogenous variables. Sometimes, it is
useful to present the results in a different way or to design tables which summarize the most important results.
SUP3 provides a simple example. The two new parameters are defined as the percentage change in price and
supply compared to their original values, P0 and S0. Note that the endogenous variable S (supply) is in the
equation as S.L(C,R). The two OPTION commands tell GAMS to print only one digit at the right of the
decimal point (5.1 instead of 5.138943).
PARAMETERS
PCCPRICE(C,R) Percentage change in price
PCCSUPPL(C,R) Percentage change in supply ;
PCCPRICE(C,R) = 100*(P(C,R)-P0(C,R))/P0(C,R) ;
PCCSUPPL(C,R) = 100*(S.L(C,R)-S0(C,R))/S0(C,R) ;
OPTION PCCPRICE:1 ;
OPTION PCCSUPPL:1 ;
DISPLAY PCCPRICE, PCCSUPPL ;
The following is a somewhat more complicated example. The asterisk (*) in the parameter definition
indicates that the values of the third index will be defined later. In the parameter equations, the values of the
third index are specified by the words in quotation marks. Note that the variables (S and X) are followed by
.L but the parameters are not.
PARAMETERS
TAB5(C,R,'Demand') = D(C,R) ;
TAB5(C,R,'Supply') = S.L(C,R) ;
TAB5(C,R,'Surplus') = S.L(C,R)-D(C,R) ;
TAB5(C,R,'Exports') = X.L(C,R) ;
TAB5(C,R,'Imports') = M.L(C,R) ;
DISPLAY TAB1, TAB2, TAB2PCT
TAB3, TAB3PCT ;
DISPLAY TAB4, TAB5, TAB6, IXT.L ;
In Section 4, we explained how the TABLE command can be used to provide the values of parameters with
two or more indexes. The PARAMETER command can also be used to list the values of a parameter with
two or more indexes. In this case, the values of the indexes are listed to the left of the data. This is an
example from SDP4 (see Annex 1):
118 TABLE ITX(C,R,RR) Implicit tax on internal trade (LC per kg)
119
120 WEST EAST S_WEST S_CENT S_EAST
121 RICE .WEST 400 400
122 RICE .EAST 200
123 RICE .S_WEST 100 100
124 RICE .S_CENT 400 200 100
125 RICE .S_EAST 400 100
126 MAIZE .WEST 300 300
127 MAIZE .S_CENT 300
The first index (C for crop) is in the first column, the second index (RW for region) is in the second, and the
third index (RWW for region) in the third column. Thus, the implict tax on rice between the MRD and the
Central Highlands is 100 (see line 176). Note that the columns of index values must be separated by a dot
(.). The difference between a TABLE command and a PARAMETER command is that the TABLE
command has at least two columns of data, while the PARAMETER command can have no more than one
column.
The supply equations discussed in Section 5 assume that supply is a function of the price of the same product
only. In fact, supply of a commodity is affected by the prices of related goods. For example, the supply of
maize is affected by the price of rice. When the supply of two goods is affected by the price of the other good,
we say they are substitutes in production. Usually, this is because producers can switch between the two
goods depending on the profitability of each. Because farmland can be changed from one crop to another,
many crops are substitutes in production. In general, the effect of the price of one good on the supply of other
goods is called a cross-price effect. In contrast, the effect of a price on the supply of the same good is called
the own-price effect.
We represent cross-price effects by including other prices in the supply equation. In the linear model, the
result would be as follows:
log(Si) = ai + bii log(pi) + bij log(pj) + bik log(pk) ... = ai + bij log(pj)
Note the price coefficient now has two indexes: one representing the crop affected and the other representing
the crop whose price is affecting the other. In other words, bij represents the effect of pj on Si. Because both
indexes represent crops, we need two different indexes that represent crops. If we add a regional index, the
price coefficients have three indexes. Below, we show how the values of a parameter with three indexes can
be organized in a TABLE command.
ALIAS
In general, an alias is a second name for the same person or thing. In GAMS, an alias is a second name for
the same index. The format is to put the two aliases in parentheses after the ALIAS command. Commas
separate the two aliases and the different pairs of aliases. The SDP4 program has two indexes with aliases,
as shown:
The usefulness of this command will be easier to see when we discuss the GAMS equations used to represent
cross-price effects.
SUM is not a command in GAMS, but rather a function which can be used in equations. The SUM function
in GAMS is equivalent to the summation sign ( ) in conventional math notation. The general format of the
SUM function is as follows:
SUM(<index>, <expression>)
192 IN_OUT(C,R)..
193 S(C,R) + SUM(RR,TQ(C,RR,R)) - SUM(RR,TQ(C,R,RR)) - X(C,R) + M(C,R)
194 =E= D(C,R) ;
This equation says that supply of a given commodity in one region plus inflows from all other regions minus
outflows to all other regions minus exports plus imports is equal to demand.
The SUM function can also be used for summation over two or more indexes, by putting the indexes in
parentheses. For example, the total value of all crops in the model over all the regions in the model
(VALPROD) can be written as:
As mentioned above, when you sum over one or more indexes (C and R in this example), those indexes
cannot appear in the result (VALPROD in this example). Thus, VALPROD does not have any indexes
because it is a sum over all regions and over all crops in the model.
In Module 2, we discussed the TABLE command which presents the values of parameters in a table-like
format. The examples we used all had two indexes. However, the TABLE command can also be used to
give the values of parameters with three (or more) indexes. This is done by having two (or more) indexes in
columns to the left side of the table and the last index indicating the column. The two columns of index
values are separated by dots (.), as shown in this example from the model SDP4 (see Annex 1):
118 TABLE ITX(C,R,RR) Implicit tax on internal trade (LC per kg)
119
120 WEST EAST S_WEST S_CENT S_EAST
121 RICE .WEST 400 400
122 RICE .EAST 200
123 RICE .S_WEST 100 100
124 RICE .S_CENT 400 200 100
...
Exercise #4
Open the program file SUP1 and answer the following questions about the program.
3. Run three simulations with the price at the different levels in this table and write the quantity supplied
for each simulation.
4. Make a graph (by hand) with price on the vertical axis to show the three points that correspond to the
simulation.
5. In terms of the parameters in the model, why does the line go upward ?
7. Calculate the elasticity of supply at the original point (p = 3000). Remember that the elasticity from
a linear equation is calculated as:
Ei = b (p/S)
Open the program file SUP3 and answer the following questions.
8. Add commands at the end of the program so that it calculates and displays the value of crop
production for each crop and each region. Call the parameter VALRC.
9. Add commands at the end of the program to calculate and display the national value of each of the two
crops. Call the parameter CROPTOT.
10. Add commands at the end of the program to calculate and display the value of the production of both
crops for each region. Call the parameter REGTOT.
Key words
Equilibrium price, equilibrium quantity, commodity balance, change in quantity demanded vs shift in
demand curve, change in quantity supplied vs shift in supply, and static comparative analysis.
In the previous modules, we considered supply and demand separately with an exogenous price. However,
it is not realistic to consider price to be exogenous except when the government sets the price. In a market
economy, prices are determined by the interaction between supply and demand. For example, if the weather
is good and the rice harvest is larger than usual, the increase in supply causes prices to fall. Another example
is that during Tet, people increase the demand for some goods and this can cause some prices to rise. In other
words, in a market economy, prices are not exogenous - they are endogenous.
In the market, the equilibrium price is the price which makes the quantity supplied equal the quantity
demanded. This quantity is called the equilibrium quantity. If the price is below the equilbrium price, supply
will be less than demand. Some consumers will not be able to buy all they want to buy and this demand will
push the market price higher. On the other hand, if the price is above the equilibrium price, demand will be
less than supply. Producers will not be able to sell all they want to sell at this price, so they will offer
discounts which push the price down. Thus, there is a natural tendency to move toward the equilibrium
price.
Although prices tend to move toward their equilibrium level, they do not move their instantly. There are
often delays in responding to new prices, partly because of lack of good information and partly because
producers and consumers cannot react instantly to conditions. In many types of economic analysis, we
compare two equilibriums without trying to show the process of adjustment from one equilibrium to the other.
For example, we might compare the equilibrium prices and quantities under a 10% rice export tax with the
equilibrium prices and quantity under a 3 million ton rice export quota. This is called static comparative
analysis.
In any economic model, the number of equations must be equal to the number of endogenous variables. We
have already said that in a market economy, prices are endogenous. Thus, we have three types of endogenous
variables:
To solve the model, we need three equations. We have already worked with the demand equation and the
supply equation. The third equation is the commodity balance. In a simple model without trade, the
commodity balance says that supply equals demand (S = D). Thus, the three types of equations are:
S = f(P)
Using simple linear models of supply and demand, the model would look like this:
S = sa + sb*P
D = da + db*P + dc*y
S=D
where S, D, and P are endogenous variables and sa, sb, da, db, dc, and y are exogenous variables (or
parameters in GAMS).
If the model has many goods and many regions, we can still solve the model. Suppose there are C goods and
R regions. Then the number of endogenous variables will be 3*C*R (C*R supply variables + C*R demand
variables + C*R prices). But there will also be 3*C*R equations (C*R supply equations, C*R demand
equations, and C*R price equations). Thus, the equality of equations and endogenous variables still holds.
In analyzing the movement of prices and quantities, it is important to distinguish between changes in
quantities and shifts in the supply and demand curve. A change in the quantity demanded refers to
movement along the demand curve, while a shift in demand refers to movement of the demand curve itself.
Similarly, a change in the quantity supplied refers to movement along the supply curve, while a shift in
supply refers to movement of the supply curve itself. For example, if income rises the demand curve will
shift to the right (an increase in demand). The equilibrium price, the quantity demanded, and the quantity
supplied will increase. This is not the same as an increase in supply.
1. Open the file SD1. Look at the three variables and the three equations. Run the model and look at the
results.
What is the equilibrium quantity supplied?
What is the equilibrium quantity demanded?
What is the equilibrium price?
11. Suppose that a drought reduces the harvest by 2 million tons. We can represent this by reducing the
supply intercept by 2000. Run the model and look at the results.
What is the equilibrium quantity supplied?
What is the equilibrium quantity demanded?
What is the equilibrium price?
12. Suppose income increases by 10%. Change the income parameter to show this. Run the model and
look at the results.
Key words
World prices, CIF price, FOB price, export parity price, import parity price, autarky price, export
price relations, import price relations, commodity balance, small country assumption, large country
assumption, complementarity relationship, export tax, import tax (or tariff), export quota, import
quota, implicit export tax, implicit import tax, binding quota, economic rent, exchange rate,
appreciation, depreciation, and purchasing power parity. GAMS commands POSITIVE VARIABLE
and requirements for inequalities.
The economic principles of trade between two regions of one country are no different than the principles of
trade between a country and the rest of the world. In practice, however, there are some differences:
International trade is subject to a wide variety of policy interventions such as import tariffs, export taxes,
import quotas, export quotas, local-content rules, and so on. Taxes and restrictions on trade between
regions are typically small.
The transportation costs of international trade are often larger than the costs of internal trade, although
this is not always true.
Different regions of a country are usually of similar sizes. Thus, changes in supply or demand in one
region affect prices in other regions. In contrast, changes in supply or demand of one country have little
or no effect on world trade because each country s trade is small relative to world markets.
We begin by assuming there are no policy barriers to international trade to focus on the relationship between
world prices, transportation costs, and domestic prices. Later in Section 7, we consider the effect of taxes and
quotas on imports and exports.
The analysis of international trade policy is simpler if we assume that the country s policies have no effect on
international prices. This is called the small country assumption. The small country assumption is
reasonable for a country when the country s exports and imports are a small proportion of world trade. What
is a small proportion? The small country assumption is probably reasonable provided that the country does
not account for more than 10-20 percent of world trade in each commodity.
The large country assumption is that exports or imports from the country are large enough to affect world
markets. Imports are relatively evenly distributed among countries, so each countries share of import
markets is normally small. As a result, only very rarely are countries able to affect the prices of goods they
import. Exports, on the other hand, tend to be more concentrated, so large countries are less rare. Brazil is
a large country in the world coffee market, and Thailand is a large country in the world rice markets.
Throughout Section 7, we adopt the small country assumption. In the next section, we discuss how to model
trade between regions, which involves techniques can also be used to model trade under the large country
assumption.
Export and import prices differ because of transportation costs. The cost of importing a good would be the
world price plus the cost of transportation, handling, insurance, etc. to the country. If the world price of
maize is $ 200 per ton and transportation costs are $ 50 per ton, then the long-run equilibrium import price
in the country would be $ 250 per ton (assuming competitive markets). This is called the CIF price (CIF
means cargo, insurance, and freight).
If maize were exported from the country, the domestic price would the world price minus the cost of
transporting it there. Thus, the export price in the country would be $ 200 - $ 50 = $ 150. This price is called
the FOB price (FOB means free on board). The gap between the import price ($ 250) and the export price
($ 150) is twice the transportation cost.
If there are no trade restrictions, the CIF and FOB prices put an upper and a lower limit on price in the port
city of the country. Why is this? If the domestic price of maize rises above $ 250, traders will import more
maize and push the price down to $ 250 per ton. No one in the country would buy maize at $ 260 per ton if
they could import it at $ 250 per ton. Thus, $ 250 is the upper limit of maize prices in the country.
At the same time, if the domestic price of maize falls below $ 150 per ton, traders will export maize, pushing
the local price up. No one would sell maize in the country for $ 140 if they could export it for $ 150 per ton.
Thus, $ 150 is the lower limit on the long-run maize prices in the country.
International prices also put upper and lower limits on the prices in the interior of the country, but the gap is
wider because of the transportation costs within the country. Suppose it costs $ 15 per ton to transport maize
from the port city to an interior city. Then maize prices in the interior city cannot rise above $ 265. This is
called the import parity price (the cost of importing maize and transporting it there). Nor can maize prices
in the interior city fall below $ 135 per ton. This is called the export parity price (the FOB price minus the
cost of transporting to the port).
Direction of trade
How do we know whether the country will import or export a given product? It depends on the autarky price,
defined as the price that would occur in the absence of international trade. The direction of trade (importing
or exporting) depends on the relationship between the autarky price, the import parity price, and the export
parity price. The table below describes this relationship.
If the autarky price is: then the country will: and the domestic price will settle at:
Above the import parity price import the commodity the import parity price
Between the import and export neither export nor import the the autarky price, between the import
parity price commodity parity price and the export parity price
Below the export parity price export the commodity the export parity price
Of course, these rules apply only when there are no restrictions in international trade within the country and
competitive markets. The effect of policy restrictions will be later in this Section.
Until now, we have expressed all prices in US dollars. The same rules could be expressed in terms of local
currency (LC) by multiplying the US dollar values by the exchange rate in LC per US dollar. It is very
important to note, however, that changes in the exchange rate have a strong effect on trade patterns. For
example, the table below calculates the import and export parity prices at different exchange rates using the
(hypothetical) parity prices from the maize example above.
Exchange rate Import parity Export parity Import parity Export parity
(LC/dollar) price (US$/ton) price (US$/ton) price (LC/ton) price (LC/ton)
35 235 165 8,225 5,775
40 235 165 9,400 6,600
45 235 165 10,575 7,425
The higher the exchange rate, the higher the LC import parity price, making it less likely that the country will
import maize. If the exchange rate is high enough, the export parity price will rise above the autarky price
making it profitable to export maize. For example, if the autarky price of maize is 9000 LC/ton, then with
an exchange rate of 35 LC/US$, it would import maize. With an exchange rate of 40 LC/US$, it would
neither import nor export maize. But if the exchange rate rose to 55 LC/US$, the export parity price would
rise to 9075 LC/ton (=55 x 165) and it would become profitable to export maize. This example is purely
hypothetical, but it illustrates the impact of exchange rates on trade patterns and even on the direction of
trade.
In order to model international trade with GAMS, we need to convert the economic principles discussed
above into equations in GAMS notation. In general terms, we need to change the supply-demand
equilibrium model from Secion 1 in four ways: 1) commodity balance equation must be modified, 2) we need
to identify the relationship between domestic and world prices, 3) we need to establish a complementarity
relationship, and 4) the associated variable must be listed as a POSITVE VARIABLE.
With regard to the commodity balance equation, demand and supply are still equal to each other but they are
defined more broadly to include international demand (exports) and international supply (imports). Using
M for imports and X for exports, we can write the equation as:
S+M=D+X
With regard to the relationship between export price and domestic prices, we need to set the export parity
price as the lower limit of domestic prices. Using PX as the FOB price, NER as the nominal exchange rate,
and TC as the transportation cost to the port:
P + TC NER*PX
The import parity price sets the upper limit. If PM is the CIF price, then:
Third, in order to solve a model with inequalities, GAMS requires a complementary relationship between
each inequality and a variable. The relationship between the two is complex, but what is important to know
is that the export price relationship is associated with the export variable (X), while the import price
relationship is associated with the import variable (M). In GAMS, this relationship is indicated in the solve
command, where the equation and its associated variable are linked with a dot. This example is from SD2:
Fourth, the associated variable must be listed separately from the other variables; it must be under the
heading POSITIVE VARIABLE. For example, in SD2 the variables are listed as follows:
POSITIVE VARIABLES
X Exports (thousand tons) ;
VARIABLES
P Equilibrium price (LC per kg)
D Quantity demanded (thousand tons)
S Quantity supplied (thousand tons) ;
This tells GAMS that exports cannot be negative. GAMS will not be able to solve a model and will give an
error message if 1) an inequality is not linked to the relevant variable in the SOLVE command and 2) if the
linked variable is not listed in the POSITIVE VARIABLE command.
Previously in Section 7, we assumed free trade. In other words, we assumed that the government did not
intervene in the import and export markets. In this subsection, we examine how to model the effects of
various types of trade restrictions on the markets. We focus on five types of policies: import taxes, export
taxes, import quotas, export quotas, and changes in the exchange rate. Each is considered in turn. We adopt
the small country assumption in this section. The effect of interventions under the large country
assumption can be modeled like interventions in regional trade, considered in Section 10.
Import taxes: An import tax (also called an import tariff) raises the domestic price above the CIF price. At
the higher domestic price, the quantity demanded is lower and the quantity supplied is higher. The
combination of these two effects is that the volume of imports falls. Under the small country assumption, the
Pd = NER*Pm *(1+t)
This equation implies that an increase in the import tax causes a proportional increase in the import tax. For
example, raising the import tax from 0% to 10% will increase the domestic price by 10%. Under the large
country assumption, the reduction in imports reduces the world price, so the increase in domestic prices is
slightly less than proportional to the increase in the import tax. However, there are very few cases of
countries that are large in any of their import markets.
Import tax revenue is equal to the tax rate multiplied by the value of imports.
TR = M*Pm*t
A small or medium import tax will generate tax revenue. However, a very large import tax will cause imports
to decrease so much that tax revenue is decreased. In an extreme case, the import tax can be so high that
imports are reduced to zero, eliminating tax revenue.
Export tax: An export tax reduces the domestic price below the FOB price. This is because the tax reduces
exports, thus reducing total demand for the product. At the lower domestic price, the quantity supplied
decreases and the quantity demanded increases. Both of these trend cause exports to decrease. Under the
small country assumption, the domestic price is as follows:
Pd = NER*Px *(1-t)
Under the large country assumption, an export tax reduces the world price. Thus, the decrease in the
domestic price is somewhat less than proportional to the tax.
As in the case of import taxes, small to medium export taxes generate tax revenue. However, it is possible
for the export tax to be so high that exports are not profitable, eliminating both exports and export tax
revenue.
Import quota: An import quota is a limit, imposed by the government, on the volume of imports of a
product. We assume in this section that the quota is binding, meaning that the quota is less than the
equilibrium level of imports. The effects of an import quota are less obvious than those of the import tax.
The key to understanding the quota is that it reduces the availability of the good in the country. By reducing
domestic supply, the import quota raises the domestic price above the CIF price. The domestic price rises
until the supply (domestic production plus imports) equals demand. The effects of an import quota are very
similar to those of an import tax. Both policies raise the domestic price, decrease the quantity demanded,
Import quotas are valuable. For example, in the motorbike example above, a quota to import 1000
motorbikes would be worth US$ 500,000. This is because the quota allows an importer to make a pure profit
of US$ 500 per motorbike. The profit associated with owning a scarse resource (in this case, quota
allocations) is called economic rent. This rent creates a strong incentive for corruption since importers are
willing to pay up to US$ 500 per motorbike for import quotas.
Export quota: An export quota is a limit, imposed by the government, on the volume of exports of a product.
Again, we assume that the export quota is binding. The export quota reduces the effective demand for the
product by limiting exports. By limiting demand, the export quota reduces the domestic price below the
FOB price. The domestic price falls until the demand (domestic demand plus exports) is equal to supply.
The export quota reduces the quantity supplied and increases the quantity demanded, just like the export tax.
As in the case of the import quota, we can measure the impact of the export quota with the implicit export tax,
defined as the export tax that would have the same effect on domestic prices. For example, if the export
quota on rice reduces the domestic price from US$ 250/ton to US$ 200/ton, then the implict export tax is
20%.
Like import quotas, export quotas are valuable. In the rice example above, a quota to export 100 thousand
tons would be worth US$ 5 million. This is economic rent. The incentive for corruption between exporters
and those allocating the quotas is strong.
Exchange rate: The exchange rate is the price of one currency in terms of another currency. When we
discuss the exchange rate, we refer to the number of local currency (LC) units per units foreign currency
(such as the US dollar). Suppose the exchange rate is 40 LC/US$. A depreciation of the exchange rate
means increasing the number of local currency per unit of foreign currency. If the rate changed from 40
LC/US$ to 45 LC/US$, this would be a depreciation of the LC. An appreciation of the exchange rate is a
decrease in the number of local currency units per unit of foreign currency, such as a change from 40
LC/US$ to 35 LC/US$..
As we showed earlier, depreciation of the local currency increases the domestic price of imported goods and
exportable goods in the country. This increases the quantity supplied of imports and exports and reduces the
demand for them. These changes in supply and demand increase exports and decrease imports. In contrast,
an appreciation of the local currency decreases the domestic price of imported goods and exportable goods.
This reduces the quantity supplied and increases the quantity demanded, thus making exports fall and
imports rise.
Over time, currencies tend to depreciate when domestic inflation is higher than inflation in other countries
and currencies tend to appreciate when domestic inflation is lower. For example, if inflation in the country
is 20% and inflation in the US is 5%, then we expect the LC/US$ exchange rate to depreciate at about 15%,
if other factors remain unchanged. This relationship between inflation and the exchange rate is called
purchasing power parity.
Import and export taxes: Representing import and export taxes in a GAMS model is relatively simple. The
only change necessary is to put the tax rate into the parameter equation that describes the import and export
prices in local currency. For example, in the program SDP1, the equation for the export price is as follows:
PX = NER*WP(1-TAX) ;
In the SDP4 (see Annex 1), the equations for the import and export prices are similar:
Import and export quotas: Representing import and export quotas in a GAMS model is somewhat more
complex because it involves inequalities. The export and import quotas are represented as inequalities in the
EQUATION section of a GAMS program. The following example comes from the SDP4 program (see
Annex 1):
205 XQUOTA(C)..
206 QUOTA(C,'X') =G= SUM(R,X(C,R)) ;
207
208 MQUOTA(C)..
209 QUOTA(C,'M') =G= SUM(R,M(C,R)) ;
As discussed in Module IV, any inequality in GAMS must have a complementarity relationship with a
variable that is positive when the inequality is binding. In the case of import and export quotas, the
associated variables are the implicit import tax and the implicit export tax, respectively. The association
between the inequalities and the variables is identified in the SOLVE section. This is illustrated by this
example from the SDP4 program:
IXT and IMT are variables representing the implicit export tax and the implicit import tax, respectively.
These variables must be listed in the POSITIVE VARIABLE section as shown below:
And finally, the implicit tax variables appear in the equations that relate domestic prices to international
prices. In the SDP4 program, these equations are as follows:
199 EXPORTS(C,R)..
PD is the consumer price, PS is the producer price, and the two MARG parameters are marketing margins.
Exchange rate: Modeling changes in the exchange rate is simple: we just change the parameter that
represents the exchange rate. In the SDP4 and the smaller models used here, this parameter is called the NER,
for nominal exchange rate. Although the price of commodities on the international market remains
unchanged because of the small-country assumption, a change in the exchange rate will affect the domestic
prices of tradable goods. For example, increasing the exchange rate from 40 Ngultrums/US$ to 50
Ngultrums/US$ would increase the local currency price of imported goods and exported goods. This would
cause the demand for both goods to decline, while stimulating the supply of these goods. Decreasing the
exchange rate would have the opposite effect.
13. The program SDP1 is a one-good one-market model with exports, export taxes, and export quotas.
To see the equilibrium without restrictions, set the tax to zero and the quota to 10000 (to ensure that
it is not binding).
What is the equilibrium price?
What is the quantity demanded?
What is the quantity supplied?
What is the level of exports?
14. Now impose an export quota of 2.7 million tons and run the program.
What is the equilibrium price?
What is the quantity demanded?
What is the quantity supplied?
What is the level of exports?
What is the implicit export tax?
Calculate the implicit export tax as a percentage of the no-quota equilibrium price.
Calculate the total value of the export quotas by multiplying the implicit export tax by the volume of
exports.
15. Set the quota at 10000 again so it is not binding. Now impose an export tax of 0.1111 and run the
program.
What is the equilibrium price?
What is the quantity demanded?
What is the quantity supplied?
What is the level of exports?
Compare the results under the 2.7 m ton quota and the 11.11% tax.
Calculate the export tax revenue by multiplying the tax rate by the price and by the volume of exports.
16. Open the program SD2. This program has one region, one product, and an export market.
17. Run a simulation using SD2 in which a drought reduces the harvest by 2 million tons (reduce the
supply intercept by 2000).
What is the equilibrium quantity supplied?
What is the equilibrium quantity demanded?
What is the equilibrium price?
What is the level of exports?
How is this result different than the effect of the same drought on the model without exports in SD1?
19. Run a simulation in which the world price increases by $30 per ton.
What is the equilibrium quantity supplied?
What is the equilibrium quantity demanded?
What is the equilibrium price?
What is the level of exports?
20. Open the program SD3 This program has one region, three goods, and import and export markets.
Calculate the import and export prices in LC per kilogram.
21. Make two copies of the table giving the world prices. Use asterisks to turn offf one copy. Change the
other copy so the import prices are all $1000 and the export prices are $ 0 (this will turn off
international trade). Run the model and write down the autarky prices. Based on the autarky prices
and the import and export prices, predict which crops will be imported, which will be exported, and
which will not be traded.
22. Now use asterisks to turn off the 0/1000 world prices and turn on the original world prices. Run the
model Check to see if your predictions were correct.
23. Suppose the world prices of cassava rises $30 per ton to $180 and $280. What is the effect on cassava
production, consumption, and prices?
Key words
Price differential, cost of transportation, domestic price relations, commodity balance,
complementarity relationship, and implicit tax.
.
In this section, we consider regional trade (trade between regions of a country), focusing on the relationship
between transportation costs and regional price differences. Initially, we assume that there are no policy
restrictions on regional trade. Later in Section 8, we consider the effect of restrictions on regional trade.
As discussed in Section 7, international trade and internal trade are very similar. Internal trade generally has
fewer policy trade barriers and smaller transportation costs. In addition, the analysis of international trade
often assumes that world prices are exogenous, but the analysis of regional trade does not make this
assumption. For example, changes in the demand for rice in the Red River Delta affect the price of rice in the
North Mountain and Midlands region. In addition, changes in the supply of rice in the Mekong River Delta
affect the price of rice in Ha Noi. In a model of internal trade, all regional prices are endogenous.
Because there are no exogenous prices in a model of internal trade, there are no upper and lower limits on
prices, as there are with international trade. Other aspects of the analysis are similar, however. The cost of
moving goods from one region to another sets an upper limit on the difference in prices between the two
regions, unless there are trade restrictions (trade restrictions are discussed in Module V). Why is this? If the
price differential is larger than the cost of transporting goods from one region to another, traders will ship
goods from the low-price region to the high-price region. This reduces the supply in the low-price region,
pushing up the price there. At the same time, the trade increases the supply in the high-price region, pushing
down the price in that region. This process continues as long as the price differential is greater than the total
cost of transporting goods from one region to the other.
For example, if the cost of transporting rice from south to north is 500 LC/kg and the prices in the north are
3000 D/kg while the prices in the south are 2200 D/kg, traders will find it profitable to ship rice from the
south to the north. Supplies will increase in the north and decrease in the south until the price difference is
about 500 D/kg.
As in the case of international trade, if there is trade between two regions, the price differential will equal to
the cost of transportation between the two regions. If the price differential is less than the cost of
transportation, then there cannot be trade between the two regions.
In order to adapt a two-region one-good no-trade model to include trade between the regions, we need to
make four modifications: 1) the commodity balance equation must be changed to incorporate regional flows,
2) we need to add inequalities that express the relationship among prices, 3) a complementarity relationship
must be established, and 4) the variable associated with the equation must be listed as a POSITIVE
VARIABLE.
Si + TQji = Di + TQij
j j
flows from region i to region I. Thus, the commodity balance equation is as follows:
where TQij is the transported quantities going from region i to region j. In GAMS notation, the equation may
look like this example from SD4:
IN-OUT(R)..
S(R) + SUM(RR,TQ(RR,R)) - SUM(RR,TQ(R,RR)) =E= D(R) ;
Second, inequalities must be used to set upper limits on the price differentials of each pair of markets that can
trade. If TCij is the cost of transporting goods from region i to region j, then the inequality is written as
follows:
Pi + TCij Pj
DOMTRADE(R,RR)..
P(R) + TCOST(R,RR) =G= P(RR) ;
Third, as discussed in Section 7, an inequality can only be included in the model if it has a complementary
relationship with a variable. The important thing to know is that the inequality representing the domestic
price relationship is associated with the volume of inter-regional shipments (TQ). In GAMS, this
relationship is indicated in the solve command, where the equation and its associated variable are linked
with a dot. This example is from SD4:
And fourth, the variables associated with the inequalities must be listed under the command POSITIVE
VARIABLES, as shown in the example below:
POSITIVE VARIABLES
TQ(R,RR) Transported quantity (thousand tons) ;
In Section 7, we noted that modeling regional trade between countries is very similar to modeling trade
among large countries. In both cases, the cost of transporting goods from one market to the other is the
upper limit on the price differential between the markets, unless there are barriers to trade. If there is trade
between the two markets, the price difference will equal the cost of transportion (including related costs of
Restrictions on trade between regions can take the form of policies that raise the cost of moving goods (such
as road and bridge tolls, checkpoints, and other additional expenses) or restrictions on the quantity of goods
moved (such as quotas). In either case, the flow of goods is reduced. This increases the supply in the surplus
region, thus reducing prices, while decreasing supply in the deficit region, thus increasing prices. The net
effect is to increase the price difference between the two regions.
Information on the degree of restrictions on internal trade is often more difficult to obtain than information
on international trade barriers. If tolls and other fees are collected by local authorities, it is more difficult to
estimate the size of those costs. Similarly, data on the costs associated with delays due to police checkpoints
and bureaucratic obstacles are not easy to collect.
The most difficult part of modeling restrictions on regional trade is obtaining relevant data. Often the easiest
approach is the infer the implicit costs related to restrictions on trade by comparing the observed price
differentials with the actual cost of transportation. The difference between the two is a measure of the costs
associated with restrictions on trade.
If we assume that marketing margins are fixed and that the costs associated with trade restrictions are fixed,
then modeling the restrictions is simple. The total marketing margin between regions is represented by two
components: the actual cost of transportation and the cost related to restrictions. In the some models, for
example, the actual transportation cost is calculated from distances between pairs of regions.
The implicit taxes (ITX) associated with the restrictions on trade are provided in another table in the SDP4
program (see lines 118-134). The implicit taxes are included in the margin between prices in one region and
prices in another region in SDP4:
196 DOMTRADE(C,R,RR)..
197 P(C,R) + TCOST(R,RR) + ITX(C,R,RR) =G= P(C,RR) ;
Thus, the base scenario includes the effect of restrictions on internal trade. To simulate the removal of these
restrictions, the equation in line 197 would be changed to exclude the implict tax parameter (ITX).
1. The program SD4 is a two-region, one-good model with trade between the two regions.
What is the cost of transportation between north and south?
Can you tell from the intercepts the direction of trade?
a) north to south
b) south to north
c) both directions
d) neither direction
Which variable is associated with the domestic price inequality?
2. After the TCOST parameter, add an equation setting TCOST at 5000. This will make any regional
3. With this self-sufficiency model, suppose there is a drought in the north and supply shift back 1
million tons. Run a simulation of this.
What is the equilibrium price in the north?
What is the equilibrium price in the south?
4. Now remove the line setting TCOST at 5000 and set the supply intercept in the north at its original
level (7200) and run the program again.
What is the equilibrium price in the north?
What is the equilibrium price in the south?
What is the equilibrium level of trade?
5. Simulate the same drought in the north again, shifting back supply by 1 million tons. Run the model.
What is the equilibrium price in the north?
What is the equilibrium price in the south?
What is the equilibrium level of trade?
7. Open the program SD5. This is a three-good two-region model with both international trade and
regional trade. Run the program.
Which crops are exported, imported, and not traded?
Which crops are transported within the country and which direction (N to S or S to N)?
8. Suppose world maize prices rise by $ 20 per ton. Increase both import and export prices to represent
this change.
How does this affect maize trade in the north?
How does this affect maize trade in the south?
9. The program SDP3 is a two-region one-good model with regional trade and restrictions on internal
trade. The internal restrictions are represented by the parameter ITX (implicit tax). This parameter
increases the gap between the price in the south and the north, as seen in the equation DOMTRADE.
11. Now we will simulate a policy which increases restrictions on internal trade. This is represented by
changing the values of ITX to 2000. Run the model and answer the following.
What is the price in the north?
What is the quantity demanded in the north?
What is the quantity supplied in the north?
What is the price in the south?
What is the quantity demanded in the south?
What is the quantity supplied in the south?
How much is transported from south to north?
Keywords
Cash income, non-cash income, gross income, net income, multiplier, farm-non-farm linkages,
partial equilibrium model, and general equilibrium model.
In the models discussed so far, we assumed that household income was exogenous, meaning that income was
assumed to be fixed. We know, however, that household income is partly determined by the production and
price of agricultural crops. For example, if the price of a crop rises, farm income will rise, thus affecting
demand patterns. In this section, we show how household income can be made endogenous in the model.
Income can be divided into two categories for the purpose of a model. The first category is income from the
production of the good or goods represented in the model. The second category is income from all other
sources. For example, if the model includes all farm products, it is useful to separate farm income from
non-farm income. In such a model, farm income is endogenous, while non-farm income is exogenous. We
now examine how farm income should be calculated.
The first question is whether we want the value of agricultural sales or the value of agricultural production.
There is a difference between the two because part of agricultural production is retained by the household
for consumption, animal feed, seed, or other uses. Since retained output is valuable to the household, we can
think of this as non-cash income from agricultural production. It is generally assumed that demand patterns
are affected by the level of total income, including both cash and non-cash income. Therefore, when we
calculate income, we want to use the value of agricultural production, not just agricultural sales.
The second question is whether to use the gross value of agricultural production or the net value. The net
value is the gross value minus the costs of production. Since demand is a function of the amount of
disposable income, we are interested in the net value of farm production, where net is defined as gross minus
the costs of fertilizer, pesticides, seed, rented land, rented machinery, and hired labor. The net value of farm
production is the return on family labor, family-owned machinery, and family-owned land.
The third question is how to calculate the net value of production. The gross value of production for a given
crop is simply the price multiplied by the quantity produced, both of which are available from the models
discussed in Modules 1 to 5. There are two ways to calculate the net value from the gross value.
1) Economic theory indicates the cost of producing quantity Q is the area under the supply curve and
to the left of Q. This method is useful for estimating the change in net income when prices or quantity
change, but not for estimating total net income because we do not have good information on the shape
of the supply curve for very low prices.
2) Studies of the cost of production may indicate the costs of inputs, hired labor, and rented land as a
proportion of the value of output. We can assume that this ratio is constant over the relevant range of
prices and quantities.
For a household that consumes a good but doesn t produce it, the welfare impact of a price change can be
measured using the consumer surplus, defined as the area behind the demand curve between the two price
lines. We define CS to be negative when the price increases. A first-order approximation of the consumer
surplus is:
CS = - qd (p1 - p0) = - qd p
where Δp is the change in price and qd is the original quantity demanded (consumed). This is the welfare
impact of a price change assuming that the consumer cannot respond to the change by adjusting consumption.
Geometrically, it is a rectangular approximation of the area behind the curve.
The second-order approximation takes into account the response of consumers to the higher price. It is a
parallelogram approximation of consumer surplus. It is an approximation because it assumes the demand
curve is linear.
2
p p
CS = - (qd p0) - 0.5 D q d p0
p0 p0
Next, we can write the proportional welfare impact as the consumer surplus as a proportion of income.
2
CS p p
= - (CBR) - 0.5 D (CBR)
y p0 p0
where CBR is the consumption benefit ratio, defined as the value of the consumption of the good as a
proportion of total income, and εD is the price elasticity of demand.
2
p p
PS = (qs p0) + 0.5 S q s p0
p0 p0
except that the signs are positive. This is because a price increase has a positive effect on the welfare of a
producer. By the same transformation as above, we can write the producer surplus as a proportion of income.
where PBR is the production benefit ratio, defined as the share of income coming from the production of the
good, and εS is the price elasticity of supply.
We can combine these two equations to get the net welfare impact on a household as both producer and
consumer.
2
CS + PS p p
= (PBR - CBR) + 0.5 S PBR - D CBR
y p0 p0
If we defined the PBR and the CBR as parameters for each commodity and each region, then the weflare
impact of a change in a given commodity price on a region could be calculated in GAMS as follows:
WELF(R = PCTDP(‘RICE’,R)*(PBR(‘RICE’,R)-CBR(‘RICE’,R))
+ 0.5*(ELAST_S(C)*PBR(‘RICE’,R) - ELAST_D(C)*CBR(‘RICE’,R))
*(PCTDP(‘RICE’,R)**2);
With household-level data on the patterns of production and consumption of each agricultural commodity,
we can further disaggregate the results to calculate the impact of price changes on different types of
households within each region. For example, it is very likely that the CBR of staple food commodities is
larger for poor households than rich households, so the relative impact of a food price increase on a poor
urban household would be greater than for a rich urban household. Similarly, the PBR for a farmer will be
higher than the PBR for a salaried worker. We can modify the GAMS commands above to take into account
different types of households, provided we can also disaggregate PBR and CBR by household group.
WELF(R,H) = PCTDP(‘RICE’,R)*(PBR(‘RICE’,R,H)-CBR(‘RICE’,R,H))
+ 0.5*(ELAST_S(C)*PBR(‘RICE’,R,H) - ELAST_D(C)*CBR(‘RICE’,R,H))
*(PCTDP(‘RICE’,R)**2);
1. Open the file SDY1. This program has an exogenous original income (Y0) and an endogenous
income (Y) calculated from the farm price and the supply (it assumes that there are no costs of
production so net income equals gross income). Notice that in this version of the program,
endogenous income is calculated in the INCOME equation. However, the endogenous income does
not appear in any other equation: income is calculated but not used. The demand equation uses the
exogenous original income. Run the model and record the results.
2. Simulate an increase in supply of 1.5 million tons (hint: increase SA by 1500). Run the model and
record the results. Why does income (gross revenue) fall when the supply increases? Is this always
true or does it depend on the particular elasticities in this model? What elasticity determines whether
an increase in supply raises or lowers income?
3. Change Y0 to Y in the INCOME equation. This makes demand a function of the endogenous income,
creating feedback from supply to income to demand. Run the program once with the original supply
curve (SA = 13500) and with the higher supply curve (SA = 13500). Compare the original supply
results with and without the income effect. Why is there no difference? Now compare the higher
supply results with and without the income effect. Why does the increase in supply make the price
lower when income is endogenous than when it is exogenous? Why does the increase in supply make
the quantity lower when income is endogenous than when it is exogenous?
4. The program SDY3 is a model of supply and demand for one good and one region with endogenous
income. Instead of specifying the supply and demand parameters directly, it specifies the elasticities
and the original price, consumption, and production and calculates the supply and demand parameters
from these numbers.
Assume that the consumption and production benefit ratios are as follows:
Write equations to calculate the first- and second-order approximation of the welfare impact of price
changes on poor and rich households. You can call the new parameters WELFP1, WELFP2,
WELFR1, and WELFR2.
5. After perfecting the welfare impact calculation, simulate an increase in the supply by increasing the
value of S0 by 3000. How does it affect the welfare of poor and rich households? Why are the
second-order approximations more positive than the first-order approximations?
6. Now change the price elasticity of demand to -2.0 and run the simulations of the two supply situations
(original and higher supply). How does the shift affect poor and rich households now?
* FILE: SDP4
* GAMS PROGRAM TO SIMULATE SUPPLY AND DEMAND FOR FOUR GOODS
* IN SIX REGIONS WITH INTERNAL TRADE, IMPORTS AND EXPORTS
* WITH TRADE TAXES AND QUOTAS AND REGIONAL TRADE RESTRICTIONS
* Note: LC refers to local currency units.
OPTION LIMCOL = 0 ;
OPTION LIMROW = 0 ;
$OFFSYMLIST ;
$OFFSYMXREF ;
SET
C Crops /Rice
Maize
Mustard
Citrus /
RW Region including world
/WEST
CENTRAL
EAST
S_WEST
S_CENT
S_EAST
WORLD /
R(RW) Region
/WEST
CENTRAL
EAST
S_WEST
S_CENT
S_EAST /;
PARAMETERS
DA Intercept of demand equation
DB Price coefficient of demand equation
DC Income coefficient of demand equation
SA Intercept of supply equation
SB Price coefficient of supply equation
NER Nominal exchange rate (LC per US$)
PX(C) Export price (LC per kg)
PM(C) Import price (LC per kg)
Y0(R) Expenditure in 1995 (m LC per capita)
Y92(R) Expenditure in 1992-93 (m LC per capita)
/ WEST 1.102
CENTRAL 0.871
Y0(R) = 1.6*Y92(R) ;
DB(C,R) = DPE(C,R)*D0(C,R)/P0(C,R) ;
DC(C,R) = DYE(C,R)*Y0(R)/P0(C,R) ;
DA(C,R) = D0(C,R) - DB(C,R)*P0(C,R) - DC(C,R)*Y0(R) ;
SB(C,R) = SPE(C,R)*S0(C,R)/P0(C,R) ;
SA(C,R) = S0(C,R) - SB(C,R)*P0(C,R) ;
NER = 10;
PX(C) = NER*WP(C,'X')*(1-TAX(C,'X')) ;
PM(C) = NER*WP(C,'M')*(1+TAX(C,'M')) ;
VARIABLES
P(C,R) Equilibrium price (LC per kg)
D(C,R) Quantity demanded (thousand tons)
S(C,R) Quantity supplied (thousand tons) ;
POSITIVE VARIABLES
TQ(C,R,RR) Transported quantity (thousand tons)
IXT(C) Implicit export tax (LC per kg)
IMT(C) Implicit import tax (LC per kg)
X(C,R) Exports (thousand tons)
M(C,R) Imports (thousand tons) ;
EQUATIONS
DEMAND Demand equation
SUPPLY Supply equation
IN_OUT Shipments into and out of region
DOM_TRADE Domestic trade price relationships
EXPORTS Export price relationships
IMPORTS Import price relationships
XQUOTA Export quota
MQUOTA Import quota ;
DEMAND(C,R)..
D(C,R) =E= DA(C,R) + DB(C,R)*P(C,R) + DC(C,R)*Y0(R) ;
SUPPLY(C,R)..
S(C,R) =E= SA(C,R) + SB(C,R)*P(C,R) ;
IN_OUT(C,R)..
S(C,R) + SUM(RR,TQ(C,RR,R)) - SUM(RR,TQ(C,R,RR)) - X(C,R) + M(C,R)
=E= D(C,R) ;
DOM_TRADE(C,R,RR)..
P(C,R) + TCOST(R,RR) =G= P(C,RR) ;
EXPORTS(C,R)..
P(C,R) + IXT(C) + TCOST(R,'WORLD') =G= PX(C) ;
IMPORTS(C,R)..
PM(C) + IMT(C) + TCOST('WORLD',R) =G= P(C,R) ;
XQUOTA(C)..
QUOTA(C,'X') =G= SUM(R,X(C,R)) ;
MQUOTA(C)..
QUOTA(C,'M') =G= SUM(R,M(C,R)) ;
TQ.FX(C,R,R) = 0 ;