gemmge.gms : GEMTAP: A general equilibrium model for tax policy

Description

This dataset based on an update of the original model
to a 1983 benchmark by Charles Schultz.


Large Model of Types : MPSGE mcp


Category : GAMS Model library


Main file : gemmge.gms

$title GEMTAP: A general Equilibrium Model for Tax Policy (GEMMGE,SEQ=146)

$onText
This dataset based on an update of the original model
to a 1983 benchmark by Charles Schultz.


Balard, C, Fullerton Don, Shoven, J, and Whalley, J, A General
Equilibrium Model for Tax Policy Evaluation. University of
Chicago Press, 1985.

Keywords: mixed complementarity problem, general equilibrium model, tax policy,
          GAMS - MPSGE framework, fiscal policy
$offText

* Set definitions and input data for 1983 version of GEMTAP.
Set
   S 'sectors (producer goods)'
     / AGRI,  MINES, CRUDE, CONST, FOOD,  TEXTL, PAPER
       REFIN, CHEM,  LUMBR, METLS, EQUIP, VEHCL, TRNSP
       TRADE, FNANC, REALT, SRVCS, GOVT                /
   G 'consumer goods'
     / FOOD,  ALCHL, TOBAC, UTIL,  HOUSG, FRNSH, APPL
       CLTH,  TRNSP, VEHCL, SERVC, BNKNG, READG, N_DUR
       PETRL, HLTH,  EDUC,  SAVNG                      /;

Alias (S,SS), (G,GG);

Set
   HH     'all households'           / H1*H14, HH2*HH14 /
   H(HH)  'aggregated households'    / HH2*HH14 /
   DH(HH) 'disaggregated households' / H1*H14   /;

* THE FOLLOWING ASSIGNMENT OMITS H1 WHICH APPEARS TO BE
* A RESIDUAL ACCOUNT IN THIS DATA SET:
Set HMAP(DH,H) 'mapping from disaggregated households'
               / H2.HH2, H3.HH3,   H4.HH4,   H5.HH5,   H6.HH6,   H7.HH7, H8.HH8
                 H9.HH9, H10.HH10, H11.HH11, H12.HH12, H13.HH13, H14.HH14     /;

Scalar
   GDK 'government capital purchases.     (p. 118)' / 1.65084E+05 /
   GSK 'government capital ownership.  (table 6.3)' / 1.13409E+05 /
   GDL 'government labor demand.          (p. 107)' / 2.72392E+05 /
   GTL 'labor tax payments by government. (p. 107)' / 4.41080E+04 /;

Parameter
   COUNT(HH) 'population count'
             / H1   0.347, H2   1.183, H3   3.753, H4   8.457, H5  13.328
               H6  13.988, H7  12.876, H8  11.523, H9  18.538, H10 13.362
               H11 16.565, H12  4.501, H13  2.725, H14  0.573             /
   DK(S)     'capital payments by sector. (table 4.7)'
             / AGRI  1.50670E+04, MINES 9.14909E+02, CRUDE 2.99886E+03
               CONST 4.99169E+03, FOOD  6.71724E+03, TEXTL 2.97874E+03
               PAPER 4.31363E+03, REFIN 1.39132E+04, CHEM  4.78283E+03
               LUMBR 2.57358E+03, METLS 2.78550E+03, EQUIP 1.43345E+03
               VEHCL 2.49335E+02, TRNSP 3.31062E+04, TRADE 2.77352E+04
               FNANC 2.91767E+03, REALT 1.57818E+05, SRVCS 2.90328E+04
               GOVT  1.23209E+04                                       /
   SK(HH)    'capital ownership by household. (table 6.2)'
             / H1 -1.15989E+04, H2  1.32289E+02, H3  1.40763E+03, H4 5.82356E+03
               H5  1.51394E+04, H6  2.17343E+04, H7  2.44363E+04, H8 2.57096E+04
               H9  4.68859E+04, H10 4.02364E+04, H11 6.74481E+04
               H12 3.33326E+04, H13 4.47871E+04, H14 6.28510E+04               /

Scalar SKTOT 'total capital stock';
SKTOT = sum(H, SK(H));

Parameter
   DL(S)   'labor demand by sector. (table 4.1)'
           / AGRI  1.92060E+04, MINES 1.18360E+04, CRUDE 1.92690E+04
             CONST 1.12095E+05, FOOD  3.57680E+04, TEXTL 2.79840E+04
             PAPER 4.39730E+04, REFIN 6.36500E+03, CHEM  4.58740E+04
             LUMBR 2.59050E+04, METLS 1.82051E+05, EQUIP 3.12680E+04
             VEHCL 2.51430E+04, TRNSP 1.46020E+05, TRADE 3.13381E+05
             FNANC 1.02262E+05, REALT 1.68840E+04, SRVCS 3.73269E+05
             GOVT  3.07730E+04                                       /
   SL(HH)  'labor supply by household. (table 6.1)'
           / H1 -4.07035E+02, H2  9.72331E+02, H3  4.94308E+03, H4  2.55985E+04
             H5  8.32951E+04, H6  1.27887E+05, H7  1.53337E+05, H8  1.72699E+05
             H9  3.26104E+05, H10 2.86196E+05, H11 3.83643E+05, H12 1.19378E+05
             H13 1.02400E+05, H14 5.56721E+04                                  /
   ZTA(HH) 'labor endowment : supply ratios by household.'
           / H1  1.26791E+00, H2  1.27168E+00, H3  1.33304E+00, H4  1.40639E+00
             H5  1.48221E+00, H6  1.53994E+00, H7  1.58088E+00, H8  1.61328E+00
             H9  1.64773E+00, H10 1.68873E+00, H11 1.71083E+00, H12 1.69191E+00
             H13 1.63084E+00, H14 1.34709E+00                                 /;

* FOR INCREASED COMPARABILITY WITH 1973 DATASET, WE USE A VALUE
* OF 1.75 FOR ALL HOUSEHOLDS:
ZTA(HH) = 1.75;

Scalar ELS 'elasticity of labor supply' / 0.15 /;

Parameter
   PIT(HH) 'income tax payments by household. (table 6.5)'
           / H1   4.70693E+03, H2  -4.78527E+01, H3  -4.83605E+02
             H4  -1.38173E+03, H5  -8.30128E+02, H6   2.07466E+03
             H7   5.51451E+03, H8   9.36992E+03, H9   2.08846E+04
             H10  2.25915E+04, H11  3.28106E+04, H12  1.08714E+04
             H13  1.28299E+04, H14  1.30979E+04                   /
   TAU(HH) 'marginal tax rates by household. (table 5.8)'
           / H1   7.30000E-02, H2   1.00000E-03, H3   2.00000E-02
             H4   6.10000E-02, H5   1.11000E-01, H6   1.39000E-01
             H7   1.65000E-01, H8   1.95000E-01, H9   2.19000E-01
             H10  2.56000E-01, H11  2.93000E-01, H12  3.43000E-01
             H13  3.96000E-01, H14  4.01000E-01                   /
   TRN(HH) 'transfer levels by household (from government). (table 6.5)'
           / H1   4.62898E+02, H2   7.16898E+02, H3   9.99424E+03
             H4   2.82718E+04, H5   4.06371E+04, H6   4.04673E+04
             H7   3.55249E+04, H8   2.80239E+04, H9   4.10061E+04
            H10   2.63098E+04, H11  3.01152E+04, H12  7.94427E+03
            H13   4.27825E+03, H14  8.37153E+02                   /
   TC(G)   'consumption tax payments by good. (able 5.4)'
           / FOOD  1.02623E+02, ALCHL 3.43401E+01, TOBAC 4.92577E+01
             UTIL  5.27143E+01, FRNSH 6.82659E+01, APPL  5.61957E+01
             CLTH  7.82538E+02, TRNSP 1.29003E+00, VEHCL 1.30150E+02
             SERVC 8.53633E+00, READG 1.38249E+02, N_DUR 9.66488E+01
             PETRL 7.99788E+01, HLTH  4.19992E+01                    /;

*-----------------------------------------------------------------------------
$onText
THE FOLLOWING THREE VECTORS WHICH APPEAR IN THE 83 DATASET ARE CONVERTED
TO PERCENTAGE RATE FORM IN TABLE TAXRATE:

Parameter
   TXO(S)
   / AGRI  5.42000E+02, MINES 2.00500E+03, CRUDE 1.61310E+04, CONST 2.34900E+03
     FOOD  1.12890E+04, TEXTL 1.69000E+02, PAPER 7.52000E+02, REFIN 9.20100E+03
     CHEM  1.45500E+03, LUMBR 4.76000E+02, METLS 2.48100E+03, EQUIP 5.41000E+02
     VEHCL 7.61000E+02, TRNSP 2.03530E+04, TRADE 8.50440E+04, FNANC 8.57600E+03
     REALT 1.76200E+04, SRVCS 8.45000E+03                                      /
   TK(S)
   / AGRI  1.01810E+04, MINES 1.34009E+03, CRUDE 5.18414E+03, CONST 4.60731E+03
     FOOD  7.47776E+03, TEXTL 3.00226E+03, PAPER 5.31437E+03, REFIN 9.16883E+03
     CHEM  7.16117E+03, LUMBR 3.09542E+03, METLS 1.15835E+04, EQUIP 1.10355E+03
     VEHCL 1.35867E+03, TRNSP 3.50988E+04, TRADE 2.69098E+04, FNANC 2.22403E+04
     REALT 1.09969E+05, SRVCS 1.90732E+04, GOVT  3.35605E+03                   /
   TL(S)
   / AGRI  2.67400E+03, MINES 1.26600E+03, CRUDE 2.18700E+03, CONST 1.45680E+04
     FOOD  5.23400E+03, TEXTL 4.68000E+03, PAPER 5.97300E+03, REFIN 7.68000E+02
     CHEM  6.86600E+03, LUMBR 1.18640E+04, METLS 2.51540E+04, EQUIP 3.27600E+03
     VEHCL 3.93400E+03, TRNSP 1.86950E+04, TRADE 4.33670E+04, FNANC 1.29190E+04
     REALT 2.52100E+03, SRVCS 4.43190E+04, GOVT  1.34930E+04                  /;

