Introduction to Quantitative Policy Analysis with GAMS Technical issues

Maria Sassi Introduction

Topics Knowledge Skills

1. Introduction to Quantitative Policy Analysis Basics of - Objective and steps of QPA; quantitative - Component of a model; Understanding of modelling basic concepts policy - Base run; analysis - Types of models. - What is GAMS; - Installation; Introduction - Knowing the interface; Understanding of GAMS basic elements to GAMS - Starting a new project; - Input and output structure; 2. Using GAMS for QPA Short introduction of basic concepts of Modeling with GAMS economic theory for modelling with Developed models with GAMS elements GAMS GAMS introduced by exercises - Single good, single The structure of a model market linear demand In GAMS function - Single good, two SET command markets linear demand - The concept of demand function - The objective of demand analysis - Single good, two - Log Demand - Elasticities and functional form of markets, Engel function, - DISPLAY command Analysis demand (pragmatic approach, Engel semi-log Engel function - Log endogenous function, LES, AIDS, GAIDS) variable (.L=1) - Single good, two Definition of a system of markets, AIDS and CES equation - Two goods, two TABLE command markets, linear demand function Supply - Objective of supply analysis - Technical progress with - notation exp(…) analysis - Producer response: production function CD production function - LOOP command - Production function types (equation (two goods, 1 market) for: linear, Leontief, Cobb-Douglas, CES) - List of other functional forms - how to select the appropriated production function - technical progress - Supply (what is) Impact of a change in - Direct attribution in - Its determinants own price, two markets, PARAMETERS - Own- and cross- price effect two goods, double-log - Calculation and show of supply function % change with respect to the initial values - OPTION for the selection of the number of decimals Impact of cross price - TABLES with more effect, two markets, two than 3 indexes goods, double-log supply - SUM operator function - ALIAS Closed economy and the equilibrium Equilibrium price in a - How to show base run price closed economy and simulation with “DISPLAY” - $ONSYMXREF $ONSYMLIST Open economy: Large vs. small - Market equilibrium - Modification of the country; Tradeable goods (exportables with the specification of commodity balance and importables); financial parity price the relationship between equation; specification of (exchange rate); CIF and FOB prices; domestic and world the relationship between transportation costs; relationship prices domestic and world between domestic and world prices prices; establishment of a complementary relationship; the associated variables - INCLUDE command Instrument of protection: - Market equilibrium - Direct interventions with imports and exports Market - Indirect interventions equilibrium - Market equilibrium with import and export tariffs; - Market equilibrium with Import and export tariffs and quotas; - Market equilibrium and exchange rate devaluation Regional trade: - Market equilibrium in - Modelling - comparison with international trade and regional trade in a transportation costs and (the role of prices and transportation closed economy with no quantities in market costs); regional trade equilibrium with regional - Restrictions to regional trade restrictions; trade - Trade restrictions in the form of implicit tax on regional trade 1 Basic concepts for quantitative policy analysis

1.1. Introduction The purpose of this Chapter is to introduce a selection of basic concepts of quantitative policy analysis that represent the components of the framework adopted in the section dedicated to modelling with GAMS. More precisely, after the clarification of the objective of policy analysis the steps in which it is articulated are introduced. Afterwards, the components of a model are described and the importance of its solution with respect to the observed values is discussed. Finally, the different types of model are introduced.

1.2. Steps in quantitative policy analysis Quantitative policy analysis involves quantitative methods to: - Define a policy problem; - Demonstrate its impact; - Show potential solutions and policy alternatives. It can be developed at three different levels corresponding to the policy levels. They are: - Microeconomic level, which is focused on policies aimed at individual parts of the economy, such as, industries, businesses and households; - Sector level, which is targeted to interventions directed to a specific sector of the economy, for example, the maize sector; - Macroeconomic level, which is centred on policies aimed at the aggregate economy. In order to investigate the policy impact, quantitative policy analysis adopts a four-step approach illustrated in Figure 1. Figure 1 - Steps in quantitative policy analysis

The roots of the process are represented by the economic theory that, implemented with information provided by historical trends and experience, provides guidelines to help conceptualise and design policy interventions (De Janvry, Saudolet, ….). For this reason, quantitative policy analysis can be define as a process aimed at quantifying the various mechanisms analysed by theory. On the basis of a theory, quantitative modelling designs a model and estimate parameters and calibrate the model itself in order to provide the framework for policy simulation. Modelling and policy simulation are the two core elements of quantitative policy analysis. Modelling includes the construction of a model and the computation of the base run.

1.3. Construction of a model Constructing a model consists on the definition of a theoretical construct that represents the investigated economic process. It is made of equations which represent logical and/or quantitative relationships (equalities or inequalities) between a set of four components. They are: - Exogenous variables; - Endogenous variables; - Parameters; - Indices. The exogenous or independent variables are factors that affect a model without being affected by the model. They are fixed in the sense that they cannot be manipulated within the economic model. The endogenous or dependent variables are those whose values are determined within the model. Parameters or coefficients are fixed values that describe the effect of one exogenous variable on the endogenous variable. Let us consider a linear model for the estimate of the quantity of meat demanded by a group of consumers (D) given a certain level of price (P), income (Y), the related price and income coefficients (, ) and technical efficiency (). Its mathematical notation and the typology of components is represented in Figure 2.

Figure 2 - Linear demand model The exogenous variables and parameters can be further distinguished in uncontrollable and policy instruments. They are both observable variables and coefficients, but the latter are the objective of the policy intervention. In addition, in the model the endogenous variable is selected to enter into the definition of criteria for policy evaluation. In our previous example, let us assume that the government controls meat price (policy instrument) and wants to change it in order to achieve a certain level of meat consumption (criteria for policy evaluation). The other exogenous variables and the parameters are uncontrollable to the purpose of the policy intervention (Figure 3).

Figure 3 - Linear demand model with uncontrolled variables and parameters and a policy instrument

The indices are used to specify the elements of an array of numbers (variables and parameters). Turning to the above described example, let us assume that the same model structure allows estimating demand of the same group of consumers for not only meat but also maize. The model in Figure 2 or 3 can be rewritten as:

In a model, equations describe a system, namely a set of two or more simultaneous equations with the same set of unknowns. Let us consider a linear model for the analysis of the market equilibrium for two commodities, meat and fish, with demand (D), supply (S) and prices (P) the endogenous variables. The index i is while the equations are

(1. Demand function)

(2. Supply function)

(3. Equilibrium condition)

where a and f are the technical coefficients of the demand and supply equations, respectively, and b and

z the price coefficients of demand and supply.

The definition of system of equations provide an important rule in modelling design: in order to be solved, a system of equations must be characterised by a number of equations equals to the number of endogenous variables. The model, in our example, is consistent in the sense that it has three unknown

variables (D, S and P) and three equations and, thus, it has a solution.

When the number of equations is greater than the number of endogenous variables, the model is inconsistent, that is it provides no solution while if the number of equations is less than the number of endogenous variables, the model has an infinite number of solutions.

1.4. Computation of the base run Once the model is constructed, its solution for the observed values yields the base run. Let us consider the linear market equilibrium model specified for meat and fish in the previous paragraph. Given the observed values for the known components, the endogenous variables can be estimated as illustrated in the following. The liner market equilibrium model components are

- Two commodities

- The system of equations

