General Equilibrium Modeling with MPSGE:
Some Examples for Self-Study

Models M1: Closed Economy Models

James Markusen and Thomas F. Rutherford

Department of Economics
University of Colorado

rutherford@colorado.edu

1995

Return to the MPSGE home page

$TITLE Model M1_1S: Closed 2x2 Economy -- A Quick Introduction to the Basics


$ontext

November, 1995 (revised)

The Social Accounting Matrix

The starting point for many models is a balanced input social
accounting matrix (SAM).  Traditionally, SAMs are presented as square
matrices in which row i and column i refer to a single account.  In
the traditional SAM, rows correspond to receipts and columns are
expenditures.  A 9x9 SAM describes the benchmark equilibrium for the
first model we consider:

        PX      PY      PW      PL      PK      X       Y       W       CONS
PX                                                              100
PY                                                              100
PW                                                                      200
PL                                              40      60
PK                                              60      40
X       100
Y               100
W                       200
CONS                            100     100

Reading rows as receipts, we see from the first row of the SAM that
100 is spent on good X in sector W.  Likewise, reading across row 4
we see that 40 units of labor enter sector X and 60 units enter
sector Y.  SAMS can be quite detailed in their representation of an
economy, and they are also quite flexible.  All sorts of
inter-account taxes, subsidies and transfers can be represented
through an appropriate definition of the accounts.  (For an
introduction, see Pyatt and Round, "Social Accounting Matrices: A
Basis for Planning", The World Bank, 1985.)

For simple MPSGE models, it is convenient to use a rectangular SAM
format.  This format emphasizes how the MPSGE program structure is
connected to the benchmark data.  In the rectangular SAM, we have one
row for every market (traded commodity).  In the present model, there
are five markets, for goods X, Y and W and factors L and K.  

There are two types of columns in the rectangular SAM, corresponding
to production sectors and consumers.  In the present model, there are
three production sectors (X, Y and W) and a single consumer (CONS).

The numbers which appear in a conventional SAM are typically
positive, apart from very special circumstances.  In the MPSGE SAM,
there are both positive and negative entries.  A positive entry
signifies a receipt (sale) in a particular market.  A negative entry
signifies an expenditure (purchase) in a particular market.  Reading
down a production column, we then observe a complete list of the
transactions associated with that activity.  

The following rectangular SAM conveys the same information as the
traditional square SAM presented above:

                  Production Sectors          Consumers
   Markets   |    X       Y        W    |       CONS
   ------------------------------------------------------
        PX   |  100             -100    |
        PY   |          100     -100    |
        PW   |                   200    |       -200
        PL   |  -40     -60             |        100
        PK   |  -60     -40             |        100
   ------------------------------------------------------

A square SAM is "balanced" when the vector of row sums equals the
vector of column sums.  A rectangular SAM is "balanced" when row and
column sums are zeros.  

Positive numbers represent the value of commodity flows into the
economy (sales or factor supplies), while negative numbers represent
the value of commodity flows out of the economy (factor demands or
final demands).  With this interpretation, a row sum is zero if the
total amount of commodity flowing into the economy equals the total
amount of commodity flowing out of the economy.  This is market
clearance, and one such condition applies for each commodity in the
model.

Columns in this matrix correspond to production sectors or consumers.
A production sector column sum is zero if the value of outputs equals
the cost of inputs.  A consumer column is balanced if the sum of
primary factor sales equals the value of final demands.

In this simple model there are really only two produced commodities
(X and Y), two factors of production (L and K) and one consumer
(CONS).  An extra column (W) and extra row (PW) have been introduced
to represente aggregate consumption index and the corresponding
price index.

$OFFTEXT

*       Next, we specify a general equilibrium model based on
*       this data using MPSGE syntax.

*       First, declare GAMS parameters which we will use in model
*       specification.

SCALAR  TX      Ad-valorem tax rate for X sector inputs /0/,
        LENDOW  Labor endowment multiplier              /1/;

$ONTEXT

*       An MPSGE model is specified within an $ONTEXT / $OFFTEXT
*       block, and the first keyword must define the model name.
*       The model name must conform to the usual rules for GAMS 
*       MODEL names (e.g., maximum 10 characters):

$MODEL:M1_1S

*       The declaration of variables for an MPSGE model immediately
*       follows the $MODEL statement.  There are three classes of
*       variables, $SECTORS, $COMMODITIES and $CONSUMERS.  A
*       variable definition may include a description in the trailing
*       comment (following a "!" -- Not that this is unlike the
*       ordinary GAMS syntax for variable and equation definitions,
*       in which any trailing text, up to a comma, is interpreted as
*       a description.).

$SECTORS:
        X       ! Activity level for sector X
        Y       ! Activity level for sector Y
        W       ! Activity level for sector W (Hicksian welfare index)

$COMMODITIES:
        PX      ! Price index for commodity X
        PY      ! Price index for commodity Y
        PL      ! Price index for primary factor L
        PK      ! Price index for primary factor K
        PW      ! Price index for welfare (expenditure function)

$CONSUMERS:
        CONS    ! Income level for consumer CONS

*       Cobb-Douglas technology is characterized by unitary elasticity
*       of substitution at the top level (s:1).  Taxes are always 
*       applied on a value-added basis.  Here, the user cost of labor
*       inputs is then PL*(1+TX) and the user cost of capital inputs
*       is PK*(1+TX).  The A: field indicates that tax revenue should
*       accrue to CONS.

$PROD:X s:1
        O:PX  Q:100
        I:PL  Q:40 A:CONS T:TX
        I:PK  Q:60 A:CONS T:TX

$PROD:Y s:1
        O:PY  Q:100
        I:PL  Q:60
        I:PK  Q:40

$PROD:W s:1
        O:PW   Q:200
        I:PX   Q:100
        I:PY   Q:100

*       Here we represent final excess demand.  This function
*       represents preferences (using reference demands), and 
*       initial factor endowments:

$DEMAND:CONS
        D:PW   Q:200
        E:PL   Q:(100*LENDOW)
        E:PK   Q:100

$OFFTEXT

*       Include a compiler directive instructing MPSGE to compile
*       the functions.  This statement must be issue, otherwise the 
*       MPSGE functions are invisible to GAMS:

$SYSINCLUDE mpsgeset M1_1S

*       An equilibrium in this model determines only relative prices --
*       there is no "money illusion" and the absolute price level is
*       irrelevant.  This must be considered when reporting induced 
*       changes in relative prices.  It is convenient to select one
*       good as numeraire and fix its price as unity.  Labor is 
*       a traditional choice as numeraire, so we use it:

        PL.FX = 1;

*       N.B.  Fixing a price instructs MPSGE to omit the corresponding
*       equation -- In equilibrium, this equation will be satisfied 
*       automatically through Walras' law.  

*       It is not necessary to fix a numeraire, however if a numeraire
*       is not specified, the normalization of prices is arbitrary.
*       (When no price is exogenously fixed, the system uses one consumer
*       income as normalization, and this income level is determined by the
*       initial price vector).

*       Instruct GAMS to generate and evaluate the model.  The data
*       for this model is balanced, so this model should return
*       with "solved" status.  If it is not solved, the solution 
*       listing can be used to identify the source of the inconsistency.

        M1_1S.ITERLIM = 0;
$INCLUDE M1_1S.GEN
        SOLVE M1_1S USING MCP;
        M1_1S.ITERLIM = 2000;

*       Solve a counterfactual: 50% tax on inputs to X production.

        TX = 0.5;       
        LENDOW = 1;

$INCLUDE M1_1S.GEN
        SOLVE M1_1S USING MCP;

*       Solve a counterfactual: 100% increase in labor endowment (TX=0)

        TX = 0;         
        LENDOW = 2;

$INCLUDE M1_1S.GEN
        SOLVE M1_1S USING MCP;

*       Finally, to remove some of the mystery from the model 
*       description, we provide an algebraic presentation of the
*       same equations which have been generated automatically by 
*       MPSGE.

*       We write these equations using precisely the same variables
*       which have already been delcared within the MPSGE model
*       (hence, they need not be declared a second time).

*       We need to give names to the equations, however, because the 
*       MPSGE-generate equations are not named.  

EQUATIONS
        PRF_X   Zero profit for sector X
        PRF_Y   Zero profit for sector Y
        PRF_W   Zero profit for sector W (Hicksian welfare index)

        MKT_X   Supply-demand balance for commodity X
        MKT_Y   Supply-demand balance for commodity Y
        MKT_L   Supply-demand balance for primary factor L
        MKT_K   Supply-demand balance for primary factor L
        MKT_W   Supply-demand balance for aggregate demand

        I_CONS  Income definition for CONS;

*       Zero profit conditions are produced for all of the production
*       sectors.  These are interpreted as:

*               Cost of Production Gross of Tax  =  Value of Output

PRF_X..         100 * PL**0.4 * PK**0.6 * (1+TX) =E= 100 * PX;

PRF_Y..         100 * PL**0.6 * PK**0.4 =E= 100 * PY;

PRF_W..         200 * PX**0.5 * PY**0.5 =E= 200 * PW;

*       Market clearance conditions for each of the final goods and
*       primary factors.  These are interpreted as:

*               Output plus Initial Endowment  = Intermediate + Final Demand

MKT_X..         100 * X =E= 100 * W * PX**0.5 * PY**0.5 / PX;

MKT_Y..         100 * Y =E= 100 * W * PX**0.5 * PY**0.5 / PY;

MKT_W..         200 * W =E= CONS / PW;

MKT_L..         100 * LENDOW =E= 40 * X * PL**0.4 * PK**0.6 / PL +
                                 60 * Y * PL**0.6 * PK**0.4 / PL;

MKT_K..         100 =E= 60 * X * PL**0.4 * PK**0.6 / PK +
                        40 * Y * PL**0.6 * PK**0.4 / PK;

*       Income balance states that the level of expenditure (CONS)
*       equals the value of factor income plus tax revenue:

I_CONS..        CONS =E= 100*LENDOW*PL + 100*PK + TX*100*X*PL**0.4*PK**0.6;

*       We declare this model using the mixed complementarity syntax
*       in which equation identifiers are associated with variables.

*       One advantage of this syntax is that if a variable value is
*       fixed within an MCP model, the associated equation is
*       automatically omitted from the model:

MODEL ALGEBRAIC /PRF_X.X, PRF_Y.Y, PRF_W.W, MKT_X.PX, MKT_Y.PY, MKT_L.PL, 
                 MKT_K.PK, MKT_W.PW, I_CONS.CONS /;

*       Check the benchmark (again):

        X.L=1; Y.L=1; W.L=1; PX.L=1; PY.L=1; PK.L=1; PW.L=1; CONS.L=200;

        TX = 0; 
        LENDOW=1;
        SOLVE ALGEBRAIC USING MCP;

*       Solve the same counterfactuals:

        TX = 0.5;       
        LENDOW = 1;
        SOLVE ALGEBRAIC USING MCP;

        TX = 0;         
        LENDOW = 2;
        SOLVE ALGEBRAIC USING MCP;

$ontext


Exercises for M1_1S:

(1) Remove the PL.FX = 1.  This will cause MPSGE to select use the
default normalization of prices. (Note that if the PL is not fixed,
the algebraic model may not solve because the Jacobian is singular at
the solution.)

Rerun the counter-factual simulations using the MPSGE model and the
default price normalization.  Verify that relative price in the new
solution are identical to the original solution.

(2) Introduce a "typo" in a sector X input, e.g. O:PX Q:101, and then
examine the benchmark replication listing to see how this error is
manifested in the output.

(3) Consult a microeconomics text book to verify that the algebraic
model is properly specified.  A close familiarity with CES algebra is
useful but not essential.  One motivation for the development of
MPSGE is that the algebraic approach is difficult and error prone.

$offtext

$TITLE Model M1_1V: Closed 2x2 Economy -- Introduces Vector Syntax


$ontext

November, 1995 (revised)


In this program, the scalar model, M1_1S, is interepreted as a
general model using GAMS sets and the MPSGE vector syntax.

$offtext

TABLE BENCH(*,*)  Benchmark financial flows (e.g. an input-output table)

                X       Y        W           CONS
        X     100             -100    
        Y             100     -100    
        W                      200           -200
        L     -40     -60                     100
        K     -60     -40                     100;

*       Declare the underlying sets:

SET     I   Produced goods          /X, Y/,
        F   Factors of production   /L, K/;

*     Use I and J to both index goods:

ALIAS (I,J), (F,FF);

PARAMETER       Y0(I)         Benchmark sectoral output,
                FD0(F,I)      Benchmark factor demands,
                C0(I)         Benchmark consumption demand, 
                E(F)          Factor endowments, 
                T(I)            Sectoral ad-valorem tax rate, 
                W0            Benchmark total consumption;

*       Extract data from the original format into model-specific arrays:

Y0(I)         = BENCH(I,I);          
FD0(F,I)      = -BENCH(F,I);
C0(I)         = -BENCH(I,"W");       
W0            = SUM(I, C0(I));
E(F)          = BENCH(F,"CONS");     
T(I)          = 0;

DISPLAY Y0, FD0, C0, E, T;

*       MPSGE model declaration follows:

$ONTEXT

$MODEL:M1_1V

*     Here we define production activities over the set I:

$SECTORS:
        Y(I)            ! Commodity production index
        W               ! Welfare index

$COMMODITIES:
        PW              ! Utility price index
        PC(I)           ! Commodity price index
        PF(F)           ! Factor price index

$CONSUMERS:
        CONS            ! Representative consumer


$PROD:Y(I) s:1
        O:PC(I)         Q:Y0(I)
        I:PF(F)         Q:FD0(F,I)   A:CONS  T:T(I)

$PROD:W  s:1
        O:PW            Q:W0
        I:PC(I)         Q:C0(I)

$DEMAND:CONS
        D:PW            Q:W0
        E:PF(F)         Q:E(F)

$OFFTEXT
$SYSINCLUDE mpsgeset M1_1V

*       Check the calibration:

M1_1V.ITERLIM = 0;
$INCLUDE M1_1V.GEN
SOLVE M1_1V USING MCP;
M1_1V.ITERLIM = 2000;

*       Use labor as the numeraire commodity:

PF.FX("L") = 1;

*       Declare a GAMS parameter to hold the solution values:

PARAMETER REPORT        Summary report;

*       Extract solution values into this parameter:

REPORT("WELFARE"," ","BENCH") = W.L;    
REPORT("PRICE",I,"BENCH")     = PC.L(I);
REPORT("PRICE",F,"BENCH")     = PF.L(F);
REPORT("OUTPUT",I,"BENCH")    = Y.L(I);

*       Solve some counterfactuals: 50% tax on inputs to X production:

T("X") = 0.5;
$INCLUDE M1_1V.GEN

SOLVE M1_1V USING MCP;

REPORT("WELFARE"," ","50%TAX") = W.L;   
REPORT("PRICE",I,"50%TAX")     = PC.L(I);
REPORT("PRICE",F,"50%TAX")     = PF.L(F);   
REPORT("OUTPUT",I,"50%TAX")    = Y.L(I);

*       100% increase in labor Ement, tax set back to zero:

E("L") = 2 * E("L");    
T(I) = 0;

$INCLUDE M1_1V.GEN
SOLVE M1_1V USING MCP;

REPORT("WELFARE"," ","100%L") = W.L;
REPORT("PRICE",I,"100%L")     = PC.L(I);
REPORT("PRICE",F,"100%L")     = PF.L(F);
REPORT("OUTPUT",I,"100%L")    = Y.L(I);

*       Place all the output at the bottom of the listing file:

DISPLAY REPORT;

*     Present the algebraic syntax for the sake of completeness:

PARAMETER   ALPHA(F,I)  Factor input benchmark value share
            BETA(I)           Consumption value share;

ALPHA(F,I) = FD0(F,I) / SUM(FF, FD0(FF,I));
BETA(I) = C0(I) / W0;

EQUATIONS
      PROFIT(I)   Zero profit condition 
      CMKT(I)           Commodity market clearance
      FMKT(F)           Factor market clearance
      PRF_W       Zero profit for aggregate consumption
      MKT_W       Market clearance for aggregate consumption
      I_CONS            Income = factor earnings plus taxes;

PROFIT(I)..    (1+T(I)) * PROD(F, PF(F)**ALPHA(F,I)) =E= PC(I);

PRF_W..         PROD(I, PC(I)**BETA(I)) =E= PW;

CMKT(I)..   Y0(I) * Y(I) =E= C0(I) * W * PROD(J, PC(J)**BETA(J)) / PC(I);

MKT_W..         W0 * W =E= CONS / PW;

FMKT(F)..   E(F) =E= SUM(I, FD0(F,I) * Y(I) 
                  * PROD(FF, PF(FF)**ALPHA(FF,I))) / PF(F);

I_CONS..        CONS =E= SUM(F, PF(F) * E(F)) + SUM(I, T(I) * Y0(I) * Y(I) * 
                        PROD(F, PF(F)**ALPHA(F,I)) );

MODEL ALGEBRAIC /PROFIT.Y, PRF_W.W, CMKT.PC, FMKT.PF, MKT_W.PW, I_CONS.CONS/;
SOLVE ALGEBRAIC USING MCP;
Here is a solution to Example M1_1S.

$TITLE Model M1_2S: Closed 2X2 Economy with Intermediate Inputs and Nesting


$ontext

November, 1995 (revised)


                 Production Sectors          Consumers
   Markets  |    X       Y        W    |       CONS
   ------------------------------------------------------
       PX   |  120     -20     -100    |
       PY   |  -20     120     -100    |
       PW   |                   200    |       -200
       PL   |  -40     -60             |        100
       PK   |  -60     -40             |        100
    ------------------------------------------------------
 
$offtext

SCALAR  TX      Ad-valorem tax rate for X sector inputs /0/;

$ONTEXT

$MODEL: M1_2S

$SECTORS:
        X       ! Activity level for sector X
        Y       ! Activity level for sector Y
        W       ! Activity level for sector W (Hicksian welfare index)

$COMMODITIES:
        PX      ! Price index for commodity X
        PY      ! Price index for commodity Y
        PL      ! Price index for primary factor L
        PK      ! Price index for primary factor K
        PW      ! Price index for welfare (expenditure function)

$CONSUMERS:
        CONS    ! Income level for consumer CONS

*       MPSGE is based on the use of composite CES functions.

*       The following production function is a two-level CES.
*       In the VA, L and K form a Cobb-Douglas aggregate.
*       In the top level, Y and VA(L,K) have an elasticity of 
*       substituion equal to 0.5

*       Syntax issues regarding aggregate labels:
*
*       (i)   Labels may have 1-4 characters.
*       (ii)  These names are not case sensitive ("va:" = "VA:").
*       (iii) Names s: and t: are reserved for top level input and
*               output (substitution and transformation) aggregates.

$PROD:X s:0.5  va:1
        O:PX  Q:120
        I:PY  Q: 20
        I:PL   Q:40  va: A:CONS  T:TX
        I:PK   Q:60  va: A:CONS  T:TX

$PROD:Y s:0.75  va:1
        O:PY   Q:120
        I:PX   Q: 20
        I:PL   Q: 60  va:
        I:PK   Q: 40  va:

$PROD:W s:1
        O:PW   Q:200
        I:PX   Q:100
        I:PY   Q:100

$DEMAND:CONS
        D:PW   Q:200
        E:PL   Q:100
        E:PK   Q:100

$OFFTEXT
$SYSINCLUDE mpsgeset M1_2S

*       Benchmark replication:

        M1_2S.ITERLIM = 0;
$INCLUDE M1_2S.GEN
        SOLVE M1_2S USING MCP;
        M1_2S.ITERLIM = 2000;

*       Fix the wage rate as numeraire: 

        PL.FX = 1;

*       Counterfactual:  100% tax on X sector inputs:

        TX = 1.0;
$INCLUDE M1_2S.GEN
        SOLVE M1_2S USING MCP;

*       Algebraic representation -- note the complexity of two-
*       level CES functions which are automatically generated within
*       MPSGE.


EQUATIONS
        PRF_X   Zero profit for sector X
        PRF_Y   Zero profit for sector Y
        PRF_W   Zero profit for sector W (Hicksian welfare index)

        MKT_X   Supply-demand balance for commodity X
        MKT_Y   Supply-demand balance for commodity Y
        MKT_L   Supply-demand balance for primary factor L
        MKT_K   Supply-demand balance for primary factor L
        MKT_W   Supply-demand balance for aggregate demand

        I_CONS  Income definition for CONS;

PRF_X.. 120 * ( 1/6 * PY**(1-0.5) +
                5/6 * (PL**0.4 * PK**0.6 * (1+TX))**(1-0.5) )**(1/(1-0.5))
                        =E= 120 * PX;

PRF_Y.. 120 * ( 1/6 * PX**(1-0.75) +
                5/6 * (PL**0.6 * PK**0.4)**(1-0.75) )**(1/(1-0.75))  
                        =E= 120 * PY;

PRF_W.. 200 * PX**0.5 * PY**0.5 =E= 200 * PW;

MKT_X.. 120 * X =E= 100 * W * PX**0.5 * PY**0.5 / PX + 20*Y*(PY/PX)**0.75;

MKT_Y.. 120 * Y =E= 100 * W * PX**0.5 * PY**0.5 / PY + 20*X*(PX/PY)**0.5;

MKT_W.. 200 * W =E= CONS / PW;

MKT_L.. 100  =E= 40 * X * (PX/((1+TX)*PL**0.4*PK**0.6))**0.5 
                                * PL**0.4 * PK**0.6 / PL +
                 60 * Y * (PY/(PL**0.6 * PK**0.4))**0.75
                                * PL**0.6 * PK**0.4 / PL;

MKT_K.. 100 =E=  60 * X * (PX/((1+TX)*PL**0.4*PK**0.6))**0.5 
                        * PL**0.4 * PK**0.6 / PK +
                 40 * Y * (PY/(PL**0.6 * PK**0.4))**0.75
                        * PL**0.6 * PK**0.4 / PK;

I_CONS.. CONS =E= 100*PL + 100*PK + 
                  TX * 100 * X * PL**0.4*PK**0.6 * 
                        (PX/((1+TX)*PL**0.4*PK**0.6))**0.5;

MODEL ALGEBRAIC /PRF_X.X, PRF_Y.Y, PRF_W.W, MKT_X.PX, MKT_Y.PY, MKT_L.PL, 
                 MKT_K.PK, MKT_W.PW, I_CONS.CONS /;

*       Check the benchmark:

        X.L=1; Y.L=1; W.L=1; PX.L=1; PY.L=1; PK.L=1; PW.L=1; CONS.L=200;

        TX = 0; 
        SOLVE ALGEBRAIC USING MCP;

*       Solve the same counterfactual:

        TX = 1; 
        SOLVE ALGEBRAIC USING MCP;


$ontext


Exercises for M1_2S:

1. Revise the X sector production to nest Y with K at the bottom
(Cobb-Douglas) level, and then let these inputs trade off with L 
at the top (CES) nest.  

$PROD:X s:0.5  LY:1
        O:PX  Q:120
        I:PY  Q: 20  LY:
        I:PL   Q:40  A:CONS  T:TX
        I:PK   Q:60  LY: A:CONS  T:TX

Before running TX=1 experiment, guess as to whether this revised
nesting will increase or decrease the excess burden of taxation.  Run
the experiment, and see if the results confirm or contradict your
economit economic intuition.

2. Rewrite the algebraic model in accordance with the new nesting
structure, and verify that you obtain identical solution values.
(This exercise is tedious but educational, with a level of
difficulty roughly comparable to 500 piece jig-saw puzzle.

$offtext
Here is a solution to Example M1_2S.

$TITLE Model M1_3S: Closed 2x2 Economy with Joint Production


$ontext

November, 1995 (revised)

Joint production is easily accomodated in the general equilibrium
framework.  Here we revise the data from model M1_1 so that goods
X and Y are each produced by sectors A and B.


                  Production Sectors          Consumers
   Markets   |    A       B        W    |       CONS
   ------------------------------------------------------
        PX   |   80      20     -100    |
        PY   |   20      80     -100    |
        PW   |                   200    |       -200
        PL   |  -40     -60             |        100
        PK   |  -60     -40             |        100
   ------------------------------------------------------

$offtext

*       Declare GAMS parameters which we will use in model
*       specification:

SCALAR  TA      Ad-valorem tax rate for sector A inputs /0/;

$ONTEXT

$MODEL: M1_3S

$SECTORS:
        A       ! Activity level for sector A (80:20 for X:Y)
        B       ! Activity level for sector B (20:80 for X:Y)
        W       ! Activity level for sector W (Hicksian welfare index)

$COMMODITIES:
        PX      ! Price index for commodity X
        PY      ! Price index for commodity Y
        PL      ! Price index for primary factor L
        PK      ! Price index for primary factor K
        PW      ! Price index for welfare (expenditure function)

$CONSUMERS:
        CONS    ! Income level for consumer CONS


*       On the first line of the production declaration, the t: 
*       field specifies the transformation elasticity between outputs.  
*        can be zero but not infinity.  (If the transformation
*       elasticity is infinite, then two activities are warranted -- 
*       one for each output.)

$PROD:A  t:2  s:1
        O:PX    Q:80
        O:PY    Q:20
        I:PL    Q:40.0  A:CONS T:TA
        I:PK    Q:60.0  A:CONS T:TA

$PROD:B t:1.5 s:1
        O:PX    Q:20
        O:PY    Q:80
        I:PL    Q:60
        I:PK    Q:40

$PROD:W s:1
        O:PW    Q:200
        I:PX    Q:100
        I:PY    Q:100
        
$DEMAND:CONS
        D:PW    Q:200
        E:PL    Q:100
        E:PK    Q:100

$OFFTEXT
$SYSINCLUDE mpsgeset M1_3S

*       Fix a numeraire to avoid the work involved in scaling
*       the solution:

        PL.FX = 1;

*       Benchmark replication:

        M1_3S.ITERLIM = 0;
$INCLUDE M1_3S.GEN
        SOLVE M1_3S USING MCP;
        M1_3S.ITERLIM = 2000;

*       Counterfactual: 10% tax on X sector inputs:

        TA = 0.10;
$INCLUDE M1_3S.GEN
        SOLVE M1_3S USING MCP;

*       Counterfactual: 100% tax on X sector inputs:

        TA = 1.00;
$INCLUDE M1_3S.GEN
        SOLVE M1_3S USING MCP;

EQUATIONS
        PRF_A   Zero profit for sector X
        PRF_B   Zero profit for sector Y
        PRF_W   Zero profit for sector W (Hicksian welfare index)

        MKT_X   Supply-demand balance for commodity X
        MKT_Y   Supply-demand balance for commodity Y
        MKT_L   Supply-demand balance for primary factor L
        MKT_K   Supply-demand balance for primary factor L
        MKT_W   Supply-demand balance for aggregate demand

        I_CONS  Income definition for CONS;

*       Write the profit constraints as inequalities -- the tax
*       can cause sector A to shut down completely:

PRF_A.. 100 * PL**0.4 * PK**0.6 * (1+TA) =G= 
        100 * (0.8 * PX**(1+2.0) + 0.2 * PY**(1+2.0))**(1/(1+2.0));

PRF_B.. 100 * PL**0.6 * PK**0.4 =G= 
        100 * (0.2 * PX**(1+1.5) + 0.8 * PY**(1+1.5))**(1/(1+1.5));

PRF_W.. 200 * PX**0.5 * PY**0.5 =E= 200 * PW;

MKT_X.. 80 * A * (PX/(0.8*PX**(1+2.0)+0.2*PY**(1+2.0))**(1/(1+2.0)))**2
     +  20 * B * (PX/(0.2*PX**(1+1.5)+0.8*PY**(1+1.5))**(1/(1+1.5)))**1.5
        =E= 100 * W * PX**0.5 * PY**0.5 / PX;

MKT_Y.. 20 * A * (PY/(0.8*PX**(1+2.0)+0.2*PY**(1+2.0))**(1/(1+2.0)))**2.0
     +  80 * B * (PY/(0.2*PX**(1+1.5)+0.8*PY**(1+1.5))**(1/(1+1.5)))**1.5
        =E= 100 * W * PX**0.5 * PY**0.5 / PY;

MKT_W.. 200 * W =E= CONS / PW;

MKT_L.. 100  =E= 40 * A * PL**0.4 * PK**0.6 / PL +
                 60 * B * PL**0.6 * PK**0.4 / PL;

MKT_K.. 100 =E= 60 * A * PL**0.4 * PK**0.6 / PK +
                40 * B * PL**0.6 * PK**0.4 / PK;

I_CONS.. CONS =E= 100*PL + 100*PK + TA*100*A*PL**0.4*PK**0.6;

MODEL ALGEBRAIC /PRF_A.A, PRF_B.B, PRF_W.W, MKT_X.PX, MKT_Y.PY, MKT_L.PL, 
                 MKT_K.PK, MKT_W.PW, I_CONS.CONS /;

*       Check the benchmark:

        A.L=1; B.L=1; W.L=1; PX.L=1; PY.L=1; PK.L=1; PW.L=1; CONS.L=200;

        TA = 0; 
        ALGEBRAIC.ITERLIM = 0;
        SOLVE ALGEBRAIC USING MCP;
        ALGEBRAIC.ITERLIM = 2000;

*       Solve the same counterfactuals:

        TA = 0.10;
        SOLVE ALGEBRAIC USING MCP;

        TA = 1.00;
        SOLVE ALGEBRAIC USING MCP;

$ontext


Exercise for M1_3S:      


Revise the model structure to represent an infinite elasticity of
transformation in sector A.  You will need to rewrite the model with
two sectors A1 and A2.  These will have identical cost structure, one
producing good X and the other producing good Y.

$offtext
Here is a solution to Example M1_3S.

$TITLE Model M1_4S: Close 2x2 economy with labor-leisure choice


$ontext

November, 1995 (revised)

In this model, the consuer is endowed with 200 units of time.  In
the benchmark equilibrium, 100 units of time are provided to the
market and 100 units are "purchased" by the consumer.  This formulation
provides an elastic labor supply.

                   Production Sectors          Consumers
    Markets   |    X       Y        W    |       CONS
    ------------------------------------------------------
         PX   |  100             -100    |
         PY   |          100     -100    |
         PW   |                   300    |       -300
         PL   |  -40     -60     -100    |        200
         PK   |  -60     -40             |        100
    ------------------------------------------------------

$offtext

*       GAMS parameters which we will use in model specification:

SCALAR  TX      Ad-valorem tax rate for X sector inputs /0/,
      ESUBL Elasticity of substitution for leisure vs consumption /0.5/;

$ONTEXT

$MODEL: M1_4S

$SECTORS:
        X       ! Activity level for sector X
        Y       ! Activity level for sector Y
        W       ! Activity level for sector W (Hicksian welfare index)

$COMMODITIES:
        PX      ! Price index for commodity X
        PY      ! Price index for commodity Y
        PL      ! Price index for primary factor L
        PK      ! Price index for primary factor K
        PW      ! Price index for welfare (expenditure function)

$CONSUMERS:
        CONS    ! Income level for consumer CONS

$PROD:X s:1
        O:PX  Q:100
        I:PL   Q:40  A:CONS T:TX
        I:PK   Q:60  A:CONS T:TX

$PROD:Y s:1
        O:PY  Q:100
        I:PL  Q: 60
        I:PK  Q: 40

$PROD:W s:ESUBL  a:1
        O:PW  Q:300
        I:PX  Q:100  a:
        I:PY  Q:100  a:
        I:PL  Q:100

$DEMAND:CONS
        D:PW  Q:300
        E:PL  Q:200
        E:PK  Q:100
$OFFTEXT
$SYSINCLUDE mpsgeset M1_4S

*       Replicate the benchmark:

        M1_4S.ITERLIM = 0;
$INCLUDE M1_4S.GEN
        SOLVE M1_4S USING MCP;
        M1_4S.ITERLIM = 2000;

*       Solve a counterfactual: 100% tax on X:

        TX = 1;
$INCLUDE M1_4S.GEN
        SOLVE M1_4S USING MCP;

$ontext


Exercises for M1_4S:


(i) Derive an analytic expression for the elasticity of labor supply as a
function of ESUBL and the benchmark value shares.  Determine values of
ESUBL consistent with labor supply elasticities equal to -0.10, 0, 0.10
and 0.20.

(ii) Plot Exess burden versus the price elasticity of labor supply over
the range -0.10 to 0.20.

$offtext

$TITLE Model M1_4AS: Closed 2x2 economy with labor-leisure (alt. formulation)


$ontext

November, 1995 (revised)


Activity T transforms leisure into labor supply:

                  Production Sectors               Consumers
   Markets   |    A       B        W       T  |       CONS
   ---------------------------------------------------------
        PX   |   80      20     -100          |
        PY   |   20      80     -100          |
        PW   |                   300          |       -300
        PLS  |  -40     -60              100  |        
        PL   |                  -100    -100  |        200
        PK   |  -60     -40                   |        100
   ---------------------------------------------------------

$offtext

*       GAMS parameters which we will use in model specification:

SCALAR  TX      Ad-valorem tax rate for X sector inputs /0/;

$ONTEXT
$MODEL:M1_4AS

$SECTORS:
        X       ! Activity level for sector X
        Y       ! Activity level for sector Y
        T       ! Labor supply  
        W       ! Activity level for sector W (Hicksian welfare index)

$COMMODITIES:
        PX      ! Price index for commodity X
        PY      ! Price index for commodity Y
        PL      ! Price index for leisure
        PLS     ! Price index for labor supply (factor L input)
        PK      ! Price index for primary factor K
        PW      ! Price index for welfare (expenditure function)

$CONSUMERS:
        CONS    ! Income level for consumer CONS

$PROD:X s:1
        O:PX  Q:100
        I:PLS Q:40 A:CONS T:TX
        I:PK  Q:60 A:CONS T:TX

$PROD:Y s:1
        O:PY  Q:100
        I:PLS Q:60
        I:PK  Q:40

$PROD:T
        O:PLS Q:100
        I:PL  Q:100

$PROD:W s:0.5  cons:1
        O:PW   Q:300
        I:PX   Q:100  cons:
        I:PY   Q:100  cons:
        I:PL   Q:100

$DEMAND:CONS
        D:PW   Q:300
        E:PL   Q:200
        E:PK   Q:100

$OFFTEXT
$SYSINCLUDE mpsgeset M1_4AS

*       Replicate the benchmark:

        M1_4AS.ITERLIM = 0;
$INCLUDE M1_4AS.GEN
        SOLVE M1_4AS USING MCP;
        M1_4AS.ITERLIM = 2000;

*       Solve a counter-factual:

        TX=1;
$INCLUDE M1_4AS.GEN
        SOLVE M1_4AS USING MCP;
Here is a solution to Example M1_4S.

$TITLE Model M1_5S: Closed 2x2 Economy with Specific Factors


$ontext

November, 1995 (revised)

Sector-specific inputs can represent decreasing returns to scale.
Rents accrue to a ficticious factor called "capital".

                   Production Sectors          Consumers
    Markets   |    X       Y        W    |       CONS
    ------------------------------------------------------
         PX   |  100             -100    |
         PY   |          100     -100    |
         PW   |                   200    |       -200
         PL   |  -50     -50             |        100
         PKX  |  -50                     |         50
         PKY  |          -50             |         50
    ------------------------------------------------------

$offtext

*       Declare GAMS parameters which we will use in model:

SCALAR  TX      Ad-valorem tax rate for X sector inputs /0/;

$ONTEXT

$MODEL:M1_5S

$SECTORS:
        X       ! Activity level for sector X
        Y       ! Activity level for sector Y
        W       ! Activity level for sector W (Hicksian welfare index)

$COMMODITIES:
        PW      ! Price index for welfare (expenditure function)
        PX      ! Price index for commodity X
        PY      ! Price index for commodity Y
        PL      ! Price index for primary factor L
        PKX     ! Price index for sector-specific input for sector X
        PKY     ! Price index for sector-specific input for sector Y

$CONSUMERS:
        CONS    ! Income level for consumer CONS

$PROD:X s:1
        O:PX   Q:100
        I:PL   Q: 50  A:CONS T:TX
        I:PKX  Q: 50  A:CONS T:TX

$PROD:Y s:1
        O:PY   Q:100
        I:PL   Q: 50
        I:PKY  Q: 50

$PROD:W s:1
        O:PW   Q:200
        I:PX   Q:100
        I:PY   Q:100

*       Note: If we wanted to think of the specific factor earnings
*       as the rents of firms with decreasing returns, we could
*       introduce separate agents with endowments equal to the
*       specific factors returns to the specific factors would then
*       be the "profits of the firms see exercise 1.6 for multiple
*       consumers.

$DEMAND:CONS
        D:PW  Q:200
        E:PL  Q:100
        E:PKX Q:50
        E:PKY Q:50

$OFFTEXT
$SYSINCLUDE mpsgeset M1_5S

*       Benchmark replication:

        M1_5S.ITERLIM = 0;
$INCLUDE M1_5S.GEN
        SOLVE M1_5S USING MCP;
        M1_5S.ITERLIM = 2000;

*       Solve a counterfactual:

        TX = 1;
$INCLUDE M1_5S.GEN
        SOLVE M1_5S USING MCP;

$ontext


Exercises for M1_5S:


(1) Evaluate the price elasticity of supply for good X at the benchmark
point and then design an experiment to measure this elasticity numerically.

(2) Convert sector X from Cobb-Douglas to CES and set the elasticity of
substitution between PL and PKX so that the benchmark price elasticity of
supply equals an assumed value:

SCALAR      ES_X  Elasticity of supply for good X
      ESUB  Elasticity of substitution for good X;

ESUB = ;

$offtext
Here is a solution to Example M1_5S.

$TITLE Model M1_6S: Closed 2x2 Economy with Two Consumers


$ontext

November, 1995 (revised)


Two consumers in a closed economy.

                  Production Sectors               Consumers
   Markets   |    X       Y      WA      WB  |     A      B
   ----------------------------------------------------------
        PX   |  100             -25     -75  |
        PY   |          100     -75     -25  |
        PWA  |                  100          |  -100    
        PWB  |                          100  |          -100
        PL   |  -40     -60                  |    90      10
        PK   |  -60     -40                  |    10      90
   ----------------------------------------------------------

$offtext

*       Declare GAMS parameters which we will use in model:

SCALAR  TX      Ad-valorem tax rate for X sector inputs /0/;

$ONTEXT

$MODEL:M1_6S

$SECTORS:
        X       ! Activity level for sector X
        Y       ! Activity level for sector Y
        WA      ! Welfare index for consumer A
        WB      ! Welfare index for consumer B

$COMMODITIES:
        PX      ! Price index for commodity X
        PY      ! Price index for commodity Y
        PL      ! Price index for primary factor L
        PK      ! Price index for primary factor K
        PWA     ! Price index for consumer A welfare (expenditure function)
        PWB     ! Price index for consumer B welfare (expenditure function)

$CONSUMERS:
        CONSA   ! Income level for consumer A
        CONSB   ! Income level for consumer B

*       More than one tax may be levied on a single transaction with
*       revenues acruing to different agents.  As specified here, the
*       ad-valorem tax rate on inputs to sector X equals 2*TX.  Half
*       of the tax revenue acrues to A and half to B.

$PROD:X s:1
        O:PX    Q:100
        I:PL    Q: 40 A:CONSA T:TX A:CONSB T:TX
        I:PK    Q: 60 A:CONSA T:TX A:CONSB T:TX

$PROD:Y s:1
        O:PY    Q:100
        I:PL    Q: 60
        I:PK    Q: 40

$PROD:WA s:1
        O:PWA   Q:100
        I:PX    Q:25
        I:PY    Q:75

$PROD:WB s:1
        O:PWB   Q:100
        I:PX    Q:75
        I:PY    Q:25

$DEMAND:CONSA
        D:PWA   Q:100
        E:PL    Q: 90
        E:PK    Q: 10

$DEMAND:CONSB
        D:PWB   Q:100
        E:PL    Q: 10
        E:PK    Q: 90

$OFFTEXT
$SYSINCLUDE mpsgeset M1_6S

        M1_6S.ITERLIM = 0;
$INCLUDE M1_6S.GEN
        SOLVE M1_6S USING MCP;
        M1_6S.ITERLIM = 2000;

*       Solve a counterfactual:

        TX = 0.5;
$INCLUDE M1_6S.GEN
        SOLVE M1_6S USING MCP;

$ontext


Exercises for M1_6S:


(1) Interpret the solution --- is either agent in favor of the tax.
(Hint: look at the welfare indices, preferences and endowments.)

(2) Use the model to ascertain the utility possibility frontier for
this economy, with TX as the sole redistributive instrument.  Compare
this frontier with the Pareto-optimal frontier based on lump-sum
redistribution.  This assignment requires several calculations and use of
the GAMS LOOP statement.  The following code generates 4 equilbria:

SET     SC  Scenarios /SC1*SC4/;

PARAMETER       TXVALUE(SC)     Values of TX by scenario /
                        SC1 -0.5, SC2 -0.1, SC3 0.1, SC4 0.5 /,

                WELFARE(SC,H)   Welfare indices by scenario;

LOOP(SC,

*       Install a tax rate for the current scenario:

        TX = TXVALUE(SC);

$INCLUDE M1_6S.GEN
        SOLVE M1_6S USING MCP;

*       Extract the solution value:

        WELFARE(SC,"A") = WA.L;
        WELFARE(SC,"B") = WB.L;

);

DISPLAY WELFARE;

$offtext
Here is a solution to Example M1_6S.

$TITLE Model M1_7S: Closed 2x2 Economy with an Unprofitable Activity


$ontext

November, 1995 (revised)

                  Production Sectors          Consumers
   Markets   |    X       Y        W    |       CONS
   ------------------------------------------------------
        PX   |  100             -100    |
        PY   |          100     -100    |
        PW   |                   200    |       -200
        PL   |  -40     -60             |        100
        PK   |  -60     -40             |        100
   ------------------------------------------------------

Activity Z is unprofitable at initial equilibrium prices.  It is
therefore not operated, and we cannot infer its technical properties
from the benchmark social accounting data.  

In situations like this, we must use other information such as
engineering cost estimates to specify the unobserved technology.
Here, we will assume that Z is very similar to sector X but roughly
10% less efficient.  (Can you guess how this will affect the excess
burden of a tax on sector X?)

$offtext

*       Declare GAMS parameters which we will use in model:

SCALAR  TX      Ad-valorem tax rate for X sector inputs /0/;

$ONTEXT

$MODEL:M1_7S

$SECTORS:
        X       ! Activity level for sector X
        Y       ! Activity level for sector Y
        W       ! Activity level for sector W (Hicksian welfare index)
        Z       ! Alternative activity for producing X.

$COMMODITIES:
        PX      ! Price index for commodity X
        PY      ! Price index for commodity Y
        PL      ! Price index for primary factor L
        PK      ! Price index for primary factor K
        PW      ! Price index for welfare (expenditure function)

$CONSUMERS:
        CONS    ! Income level for consumer CONS

$PROD:X s:1
        O:PX   Q:100
        I:PL   Q: 40  A:CONS T:TX
        I:PK   Q: 60  A:CONS T:TX

$PROD:Y s:1
        O:PY  Q:100
        I:PL   Q:60
        I:PK   Q:40

*       Note that at the benchmark (when all prices equal unity), the
*       cost of Z inputs equals 1.1 and the value of outputs equals 1.0.
*       An economic equilibrium prevails provided that this sector is
*       idle:

$PROD:Z s:1
        O:PX    Q: 1.00
        I:PL    Q: 0.44
        I:PK    Q: 0.66

$PROD:W s:1
        O:PW    Q:200
        I:PX    Q:100
        I:PY    Q:100

$DEMAND:CONS
        D:PW    Q:200
        E:PL    Q:100
        E:PK    Q:100

$OFFTEXT
$SYSINCLUDE mpsgeset M1_7S

*       Check the benchmark calibration --- after setting the activity
*       level for Z equal to 0:

        Z.L = 0;

        M1_7S.ITERLIM = 0;
$INCLUDE M1_7S.GEN
        SOLVE M1_7S USINCP MCP;
        M1_7S.ITERLIM = 2000;


*       Lets levy a high tax on sector X and see what happens:

        TX = 1.00;
$INCLUDE M1_7S.GEN
        SOLVE M1_7S USINCP MCP;

$ontext


Exercise for M1_7S:


(1) Plot the Laffer curve for TX in this model. Compare your
results with the curve from a model in which sector Z does
not exist.

An activity may be omitted from the model by fixing its value to 0,
that is by specifying:

        Z.FX=0; 

If you subsequently want to compute an equilibrium in which Z is not
fixed, you may enter:

        Z.LO = 0;
        Z.UP = +INF;


(2) Compare results with a third model in which sectoral capital
stocks are differentiated (replace PK by PKX and PKY). Do the same
comparison plotting welfare cost versus TX.

$offtext
Here is a solution to Example M1_7S.

$TITLE Model M1_8S: Closed 2x2 Economy -- Stone Geary (LES) Preferences


$ontext

November, 1995 (revised)


This model poses a simple calibration problem.


The benchmark data is identical to problem M1_1:

                  Production Sectors          Consumers
   Markets   |    X       Y        W    |       CONS
   ------------------------------------------------------
        PX   |  100             -100    |
        PY   |          100     -100    |
        PW   |                   200    |       -200
        PL   |  -40     -60             |        100
        PK   |  -60     -40             |        100
   ------------------------------------------------------

We want to produce a benchmark in which the income elasticity of
demand for X equals 0.75.

Begin with a utility function of the form:

        U(X,Y) = a ln(X - X*) + (1-a) ln(Y)             

where X* is a "minimum consumption level"

Demand function for X is given by:

                   a (I - PX X*)
        X = X*  +  ------------- 
                        PX

in which I is income and PX is the price of X.  The income share of
good X is then:

                PX X      (a I + (1-a) PX X*) 
                ----   =  --------------------  ,
                  I                I


and the income elasticity of demand is give by:

                 I    d X            a I
                ---   ---   =   -----------------  .
                 X    d I       a I + (1-a) PX X*

Knowing the share from the data and the chosen income elasticity, we
can solve for X*/I (with PX=1).  This level of X* is then specified
as a negative endowment for the consumer, and (X - X*) is the value
used in specifying the utility function.

$offtext

*       First, declare GAMS parameters which we will use in model
*       specification.

SCALAR ENDOW  Economy factor endowment index /1/;

$ONTEXT

$MODEL:M1_8S

$SECTORS:
        X       ! Activity level for sector X
        Y       ! Activity level for sector Y
        W       ! Activity level for sector W (Hicksian welfare index)

$COMMODITIES:
        PX      ! Price index for commodity X
        PY      ! Price index for commodity Y
        PL      ! Price index for primary factor L
        PK      ! Price index for primary factor K
        PW      ! Price index for welfare (expenditure function)

$CONSUMERS:
        CONS    ! Income level for consumer CONS

$PROD:X s:1
        O:PX    Q:100
        I:PL    Q: 40
        I:PK    Q: 60

$PROD:Y s:1
        O:PY    Q:100
        I:PL    Q: 60
        I:PK    Q: 40

$PROD:W s:1
        O:PW    Q:160
        I:PX    Q: 60
        I:PY    Q:100

$DEMAND:CONS
        D:PW    Q:160
        E:PL    Q:(100*ENDOW)
        E:PK    Q:(100*ENDOW)
        E:PX    Q:-40

$OFFTEXT
$SYSINCLUDE mpsgeset M1_8S

*       Benchmark replication:

        M1_8S.ITERLIM = 0;
$INCLUDE M1_8S.GEN
        SOLVE M1_8S USING MCP;
        M1_8S.ITERLIM = 2000;

*       Counterfactual: double the factor endowment.

        ENDOW = 2;
$INCLUDE M1_8S.GEN
        SOLVE M1_8S USING MCP;

$ontext


Exercises for M1_8S:


(1) Modify the program to read the income elasticity of demand for good X,
compute the subsistence demand and automatically calibrate the model.

(2) Generate a sequence of equilibria and measure the income elasticity of
demand for good X over the range of income from 1 to 10 times the
benchmark level.

(3) Replace the Cobb-Douglas utility function by a general CES utility 
function with elasticity of substitution SIGMA.  Determine the subsistence
demand which is consistent with a given income elasticity of demand for X.
Generate plots of the income elasticity of demand for good X to compare
with results from question (2), taking SIGMA = 0.5 and SIGMA = 2.0.

$offtext
Here is a solution to Example M1_8S.