Parameter TAXRATE(S,*) 'taxes (%) (tables 4.13 4.7 and 4.1 respectively)';
CODE:
TAXRATE(S,"TXO") = 100*TXO(S)/Y(S);
TAXRATE(S,"TL")  = 100*TL(S)/DL(S);
TAXRATE(S,"TK")  = 100*TK(S)/DK(S);

display TAXRATE;

Table TKVAL(S,*) 'sectoral capital tax rates in 73 and 83'
                TK73    TK83
   AGRI      54.0162   67.572
   MINES     95.0472  146.472
   CRUDE    101.5675  172.870
   CONST    210.4031   92.300
   FOOD     346.9550  111.322
   TEXTL    253.4060  100.790
   PAPER    162.5490  123.199
   REFIN     46.3458   65.900
   CHEM     186.6596  149.727
   LUMBR     91.2334  120.277
   METLS    171.6036  415.850
   EQUIP   2356.8627   76.986
   VEHCL    128.7486  544.917
   TRNSP    170.1676  106.019
   TRADE    185.0761   97.024
   FNANC    199.2051  762.262
   REALT     62.9748   69.681
   SRVCS     86.0299   65.695
   GOVT      26.3711   27.239;
$offText
*-----------------------------------------------------------------------------

Table TAXRATE(S,*) 'taxes (%) (tables 4.13 4.7 and 4.1 respectively)'
              TXO      TL       TK
   AGRI     0.311  13.923   67.572
   MINES    4.529  10.696  146.472
   CRUDE   19.296  11.350  172.870
   CONST    0.775  12.996   92.300
   FOOD     4.016  14.633  111.322
   TEXTL    0.133  16.724  100.790
   PAPER    0.454  13.583  123.199
   REFIN    4.698  12.066   65.900
   CHEM     0.618  14.967  149.727
   LUMBR    0.427  45.798  120.277
   METLS    0.337  13.817  415.850
   EQUIP    0.700  10.477   76.986
   VEHCL    0.682  15.647  544.917
   TRNSP    3.760  12.803  106.019
   TRADE   12.991  13.838   97.024
   FNANC    3.585  12.633  762.262
   REALT    3.650  14.931   69.681
   SRVCS    1.080  11.873   65.695
   GOVT            43.847   27.239;

Parameter GSE(S) 'government commodity endowments. (table 6.3)';
GSE(S) = 0;

Parameter
   GD(S)    'government commodity demands. (table 6.4)'
            / AGRI  5.74182E+02, MINES 1.55043E+02, CRUDE 3.63664E+02
              CONST 4.50692E+04, FOOD  2.67746E+03, TEXTL 8.95648E+02
              PAPER 4.45026E+03, REFIN 5.48673E+03, CHEM  4.57070E+03
              LUMBR 1.12229E+03, METLS 1.78503E+05, EQUIP 1.93211E+04
              VEHCL 2.35552E+03, TRNSP 1.46367E+04, TRADE 4.89975E+03
              FNANC 3.05061E+03, REALT 3.17531E+03, SRVCS 3.04402E+04
              GOVT  6.39613E+02                                       /
   VM(S)    'import levels by sectoral commodity. (table 5.1)'
            / AGRI  3.84500E+03, MINES 3.49000E+03, CRUDE 6.61250E+04
              FOOD  1.39690E+04, TEXTL 1.60500E+04, PAPER 6.58100E+03
              REFIN 2.23780E+04, CHEM  1.53900E+04, LUMBR 8.32600E+03
              METLS 1.01264E+05, EQUIP 5.50100E+03, VEHCL 2.90780E+04
              TRNSP 5.29900E+03, TRADE 7.80800E+03, FNANC 7.43000E+02
              SRVCS 1.74900E+03                                       /
   VX(S)    'export levels by sectoral commodity. (table 5.1)'
            / AGRI  2.14831E+04, MINES 5.09111E+03, CRUDE 1.45680E+03
              CONST 3.71680E+01, FOOD  1.27640E+04, TEXTL 4.89076E+03
              PAPER 4.99139E+03, REFIN 5.75651E+03, CHEM  2.02557E+04
              LUMBR 5.10924E+03, METLS 1.46532E+05, EQUIP 1.51174E+04
              VEHCL 1.07298E+04, TRNSP 1.52072E+04, TRADE 2.29182E+04
              FNANC 8.49425E+02, REALT 5.32137E+03, SRVCS 9.01913E+03
              GOVT  6.61772E+01                                       /
   EL(HH)   'elasticity between leisure and consumption. (table 6.8)'
            / H1    5.69000E-01, H2    6.74000E-01, H3    7.77000E-01
              H4    8.38000E-01, H5    8.86000E-01, H6    9.48000E-01
              H7    9.83000E-01, H8    9.90000E-01, H9    1.02700E+00
              H10   1.00500E+00, H11   9.69000E-01, H12   7.38000E-01
              H13   7.38000E-01, H14   7.38000E-01                    /
   EC(HH)   'elasticity in current consumption. (table 6.9)'
            / H1    1.26791E+00, H2    1.27168E+00, H3    1.33304E+00
              H4    1.40639E+00, H5    1.48221E+00, H6    1.53994E+00
              H7    1.58088E+00, H8    1.61328E+00, H9    1.64773E+00
              H10   1.68873E+00, H11   1.71083E+00, H12   1.69191E+00
              H13   1.63084E+00, H14   1.34709E+00                    /
   EKL(S)   'labor-capital elasticity. (table 6.11)'
            / AGRI  1.92123E+00, MINES 1.00000E+00, CRUDE 1.00000E+00
              CONST 1.00000E+00, FOOD  1.68095E+00, TEXTL 1.12108E+00
              PAPER 1.11995E+00, REFIN 1.38332E+00, CHEM  1.04308E+00
              LUMBR 1.10632E+00, METLS 1.55352E+00, EQUIP 1.29132E+00
              VEHCL 1.09135E+00, TRNSP 1.00000E+00, TRADE 1.00000E+00
              FNANC 1.00000E+00, REALT 1.00000E+00, SRVCS 1.00000E+00
              GOVT  1.00000E+00                                       /
   EKL73(S) 'labor-capital elasticity. (table 6.11)'
            / AGRI  6.75900E-01, MINES 1.00000E+00, CRUDE 1.00000E+00
              CONST 1.00000E+00, FOOD  7.11700E-01, TEXTL 9.02500E-01
              PAPER 9.03300E-01, REFIN 7.83000E-01, CHEM  9.60300E-01
              LUMBR 9.12300E-01, METLS 7.37300E-01, EQUIP 8.15900E-01
              VEHCL 9.22800E-01, TRNSP 1.00000E+00, TRADE 1.00000E+00
              FNANC 1.00000E+00, REALT 1.00000E+00, SRVCS 1.00000E+00
              GOVT  1.00000E+00                                       /
   EKL83(S) 'labor-capital elasticity. (table 6.11)'
            / AGRI  1.92123E+00, MINES 1.00000E+00, CRUDE 1.00000E+00
              CONST 1.00000E+00, FOOD  1.68095E+00, TEXTL 1.12108E+00
              PAPER 1.11995E+00, REFIN 1.38332E+00, CHEM  1.04308E+00
              LUMBR 1.10632E+00, METLS 1.55352E+00, EQUIP 1.29132E+00
              VEHCL 1.09135E+00, TRNSP 1.00000E+00, TRADE 1.00000E+00
              FNANC 1.00000E+00, REALT 1.00000E+00, SRVCS 1.00000E+00
              GOVT  1.00000E+00                                       /;

Parameter
   EM(S) 'elasticity of import supply'
   EX(S) 'elasticity of export demand';

EM(S) = 0.465;
EX(S) = 10;

Parameter Y(S) 'gross output level by sector. (table 4.13)'
               / AGRI  1.74055E+05, MINES 4.42744E+04, CRUDE 8.35975E+04
                 CONST 3.03029E+05, FOOD  2.81073E+05, TEXTL 1.26674E+05
                 PAPER 1.65760E+05, REFIN 1.95844E+05, CHEM  2.35265E+05
                 LUMBR 1.11494E+05, METLS 7.35374E+05, EQUIP 7.72401E+04
                 VEHCL 1.11519E+05, TRNSP 5.41315E+05, TRADE 6.54613E+05
                 FNANC 2.39210E+05, REALT 4.82737E+05, SRVCS 7.82546E+05
                 GOVT  9.61957E+04                                       /;