- the observed variables a technical coefficient of the demand equation f technical coefficient of the supply equation b price coefficient of demand z price coefficient of supply

- the value of the observed variables

For the computation of the base run for meat: - First, substitute the observed values in the model (a) (b) (c) - Second, solve the model as follows. Substitute in equation c, equation a and b

Calculate meat equilibrium price

Substitute meat price in equation a and b and calculate demand and supply that mast be equal because this quantity is the meat equilibrium quantity

For the computation of the base run for fish: - First, substitute the observed values in the model (A) (B) (C) - Second, solve the model as follows. Substitute in equation C, equation A and B = Calculate fish equilibrium price

Substitute fish price in equation A and B and calculate demand and supply that mast be equal because this quantity is the fish equilibrium quantity

Table 1 summarizes the base run.

Table 1 - Base run for meat and fish Equilibrium value Meat Fish Price 0.021 0.068 Quantity 1.053 0.801

1.4.1. Importance of the base run Calculating the base run has different purposes. Two of them have a specific importance. The solution of a model for the observed values can be adopted: - for the validation of the model; - as a benchmark against which to measure the impact of counterfactual policy scenarios. The objective of the validation of a model is to seek to minimize the difference between the observed values of the endogenous variable and its estimated value. The validation techniques can be classified in: - Econometric approaches, with which the accuracy of the model is verified by statistical criteria of goodness of fit; - Calibration procedures, adopted when the number of available observed values is not enough to apply econometric techniques. GAMS adopt the latter technique for CGE models……. The second purpose of the base run is to represent the benchmark against which to measure the impact of alternative simulated policies or shocks. This is a very important point. It means that in order to understand the effect of a simulation on an endogenous variable, the value of the impact variable after the simulation must be compare with its base run value and not with its observed value. An example allows clarifying the issue. Figure 4 illustrates the historical trend in production of maize in a hypothetical country where two drought periods brake the normal production years.

Figure 4 - Data on production of maize in a hypothetical country (1990-2012)

Let us model this trend with a linear model where production of maize (y) is a function of labor (x) that is where a is equal to 7.055 and b to 0.825. Figure 5 compare the base run with the observed historical data

Figure 5 - Data on production of maize in a hypothetical country and base run (1990-2012)

Let us introduce a policy aimed at increasing production as described by the “policy impact” line in Figure 6.

Figure 6 - Data on production of maize in a hypothetical country, base run and policy impact line (1990-2012)

If we compare the 2007 observed value with its value in the same year after the policy intervention we make a mistake because the shock is calculated with a model that predict a level of production, in that year, represented by the base run. In other words, the effect of a policy must be assessed against the state predicted by the model that describe how the observed economic process evolves without the implementation of any shock. In our example, the comparison must be between the base run and the policy impact lines. 1.5. Taxonomy of models Models can be classified into four typologies, namely conceptual, analytical, stylized and applied models (Figure 7).

Figure 7 - Taxonomy of models and policy evaluation options

A model is a simplified framework designed to illustrate a complex observed economic process. Theoretical framework and mathematical methods allow to filter out its inessential details and to represent the investigated real complex process in terms of stylized facts, that is to design a conceptual model. This latter allows describing the observed economic process. Focusing on few important assumptions and casual mechanisms, casting economic relationships into a form susceptible to mathematical analysis leads to analytical models. They are suitable for the investigation of the implications of various sets of postulates with a few assumptions as possible about the magnitudes of parameters. Attaching numbers to an analytical model and relating them to the economic performance allows designing a stylized model. This typology of framework can be adopted not only to investigate the size of various effects but also to analyse problems that are too difficult to solve analytically or that have ambiguous analytical answers and hence depend on particular parameter values (Dervarajan, Lewis, Robinson (1994) Getting the Model Right: The General Equilibrium Approach to Adjustment Policy). Including in stylized model more details and important features of a particular economy or situation lead to an applied model. An example can better clarify the distinction between a stylized and applied model: the former may refer to a group of countries, for instance the Oil-importing countries, while the applied model is related to a specific country in a group, such as Saudi Arabia. The specific features of the above mentioned models made them suitable for different purposes. A conceptualise model allows describing the observed economic process, an analytical model is useful for strategic planning that is for the definition and analysis of strategies (general, undetailed plan of action over the long time period in order to achieve the overall organization’s goals), while stylized and applied models are indicated for policy analysis, that is for the investigation of particular interventions aimed at specific targets.

2 Introduction to GAMS

2.1. Introduction GAMS stands for General Algebraic Modeling System. It is a software package for: - Designing and - Solving various types of models. Originally developed by a group of economists at the World Bank for economic models, GAMS is today suitable to solve systems of equations in any field of study. Designing and solving represents the two parts of GAMS (Figure 8).

Figure 8 – The two parts of GAMS

The former is the core of the software that allows creating the model through a specific language. The latter consists on a set of solvers for running the model. In this Chapter, after some preliminary information on how to download and install GAMS, the user interface is presented and information on how to start a new project are provided. 2.2. Downloading GAMS and the user interface A free version of the software can be downloaded at the GAMS Home Page (www.gams.com) clicking on “Download the current GAMS system”. The free version of GAMS has some model limitations. They are: - The number of constraints and variables, which must be lower than 300; - The number of nonzero elements, which must be not more than 2,000 (of which 1,000 nonlinear); - The number of discrete variables, for a maximum of 50 (including semi continuous, semi integer and member of SOS-Sets). Once installed, clicking on the GAMS icon the software opens showing the user interface (Figure 9).

Figure 9 - GAMS’ user interface

At the top of the user interface there are the Menu headings and the Buttons, which in most cases are just an alternative way of carrying out functions of the menu options, (Figure 10) whose meaning is explained in Figure 11. Figure 10 – Components of the user interface

Figure 11 - Menu headings and buttons A - Menu headings B- Buttons

2.3. Starting a new project According to the GAMS’ logic, starting a new project is a three-steps process. It requires to create, in the following order: - a folder, which is the box where the project is saved; - a project within the folder, where the working files are saved; - the working files within the project box, that is the model and output files (Figure 12).

Figure 12 – Three-steps process for starting a new project

In practice, the Folder can be open on the desktop or in Documents or in a working folder right- clicking the mouse, selecting “new” and then “folder”. A new cartel is created on desktop or the other selected position. It has to be named. For a project to be created GAMS must be opened. Afterwards, on the menu headings click on File/Project/New project (Figure 13).

Figure 13 - The first three steps requested for the creation of a project

The previously originated folder must be opened and then the project must be named and opened (Figure 14).

Figure 14 - How to give a project a name

Now the working files can be created clicking on File and then New. The model is written in one of the working file and its solution in the second working file. They can be saved in the project box clicking on File on the Menue headings, giving it a name cicking on New and then saving them selecting the option Save as in File on the Menue headgings (Figure 15).

Figure 15 – How to create and save the working files 3 GAMS modeling structure: the input file

3.1. Introduction This Chapter considers the input file, that is one of the core component of the GAMS modeling framework. Basic commands and their specification are illustrated following the structure of an equilibrium market model for a closed economy. Additional information on GAMS language are introduced developing specific models. For further details it is recommended to consider the GAMS’ user guide included in the Help of the software.

3.2. Basic input elements Figure 16 provides an example of model written in GAMS language. It is the representation of the equilibrium market model for two commodities developed in Par. 1.4.