Table Z(S,G) 'consumption composition matrix. (table 4.10)'
                FOOD       ALCHL       TOBAC        UTIL       HOUSG       FRNSH
   AGRI  3.49303E-02 3.49250E-02
   MINES 8.89490E-06
   FOOD  4.44127E-01 4.44162E-01 4.96879E-01
   TEXTL                                                             1.51941E-01
   PAPER                                                             1.13370E-03
   REFIN                                                             2.57659E-05
   CHEM  2.13478E-04 1.95293E-04
   LUMBR                                                             2.60854E-01
   METLS                                                             9.58233E-02
   EQUIP                                                             7.98743E-04
   TRNSP 1.80389E-02 1.80321E-02 4.29918E-03 9.67120E-01             1.03579E-02
   TRADE 2.34928E-01 2.34938E-01 4.98822E-01                         4.79065E-01
   FNANC 8.89490E-06
   REALT                                                 9.63414E-01
   SRVCS 2.67745E-01 2.67747E-01             4.22719E-03 3.65864E-02
   GOVT                                      2.86527E-02

   +            APPL        CLTH       TRNSP       VEHCL       SERVC       BNKNG
   TEXTL 1.96668E-04 4.22525E-01             2.43355E-04
   PAPER             9.72015E-03
   CHEM  2.17739E-02 9.63838E-03             4.00725E-02
   LUMBR 3.21973E-02                         4.23618E-04 2.15520E-03
   METLS 5.17911E-01 5.98949E-02             1.54125E-02 2.28764E-04
   EQUIP                                     2.40200E-02
   VEHCL                                     4.15732E-01
   TRNSP 8.28815E-03 3.03563E-03 9.43310E-01 1.55927E-02 4.17193E-02
   TRADE 4.18734E-01 4.71361E-01             2.05121E-01 1.32442E-03
   FNANC                                                 1.65312E-02 1.00000E+00
   REALT                                                 6.51376E-03
   SRVCS 8.99053E-04 2.38251E-02             2.83382E-01 8.99115E-01
   GOVT                          5.66898E-02             3.24123E-02

   +           READG       N_DUR       PETRL        HLTH        EDUC       SAVNG
   AGRI  4.41326E-02 6.14907E-04                                    -3.63988E-02
   MINES             6.47270E-04 3.66763E-03                         2.50821E-03
   CRUDE                                                             9.10418E-04
   CONST                                                             4.91561E-01
   FOOD                                                             -7.32829E-04
   TEXTL 8.28619E-03 2.39490E-03                                     2.14316E-03
   PAPER 1.66921E-01 1.60038E-01             5.69271E-03            -4.07667E-04
   REFIN                         6.58331E-01 1.93630E-05            -1.18903E-03
   CHEM  4.02524E-03 3.92213E-01 1.70587E-03 5.59009E-02             1.37297E-03
   LUMBR             3.46290E-03 1.80823E-03                         1.71430E-02
   METLS 1.33159E-01 7.86757E-02 8.52937E-05 1.55000E-02             2.84313E-01
   EQUIP 9.83283E-02                                                 3.99168E-02
   VEHCL                                                             7.10858E-02
   TRNSP 1.06977E-01 2.17483E-02 2.67993E-02 1.04560E-03             1.71905E-02
   TRADE 2.68150E-01 3.40205E-01 3.07603E-01 7.96495E-02             1.19901E-01
   FNANC 5.43951E-05
   REALT                                                             2.95876E-02
   SRVCS 1.55407E-01                         8.42192E-01 1.00000E+00 -3.8905E-02
   GOVT  1.45598E-02                                                           ;

Table RAS(S,S) 'adjusted input-output table. (tables 4.8 and 4.9)'
                AGRI       MINES       CRUDE       CONST        FOOD       TEXTL
   AGRI  4.77039E+04 1.29167E+01 4.94328E+00 4.14308E+02 8.07202E+04 2.16489E+03
   MINES 3.19103E+02 6.05761E+03 1.28523E+01 1.74414E+03 1.58516E+02 6.93484E+01
   CRUDE 2.75040E+02 1.05530E+02 5.46406E+03 1.82005E+02 1.00093E+02 5.49454E+01
   CONST 2.68590E+03 4.87043E+02 1.08872E+04 2.86600E+02 1.46124E+03 5.88429E+02
   FOOD  1.70603E+04 1.21148E+01 1.67424E+01 3.48826E+01 5.83569E+04 6.66520E+02
   TEXTL 3.42696E+02 1.02025E+02 2.83085E+01 1.67936E+03 1.22183E+02 4.95362E+04
   PAPER 7.80488E+02 3.25057E+02 2.55315E+02 3.81202E+03 1.11966E+04 1.81391E+03
   REFIN 9.88521E+03 2.35625E+03 1.24116E+03 6.24300E+03 1.93248E+03 1.25882E+03
   CHEM  9.77087E+03 1.45763E+03 9.50792E+02 6.56288E+03 5.42140E+03 1.26869E+04
   LUMBR 4.56307E+02 4.98159E+02 5.60705E+01 3.76413E+04 4.69320E+03 3.62200E+02
   METLS 2.03185E+03 4.63286E+03 3.27433E+03 3.80960E+04 7.48649E+03 1.61303E+03
   EQUIP 5.35927E+02 1.06592E+02 5.83976E+01 5.32920E+02 2.83783E+01 4.00452E+01
   VEHCL 1.70121E+02 2.10930E+02 3.52576E+01 3.80755E+02 3.22277E+01 1.79056E+01
   TRNSP 6.02777E+03 3.34213E+03 2.53607E+03 9.87724E+03 1.02177E+04 3.74510E+03
   TRADE 1.34513E+04 3.00750E+03 1.51076E+03 3.21204E+04 2.11882E+04 7.67672E+03
   FNANC 2.55270E+03 6.17634E+02 7.68909E+02 2.51563E+03 1.28108E+03 6.32573E+02
   REALT 7.40672E+03 8.34401E+02 7.56553E+03 4.67231E+02 5.58298E+02 4.84227E+02
   SRVCS 3.93065E+03 2.15643E+03 2.06860E+03 2.08522E+04 7.80496E+03 3.21905E+03
   GOVT  7.84913E+02 5.72576E+02 1.07121E+03 8.76811E+02 1.79685E+03 1.22383E+03

   +           PAPER       REFIN        CHEM       LUMBR       METLS       EQUIP
   AGRI  4.95558E+01 2.57982E+00 6.13878E+02 4.10659E+03 6.67960E+01 3.48058E+00
   MINES 4.80497E+02 2.99266E+02 3.97423E+03 2.06994E+03 1.49215E+04 1.39879E+01
   CRUDE 1.58425E+02 1.05766E+05 3.90772E+03 1.16685E+02 6.21400E+02 2.88911E+01
   CONST 1.26204E+03 1.38001E+03 2.06264E+03 1.15375E+03 8.36066E+03 3.29064E+02
   FOOD  5.14232E+02 8.75865E+01 2.47313E+03 9.32015E+01 3.70207E+02 1.01664E+01
   TEXTL 1.63620E+03 3.74388E+01 3.27421E+03 1.87451E+03 2.84958E+03 4.06322E+02
   PAPER 4.63469E+04 1.05641E+03 7.79450E+03 2.06093E+03 1.33010E+04 4.51683E+02
   REFIN 4.06976E+03 2.00380E+04 1.46170E+04 2.50776E+03 1.02380E+04 5.87484E+02
   CHEM  7.17832E+03 4.89943E+03 6.65589E+04 3.88466E+03 3.24850E+04 8.95859E+02
   LUMBR 4.95827E+03 3.82156E+02 2.35622E+03 2.37056E+04 1.14772E+04 1.31904E+03
   METLS 3.45937E+03 9.70241E+02 8.31886E+03 4.95921E+03 2.42505E+05 1.21644E+04
   EQUIP 1.68734E+02 9.82306E+00 7.99628E+01 9.83550E+01 3.14783E+03 1.27697E+04
   VEHCL 6.40378E+01 1.51190E+02 8.71123E+01 1.75502E+02 2.81914E+03 4.12245E+02
   TRNSP 1.03269E+04 1.16825E+04 1.82501E+04 8.00805E+03 4.25135E+04 2.19451E+03
   TRADE 1.16057E+04 5.01511E+03 1.57178E+04 7.18179E+03 7.46440E+04 3.26569E+03
   FNANC 1.02228E+03 8.44861E+02 1.48315E+03 8.28850E+02 6.18708E+03 6.20171E+02
   REALT 1.11894E+03 2.62709E+02 1.58982E+03 4.76650E+02 5.53245E+03 3.65087E+02
   SRVCS 6.83419E+03 2.35907E+03 1.23156E+04 3.00436E+03 2.84889E+04 2.54310E+03
   GOVT  4.15367E+03 1.17168E+03 3.63197E+03 1.21178E+03 1.07284E+04 1.23522E+03

   +           VEHCL       TRNSP       TRADE       FNANC       REALT       SRVCS
   AGRI  1.52082E+00 4.91644E+01 8.73337E+02 4.84854E+00 4.31162E+03 2.60626E+03
   MINES 4.38196E+01 9.75567E+03 4.67007E+00 5.24419E-01 2.40127E+01 1.13320E+02
   CRUDE 2.61194E+01 2.93924E+04 4.70898E+02 7.15163E+01 1.70123E+02 6.09765E+02
   CONST 3.25754E+02 2.40091E+04 3.86461E+03 7.62033E+02 7.12670E+04 1.33394E+04
   FOOD  2.69740E+01 1.64303E+02 4.83188E+02 1.47578E+01 9.62752E+00 6.62090E+03
   TEXTL 2.61111E+03 4.85133E+02 3.71442E+02 1.64973E+02 2.33814E+01 4.00854E+03
   PAPER 6.22244E+02 3.04369E+03 1.11278E+04 6.03662E+03 3.09007E+03 2.12056E+04
   REFIN 4.10666E+02 4.84692E+04 1.10733E+04 1.18735E+03 1.89838E+03 1.40215E+04
   CHEM  5.36451E+03 3.25176E+03 1.62399E+03 1.35312E+02 1.27542E+03 1.83553E+04
   LUMBR 2.10358E+03 4.08367E+02 9.40659E+02 2.70518E+01 7.10703E+01 2.67436E+03
   METLS 2.38947E+04 8.37612E+03 2.37642E+03 7.60264E+02 8.25374E+02 2.00537E+04
   EQUIP 4.30563E+02 6.16430E+03 3.06914E+01 6.41174E+01 1.09553E+01 1.25107E+03
   VEHCL 3.01012E+04 9.05646E+02 4.43927E+02 3.53968E+01 4.16257E+01 8.12870E+03
   TRNSP 2.25330E+03 9.36376E+04 2.96017E+04 9.49454E+03 9.99490E+03 4.07070E+04
   TRADE 8.26929E+03 1.55832E+04 1.22973E+04 1.42583E+03 3.51304E+03 2.94769E+04
   FNANC 3.80231E+02 5.55400E+03 7.08814E+03 4.20652E+04 2.05804E+04 8.10357E+03
   REALT 1.13128E+02 4.24392E+03 1.37242E+04 3.72805E+03 3.96620E+04 2.46183E+04
   SRVCS 2.60763E+03 2.19662E+04 4.69394E+04 1.75710E+04 1.53004E+04 7.48002E+04
   GOVT  4.79289E+02 1.17297E+04 1.42000E+04 6.69891E+03 5.80996E+03 1.74284E+04;