Figure 16 – Equilibrium market model for two commodities in GAMS This example is adopted to provide an overview of a model structure in GAMS. In blue, in bold and capitals, the basic commands are indicated. As illustrated in Table 2, each of them must be introduced in a specific way. More precisely, Sets, Parameters, Variables and Equations must be first declared and then defined.

Table 2 – GAMS’ commands Inputs Sets Declaration Definition: Assignment of members Data (Parameters, Tables, Scalars) Declaration Definition: Assignment of values Variables Declaration Definition: Assignment of type (optional) Optional: assignments of bounds and/or initial values Equations Declaration Definition Model statement Solve statement Optional: Display statement

With the Declaration the user must specify the name of the element and provide a description; this latter is written in blue by the software. With the Definition, a process that in process in GAMS is called initialisation, the user must assign a member (of a set) or value (of the parameters) to the elements or specify the type of element. Members are written in green while numbers in black. Colours are important in GAMS. If a declaration or definition is written a colour different from the above mentioned, the user has made a syntax error.

3.3. Syntax: general rules Before introducing the syntax for each input command, six general remarks should be introduced. They are: a. First declare and second use - A GAMS model is a collection of statements in the GAMS language whose order is governed by the only rule according to which an entity of the model cannot be referenced before it is declared to exist; b. Style does not matter - GAMS statements may be laid out typographically in almost any style that is appealing to the user and multiple lines per statement, embedded blank lines, and multiple statements per line are allowed; c. Semicolon terminates a statement – if the semicolon is not properly used GAMS does not recognises the following command, indicates a mistake and the model cannot be solved. Table 3 illustrates the use of semicolon.

Table 3 – Use of semicolon USE SEMICOLON DO NOT USE SEMICOLON - after the end of each declaration block- after each line within a block (for blocks of parameters, (parameters, variables, equations, etc.) variables, etc.) - after each defined parameter - after each declared scalar and parameter, only at the end of the block - after each defined table - after each declared variable - after each defined equation - after each declared equation d. upper- and lower-case letters have the same meaning - GAMS compiler does not distinguish between that, so the user is free to use either: e. Comments and documentary text can be included in the model - They are useful to explain parts of the model and can be inserted in two ways. Any line that starts with an asterisk (*) is disregarded as a comment line by the GAMS compiler. In Figure 16, this statement has been adopted to specify the type of model developed before model design (* GAMS model market equilibrium in a closed economy). Characters are in grey. A second way to include comments and documentary text is with the specific GAMS statements $ontext and $offtext. $ontext opens comments or documentary text and $offtext close it. In the example in Figure 16, the asterisk should have been replaced by the following syntax: $ontext GAMS model market equilibrium in a closed economy $offtext,that is

$ontext GAMS model market equilibrium in a closed economy $offtext f. Start entities with a letter and stop at nine alpha-numerical characters - The names given to the entities of the model must start with a letter and can be followed by up to nine more letters or digits.

3.4. Model structure and command syntax Modelling in GAMS starts with writing in pencil the model. The model structure and command syntax is illustrated taking as reference the market equilibrium model introduced in par. 1.3 and 1.4 and recalled in Figure 17.

Figure 17 – Linear equilibrium market model for meat and fish - Two commodities

- The system of equations

- The value of the observed variables

- The endogenous variables

In GAMS the elements of the model are defined and declared with specific commands, shown for our model in Table 4.

Table 4 – Elements of a model and GAMS’ command for their specification Element Type GAMS’ Command i Index Sets Observed values

ai Observed exogenous variable Parameters

bi Observed parameter Parameters

fi Observed exogenous variable Parameters

zi Observed parameter Parameter Unknown variables

Di Endogenous variable Variables

Si Endogenous variable Variables

Pi Endogenous variable Variables System of equations Demand Demand function Equations Supply Supply function Equations Equil Equilibrium condition Equations

3.4.1. Sets The command Sets defines the indices used in the model, which must be first declared and then defined (Figure 18).

Figure 18 – Declaration and definition of Sets

Declaration implies to list the names of the sets (i in our case) with a short description (in our case Commodity type) while definition consists in listing the members of each set (in our case Meat and Fish). Figure 19 shows the syntax for this command where the words in between < > describe what type of words should go in that place. < > are not GAMS syntax

Figure 19 – Syntax for the command Set

Definition of the set members must be put in slashes with set members one below the other or in the same row, but in this case each set is separated by a comma. A semicolon must be written at the end of the definition of Sets to conclude the command specification. The choice of the name of the set members does not affect the overall result: the two members meat and fish might be called 1 and 2, or Mary and Susy and still they would be equally working. Name are not part of GAMS syntax. The command Sets is only necessary when one or more elements in the model are indexed, if not the command must be excluded. Sets is the only compulsory when there are indices.

3.4.2. Parameters The command Parameters specifies the observed exogenous variables and coefficients of the model. It is articulated in a section where these elements are declared and another where they are defined (Figure 20).

Figure 20 – Parameters declaration and definition With the declaration the names of the parameters with a short description is provided while definition consists in the assignment of a value or a formula to each parameter. As illustrated in Figure 20 indices must be put in quotation marks. A semicolon is located at the end of the Parameters declaration and after each defined parameter. Figure 21 shows the syntax for this command.

Figure 21 – Syntax for the command Parameters

Two alternative ways for the specification of the command is illustrated in Figure 22.

Figure 22 - Alternative syntax for the command Parameters

GAMS also accepts to break this one statement into four, putting a semicolon at the end of each of them, as illustrated for the first alternative by Figure 23.

Figure 23 – Alternative use of semicolon in Parameters entry

The use of tables and direct assignment for data entry will be illustrated in the following, when requested by the examples.

3.4.3. Variables The command Variables defines the endogenous variables used in the model. They must be declared and optionally defined. Declaration consists in listing the variables with a short description of each of them and end with a semicolon, as illustrated by Figure 24 for our example.

Figure 24 – Declaration of the command Variables The syntax for this command is presented in Figure 25.

Figure 25 - Syntax for the command Variables

Definition is an optional component that usually refers to the specification of the variable type, as reported in Table 5.

Table 5 – Variable type Variable type Allowed range of variable Free -∞ to +∞ Positive 0 to +∞ Negative -∞ to 0 Binary 0 or 1 Integer 0, 1, …, 100

By default all variables are free. However, if the user wants to specify the variable type, the command corresponding to the chosen variable type must be added. For example, if in our example the user wants the prices-an endogenous variable-to be positive, the definition for Variables must be written as in Figure 26.

Figure 26 – Specification of the variable type

The user has the possibility to apply special records in order to assign a bound or an initial value to a variable. This can be done with the peculiar variable suffixes shown in Table 6.

Table 6 – Main suffixes Suffix Description .L Level or boundary (edge) value .LO Lower boundary .UP Upper boundary .FX Fixed value

For example, if the user wants equilibrium prices to be positive the command to be included is P.LO(i) = 1 3.4.4. Equations The command Equation specifies the equations that characterize the relationships between the variables and parameters in the model. They must be declared and defined, as in Figure 27 for our example.

Figure 27 – Declaration and definition of Equations

Equation declaration lists the names of the equations with a brief description of each one and end with a semicolon. Equation definition specifies the equations themselves. The two points (..) after the equation name are compulsory. In equations =E= represent the equal sign. A semicolon must be used after each defined equation. The syntax is illustrated in Figure 28.

Figure 28 – Syntax for the command Equation

Table 7 provides a selection of GAMS notations for standard arithmetic operations, indexed operations and functions.

Table 7 – Notations for a selection of operations Operation Symbol Operation Symbol Standard arithmetic operations Indexed operations Multiplication * Summation SUM(set domain, element) Subtraction - Product PROD(set domain, element) Addition + Functions Division / Exponential EXP(.) Exponent ** Logarithm LOG(.) Equality in operation = Maximum MAX(.,.) Minimum MIN(.,.)

3.4.5. Model and Solve The command Model names the model and, in brackets, lists the equations that are part of it followed by the semicolon (Figure 29). Figure 29 – The command Model

The name given to the model (in our case CLMKEQ) does not affect the overall result. It is not GAMS language and can be selected as the user likes. The list of each single equation that become part of the model can be substituted by the statement All as follows:

MODEL CLMKEQ /ALL/ ;

ALL tells GAMS to include all equations in the model. The syntax for this command is illustrated in Figure 30.

Figure 30 – Syntax for the command Model

As in the case of the command Sets, also with this command the equation names can be put on the same line, but they must be separated by a comma. The command Solve tells GAMS the method to use in order to “solve” the model, that is to find the values of the endogenous variables that make all equations true. The defined command in our example and the syntax are shown in Figure 31.

Figure 31 - The command Solve

With this command the user selects the method adopted to solve the model. In our example the Mixed Complementarity Problems (MCP) which can be used both for linear and nonlinear programming. The list of available solution procedures see the GAMS’ user guide. The solve statement completes the modeling structure.

3.5. Checking errors in the code string or file and running the model Before running the model, a check for compilation errors, such as typing mistakes, is advisable. Two commands can be alternatively used for compiling mistakes. The user can: - Click on File in the Menu headings and then on Compile; or - press Shift+F9. When the GAMS compiler encounters an error in the input file, it inserts a coded error message inside the echo print, a new window, on the line immediately following the scene of the offense. These messages always start with **** and contain a $ directly below the point at which the compiler thinks the error occurred. The $ is followed by a numerical error code, which is explained after the echo print. Making reference to our example, let us assume that, by mistake, an error in the definition of one parameters has been done: the intercept of the fish demand function has been written as fis instead of fish (Figure 32).

Figure 32 - Typing mistake in Parameters definition in the input file

Checking error, the echo print will highlight the mistake as shown in Figure 33, and at the end the typology of error will be clarified. In our case there is a violation of the domain of the specific element.

Figure 33 - Echo print with error indication

Once all the errors have been corrected, the model can be run following three possible ways: - Clicking on the red arrow on the Buttons line; - Pressing F9; or - Clicking on File in the Menu headings and then on Run. Two new windows will provide the output of the model.

4 GAMS modeling structure: the output files

4.1. Introduction Once the model is run, two windows appear (Figure 34).

Figure 34 – Output files

The one provides information about the solution procedures, such as the time spent to find the solution, the other show the solution and is the window where the output can be red. The solution window is structured into the six sections. They are, in the order in which they are presented in the output file: - Echo Print; - Reference Maps; - Equation Listings; - Model Statistics; - Status Reports; - Results. The Echo Print, Reference Maps and Model Statistics give information on the model and its components while the other sections are the result of the Solve command. This Chapter illustrates each of these components.

4.2. Echo Print and Reference Maps Echo Print is the first section of the output from a GAMS run. It is a copy of the input file. As previously underlined possible spelling, typing, conceptual or mathematical errors are indicated in this section in the form analysed in the previous chapter at Par. 3.5. For the sake of future reference, GAMS puts line numbers on the left-hand side of the echo, as shown for our example by Figure 35.

Figure 35 – The initial part of the Echo Print

Reference Maps contain summaries and analyses of the input file for the purposes of debugging and documentation. They are a Cross-reference map and a Model entities map. The IDE version of GAMS does not show these maps by default. They must be included with particular statements: - $ONSYMXREF for the Cross-reference map; - $ONSYMLIST for the Model entities map; written at the beginning of the input file (Figure 36). They are not compulsory; the user can decide to include none, one or both the maps.

Figure 36 – Statements for Reference Maps to be included at the beginning of the input file

The Cross-reference map is an alphabetical, cross-referenced list of all the entities (sets, parameters, variables, and equations) of the model. Figure 37 shows a part this map related to our example.

Figure 37 – Cross-reference map For each element of the model it provides three types of information, the symbol, the type and references. Let us consider the first element of the map. It is the intercept of the demand function. The cross- reference map informs that that this coefficient is represented in the model by the symbol “a”, is specified as a parameter that was declared in line 11, defined (assigned two values) in line 15, and referenced in line 28. The number of the lines are those in the Echo Print, as illustrated in Figure 38 with reference to our example. Figure 38 – Echo Print and cross-reference map information

The Model entities map provides a list of model entities grouped by type and listed with their associated description, as in Figure 39 for our example.

Figure 39 - Model entities map

The user can compare this map with the previously written Table 4 in Par 3.4 in order to verify if all the elements have been included in the model.

4.3. Equation Listings

The equation listing is probably the best device for studying an extremely important question, that is if

GAMS has generated the intended model. It shows the specific instance of the model that is created when the current values of the sets and parameters are plugged into the general algebraic form of the model. In the model of our example there is a generic demand equation in the input file. It is

DEMAND(i).. D(i) =E= a(i) + b(i)*P(i);

The model has also specified the parameters PARAMETERS a('Meat')=1.07; a('Fish')=1.012; b('Meat')=-0.804; b('Fish')= -3.09;

The equation listing of the corresponding specific demand equations is:

---- DEMAND =E= Demand equation DEMAND(Meat).. D(Meat) + 0.804*P(Meat) =E= 1.07 DEMAND(Fish).. D(Fish) + 3.09*P(Fish) =E= 1.012 The constant parameter (i.e. the demand coefficient) is on the right-hand side. By default the equation listing contains a maximum of three specific equations for each generic equation (in our example, the generic equation in ---- DEMAND =E= Demand equation and the specific equations are two). In order to change this number a command must be inserted in the input file prior to the solve statement. It is option limrow = r ; with r the number of desired equations. The default output also contains a section called the Column Listing, analogous to the equation listing, which shows the coefficients of three specific variables for each generic variable. To change the default number of specific column printouts per generic variable, the above command can be extended: option limrow = r, limcol = c ; where c is the desired number of columns. Setting limrow and limcol to 0 is a good way to save paper after the model has been debugged.

4.4. Model Statistics Model Statistics provides a group of statistics about the model size, as illustrated in Figure 40 for our example.

Figure 40 – Model Statistics