Table RCS(G,HH) 'adjusted consumption matrix. (tables 5.2 and 5.3)'
                   H1          H2          H3          H4          H5          H6
   FOOD   2.43154E+03 8.31012E+02 5.20838E+03 1.59696E+04 3.11945E+04 3.68235E+04
   ALCHL  5.99531E+02 7.09930E+01 4.47408E+02 1.47625E+03 3.10355E+03 3.85386E+03
   TOBAC  3.00241E+02 3.55527E+01 2.24052E+02 7.39320E+02 1.55420E+03 1.92995E+03
   UTIL   8.09773E+02 2.90719E+02 1.91339E+03 6.31809E+03 1.27338E+04 1.49690E+04
   HOUSG  6.12199E+03 1.58282E+03 9.48922E+03 2.39017E+04 4.04763E+04 4.36047E+04
   FRNSH  6.29848E+02 7.45854E+01 4.70031E+02 1.55093E+03 3.26043E+03 4.04867E+03
   APPL   5.18472E+02 1.02586E+02 5.15702E+02 1.73699E+03 3.94353E+03 4.88070E+03
   CLTH   7.22029E+03 1.94843E+02 1.20325E+03 3.92543E+03 8.34312E+03 1.02651E+04
   TRNSP  1.10486E+02 4.72766E+01 3.05804E+02 9.45871E+02 1.87616E+03 2.21232E+03
   VEHCL  1.20089E+03 2.59688E+02 1.40132E+03 5.15694E+03 1.18923E+04 1.47618E+04
   SERVC  7.30451E+02 8.64961E+01 5.45119E+02 1.79866E+03 3.78124E+03 4.69536E+03
   BNKNG  1.60339E+03 1.89865E+02 1.19656E+03 3.94812E+03 8.30000E+03 1.03067E+04
   READG  1.27226E+03 1.50655E+02 9.49461E+02 3.13278E+03 6.58597E+03 8.17810E+03
   N_DUR  8.91740E+02 6.01011E+01 3.35115E+02 1.09765E+03 2.25039E+03 2.69641E+03
   PETRL  5.46878E+02 1.12026E+02 7.24765E+02 2.64345E+03 5.97935E+03 7.57259E+03
   HLTH   3.59269E+03 3.64276E+02 2.89157E+03 9.48352E+03 1.84661E+04 2.22962E+04
   EDUC   4.10709E+02 4.86350E+01 3.06502E+02 1.01128E+03 2.12606E+03 2.64005E+03
   SAVNG -4.6884E+04  -2.8102E+03 -1.2384E+04 -2.7382E+04 -3.3634E+04 -1.7098E+04

   +               H7          H8          H9         H10         H11         H12
   FOOD   3.72263E+04 3.64173E+04 6.22303E+04 4.77327E+04 5.55705E+04 1.43476E+04
   ALCHL  4.09038E+03 4.27672E+03 7.88731E+03 6.63555E+03 8.87697E+03 3.07807E+03
   TOBAC  2.04850E+03 2.14176E+03 3.94985E+03 3.32301E+03 4.44547E+03 1.54143E+03
   UTIL   1.49085E+04 1.44047E+04 2.47844E+04 1.92801E+04 2.31262E+04 6.46643E+03
   HOUSG  4.07999E+04 3.67105E+04 5.06882E+04 3.22039E+04 3.40273E+04 9.89624E+03
   FRNSH  4.29734E+03 4.49303E+03 8.28624E+03 6.97116E+03 9.32584E+03 3.23370E+03
   APPL   5.31140E+03 5.50475E+03 9.62492E+03 7.56886E+03 9.51822E+03 2.77065E+03
   CLTH   1.07248E+04 1.10415E+04 1.98779E+04 1.64221E+04 2.13323E+04 7.18989E+03
   TRNSP  2.24502E+03 2.23530E+03 3.80079E+03 2.91343E+03 3.50719E+03 9.92770E+02
   VEHCL  1.65255E+04 1.69002E+04 2.91693E+04 2.27302E+04 2.85742E+04 8.05782E+03
   SERVC  4.98369E+03 5.21064E+03 9.60965E+03 8.08456E+03 1.08154E+04 3.75019E+03
   BNKNG  1.09396E+04 1.14377E+04 2.10939E+04 1.77463E+04 2.37406E+04 8.23194E+03
   READG  8.68036E+03 9.07556E+03 1.67376E+04 1.40813E+04 1.88378E+04 6.53186E+03
   N_DUR  2.77299E+03 2.88574E+03 5.33512E+03 4.58741E+03 6.38517E+03 2.59914E+03
   PETRL  8.00777E+03 8.11209E+03 1.44354E+04 1.14639E+04 1.36132E+04 3.64777E+03
   HLTH   2.30433E+04 2.30927E+04 4.00924E+04 3.17075E+04 3.96004E+04 1.21082E+04
   EDUC   2.80215E+03 2.92981E+03 5.40313E+03 4.54572E+03 6.08121E+03 2.10860E+03
   SAVNG -1.49995E+03 1.01676E+04 4.23748E+04 5.79356E+04 1.13118E+05 4.77507E+04

   +              H13         H14
   FOOD   8.11929E+03 5.24818E+02
   ALCHL  3.30288E+03 1.53387E+03
   TOBAC  1.65404E+03 7.68143E+02
   UTIL   4.23549E+03 3.88370E+02
   HOUSG  1.15294E+04 2.68036E+04
   FRNSH  3.46990E+03 1.61143E+03
   APPL   2.03276E+03 2.66599E+02
   CLTH   7.94568E+03 1.13218E+04
   TRNSP  6.56467E+02 7.65529E+01
   VEHCL  6.14244E+03 1.59609E+03
   SERVC  4.02413E+03 1.86881E+03
   BNKNG  8.83324E+03 4.10219E+03
   READG  7.00898E+03 3.25500E+03
   N_DUR  3.92681E+03 1.30495E+04
   PETRL  2.33556E+03 3.01442E+02
   HLTH   9.46404E+03 1.86004E+03
   EDUC   2.26261E+03 1.05077E+03
   SAVNG  4.67953E+04 3.21618E+04;

* CONVERT INTO UNITS CONSISTENT WITH THE 1973 DATA:
GDK = 1.E-5*GDK;
GSK = 1.E-5*GSK;
GDL = 1.E-5*GDL;
GTL = 1.E-5*GTL;

DK(S)     = 1.E-5*DK(S);
SK(HH)    = 1.E-5*SK(HH);
DL(S)     = 1.E-5*DL(S);
SL(HH)    = 1.E-5*SL(HH);
PIT(HH)   = 1.E-5*PIT(HH);
TRN(HH)   = 1.E-5*TRN(HH);
TC(G)     = 1.E-5*TC(G);
GD(S)     = 1.E-5*GD(S);
VM(S)     = 1.E-5*VM(S);
VX(S)     = 1.E-5*VX(S);
Y(S)      = 1.E-5*Y(S);
RCS(G,HH) = 1.E-5*RCS(G,HH);
RAS(S,SS) = 1.E-5*RAS(S,SS);

Parameter
   TAUBMK(*)  'benchmark marginal tax'
   TAUAVE(*)  'average tax'
   CC(H)      'current consumption value (market + leisure)'
   LEISURE(H) 'leisure demand in benchmark'
   GC         'government consumption'
   CP(H)      'value of private consumption'
   EG(H)      'elasticity of substitution - private vs public'
   GOVSAV     'exogenous (government) savings'
   CG(H)      'consumption plus public goods valuation'
   VPG(H)     'benchmark valuation of public goods';

Set HFIX(DH)  'households omitted from the aggregation';

Alias (HP,H);

* IDENTIFY HOUSEHOLDS FROM THE DISAGGREGATED DATA SET
* WHICH ARE NOT ASSIGNED:
HFIX(DH) = yes$(sum(H$HMAP(DH,H), 1) = 0);

Parameter
   TXO(S)     'production output taxes (total value)'
   TK(S)      'capital taxes (total value)'
   TL(S)      'labor taxes (total value)'
   PLREF(S)   'labor reference price'
   PKREF(S)   'capital reference price'
   INCADJ(HH) 'income adjustment transfer';

INCADJ(HH) = 0;
TXO(S)     =     0.01*TAXRATE(S,"TXO")*Y(S);
TK(S)      =     0.01*TAXRATE(S,"TK")*DK(S);
TL(S)      =     0.01*TAXRATE(S,"TL")*DL(S);
PLREF(S)   = 1 + 0.01*TAXRATE(S,"TL");
PKREF(S)   = 1 + 0.01*TAXRATE(S,"TK");

Parameter GCE(G) 'gross consumption expenditure by good. (table 6.6)';

Set
   EXCS / Y, INTER, NETEXP, FINDEM, CHECK /
   HCOL / EXPEND, INC_TAX, LABOR, CAPITAL, TRANSF, CHECK /
   PRFT / Y, VA, TAX, INTER, CHECK /
   GCOL / ENDOWMENT, L_TAX,  K_TAX,  PROD_TAX, CON_TAX, INC_TAX
          REVENUE,   TRANSF, EXPEND, OUTLAY,   DEFICIT          /
   VCOL / LABOR, CAPITAL, INTER, TOTAL  /
   TCOL / OUTPUT, LABOR, CAPITAL, TOTAL /
   GOVT(S) 'government sectors'  / GOVT /
   CCG(G)  'current consumption goods';

CCG(G)       = yes;
CCG("SAVNG") =  no;

* CHECK CONSISTENCY OF THE DISAGGREGATED DATA.
Parameter
   CD(S)           'consumer demand'
   FD(S)           'final demand'
   VA(S)           'value-added'
   LABMKT          'labor market clearance'
   CAPMKT          'capital market clearance'
   PMCHK(S,*)      'profit and market clearance check'
   BUDGET(HH,*)    'budget balance'
   GBDGT(*)        'government budget balance'
   ZCHK            'check of consumer goods transformation matrix,'
   ZSUM(G)         'transformation check sum'
   EXPEND(HH)      'benchmark consumption expenditure'
   SAVING(HH)      'benchmark savings'
   PROFIT(S,*)     'benchmark profit check'
   EXCESS(*,*)     'excess demand check'
   BDGTBAL(HH,*)   'budget balance calculation'
   PCTPROFIT(S,*)  'benchmark profit check (percent)'
   PCTVA(*,*)      'value-added allocation'
   PCTEXCESS(S,*)  'excess demand check (percent)'
   PCTBUDGET(HH,*) 'budget balance calculation (percent)'
   PCTRCS(G,HH)    'consumption as percentage of expenditure'
   PCTRAS(SS,S)    'intermediate input as percentage of output value'
   GOVERNMENT(*,*) 'government budget summary (percent)'
   VALUEADDED(S,*) 'value-added summary'
   TAXPAYMENT(S,*) 'tax payment summary';