The Block counts inform on the number of generic equations and variables. For the model to be balanced they must be equal. In our example there are three general equations, Demand, Supply and Equilibrium, and three generic variables Demand, Supply and Price. The Single counts refer to individual rows and columns in the specific model instance being generated. In our example, there are six specific equations (Meat Demand, Meat Supply, Meat Equilibrium, Fish Demand, Fish Supply and Fish Equilibrium) and six specific variables (Meat Demand, Meat Supply, Meat Price, Fish Demand, Fish Supply and Fish Price). The Non zero elements entry refers to the number of non-zero coefficients. For nonlinear models, some other statistics are given to describe the degree of non-linearity in the problem: - The non linear n-z entry refers to the number of nonlinear matrix entries in the model. - The derivative pool and constant pool provide more information about the nonlinear information passed to the nonlinear solver. - The code length entry reports on the complexity of the nonlinear part of the model. The numerical value reports the amount of code GAMS passes to the nonlinear solver that describes all the nonlinear terms in the model Generation time if the time used since the syntax check finished, while execution time is the requested time for running the model.

4.5. Status Report The Status Report shows a brief solve summary, as illustrated in Figure 41 for our example.

Figure 41 – Status Report

The two most important entries are Solver Status and the Model Status. They are preceded by the same **** string as an error message. The desired solver status is 1 NORMAL COMPLETION, but there are other possibilities illustrated in Table 8.

Table 8 – Alternative solver status

Solver status Description

1 NORMAL COMPLETION This means that the solver terminated in a normal way: i.e., it was not interrupted by an iteration or resource limit or by internal difficulties. 2 ITERATION INTERRUPT This means that the solver was interrupted because it used too many iterations. Use ‘option iterlim ‘ to increase the iteration limit if everything seems normal. 3 RESOURCE INTERRUPT This means that the solver was interrupted because it used too much time. Use ‘option reslim’ to increase the time limit if everything seems normal 4 TERMINATED BY This means that the solver encountered difficulty and was unable to SOLVER continue. More detail will appear following the message. 5 EVALUATION ERROR Too many evaluations of nonlinear terms at undefined values. You LIMIT should use bounds to prevent forbidden operations, such as division by zero. The rows in which the errors occur are listed just before the solution. 6 CAPABILITY The solver does not have the capability required by the model, for PROBLEMS example, BARON has a more limited set of functions than other solvers. 7 LICENSING PROBLEMS The solver cannot find the appropriate license key needed to use a specific subsolver. 8 USER INTERRUPT The user has sent a message to interrupt the solver via the interrupt button in the IDE or sending a control C from a command line. 9 ERROR SETUP FAILURE The solver encountered a fatal failure during problem set-up time.

10 ERROR SOLVER The solver encountered a fatal error. FAILURE 11 ERROR INTERNAL The solver encountered an internal fatal error. SOLVER FAILURE 12 SOLVE PROCESSING The entire solve step has been skipped. This happens if execution SKIPPED errors were encountered and the GAMS parameter ExeErr has been set to a nonzero value, or the property MaxExecError has a nonzero value. 13 ERROR SYSTEM This indicates a completely unknown or unexpected error condition. FAILURE

The model status describes the characteristics of the accompanying solution. Usual linear programming termination states are 1 OPTIMAL, 3 UNBOUNDED, 4 INFEASIBLE, while in non-linear programming, the status to look for is 2 LOCALLY OPTIMAL. If solver and model status are acceptable results of the model can be examined. Otherwise, the problem must be solved working on the model structure in the input file.

4.6. Results Results are split up into three sections. The are: - Equations, indicated with solEQU in the output file; - Variables, indicated with solVAR in the output file; - Report summary. For equations and variables there is a line of printout giving the lower limit, level, upper limit, and marginal. Results are in the Variable part. Figure 42 shows solEQU for our example.

Figure 42 - solEQU

It is organized into three parts, each of them related to one equation in the model. The values in the LOWER and UPPER columns are obtained from the constant right-hand-side value of the equation, as shown in the Equation listing, which for clarity reasons is reported in the following for demand equation:

---- DEMAND =E= Demand equation DEMAND(Meat).. D(Meat) + 0.804*P(Meat) =E= 1.07 DEMAND(Fish).. D(Fish) + 3.09*P(Fish) =E= 1.012

LEVEL and MARGINAL VALUE are determined by the solver. LEVEL represents the optimal level for the equation, which is equal to the level of all terms involving variables (VERIFY IF IT IS THE RESULT OF THE CALIBRATION PROCEDURE). The MARGINAL value of each equation is instead equal to the resulting value of the corresponding variable. As previously underlined, the solution of the model is in solVAR, which in our example is structured as reported in Figure 43.

Figure 43 - solVAR

The solution level for the variables of the model is in the column LEVEL. LOWER and UPPER limits reflect what has been declare in the model. In our example all variables are declared as (FREE) VARIABLES and for this reason the upper and lower bound is unlimited, with the GAMS syntax –INF and +INF. Concerning the language rules, a single dot (.) means zero while EPS very small but nonzero. MARGINAL is the current reduced cost to force a variable in the solution. Generally it does not have much meaning in a MCP or CNS model. For models that are not solved to optimality, some constraints may additionally be marked with specific notations. They are listed and described in Table 9. Table 9 – Notations for models not solved to optimality Syntax Description

INFES The row or column is infeasible. This mark is made for any entry whose level value is not between the upper and lower bounds. NOPT The row or column is non-optimal. This mark is made for any non-basic entries for which the marginal sign is incorrect. UNBND The row or column that appears to cause the problem to be unbounded.

Results end with a Report Summary. It gives information on the total number of non-optimal, infeasible, and unbounded rows and columns, as in Figure for our example.

Figure 44 – Report Summary

The desired value is zero for all the elements.

5 Demand analysis

5.1. Introduction This Chapter introduce how to model demand with GAMS. It starts with a succinct presentation of the theoretical concepts that will find application in the modelling section. More precisely, the focus is on the concept of demand, the objective of demand analysis and the presentation of a selection of functional for of demand. Afterwards, the introduced concepts are applied in a group of models solved for the base run. These latter are structure in order to work with some preliminary GAMS components mainly aimed at explaining how to write in GAMS’ language the basic structure of a model. In this Chapter the steps to be followed in writing a model with GAMS are also introduced.

5.2. Demand Demand refers to the amount of a given product that consumers are willing to purchase, over a certain period of time. Factors affecting consumer demand are: - Price (P) of the demanded product (i); - Price of related goods (j); - Income of consumers (Y); - Preferences of consumers, such as age, education, professional status, and geographic environment (T). In mathematical notation, they can be represented in a demand function: (…) where D is the quantity demanded of good i. A change in Pi brings about movements along the demand curve while a change in the other factors a shift in the demand curve. In light of these considerations, the objective of the demand analysis is the explanation of the level of demand for commodities an individual or group of individuals consume, given the above mentioned factors affecting consumer demand. Demand analysis requires the knowledge of - How much factors affect consumer demand, an information provided by the elasticity; - The relationship between factors affecting consumer demand and consumer demand itself, provided by the functional form of demand function.

5.3. Elasticity According to the factor affecting demand, a specific typology of elasticity finds definition, as illustrated in Table 10.

Table 10 – Factors affecting demand and elasticity typology Factor affecting demand Elasticity type Price of the demanded product Own-price elasticity of demand Price of related goods Cross-price elasticity of demand Income of consumers Income elasticity of demand Other factors Other factor price elasticity

The own-price elasticity measures the percentage change in the quantity demanded given a one percent change in its price. According to theory, holding constant all the other factors the higher the price of the product the less consumers are willing to buy. This is the so called low of demand, which suggests a negative relationship between price and demand of a good: the own-price elasticity has a negative sign. According to sign and magnitude of the own-price elasticity, demand can be classified in the typologies listed in Table 11.

Table 11 – Own-price elasticity Value Descriptive terms Meaning

Ed = 0 Perfectly inelastic demand When quantity demanded does not change to the percentage change in price

-1

-∞

Ed =-∞ Perfectly elastic demand Any increase in the price, no matter how small, will cause demand for the good to drop to zero

Ed >0 Giffen good Consumers paradoxically consume more as the price rises (violation of the law of demand)

Cross-price elasticity indicates the percentage change in the quantity demanded of a good (i) given a one percent change in the price of another related good (j). According to the sign of the cross-price elasticity the categories of goods listed in Table 12 can be distinguished.

Table 12 – Categories of goods according to the sign of the cross-price elasticity Value Definition Description

Eij < 0 Gross complements An increase in price of a good causes a decrease in demand of the other good

Eij > 0 Gross substitutes An increase in price of a good causes an increase in demand of the other good

Eij = 0 Independent Demand for a good is independent on the price (demand) for other goods

Income elasticity of demand measures Percentage change in demand for a good when income change by one percent. Table 13 lists the categories of goods according to the sign and magnitude of the income elasticity of demand.

Table 13 – Categories of goods according to the sign of the income elasticity of demand Value Definition Description

EY < 0 Inferior good An increase in income causes a decrease in demand for the good

0 1 Normal good: Superior or An increase in income causes a more than proportional luxury good increase in demand for the good

EY = 0 Neutral good An increase in income does not causes any increase in demand for the good

Even if prices and incomes are the same two or more consumers may differ in their demand due to different preferences. The specific effect on demand is measured by preference elasticity of demand.

5.4. Functional form of demand function The functional form of the demand function can be defined follow two different approaches: - the specification of a single-equation demand function in a pragmatic fashion; or - using theory as a guideline passing to a complete system of demand equations. According to the pragmatic approach, the demand function can be specified in natural logarithms (ln) as follows:

with qi the quantity demanded (purchased) of good “i” per capita, ai the intercept of demand function, ci the own-price elasticity of good “i”, pi the price of good “i” demanded, P the consumer price index, dj the cross-price elasticities, pj the price of other good “j”, ei the income elasticity of demand, y the total expenditure per capita, fk the preferences elasticities, zk the consumer preferences. Dividing prices and income by the consumer price index, the demand equations is homogeneous of degree zero in prices and income. In other words, there is no money illusion: demand is not affected by a proportional increase in all prices and income. This approach is attractive in its simplicity but it has three major drawbacks. First, the choice of the functional form for the demand function and the variables to be included is arbitrary and for this reason they might not reflect the actual consumer behavior. Second, elasticities are postulated to be constant over all values of the exogenous variables. The assumption might not be always sustainable, such as in the case of commodities that are luxuries and that become necessity at the increase in per capita income. Third, the pragmatic approach does not consider the consumer budget constraint that limits total expenditure as suggested by theory. When the price of the demanded and related goods is not available, the pragmatic approach estimates the Engel function. Table 14 provides a list of functional form for this demand function.

Table 14 – Engle function Engel curve Mathematical formulation

Linear qi=ai+ei*y

Double logarithmic ln(qi)=ai+ei*ln(y)

Semilogarithmic qi=ai+ei*ln(y) reciprocal ln(q )=a -e (1/y) Logarithmic i i i*

5.4.1. Demand Systems The most frequently adopted demand functions that reflect theoretical prescriptions are: - Linear Expenditure System (LES); - Almost Ideal Standard System (AIDS). The Linear Expenditure System takes the following form:

with n is the number of commodities demanded, pi the price of demanded good “i”, qi the demanded quantity (purchased) of good “i” per capita, y the total expenditure, si the minimum subsistence or

“committed” quantities below which consumption cannot fall and bi the marginal budget share. This latter is defined as and expresses how expenditure on each commodity changes as income changes. In the model the component represents the subsistence expenditure, while is the uncommitted or

“supernumerary” income that is the share of income is spent in fixed proportions bi between the n goods. The interpretation of the model is that consumers spend a committed amount on each good and, after that, divide the remaining uncommitted income among all products in fixed amounts bi.

As LES assumes bi>0, this system does not allow for inferior goods an assumption that is not supported by empirics; it implies a linear Engel function. The Almost Ideal Standard System (AIDS) allows overcoming this issue introducing flexibility to the estimated elasticities. An additional advantage of this demand model is that, as supported by demand theory, it consistently considers the mutual interdependence of large numbers of commodities in the choice made by consumers. An AIDS is specified as follows: with n is the number of commodities demanded, pi the price of demanded good “i”, qi the demanded quantity (purchased) of good “i” per capita, y the total expenditure, ai the intercept of demand function, dj the cross-price elasticities, pj the price of other good “j”, ei the income elasticity of demand, and P the consumer price index. is the budget share, that is the share if income spent in good “i”.

5.5. Examples In the following examples it is requested to calculate the base run of demand models introducing, step by step, new elements of the GAMS language. It is recommended to design the model in pencil before its imputation in GAMS software. A four-step process can be followed in writing the model in pencil:

1. Attribute a symbol to each model element; 2. Write the equations; 3. Classify the equation elements according to the GAMS commands, following Table 4 in Par.3.4; 4. Write the model in GAMS language following Figure 16 Par. 3.2.

In the first three models and in the last, due to its complexity, steps 1, 2 and 3 are illustrated in detail while in the others the focus is only on model design in GAMS language and the new introduced components.

5.5.1. One good, one market linear demand model Calculate the base run of a linear demand function model in one market for the simulation of the quantity of maize demanded. The available information is illustrated in Table 15.

Table 15 – Available information Known element Value Price 55 CFA kg Price coefficient of demand -0.513 Intercept 102.072 Demand function Linear

First, the model should be written in pencil and then in GAMS software. The pencil written section includes the following four steps. 1. Attribute a symbol to each model element (Table 16)

Table 16 - Symbols Model element Symbol Price P Price coefficient of demand B Intercept A Demand D Demand equation DEMAND

2. Write the equation, that is a linear demand function, as follows:

3. Classify the equation elements according to the GAMS commands, following Table 4 in Par.3.4 (Table 17).

Table 17 - Equation elements and GAMS commands Element Type GAMS’ Command Observed values A Observed exogenous variable Parameters B Observed parameter Parameters P Observed exogenous variable Parameters Unknown variables

Di Endogenous variable Variables

Pi Endogenous variable Variables Equation Demand Demand function Equations

4. Write the model in GAMS language following Figure 16 Par. 3.2.

*GAMS linear demand function model in one market PARAMETERS A Intercept of demand function B Price coefficient of demand P Fixed price CFA kg; A = 102.072; B = -0.513; P = 55; VARIABLES D Quantity demanded; EQUATIONS DEMAND Demand equation; DEMAND .. D =E= A+B*P; MODEL MARKETONE /DEMAND/; SOLVE MARKETONE USING MCP;

The model written in pencil can be now written and solved with the GAMS software.

5.5.2. One good, two markets linear demand model Calculate the base run of one good (meat), two markets linear demand model with demand a function of demanded good price and consumers income. The two markets are those of the region North and South and the available information are provided by Table 18.