*  PERFORM SOME QUICK DATA CHECKS:
ZSUM(G) = sum(S, Z(S,G));
ZCHK    = sum(G, abs(ZSUM(G)) - 1);
abort$(abs(ZCHK) > 1.E-5) " Z MATRIX ERROR: ", ZSUM;

GCE(G) = sum(DH, RCS(G,DH));
CD(S)  = sum(G, Z(S,G)*(GCE(G) - TC(G)));
FD(S)  = GD(S) + CD(S) + VX(S) - GSE(S) - VM(S);
VA(S)  = DL(S) + DK(S) + TL(S) + TK(S);
LABMKT = sum(S, DL(S)) + GDL - sum(DH, SL(DH));
CAPMKT = sum(S, DK(S)) + GDK - sum(DH, SK(DH)) - GSK;

PMCHK(S,"PROFIT")  = Y(S) - sum(SS, RAS(SS,S)) - (DL(S) + DK(S) + TL(S) + TK(S) + TXO(S));
PMCHK(S,"PROFIT%") = 100*PMCHK(S,"PROFIT")/Y(S);
PMCHK(S,"EXCESS")  = FD(S) + sum(SS, RAS(S,SS)) - Y(S);
PMCHK(S,"EXCESS%") = 100*(FD(S) + sum(SS, RAS(S,SS)) - Y(S))/Y(S);

* INCLUDE SOME OTHER STATISTICS FOR A COMPLETE REPORT:
Set
   GEXPEND / TRNSFR, ADJ, GC, SAV /
   GREVENU / GSE, GSK, PIT, TL, TK, TXO, TC, HFIX /;

GBDGT("TRNSFR")  = sum(DH, TRN(DH));
GBDGT("ADJ")     = sum(DH, INCADJ(DH));
GBDGT("GC")      = sum(S, GD(S)) + GDK + GDL + GTL;
GBDGT("GSE")     = sum(S,GSE(S));
GBDGT("GSK")     = GSK;
GBDGT("PIT")     = sum(DH, PIT(DH));
GBDGT("TL")      = sum(S, TL(S)) + GTL;
GBDGT("TK")      = sum(S, TK(S));
GBDGT("TXO")     = sum(S, TXO(S));
GBDGT("TC")      = sum(G, TC(G));
GBDGT("REVENUE") = sum(GREVENU, GBDGT(GREVENU));
GBDGT("OUTLAY")  = sum(GEXPEND, GBDGT(GEXPEND));
GBDGT("DEFICIT") = GBDGT("OUTLAY") - GBDGT("REVENUE");

EXPEND(DH) = sum(CCG, RCS(CCG,DH));
SAVING(DH) = RCS("SAVNG",DH);

BDGTBAL(DH,"EXPEND")  = EXPEND(DH);
BDGTBAL(DH,"SAVING")  = SAVING(DH);
BDGTBAL(DH,"INC_TAX") = PIT(DH);
BDGTBAL(DH,"LABOR")   = SL(DH);
BDGTBAL(DH,"CAPITAL") = SK(DH);
BDGTBAL(DH,"TRANSF")  = TRN(DH);
BDGTBAL(DH,"CHECK")   = EXPEND(DH) + SAVING(DH) - (SL(DH) + SK(DH) + TRN(DH) - PIT(DH));

PCTBUDGET(DH,"EXPEND")  = 100;
PCTBUDGET(DH,"SAVING")  = 100*BDGTBAL(DH,"SAVING")/EXPEND(DH);
PCTBUDGET(DH,"INC_TAX") = 100*BDGTBAL(DH,"INC_TAX")/EXPEND(DH);
PCTBUDGET(DH,"LABOR")   = 100*BDGTBAL(DH,"LABOR")/EXPEND(DH);
PCTBUDGET(DH,"CAPITAL") = 100*BDGTBAL(DH,"CAPITAL")/EXPEND(DH);
PCTBUDGET(DH,"TRANSF")  = 100*BDGTBAL(DH,"TRANSF")/EXPEND(DH);
PCTBUDGET(DH,"CHECK")   = 100*BDGTBAL(DH,"CHECK")/EXPEND(DH);

display ZCHK, LABMKT, CAPMKT, PMCHK, GBDGT, PCTBUDGET, BDGTBAL;

* =================================================================
* MAKE ADJUSTMENTS TO BALANCE BUDGETS:

* FIRST, REMOVE ANY NEGATIVE INCOME TAXES:
PIT(DH)    = max(0, PIT(DH));
INCADJ(DH) = sum(G, RCS(G,DH)) - (SL(DH) + SK(DH) + TRN(DH) - PIT(DH));

* MAKE ADJUSTMENTS TO BALANCE PROFITS:
Y(S) = Y(S) - PMCHK(S,"PROFIT");

* ADJUSTMENTS TO BALANCE SECTORAL MARKETS:
GSE(S) = GSE(S) + FD(S) + sum(SS, RAS(S,SS)) - Y(S);

* =================================================================
* RECHECK THE CENTRAL VARIABLES:
FD(S) = GD(S) + CD(S) + VX(S) - GSE(S) - VM(S);

PMCHK(S,"PROFIT")  = Y(S) - sum(SS,RAS(SS,S)) - (DL(S) + DK(S) + TL(S) + TK(S) + TXO(S));
PMCHK(S,"PROFIT%") = 100 * PMCHK(S,"PROFIT")/Y(S);

BUDGET(DH,"VALUE")   = sum(G, RCS(G,DH)) - (SL(DH) + SK(DH) + TRN(DH) - PIT(DH));
BUDGET(DH,"PERCENT") = 100*BUDGET(DH,"VALUE")/sum(G, RCS(G,DH));

PMCHK(S,"EXCESS")  = FD(S) + sum(SS,RAS(S,SS)) - Y(S);
PMCHK(S,"EXCESS%") = 100*(FD(S) + sum(SS, RAS(S,SS)) - Y(S))/Y(S);

* RECALCULATE THE GOVERNMENT BUDGET STATISTICS:
GBDGT("TRNSFR")  = sum(DH, TRN(DH));
GBDGT("ADJ")     = sum(DH, INCADJ(DH));
GBDGT("GC")      = sum(S, GD(S)) + GDK + GDL + GTL;
GBDGT("GSE")     = sum(S, GSE(S));
GBDGT("GSK")     = GSK;
GBDGT("PIT")     = sum(DH, PIT(DH));
GBDGT("TL")      = sum(S, TL(S)) + GTL;
GBDGT("TK")      = sum(S, TK(S));
GBDGT("TXO")     = sum(S, TXO(S));
GBDGT("TC")      = sum(G, TC(G));
GBDGT("REVENUE") = sum(GREVENU, GBDGT(GREVENU));
GBDGT("OUTLAY")  = sum(GEXPEND, GBDGT(GEXPEND));
GBDGT("DEFICIT") = GBDGT("OUTLAY") - GBDGT("REVENUE");

display PMCHK, GBDGT;

EXPEND(DH) = sum(CCG, RCS(CCG,DH));
SAVING(DH) = RCS("SAVNG",DH);

PROFIT(S,"Y")     = Y(S);
PROFIT(S,"VA")    = DL(S) + DK(S);
PROFIT(S,"TAX")   = TL(S) + TK(S) + TXO(S);
PROFIT(S,"INTER") = sum(SS, RAS(SS,S));
PROFIT(S,"CHECK") = Y(S) - sum(SS, RAS(SS,S)) - (DL(S) + DK(S) + TL(S) + TK(S) + TXO(S));

PCTPROFIT(S,"Y")     = 100;
PCTPROFIT(S,"VA")    = 100*PROFIT(S,"VA")/PROFIT(S,"Y");
PCTPROFIT(S,"TAX")   = 100*PROFIT(S,"TAX")/PROFIT(S,"Y");
PCTPROFIT(S,"INTER") = 100*PROFIT(S,"INTER")/PROFIT(S,"Y");
PCTPROFIT(S,"CHECK") = 100*PROFIT(S,"CHECK")/PROFIT(S,"Y");

PCTVA(S,"K")        = 100*DK(S)/VA(S);
PCTVA(S,"L")        = 100*DL(S)/VA(S);
PCTVA(S,"TL")       = 100*TL(S)/VA(S);
PCTVA(S,"TK")       = 100*TK(S)/VA(S);
PCTVA("TOTAL","K")  = 100*sum(S, DK(S))/sum(S, VA(S));
PCTVA("TOTAL","L")  = 100*sum(S, DL(S))/sum(S, VA(S));
PCTVA("TOTAL","TL") = 100*sum(S, TL(S))/sum(S, VA(S));
PCTVA("TOTAL","TK") = 100*sum(S, TK(S))/sum(S, VA(S));

EXCESS(S,"Y")            = Y(S);
EXCESS(S,"INTER")        = sum(SS, RAS(S,SS));
EXCESS(S,"NETEXP")       = VX(S) - VM(S);
EXCESS("TOTAL","NETEXP") = sum(S, VX(S) - VM(S));
EXCESS(S,"FINDEM")       = GD(S) + CD(S) - GSE(S);
EXCESS(S,"CHECK")        = FD(S) + sum(SS, RAS(S,SS)) - Y(S);

PCTEXCESS(S,"Y")      = 100;
PCTEXCESS(S,"INTER")  = 100*EXCESS(S,"INTER")/EXCESS(S,"Y");
PCTEXCESS(S,"NETEXP") = 100*EXCESS(S,"NETEXP")/EXCESS(S,"Y");
PCTEXCESS(S,"FINDEM") = 100*EXCESS(S,"FINDEM")/EXCESS(S,"Y");
PCTEXCESS(S,"CHECK")  = 100*EXCESS(S,"CHECK")/EXCESS(S,"Y");