Table 18 – Available information Markets Element of the model North South Intercept of demand function 0.07 0.09 Price coefficient of demand function -0.804 -0.222 Meat price (pounds/kg) 9 10 Income coefficient of demand function 1.121 1.331 Income (per month, per capita, 000 1,300 832 pounds) Demand function linear linear

First, the model should be written in pencil and then in GAMS software. The pencil written section includes the following four steps. 1. Attribute a generic symbol to each model element (Table 19).

Table 19 – Generic symbols Element of the model Generic symbol Intercept of demand function A Price coefficient of demand function B Meat price (pounds/kg) P Income coefficient of demand function C Income (per month, per capita, 000 pounds) Y Region R

2. Write the equation, that is a linear demand function, as follows:

3. Classify the equation elements according to the GAMS commands, following Table 4 in Par.3.4 (Table 20).

Table 20 - Equation elements and GAMS commands Element Type GAMS’ Command R Index Sets Observed values

AR Observed exogenous variable Parameters

BR Observed parameter Parameters

CR Observed parameter Parameters

PR Observed exogenous variable Parameters

YR Observed exogenous variable Parameters Unknown variables

DR Endogenous variable Variables Equation Demand Demand function Equations

4. Write the model in GAMS language following Figure 16 Par. 3.2. *GAMS program to simulate meat demand in two markets with meat price and income SETS R Region /North South/; PARAMETERS A(R) Intercept of demand function /North 0.07 South 0.09/ B(R) Price coefficient of demand function /North -0.804 South -0.222/ P(R) Meat price (pounds per kg) /North 9 South 10/ C(R) Income coefficient of demand function /North 1.121 South 1.331/ Y(R) Monthly income (thousand per capita pounds) /North 1300 South 832/; VARIABLES D(R) Quantity demanded; EQUATIONS DEMAND Demand equation; DEMAND (R).. D(R) =E= A(R)+B(R)*P(R)+C(R)*Y(R); MODEL TMARKETS /DEMAND/; SOLVE TMARKETS USING MCP;

The model written in pencil can be now written and solved with the GAMS software.

5.5.3. Two goods, two markets linear demand model Calculate the base run of a linear demand model for two goods in two markets, with demand function of the demanded goods price and consumers income. The two goods are meat and fish and the two markets are North and South. The available information are provided by Table 21.

Table 21 – Available information North South Meat Fish Meat Fish Intercept of demand function 0.07 0.012 0.09 0.02 Price coefficient of demand -0.804 -0.441 -0.222 -1.051 Price (punds/kg) 9 18 10 12 Income coefficient of demand 1.121 0.675 1.331 0.423 Income (per month, per capita, 000 punds) 1300 832 Demand function linear linear

First, the model should be written in pencil and then in GAMS software. The pencil written section includes the following four steps. 1. Attribute a generic symbol to each model element (Table 22) Table 22 – Generic symbols Element of the model Generic symbol Intercept of demand function A Price coefficient of demand function B Meat price (pounds/kg) P Income coefficient of demand function C Income (per month, per capita, 000 pounds) Y Goods F Region R

2. Write the equation, that is a linear demand function, as follows:

3. Classify the equation elements according to the GAMS commands, following Table 4 in Par.3.4 (Table 23).

Table 23 - Equation elements and GAMS commands Element Type GAMS’ Command R Index Sets F Index Sets Observed values

AR,F Observed exogenous variable Parameters

BR,F Observed parameter Parameters

CR,F Observed parameter Parameters

PR,F Observed exogenous variable Parameters

YR Observed exogenous variable Parameters Unknown variables

DR,F Endogenous variable Variables Equation Demand Demand function Equations

4. Write the model in GAMS language following Figure 16 Par. 3.2. The new element, in this model, relates to data entry. As A, B, C and P have two values in each region it is useful to use the command TABLE instead of that of PARAMETERS. This latter command, Parameters, is only adopted for Y, the income, which assume only one value in each region. Let us consider the initial part of the model with the specification of the command TABLE for A, Intercept of demand function:

* GAMS program to simulate meat demand in two markets with meat price and income SETS R Region /North South/ F Good /Meat Fish/; TABLE A(F,R) Intercept of demand function North South Meat 0.07 0.09 Fish 0.012 0.02;

The command SETS enter the two indices, R for regions (North and South) and F for goods (meat and Fish). After this command, TABLE enter a two-dimensional table for the intercept of demand function. First, the table is declared and then it is defined. In TABLE declaration the letters in brackets (F, R) after the general symbol of the parameter (A), indicates the former the first column and the latter the second column of the table specified for data entry. A semicolon must be put at the end of the definition of each table. Alternatively, data with more than one index can be entered using the command PARAMETERS with a specific notation. It consists on writing the parameter name substituting and * to the second index. This notation tells GAMS that the second index will be specified latter in the definition of the parameter when after the name of the fist index the user must add a dot and then the name of the second index. In our example the above mentioned statement becomes

* GAMS program to simulate meat demand in two markets with meat price and income SETS R Region /North South/ F Good /Meat Fish/; PARAMETERS A(F,*) Intercept of demand function /Meat.North 0.07 Fish.North 0.012 Meat.South 0.09 Fish.South 0.02/

The complete model is written as follows using the command TABLE. It can be easily adapted with the command PARAMETERS as above specified.

*GAMS program to simulate meat demand in two markets with meat price and income SETS R Region /North South/ F Good /Meat Fish/; TABLE A(F,R) Intercept of demand function North South Meat 0.07 0.09 Fish 0.012 0.02; TABLE B(F,R) Price coefficient of demand North South Meat -0.804 -0.222 Fish -0.441 -1.051; TABLE P(F,R) Price (pounds per kg) North South Meat 9 10 Fish 18 12; TABLE C(F,R) Income coefficient of demand North South Meat 1.121 1.331 Fish 0.675 0.423; PARAMETERS Y(R) Income per month per capita (000 pounds) /North 1300 South 832/; VARIABLES D(F,R) Quantity demanded; EQUATIONS DEMAND Demand equation; DEMAND (F,R).. D(F,R) =E= A(F,R)+B(F,R)*P(F,R)+C(F,R)*Y(R); MODEL TGOMA /DEMAND/; SOLVE TGOMA USING MCP;

The model written in pencil can be now written and solved with the GAMS software. 5.5.4. One good, two markets demand model with a different functional forms: Linear demand function and Linear Engel function Calculate the base run of one good (meat), two markets (North and South) demand model with a different functional form: - Linear demand function in the Northern region; and - Linear Engel function in the Southern region. The available information are listed in Table 24.

Table 24 – Available information Variable Value Intercept North 0.70 Price coefficient of demand function North -1.2 Price North (pounds kg) 0.10 Intercept South 1.50 Income coefficient of demand function South 0.80 Income South (000 pounds) 1.2 Demand function North Linear Demand function South Linear Engel

The new element in this model is the need to specify two endogenous demand variables (H and G) and two demand functions (DemandN and DemandS), one for the Northern region and the second for the Southern. The model in GAMS language takes the following form.

*GAMS model for different functional forms PARAMETERS A Intercept North B Price coefficient of demand function North P Price North C Intercept South D income coefficient of demand function South Y Income South; A=0.70; C=1.50; B=-1.20; D=0.80; P=0.10; Y=1.200; VARIABLES H demand north G demand south; Equations DemandN Demand equation North DemandS Demand equation South; Demandn.. H=E=A+B*P; Demands.. G=E=C+D*Y; Model ffmk/all/; Solve ffmk using mcp;

5.5.5. One good, two markets demand model with a different functional forms: Linear demand function and Semilogarithmic Engel function Calculate the base run of one good (meat), two markets (North and South) demand model with the following functional forms: - Linear demand function in the Northern region; and - Semilogarithmic Engel function in the Southern region; And display the values of demand, price and income in North and South. The available information are listed in Table 25.

Table 25 – Available information Variable Value Intercept North 0.70 Price coefficient of demand function North -1.2 Price North (pounds kg) 0.10 Intercept South 11.50 Income coefficient South 0.01 Income South (000 pounds) 1.2 Demand function North Linear Demand function South Semilogarithmic Engel

In this example there are two new elements. The first is the use of logarithms in equation entry and the second is the command DISPLAY. As illustrated in Table 7 at Par. 3.4.4, the notation for the logarithm is LOG(.) with dot in brackets the symbol of the parameter in Equation definition. As far as the comma Display is concerned, it specifies the type of output generated by the GAMS program. For this reason it is written after the SOLVE command. It is used to show the values of parameters and variables. The SYNTAX in the case we want to see two parameters and tow variables is:

DISPLAY , , .L, .L;

As noticed, for variables it must be added to the name a specific notation, that is .L. The statement ends with a semicolon. The model is written in the following form.

*GAMS model for different functional forms PARAMETERS A Intercept North B Price coefficient of demand function North P Price North C Intercept South D Income coefficient of demand function South Y Income South; A=0.70; C=11.50; B=-1.20; D=0.01; P=0.10; Y=1.200; VARIABLES H demand north G demand south; Equations Demandn Demand equation North Demands Demamnd equation South; Demandn.. H=E=A+B*P; Demands.. G=E=C+D*LOG(Y); Model ffmk/all/; Solve ffmk using mcp; Display H.L, G.L, P, Y;

In the output file, clicking on Display there is the list of the selected parameters and variables (Figure 45).

Figure 45 – Output file and DISPLAY command 5.5.6. One good, two markets demand model with a different functional forms: Linear demand function and double logarithmic Engel function Adapt the previous model (Par. 5.5.4) in order to fit the information shown in Table 26.

Table 26 – Available information Variable Value Intercept North 0.70 Price coefficient of demand function North -1.2 Price North (pounds kg) 0.10 Intercept South 1.50 Income elasticity South 0.03 Income South (000 pounds) 1.2 Demand function North Linear Demand function South Double logarithmic Engel function

The adaptation of an already developed model is an important operation. The GAMS library provides a list of implemented model that can be adjusted to the investigate problem. In the model to be designed there is a new element. It is the demand in the Southern region. It is taken in logarithm form. Running the model with the specification of Southern demand equation in a double logarithmic form, that is

*GAMS model for different functional forms PARAMETERS A Intercept North B Price coefficient of demand function North P Price North C Intercept South D Income elasticity South Y Income South; A=0.70; C=1.50; B=-1.20; D=0.03; P=0.10; Y=1.200; VARIABLES H demand north G demand south; EQUATIONS Demandn Demand equation North Demands Demamnd equation South; Demandn.. H=E=A+B*P; *Double logarithmic Engel function Demands.. LOG(G)=E=C+D*LOG(Y); MODEL ffmk/all/; SOLVE ffmk using mcp; it does not provide any solution. The output file indicates a series of errors brought about by the specification of the double logarithmic function (Figure 46)

Figure 46 – Error messages in the output file

When an endogenous variable is specified as logarithm, after the MODEL command a specific notation must be included in order to allow GAMS to start the search of possible values of an endogenous variable with a positive number. Otherwise the software begins with a value equal to zero and GAMS gives an error message. The syntax for this command is .L ()=1

Thus, the model take the following form. *GAMS model for different functional forms PARAMETERS A Intercept North B Price coefficient of demand function North P Price North C Intercept South D Income elasticity South Y Income South; A=0.70; C=1.50; B=-1.20; D=0.03; P=0.10; Y=1.200; VARIABLES H demand north G demand south; EQUATIONS Demandn Demand equation North Demands Demamnd equation South; Demandn.. H=E=A+B*P; Demands.. LOG(G)=E=C+D*LOG(Y); MODEL ffmk/all/; G.L=1; SOLVE ffmk using mcp;

5.5.7. AIDS function Calculate the base run of a model for total meat demand in two regions, North and South, where individual meat demand is represented by an AIDS function whose values are specified in Table 27.

Table 27 – Known values North South Intercept of AIDS demand function 15 18 Price elasticity of AIDS demand -0.804 -0.222 Meat price (pounds/kg) 19 30 Income elasticity of AIDS demand 1.121 1.331 Income (per month, per capita, 000 pounds) 1.500 1.832 Price index 1.20 0.98 Population (thousand) 51000 9000 This model is more complicated than those previously illustrated. For this reason the four-step process is illustrated in detail. 1. Attribute a generic symbol to each model element (Table 28)

Table 28 – Generic symbols Symbol Region R Intercept of AIDS demand function A Price elasticity of AIDS demand B Meat price (pounds/kg) P Income elasticity of AIDS demand C Income (per month, per capita, 000 pounds) Y Price index PI Population (thousand) POP Individual demand Q Total demand D

2. Write the equations; Individual AIDS demand function based on budget share (BSH)

From this equation, the individual meat demand is given by

Total meat quantity demanded is given by

Thus, the equation system to be estimated is

with two equations and two endogenous variables (BSH and D).

3. Classify the equation elements according to the GAMS commands (Table 29), following Table 4 in Par.3.4. Table 29 - Equation elements and GAMS commands Element Type GAMS’ Command R Index Sets Observed values

AR Observed exogenous variable Parameters

BR Observed parameter Parameters

CR Observed parameter Parameters

PR Observed exogenous variable Parameters

YR Observed exogenous variable Parameters

PIR Observed exogenous variable Parameters

POPR Observed exogenous variable Parameters Unknown variables

BSHR Endogenous variable Variables

DR Endogenous variable Variables Equation Badsh Budget share Equation Demand Demand function Equations

4. Write the model in GAMS language following Figure 16 Par. 3.2, and display the budget share and total meat demand.

*GAMS program to simulate total meat demand in two markets with AIDS individual demand SETS R Region /North South/; PARAMETERS A(R) Intercept of demand function /North 15 South 18/ B(R) Price elasticity of demand function /North -0.0804 South -0.0222/ P(R) Meat price (pounds per kg) /North 19 South 30/ C(R) Income elasticity of demand /North 1.121 South 1.331/ Y(R) Monthly income (thousand per capita pounds) /North 1.500 South 1.832/ PI(R) Price Index /North 1.20 South 0.98/ POP(R) Population /North 51000 South 9000/; VARIABLES BSH(R) Budget share D(R) Total demand; EQUATIONS BADSH Budget share DEMAND Total demand equation; BADSH(R) .. BSH(R)=E= A(R)+B(R)*LOG(P(R))+C(R)*LOG(Y(R)/PI(R)); DEMAND(R).. D(R)=E=(BSH(R)*Y(R)/P(R))*POP(R); MODEL TMKAIDS /ALL/; SOLVE TMKAIDS USING MCP; DISPLAY BSH.L, D.L;