BDGTBAL(DH,"EXPEND")  = EXPEND(DH);
BDGTBAL(DH,"SAVING")  = SAVING(DH);
BDGTBAL(DH,"INC_TAX") = PIT(DH);
BDGTBAL(DH,"LABOR")   = SL(DH);
BDGTBAL(DH,"CAPITAL") = SK(DH);
BDGTBAL(DH,"TRANSF")  = TRN(DH);
BDGTBAL(DH,"CHECK")   = EXPEND(DH)+SAVING(DH)-(SL(DH)+SK(DH)+TRN(DH)-PIT(DH));

PCTBUDGET(DH,"EXPEND")  = 100;
PCTBUDGET(DH,"SAVING")  = 100*BDGTBAL(DH,"SAVING")/BDGTBAL(DH,"EXPEND");
PCTBUDGET(DH,"INC_TAX") = 100*BDGTBAL(DH,"INC_TAX")/BDGTBAL(DH,"EXPEND");
PCTBUDGET(DH,"LABOR")   = 100*BDGTBAL(DH,"LABOR")/BDGTBAL(DH,"EXPEND");
PCTBUDGET(DH,"CAPITAL") = 100*BDGTBAL(DH,"CAPITAL")/BDGTBAL(DH,"EXPEND");
PCTBUDGET(DH,"TRANSF")  = 100*BDGTBAL(DH,"TRANSF")/BDGTBAL(DH,"EXPEND");
PCTBUDGET(DH,"CHECK")   = 100*BDGTBAL(DH,"CHECK")/BDGTBAL(DH,"EXPEND");

GOVERNMENT("ENDOWMENT","LEVEL") = GSK + sum(S, GSE(S));
GOVERNMENT("L_TAX","LEVEL")     = sum(S, TL(S));
GOVERNMENT("K_TAX","LEVEL")     = sum(S, TK(S));
GOVERNMENT("PROD_TAX","LEVEL")  = sum(S, TXO(S));
GOVERNMENT("CON_TAX","LEVEL")   = sum(G, TC(G));
GOVERNMENT("INC_TAX","LEVEL")   = sum(DH, PIT(DH));
GOVERNMENT("REVENUE","LEVEL")   = GSK + sum(S, GSE(S))
                                + sum(S, TL(S) + TK(S) + TXO(S))
                                + sum(G, TC(G)) + sum(DH, PIT(DH));
GOVERNMENT("TRANSF","LEVEL")    = sum(DH, TRN(DH));
GOVERNMENT("INCADJ","LEVEL")    = sum(DH, INCADJ(DH));
GOVERNMENT("EXPEND","LEVEL")    = sum(S, GD(S)) + GDL + GDK + GTL;
GOVERNMENT("OUTLAY","LEVEL")    = sum(DH, TRN(DH)) + sum(S, GD(S)) + GDL + GDK + GTL;


GOVERNMENT("DEFICIT","LEVEL")     = GOVERNMENT("OUTLAY","LEVEL")
                                  - GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("ENDOWMENT","PERCENT") = 100*GOVERNMENT("ENDOWMENT","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("L_TAX","PERCENT")     = 100*GOVERNMENT("L_TAX","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("K_TAX","PERCENT")     = 100*GOVERNMENT("K_TAX","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("PROD_TAX","PERCENT")  = 100*GOVERNMENT("PROD_TAX","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("CON_TAX","PERCENT")   = 100*GOVERNMENT("CON_TAX","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("INC_TAX","PERCENT")   = 100*GOVERNMENT("INC_TAX","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("REVENUE","PERCENT")   = 100;
GOVERNMENT("TRANSF","PERCENT")    = 100*GOVERNMENT("TRANSF","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("INCADJ","PERCENT")    = 100*GOVERNMENT("INCADJ","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("EXPEND","PERCENT")    = 100*GOVERNMENT("EXPEND","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("OUTLAY","PERCENT")    = 100*GOVERNMENT("OUTLAY","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("DEFICIT","PERCENT")   = 100*GOVERNMENT("DEFICIT","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");

PCTRCS(G,DH) = 100*RCS(G,DH)/EXPEND(DH);
PCTRAS(SS,S) = 100*RAS(SS,S)/Y(S);

VALUEADDED(S,"LABOR")   = DL(S);
VALUEADDED(S,"CAPITAL") = DK(S);
VALUEADDED(S,"INTER")   = sum(SS, RAS(SS,S));
VALUEADDED(S,"TOTAL")   = DL(S) + DK(S) + sum(SS, RAS(SS,S));

TAXPAYMENT(S,"OUTPUT")  = TXO(S);
TAXPAYMENT(S,"LABOR")   = TL(S);
TAXPAYMENT(S,"CAPITAL") = TK(S);
TAXPAYMENT(S,"TOTAL")   = TXO(S) + TL(S) + TK(S);

display PROFIT, EXCESS, BDGTBAL, PCTPROFIT, PCTVA, PCTEXCESS, PCTBUDGET, GOVERNMENT, TAXPAYMENT;
option  PCTRCS:1, PCTRAS:1;
* display VALUEADDED, PCTRCS, PCTRAS;

* DISPLAY TAX RATES BEFORE AGGREGATION:
TAUAVE(DH) = PIT(DH)/(SL(DH) + SK(DH));
display TAU, TAUAVE;
TAUAVE(DH) = 0;

*======= CHECK THE AGGREGATION.
abort$(smax(DH, sum(H$HMAP(DH,H), 1) - 1) > 0) "INVALID MAPPING.";

*======= PERFORM THE AGGREGATION ===========
Parameter POPSHR(H) 'share of population';

COUNT(H)      = sum(DH$HMAP(DH,H), COUNT(DH));
POPSHR(H)     = COUNT(H)/sum(HP,   COUNT(HP));
SK(H)         = sum(DH$HMAP(DH,H), SK(DH));
SL(H)         = sum(DH$HMAP(DH,H), SL(DH));
PIT(H)        = sum(DH$HMAP(DH,H), PIT(DH));
INCADJ(H)     = sum(DH$HMAP(DH,H), INCADJ(DH));
TRN(H)        = sum(DH$HMAP(DH,H), TRN(DH));
TAU(H)$PIT(H) = sum(DH$HMAP(DH,H), PIT(DH)*TAU(DH))/PIT(H);
RCS(G,H)      = sum(DH$HMAP(DH,H), RCS(G,DH));

ZTA(H) = sum(DH$HMAP(DH,H), SL(DH)*ZTA(DH))/sum(DH$HMAP(DH,H), SL(DH));

* FIX ELASTICITIES:
EL(H) = sum(DH$HMAP(DH,H), EL(DH)*SL(DH))/sum(DH$HMAP(DH,H), SL(DH));
EC(H) = 1.5;

TAUBMK(H)  = TAU(H);
TAUAVE(H)  = PIT(H)/(SL(H) + SK(H));
LEISURE(H) = SL(H)*(ZTA(H) - 1);
CC(H)      = sum(G$CCG(G), RCS(G,H)) + LEISURE(H);
GC         = sum(S, GD(S)) + GDK + GDL + GTL;

* SET SAVINGS LEVELS TO ZERO FOR HOUSEHOLDS WITH NEGATIVE SAVINGS
* AND MAKE ACCORDING INCOME ADJUSTMENT:
SAVING(H) = sum(G$(not CCG(G)), RCS(G,H));
EXPEND(H) = sum(CCG, RCS(CCG,H));

GOVSAV = sum(H$(SAVING(H) < 0), SAVING(H));
INCADJ(H)$(SAVING(H) < 0) = INCADJ(H) - SAVING(H);

loop(G$(not CCG(G)), RCS(G,H)$(SAVING(H) < 0) = 0;);

SAVING(H) = sum(G$(not CCG(G)), RCS(G,H));
display GOVSAV, SAVING;

BDGTBAL(DH,"EXPEND")    = 0;
BDGTBAL(DH,"SAVING")    = 0;
BDGTBAL(DH,"INC_TAX")   = 0;
BDGTBAL(DH,"LABOR")     = 0;
BDGTBAL(DH,"CAPITAL")   = 0;
BDGTBAL(DH,"TRANSF")    = 0;
BDGTBAL(DH,"CHECK")     = 0;
PCTBUDGET(DH,"EXPEND")  = 0;
PCTBUDGET(DH,"SAVING")  = 0;
PCTBUDGET(DH,"INC_TAX") = 0;
PCTBUDGET(DH,"LABOR")   = 0;
PCTBUDGET(DH,"CAPITAL") = 0;
PCTBUDGET(DH,"TRANSF")  = 0;
PCTBUDGET(DH,"CHECK")   = 0;

BDGTBAL(H,"EXPEND")  = EXPEND(H);
BDGTBAL(H,"SAVING")  = SAVING(H);
BDGTBAL(H,"INC_TAX") = PIT(H);
BDGTBAL(H,"LABOR")   = SL(H);
BDGTBAL(H,"CAPITAL") = SK(H);
BDGTBAL(H,"INCADJ")  = INCADJ(H);
BDGTBAL(H,"TRANSF")  = TRN(H);
BDGTBAL(H,"CHECK")   = EXPEND(H) + SAVING(H) - (SL(H) + SK(H) + TRN(H) + INCADJ(H) - PIT(H));

PCTBUDGET(H,"EXPEND")  = 100;
PCTBUDGET(H,"SAVING")  = 100*BDGTBAL(H,"SAVING") /BDGTBAL(H,"EXPEND");
PCTBUDGET(H,"INC_TAX") = 100*BDGTBAL(H,"INC_TAX")/BDGTBAL(H,"EXPEND");
PCTBUDGET(H,"LABOR")   = 100*BDGTBAL(H,"LABOR")  /BDGTBAL(H,"EXPEND");
PCTBUDGET(H,"CAPITAL") = 100*BDGTBAL(H,"CAPITAL")/BDGTBAL(H,"EXPEND");
PCTBUDGET(H,"TRANSF")  = 100*BDGTBAL(H,"TRANSF") /BDGTBAL(H,"EXPEND");
PCTBUDGET(H,"INCADJ")  = 100*BDGTBAL(H,"INCADJ") /BDGTBAL(H,"EXPEND");
PCTBUDGET(H,"CHECK")   = 100*BDGTBAL(H,"CHECK")  /BDGTBAL(H,"EXPEND");

display POPSHR, BDGTBAL, PCTBUDGET;

Parameter SHARE(H,*);
SHARE(H,"L/K")    = SL(H)/SK(H);
SHARE(H,"SAVING") = 100*SAVING(H)/sum(HP, SAVING(HP));
SHARE(H,"SL")     = 100*SL(H)/sum(HP, SL(HP));
SHARE(H,"SK")     = 100*SK(H)/sum(HP, SK(HP));
SHARE(H,"TR")     = 100*TRN(H)/sum(HP, TRN(HP));
SHARE(H,"PIT")    = 100*PIT(H)/sum(HP, PIT(HP));
SHARE(H,"EXPEND") = 100*EXPEND(H)/sum(HP, EXPEND(HP));

display SHARE;

GOVERNMENT("ENDOWMENT","LEVEL") = GSK + sum(S, GSE(S));
GOVERNMENT("L_TAX","LEVEL")     = sum(S, TL(S)) + GTL;
GOVERNMENT("K_TAX","LEVEL")     = sum(S, TK(S));
GOVERNMENT("PROD_TAX","LEVEL")  = sum(S, TXO(S));
GOVERNMENT("CON_TAX","LEVEL")   = sum(G, TC(G));
GOVERNMENT("INC_TAX","LEVEL")   = sum(H, PIT(H));
GOVERNMENT("TRD_BAL","LEVEL")   = sum(S, VM(S) - VX(S));
GOVERNMENT("REVENUE","LEVEL")   = GSK + sum(S, GSE(S))
                                + sum(S, TL(S) + TK(S) + TXO(S)) + GTL
                                + sum(S, VM(S) - VX(S))
                                + sum(G, TC(G)) + sum(H, PIT(H));

GOVERNMENT("TRANSF","LEVEL") = sum(H, TRN(H));
GOVERNMENT("INCADJ","LEVEL") = sum(H, INCADJ(H));
GOVERNMENT("HFIX","LEVEL")   = sum(HFIX, sum(G, RCS(G,HFIX)) - SL(HFIX) - SK(HFIX));
GOVERNMENT("EXPEND","LEVEL") = sum(S, GD(S)) + GDL + GDK + GTL;
GOVERNMENT("OUTLAY","LEVEL") = sum(H, TRN(H) + INCADJ(H)) + GOVERNMENT("HFIX","LEVEL")
                             + sum(S, GD(S)) + GDL + GDK + GTL;

GOVERNMENT("DEFICIT","LEVEL") = GOVERNMENT("OUTLAY", "LEVEL") - GOVERNMENT("REVENUE","LEVEL");

GOVERNMENT("ENDOWMENT","PERCENT") = 100*GOVERNMENT("ENDOWMENT","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("L_TAX","PERCENT")     = 100*GOVERNMENT("L_TAX","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("K_TAX","PERCENT")     = 100*GOVERNMENT("K_TAX","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("PROD_TAX","PERCENT")  = 100*GOVERNMENT("PROD_TAX","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("CON_TAX","PERCENT")   = 100*GOVERNMENT("CON_TAX","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("INC_TAX","PERCENT")   = 100*GOVERNMENT("INC_TAX","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("REVENUE","PERCENT")   = 100;
GOVERNMENT("TRANSF","PERCENT")    = 100*GOVERNMENT("TRANSF","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("INCADJ","PERCENT")    = 100*GOVERNMENT("INCADJ","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("HFIX","PERCENT")      = 100*GOVERNMENT("HFIX","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("EXPEND","PERCENT")    = 100*GOVERNMENT("EXPEND","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("OUTLAY","PERCENT")    = 100*GOVERNMENT("OUTLAY","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");
GOVERNMENT("DEFICIT","PERCENT")   = 100*GOVERNMENT("DEFICIT","LEVEL")
                                       /GOVERNMENT("REVENUE","LEVEL");

display GOVERNMENT;

* RECALCULATE THE GOVERNMENT BUDGET STATISTICS:
GBDGT("TRNSFR")  = sum(H, TRN(H));
GBDGT("ADJ")     = sum(H, INCADJ(H));
GBDGT("GC")      = sum(S, GD(S)) + GDK + GDL + GTL;
GBDGT("SAV")     = GOVSAV;
GBDGT("HFIX")    = sum(HFIX, SL(HFIX)+SK(HFIX) - sum(G, RCS(G,HFIX)));
GBDGT("GSE")     = sum(S,GSE(S));
GBDGT("GSK")     = GSK;
GBDGT("PIT")     = sum(H, PIT(H));
GBDGT("TL")      = sum(S, TL(S)) + GTL;
GBDGT("TK")      = sum(S, TK(S));
GBDGT("TXO")     = sum(S, TXO(S));
GBDGT("TC")      = sum(G, TC(G));
GBDGT("REVENUE") = sum(GREVENU, GBDGT(GREVENU));
GBDGT("OUTLAY")  = sum(GEXPEND, GBDGT(GEXPEND));
GBDGT("DEFICIT") = GBDGT("OUTLAY") - GBDGT("REVENUE");

display GBDGT;

Parameter
   TIKAVE 'average capital-income tax rate'
   TIAVE  'average income tax rate'
   TLAVE  'average labor tax rate'
   TKAVE  'average capital tax rate'
   GBENCH 'benchmark provision';

TLAVE  =  sum(S, TL(S))/sum(S, DL(S) + TL(S));
TIAVE  =  sum(H, PIT(H))/sum(H, SL(H) + SK(H));
TKAVE  =  sum(S, TK(S))/sum(S, DK(S) + TK(S));
TIKAVE = (sum(H, PIT(H)) + sum(S, TK(S)))/(sum(H, PIT(H) + SL(H) + SK(H)) + sum(S, DK(S) + TK(S)));
GBENCH = (GDL + GTL + GDK + sum(S, GD(S)))/sum((G,H), RCS(G,H));

display TIAVE, TLAVE, TIKAVE, TKAVE, GBENCH, TAUAVE, TAUBMK;

Scalar
   STATIC 'switch for fixed capital stock'              / 1    /
   REDIST 'switch for endogenous income redistribution' / 1    /
   EFKS   'elasticity of foreign capital supply'        / 0.25 /
   VSCALE 'scale factor on valuation of public good'    / 1    /
   PNUM   'numeraire price index';

Alias (HP,H);

option limRow = 0, limCol = 0;

$offSymList offSymXRef offUElList offUElXRef

Parameter
   QREF_LS(H)  'reference level of labor supply - net of tax'
   QREF_Z(S,G) 'reference level of consumer goods formation net tax'
   QREF_VA(S)  'refreence level of value-added'
   QREF_I(H)   'reference level of household income-expenditure'
   QREF_GC     'reference level of government consumption'
   QREF_TRN    'reference level of transfers'
   QREF_ADJ    'reference level of income adjustments'
   QREF_GINC   'reference level of government income'
   PREF_LS(H)  'reference price of leisure'
   PREF_L(S)   'reference price of labor'
   PREF_K(S)   'reference price of capital services'
   T_L(S)      'labor tax'
   T_K(S)      'capital tax'
   T_Y(S)      'output tax'
   T_I(H)      'income tax (marginal rate)'
   T_IAVE(H)   'income tax (average rate)'
   T_C(G)      'tax rates on consumption'
   T_GDL       'tax rate on government labor demand'
   THETA(H)    'weights applied in synthetic objective';

QREF_LS(H)  = SL(H)*(1 - TAUBMK(H));
PREF_LS(H)  = 1 + TAUBMK(H)/(1 - TAUBMK(H));
T_I(H)      = TAUBMK(H)/(1 - TAUBMK(H));
T_IAVE(H)   = PIT(H)/(SL(H) + SK(H));
QREF_Z(S,G) = Z(S,G)*(GCE(G) - TC(G));
T_C(G)      = TC(G)/GCE(G);
QREF_VA(S)  = DL(S) + TL(S) + DK(S) + TK(S);
PREF_L(S)   = 1 + TL(S)/DL(S);
T_L(S)      = TL(S)/DL(S);
PREF_K(S)   = 1 + TK(S)/DK(S);
T_K(S)      = TK(S)/DK(S);
T_Y(S)      = TXO(S)/Y(S);
QREF_GC     = GDL + GTL + GDK + sum(S, GD(S));
VPG(H)      = VSCALE*QREF_GC*sum(CCG, RCS(CCG,H))/sum((CCG,HP), RCS(CCG,HP));
CP(H)       = sum(G$CCG(G), RCS(G,H));
CG(H)       = CP(H) + VPG(H);
QREF_I(H)   = CG(H) + LEISURE(H);
T_GDL       = GTL/GDL;
QREF_TRN    = sum(H, TRN(H));
QREF_ADJ    = sum(H, INCADJ(H));
QREF_GINC   = QREF_TRN + QREF_ADJ + QREF_GC;

* CALIBRATE THE TOP LEVEL ELASTICITY OF LEISURE VS. CONSUMPTION:
EL(H) = (LEISURE(H)/(QREF_I(H) - LEISURE(H)) + 0.15 /(ZTA(H) - 1))
      / (1 - QREF_LS(H)/(QREF_I(H) - LEISURE(H)));

EL(DH)    = 0;
EG(H)     = 0.5;
VPG(H)    = QREF_GC*POPSHR(H);
CG(H)     = sum(CCG, RCS(CCG,H)) + VPG(H);
QREF_I(H) = CG(H) + LEISURE(H);
EL(H)     = (ELS/(ZTA(H) - 1) + QREF_LS(H)/QREF_I(H))/(1 - LEISURE(H)/QREF_I(H));

display EL;

$onText
$MODEL:GEMTAP

$COMMODITIES:
   P_L      ! WAGE INDEX
   P_K      ! CAPITAL RETURN INDEX
   P_W(H)   ! WELFARE PRICE INDEX
   P_LS(H)  ! LEISURE PRICE
   P_C(G)   ! CONSUMPTION GOODS PRICE
   P_GC     ! GOVERNMENT CONSUMPTION PRICE
   P_G(H)   ! HOUSEHOLD VALUATION OF PUBLIC GOOD
   P_Y(S)   ! SECTORAL GOODS PRICE

$SECTORS:
   A_GC     ! GOVERNMENT CONSUMPTION
   A_Y(S)   ! PRODUCTION INDEX
   A_W(H)   ! WELFARE INDEX
   A_C(G)   ! AGGREGATE CONSUMPTION INDEX
   A_LS(H)  ! LABOR SUPPLY

$CONSUMERS:
   I_GOVT   ! GOVERNEMTN INCOME
   RA(H)    ! HOUSEHOLD INCOME (TOTAL)

$AUXILIARY:
   NETX(S)$(VM(S) + VX(S))  ! NET EXPORTS
   P_FX     ! REAL EXCHANGE RATE
   KMX      ! CAPITAL IMPORTS MINUS EXPORTS
   Q_G      ! GOVERNMENT CONSUMPTION INDEX

$PROD:A_LS(H) s:0
   O:P_L        Q:SL(H)
   I:P_LS(H)    Q:QREF_LS(H)   P:PREF_LS(H)   A:I_GOVT   T:T_I(H)

$PROD:A_C(G) s:0
   O:P_C(G)     Q:GCE(G)                      A:I_GOVT   T:T_C(G)
   I:P_Y(S)     Q:(max(QREF_Z(S,G),0))
   O:P_Y(S)     Q:(-min(QREF_Z(S,G),0))

$PROD:A_W(H) s:EL(H) a:EG(H) b(a):EC(H)
   O:P_W(H)     Q:QREF_I(H)
   I:P_LS(H)    Q:LEISURE(H)
   I:P_G(H)     Q:VPG(H)       a:
   I:P_C(CCG)   Q:RCS(CCG,H)   b:

$PROD:A_GC
   O:P_GC       Q:QREF_GC
   I:P_L        Q:GDL                         A:I_GOVT   T:T_GDL
   I:P_K        Q:GDK
   I:P_Y(S)     Q:GD(S)

$PROD:A_Y(S) VA:EKL(S)
   O:P_Y(S)     Q:Y(S)                        A:I_GOVT   T:T_Y(S)
   I:P_Y(SS)    Q:RAS(SS,S)
   I:P_L        Q:DL(S)        P:PREF_L(S)    A:I_GOVT   T:T_L(S)   VA:
   I:P_K        Q:DK(S)        P:PREF_K(S)    A:I_GOVT   T:T_K(S)   VA:

$DEMAND:RA(H)
   D:P_W(H)     Q:(LEISURE(H) + CP(H) + VPG(H))

* PUBLIC GOODS PROVISION:
   E:P_G(H)     Q:VPG(H)       R:Q_G

* CAPITAL ENDOWMENT:
   E:P_K        Q:SK(H)

* INVESTMENT IS EXOGENOUS:
   E:P_C(G)$(not CCG(G))   Q:(-SAVING(H))

* LABOR SUPPLY:
   E:P_LS(H)    Q:(LEISURE(H) + QREF_LS(H))

* INCOME TAXES - AVERAGE RATES
   E:P_W(H)     Q:(-T_IAVE(H)*(SL(H) + SK(H)))

* INCOME TAX ON CAPITAL - MARGINAL ADJUSTMENT
   E:P_K        Q:(-T_I(H)*SK(H))
   E:P_W(H)     Q:( T_I(H)*SK(H))

* TAX ON LABOR - MARGINAL ADJUSTMENT:
   E:P_W(H)     Q:(T_I(H)*QREF_LS(H))

* TRANSFERS AND INCOME ADJUSTMENTS:
   E:P_W(H)     Q:(TRN(H) + INCADJ(H))

$DEMAND:I_GOVT
   D:P_GC       Q:QREF_GC

* GOODS IMPORTS AND EXPORTS:
   E:P_Y(S)     Q:-1           R:NETX(S)

* NET CAPITAL IMPORTS AND EXPORTS:
   E:P_K        Q:SKTOT        R:KMX

* EXOGENOUS HOUSEHOLDS;
   E:P_L        Q:(sum(HFIX, SL(HFIX)))
   E:P_K        Q:(sum(HFIX, SK(HFIX)))
   E:P_C(G)     Q:(-sum(HFIX, RCS(G,HFIX)))

* GOVERNMENT INVESTMENT DEMAND;
   E:P_C(G)$(not CCG(G))   Q:(-GOVSAV)

* GOVERNMENT ENDOWMENTS OF CAPITAL AND GOODS:
   E:P_K        Q:GSK
   E:P_Y(S)     Q:GSE(S)

* INCOME TAXES: AVERAGE RATES
   E:P_W(H)     Q:(T_IAVE(H)*(SL(H) + SK(H)))

* INCOME TAXES: MARGINAL ADJUSTMENTS FOR CAPITAL TAXES
   E:P_K        Q:(sum(H, T_I(H)*SK(H)))
   E:P_W(H)     Q:(-T_I(H)*SK(H))
   E:P_W(H)     Q:(-T_I(H)*QREF_LS(H))

* TRANSFERS AND ADJUSTMENTS:
   E:P_W(H)     Q:(-TRN(H) - INCADJ(H))

$CONSTRAINT:NETX(S)$(VM(S)+VX(S))
   NETX(S) =e= VX(S)*(P_FX/P_Y(S))**EX(S) - VM(S)*(P_Y(S)/P_FX)**EM(S);

$CONSTRAINT:P_FX
   sum(S, P_Y(S)*NETX(S)) =g= P_K*SKTOT*KMX;

$CONSTRAINT:KMX
   KMX =e= 1 - (P_FX/P_K)**EFKS;

$CONSTRAINT:Q_G
   Q_G =g= A_GC;
$offText

$sysInclude mpsgeset GEMTAP

NETX.lo(S) = -inf;
KMX.lo     = -inf;
NETX.l(S)  = VX(S) - VM(S);
P_FX.l     = 1;
KMX.l      = 0;
Q_G.l      = 1;
RA.l(H)    = QREF_I(H);
I_GOVT.l   = QREF_GC;

Set
   SC 'scenarios' / BENCH 'BENCHMARK REPLICATION'
                    ITCUT 'UNIFORM (FLAT RATE) INCOME TAX'
                    KTCUT 'UNIFORM CAPITAL TAX'
                    LTCUT 'UNIFORM LABOR TAX'
                    CTAX  'CONSUMPTION TAX'   /
   RUN(SC) / BENCH, ITCUT, KTCUT, LTCUT, CTAX /;

Parameter SUMMARY(*,*,SC) 'solution summary';

Table UNIFTAX(SC,*) 'indicators for uniform'
           K  L  I  C
   BENCH   0  0  0  0
   ITCUT   0  0  1  0
   KTCUT   1  0  0  0
   LTCUT   0  1  0  0
   CTAX    0  0  0  1;

* SET ITERATION LIMIT TO ZERO FOR THE FIRST CASE:
if(RUN("BENCH"), GEMTAP.iterLim = 0;);

loop(SC$RUN(SC),
*  FLAT RATE CAPITAL TAX:
   if(UNIFTAX(SC,"K"),
      T_K(S) = sum(SS, TK(SS))/sum(SS, DK(SS));
   else
      T_K(S) = TK(S)/DK(S);
   );

*  FLAT RATE LABOR TAX:
   if(UNIFTAX(SC,"L"),
      T_L(S) = sum(SS, TL(SS))/sum(SS, DL(SS));
   else
      T_L(S) = TL(S)/DL(S);
   );

*  MOVE TO A FLAT RATE INCOME TAX:
   if(UNIFTAX(SC,"I"),
      T_I(H)    = TIAVE;
      T_IAVE(H) = TIAVE;
   else
      T_I(H)    = TAUBMK(H)/(1 - TAUBMK(H));
      T_IAVE(H) = PIT(H)/(SL(H) + SK(H));
   );

*  FLAT CONSUMPTION TAX:
   if(UNIFTAX(SC,"C"),
      T_C(G)    = (GBDGT("PIT") + GBDGT("TL") + GBDGT("TK") + GBDGT("TC"))/sum(GG, GCE(GG));
      T_I(H)    = 0;
      T_IAVE(H) = 0;
      T_L(S)    = 0;
      T_K(S)    = 0;
   else
      T_C(G) = TC(G)/GCE(G);
   );

$  include GEMTAP.GEN
   solve GEMTAP using mcp;

*  RESET ITERATION LIMIT AFTER BENCHMARK REPLICATION  (1ST SC):
   GEMTAP.iterLim = 5000;

*  REPORT SOLUTION STATISTICS:
   SUMMARY("STATUS","_", SC) = GEMTAP.modelStat;
   SUMMARY("ITERS", "_", SC) = GEMTAP.iterUsd;
   SUMMARY("CPU",   "_", SC) = GEMTAP.resUsd;
   SUMMARY("CONTOL","_", SC) = GEMTAP.objVal;

*  PUBLIC GOODS PROVISION:
   SUMMARY("G","_",SC) = 100*(A_GC.L - 1);
   PNUM = sum((CCG,H), RCS(CCG,H)*P_C.l(CCG))/sum((CCG,H), RCS(CCG,H));

   SUMMARY("P_FX","_",SC) = 100*(P_FX.l/PNUM - 1);
   SUMMARY("PK","_",SC)   = 100*(P_K.l/PNUM - 1);
   SUMMARY("PL","_",SC)   = 100*(P_L.l/PNUM - 1);
   SUMMARY("KMX","_",SC)  = 100*KMX.l;

*  REPORT WELARE CHANGES INDICES:
   SUMMARY("EV",H,SC)       = 100*(A_W.l(H) - 1);
   SUMMARY("EV","TOTAL",SC) = 100*(sum(H, QREF_I(H)*A_W.l(H))/sum(H, QREF_I(H)) - 1);
);
display SUMMARY;