!<
    =============================
    Global Trade Analysis Project
    GTAP-RE: An Intertemporal Rational Expectations Version of the GTAPv7.0 Model 
    GTAP-RE Version 1
    May 2025
    =============================

    For documentation see:
    Pham Van Ha, Tom Kompas, and Matthew Cantele. Rethinking the Solution 
    Strategy for Large Recursive CGE Models: Solving Recursive and Rational 
    Expectations CGE Models the Non-Recursive Way. Unpublished University of
    Melbourne manuscript. Contact the lead author for documentation.

    Erwin L. Corong, Thomas W. Hertel, Robert A. McDougall, Marinos E. Tsigas, 
    and Dominique van der Mensbrugghe. The Standard GTAP Model, Version 7. 
    Journal of Global Economic Analysis, [S.l.], v.2, n.1, p. 1-119, june 2017. 
    Available at:
    <https://jgea.org/resources/jgea/ojs/index.php/jgea/article/view/47> 
    or     
    http://dx.doi.org/10.21642/JGEA.020101AF.

    The GTAPv7 paper documents all the technical changes since the GTAP book and
    GTAP.TAB (version 6.2). For older documentation, see:  

    (a) Hertel, T.W. and M.E. Tsigas, "Structure of the Standard GTAP Model",
    Chapter 2 in T.W. Hertel (editor) "Global Trade Analysis: Modeling and
    Applications", Cambridge University Press, 1997.

    (b) R.A. McDougall, "A New Regional Household Demand System for GTAP",
    GTAP Technical Paper #20, Center for Global Trade Analysis, Purdue
    University

    (c) Hertel T.W., K. Itakura and R.A. McDougall, GTAP.TAB(version 6.2)


    ----------------------------
    HISTORY of GTAPv7 model file
    ----------------------------
    Jun 2017: Version 7.0 (JGEA publication) replaces GTAP.tab version 6.2 
   
    Version 7.1
    -----------
    Nov 2017: Added variables and equations representing tax-inclusive and 
              tax-exclusive real prices for mobile and sluggish endowments
              - pefactreal(e,r)  --> tax-exclusive real factor prices
              - pebfactreal(e,r) --> tax-inclusive real factor prices
    Apr 2018: Refined set definition in Section C-A1 (Allocative efficiency 
              effect: activity, comodity and endowment Summary) 
    Jul 2018: Defined a new set ENDT to distinguish endowment types (mobile, 
              sluggish and fixed) and added an endowment binary flag parameter 
              (ENDOWFLAG) to define endowment sets at run time. 
    Nov 2019: Modified formula for ENDWMSHR  
              - old --> ENDWMSHR(e,a,r) = EVFB(e,a,r) / VENDWM(e,r);
              - new --> ENDWMSHR(e,a,r) = EVOS(e,a,r) / VES(e,r);
              The modified formula uses supply price weights instead of basic
              price weights. This fixes a defect in ENDWMSHR in the classic 
              GTAP v6.2 model (does not show up in the results since factor 
              income taxes were activity-generic). In the GTAPv7 model factor 
              income taxes, tinc(e,a,r), are activity-specific. So factor tax   
              changes in a particular activity, say labor tax in agriculture, 
              would cause reallocation as suppliers of labor would react to the 
              tax change. The old formula results in adding up inconsistency and 
              unintened endowment welfare effects when income taxes are shocked.
    Dec 2019: Modified Section C-A21 and added Section CA25 in the Welfare 
              decomposition module to distinguish between output and income tax 
              effects. This required changes to BOUTAX and BINCTAX formulae, and
              BMAKEBACT replaced by BMAKEB (See Section C: Welfare summary).    
              Also fixed a typo error by renaming Section A3 to A24
              - Section 11.5  --> added element "inctax" in the Set ALLTAX   
              - Section C-A21 --> now only reports output tax effect
        [NEW] - Section C-A25 --> reports factor income tax effect  
    Feb 2020: Added zerodivide statements in share calculations for PMSHR, GMSHR
              and IMSHR to avoid arithmetic errors. This change is associated 
              with reduced smearing (i.e., use of tiny number, typically 1.0e-6 
              in lieu of zeroes) in GTAP Data Base construction.
    Aug 2020: Modified the following:
              - Consistent use of zerodivide statements throughout the code.
              - Corrected formula for coefficient VWOU: now includes VIP(c,r)
              - Updated indices for some coefficients and variables to ensure
                consistent use of "s" for source or exporting regions and
                "d" for destination or importing regions.
              - Corrected E_del_tbary by adding 100 * on the left-hand side
                - old -->  INCOMEWLD * del_tbalry(r)  
                - new -->  INCOMEWLD * 100 * del_tbalry(r) 
              - Re-arranged Section 11 (Welfare measurement and decomposition) 
                for readability. Welfare contribution equations are now arranged
                into sub-sections and ordered in the same way as they appear in 
                E_EV_ALT(r). Some welfare contribution equations were also 
                streamlined to avoid repetitive calculations. For example,                
                - old --> CNTqe(e,r) = [0.01 * EVSCALFACT(r)] * sum{a,ACTS, 
                                         INCTAX(e,a,r) * [qes(e,a,r) - pop(r)]};
                - new --> CNTqe(e,r) = sum{a,ACTS, CNTqea(e,a,r)};
    Jan 2022: Modified the following:
              - Renamed set CTAX to ALLTAX in the welfare decomposition module 
	      	    (Section 11-5)  since this set covers ALL taxes in the economy.  
              - [NEW] World GDP indices (qgdpwld,pgdpwld,vgdpwld) in Section B-3.
    Aug 2023: Added [NEW] aggregate quantity index for private household demand, 
              qpriv(r), and government demand, qgov(r), in Sections 5-1 and 5-2.
                 	
    ----------------------------------
    Overview of the GTAP.TAB Structure
    ----------------------------------
    Preliminaries:
        A-0. FILES
        A-1. SET definitions
        A-2. READ Base Data
        A-3. Key derivatives of Base Data
        A-4. Common COEFFICIENTS
        A-5. Common VARIABLES

    Equation Modules:
        1.  Firms
        2.  Commodity supply
        3.  Income distribution
        4.  Allocation of income across expenditure categories
        5.  Domestic final demand
        6.  Trade, goods market equilibrium and prices
        7.  Factor market equilibrium
        8.  Allocation of global saving
        9.  Tax revenue streams
       10.  Numeraire and Walras law
            ................................................
            Summary Indices (for use in welfare measurement)
            ................................................
            B-0. Variables and coefficients for summary indices
            B-1. Factor price indices
            B-2. Regional terms of trade (ToT)
            B-3. GDP indices (value, price and quantity)
            B-4. Aggregate trade indices (value, price and quantity)
            B-5. Trade balance indices
            B-6. Terms of trade (ToT) decomposition 
       11.  Welfare measurement and decomposition 

    Welfare summary and post-sim calculations:
       C. Welfare decomposition summary
       D. Volume changes (GTAPVol)
       E. Data balance checks

>!

!<
    ----------
    A-0. FILES
    ----------
>!

File
    GTAPSETS # file with set specification #;
File
    GTAPDATA # file containing all base data #;
File
    GTAPPARM # file containing behavioral parameters #;
File
    GTAPINT # file containing GTAP-INT intertemporal-specific coefficients #;

!<
    --------------------
    A-1. SET definitions
    --------------------

    Sets define relevant groupings of entities over which we will be performing 
    operations in the model. SUBSETS are defined in order to facilitate 
    summation over only a portion of a given group, e.g., margin commodities.

    The GTAP Model requires separate SET specification for activities and 
    commodities because of multi-production possibilities--i.e., a single 
    activity could produce multiple commodities (e.g., an agriculture activity 
    producing multiple agricultural commodities), or for a commodity to be 
    produced by multiple activities (e.g., electricity being produced by 
    different generation activities).

    Although the standard GTAP Data Base has a diagonal 'make' matrix, it is 
    possible to aggregate it such that the resulting aggregated 
    database would have a non-diagonal 'make' matrix structure.    

    Aide-Memoire for Sets and indices
    ---------------------------------

    Activities
    |-----------|
    |  ACTS(a)  |
    |-----------|

    Commodities
    |-----------------------|
    |        COMM(c)        |
    |-----------------------|
    |  MARG(m)  |  NMRG(n)  |
    |-----------------------|

    Endowments
    |---------------------------------------------------|
    |                      ENDW(e)                      |
    |---------------------------------------------------|
    |  ENDWF(e)  |  ENDWC(e)  |  ENDWM(e)  |  ENDWS(e)  |  
    |---------------------------------------------------|
                 |              ENDWMS(e)               |  
                 |--------------------------------------|


    Commodities and endowments
    |-----------------------|
    |        DEMD(d)        |
    |-----------------------|
    |  COMM(c)  |  ENDW(e)  |
    |-----------------------|

>!


Set
    REG # regions #
    read elements from file GTAPSETS header "REG";                 
Set
    COMM # commodities #
    read elements from file GTAPSETS header "COMM";                
Set
    MARG # margin commodities #
    read elements from file GTAPSETS header "MARG";                
Subset
    MARG is subset of COMM;                              
Set
    NMRG # non-margin commodities # = COMM - MARG;  
Set
    ACTS # Activities # 
    read elements from file GTAPSETS header "ACTS";                
Set 
    ENDW # endowments #
    read elements from file GTAPSETS header "ENDW";
Set !< The single element ENDWC set is defined for the sake of convenience >!
    ENDWC # capital endowment # (capital);
Subset
    ENDWC is subset of ENDW;
Set
    ENDWF # Sector-specific endowment # (natlres);
Set
    ENDWS # sluggish endowment # (land);
Set
    ENDWFS # fixed and sluggish endowments # = ENDWF + ENDWS;
Subset
    ENDWFS is subset of ENDW;
Set
    ENDWM # mobile endowments # = ENDW - ENDWFS;
Subset
    ENDWM is subset of ENDW;
Subset
    ENDWC is subset of ENDWM;
Subset
    ENDWS is subset of ENDW;
Set 
    ENDWMS # mobile and sluggish endowments # = ENDWM + ENDWS;
Subset
    ENDWMS is subset of ENDW;
Subset
    ENDWC is subset of ENDWMS;
Set
    ENDWMSNC # mobile and sluggish not capital # = ENDWMS - ENDWC;
Set
    DEMD # demanded commodities and endowments # = ENDW + COMM;

Coefficient (integer)
    NTSP # Number of timesteps #;
Read
    NTSP from file GTAPINT header "NTSP";

Set (intertemporal)
    ALLTIME # All time steps # maximum size 51 (P[0] - P[NTSP-1]);

Coefficient (parameter)(all,t,ALLTIME)
    YEAR(t) # Actual years #;
Read
    YEAR from file GTAPINT header "YEAR";

Set (intertemporal)
    INITIME # Initial time step # size 1 (P[0]);

Set (intertemporal)
    ENDTIME # End time step # size 1 (P[NTSP-1]);

Set (intertemporal)
    FWDTIME # All time steps except ENDTIME # maximum size 50 (P[0] - P[NTSP-2]);

Subset INITIME is subset of ALLTIME;
Subset ENDTIME is subset of ALLTIME;
Subset FWDTIME is subset of ALLTIME;

!<
    -------------------
    A-2. READ Base Data
    -------------------
    We read in here almost all the base data, and define variables and
    coefficients associated with them. A few data arrays, namely: VKB, 
    VTMFSD and DPARSUM are read in their respective modules.

    Data flows and prices are valued at: supplier(S)
                                         basic(B)     
                                         purchaser(P)
                                         FOB exports 
                                         CIF imports

    The READ statements are divided into six sections:
    Firms
    Commodity Supply
    Government Consumption
    Private Consumption
    Investment Consumption
    Saving
    Global Bank
    International Trade and Transport

    Since these are invariant for each solution of the model, they are termed
    coefficients. Coefficients are assigned upper case to distinguish them
    from variables (this is purely cosmetic, as GEMPACK is not case-sensitive). 
    Variables in GEMPACK are assigned lower case labels to denote the fact that 
    they are percentage changes. In some cases, original levels values for 
    selected variables are defined to permit the user to compare post-simulation 
    levels values across several simulations.

    The updating command indicates how the new level of the coefficient will
    be computed based on the previous solution of the linearized equations.
    Note that the notation used in the update commands is a shorthand for
    total differentials of these coefficient values.  Thus, w * v indicates
    that we want to take the total differential of W * V, plug in the
    calculated values of w and v, and add this to the base level in order to
    obtain a revised value for this product.
>!

Coefficient 
    RNREG # Reciprocal of number of regions (for zerodivide default) #;
Formula
    RNREG = 1 / sum{r,REG, 1};

!<
    Firms
    -----
>!

!<  Domestic intermediate purchases by firms at basic prices >!
Variable (orig_level=1.0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME) 
    pds(c,r,t) # price of domestically supplied commodity c in region r #;
Variable (orig_level=VDFB)(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qfd(c,a,r,t) # demand for domestic commodity c by activity a in region r #;
Coefficient (ge 0)(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VDFB(c,a,r,t) # expenditure on domestic c by act. a in r at basic prices #;
Read
    VDFB from file GTAPDATA header "VDFB";
Update (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VDFB(c,a,r,t) = pds(c,r,t) * qfd(c,a,r,t);

!<  Imported intermediate purchases by firms at basic prices >!
Variable (orig_level=1.0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pms(c,r,t) # price of aggregate commodity import bundle c in region r #;
Variable (orig_level=VMFB)(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qfm(c,a,r,t) # imported commodity c for use by activity a in region r #;
Coefficient (ge 0)(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VMFB(c,a,r,t) # expenditure on imported c by act. a in r at basic prices #;
Read
    VMFB from file GTAPDATA header "VMFB";
Update (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VMFB(c,a,r,t) = pms(c,r,t) * qfm(c,a,r,t);

!<  Domestic intermediate purchases by firms at purchaser's prices >!
Variable (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pfd(c,a,r,t) # price of domestic com. c purchased by act. a in region r #;
Coefficient (ge 0)(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VDFP(c,a,r,t) # expenditure on dom. c by act. a in r at purchaser's prices #;
Read
    VDFP from file GTAPDATA header "VDFP";
Update (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VDFP(c,a,r,t) = pfd(c,a,r,t) * qfd(c,a,r,t);

!<  Imported intermediate purchases by firms at purchaser's prices >!
Variable (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pfm(c,a,r,t) # price of imported com. c purchased by act. a in region r #; 
Coefficient (ge 0)(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VMFP(c,a,r,t) # expenditure on imp. c by act. a in r at purchaser's prices #;
Read
    VMFP from file GTAPDATA header "VMFP";
Update (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VMFP(c,a,r,t) = pfm(c,a,r,t) * qfm(c,a,r,t);

!<  Endowment at supplier's (after income tax) prices >!
Variable (Orig_level=1.0)(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pes(e,a,r,t) # supply (after income tax) price of e for use by a in r #;
Variable (orig_level=EVOS)(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qes(e,a,r,t) # supply of endowment e for use by activity a in region r #;
Coefficient (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    EVOS(e,a,r,t) # value of e for use by a in r at supplier (after tax) prices #; 
Read
    EVOS from file GTAPDATA header "EVOS";
Update (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    EVOS(e,a,r,t) = pes(e,a,r,t) * qes(e,a,r,t);

!<  Endowments at basic (income tax inclusive) prices >!
Variable (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    peb(e,a,r,t) # basic price of endowment e in act. a in region r #;
Variable (orig_level=EVFB)(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qfe(e,a,r,t) # demand for endowment e by act. a in region r #;
Coefficient (ge 0)(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    EVFB(e,a,r,t) # expenditure on endowment e by act. a in r at basic prices #;
Read
    EVFB from file GTAPDATA header "EVFB";
Update (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    EVFB(e,a,r,t) = peb(e,a,r,t) * qfe(e,a,r,t);

!<  Endowments at purchaser's prices >!
Variable (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pfe(e,a,r,t) # price of endowment e purchased by activity a region r #;
Coefficient (ge 0)(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    EVFP(e,a,r,t) # expenditure on endowment e by a in r at purchaser's prices #;
Read
    EVFP from file GTAPDATA header "EVFP";
Update (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    EVFP(e,a,r,t) = pfe(e,a,r,t) * qfe(e,a,r,t);

!<
    Commodity supply
    ----------------
>!

!<  'make' matrix at supplier's (i.e., output tax exclusive) prices >!
Variable (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME) 
    ps(c,a,r,t) # supply price of commodity c produced by activity a in r #;   
Variable (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME) 
    qca(c,a,r,t) # supply of commodity c by activity a in r #;
Coefficient (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MAKES(c,a,r,t) # 'make' matrix valued at supplier's prices #;
Read
    MAKES from file GTAPDATA header "MAKS";
Update (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MAKES(c,a,r,t) = ps(c,a,r,t) * qca(c,a,r,t);

!<  'make' matrix at basic (i.e., output tax inclusive) prices >!
Variable (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME) 
    pca(c,a,r,t) # basic price of commodity c produced by activity a in r #;
Coefficient (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)  
    MAKEB(c,a,r,t) # 'make' matrix valued at basic prices #;
Read   
    MAKEB from file GTAPDATA header "MAKB";
Update (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME) 
    MAKEB(c,a,r,t) = pca(c,a,r,t) * qca(c,a,r,t);

!<
    Government consumption
    ----------------------
>!

!<  Domestic commodity purchases by government at basic prices >!
Variable (orig_level=VDGB)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qgd(c,r,t) # government demand for domestic commodity c in region r #;
Coefficient (ge 0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDGB(c,r,t) # government expenditure on domestic c in r at basic prices #;
Read
    VDGB from file GTAPDATA header "VDGB";
Update (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDGB(c,r,t) = pds(c,r,t) * qgd(c,r,t);

!<  Imported commodity purchases by government at basic prices >!
Variable (orig_level=VMGB)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qgm(c,r,t) # government demand for imported commodity c in region r #;
Coefficient (ge 0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VMGB(c,r,t) # government expenditure on imported c in r at basic prices #;
Read
    VMGB from file GTAPDATA header "VMGB";
Update (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VMGB(c,r,t) = pms(c,r,t) * qgm(c,r,t);

!<  Domestic commodity purchases by government at purchaser's prices >!
Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pgd(c,r,t) # price of domestic com. c purchased by government in region r #;
Coefficient (ge 0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDGP(c,r,t) # government expenditure on dom. c in r at purchaser's prices #;
Read
    VDGP from file GTAPDATA header "VDGP";
Update (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDGP(c,r,t) = pgd(c,r,t) * qgd(c,r,t);

!<  Imported commodity purchases by government at purchaser's prices >!
Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pgm(c,r,t) # price of imported com. c purchased by government in region r #;
Coefficient (ge 0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VMGP(c,r,t) # government expenditure on imp. c in r at purchaser's prices #;
Read
    VMGP from file GTAPDATA header "VMGP";
Update (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VMGP(c,r,t) = pgm(c,r,t) * qgm(c,r,t);

!<
    Private consumption
    -------------------
>!

!<  Domestic commodity purchases by priv. household at basic prices >!
Variable (orig_level=VDPB)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qpd(c,r,t) # private household demand for domestic commodity c in region r #;
Coefficient (ge 0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDPB(c,r,t) # private household expenditure on dom. c in r at basic prices #;
Read
    VDPB from file GTAPDATA header "VDPB";
Update (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDPB(c,r,t) = pds(c,r,t) * qpd(c,r,t);

!<  Imported commodity purchases by priv. household at basic prices >!
Variable (orig_level=VMPB)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qpm(c,r,t) # private household demand for imported commodity c in region r #;
Coefficient (ge 0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VMPB(c,r,t) # private household expenditure on imp. c in r at basic prices #;
Read
    VMPB from file GTAPDATA header "VMPB";
Update (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VMPB(c,r,t)= pms(c,r,t) * qpm(c,r,t);

!<  Domestic commodity purchases by priv. household at purchaser's prices >!
Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    ppd(c,r,t) # price of domestic com. c purchased by private household in r #;
Coefficient (ge 0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDPP(c,r,t) # private hhld expenditure on dom. c in r at purchaser's prices #;
Read
    VDPP from file GTAPDATA header "VDPP";
Update (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDPP(c,r,t) = ppd(c,r,t) * qpd(c,r,t);

!<  Imported commodity purchases by priv. household at purchaser's prices >!
Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    ppm(c,r,t) # price of imported com. c purchased by private household in r #;
Coefficient (ge 0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VMPP(c,r,t) # private hhld expenditure on imp. c in r at purchaser's prices #;
Read
    VMPP from file GTAPDATA header "VMPP";
Update (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VMPP(c,r,t) = ppm(c,r,t) * qpm(c,r,t);

!<
    Investment consumption
    ----------------------
>!

!<  Domestic commodity purchases by investment agent at basic prices >!
Variable (orig_level=VDIB)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qid(c,r,t) # investment demand for domestic commodity c in region r #;
Coefficient (ge 0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDIB(c,r,t) # investment expenditure on domestic c in r at basic prices #;
Read
    VDIB from file GTAPDATA header "VDIB";
Update (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDIB(c,r,t) = pds(c,r,t) * qid(c,r,t);

!<  Imported commodity purchases by investment agent at basic prices >!
Variable (orig_level=VMIB)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qim(c,r,t) # investment demand for imported commodity c in region r #;
Coefficient (ge 0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VMIB(c,r,t) # investment expenditure on imported c in r at basic prices #;
Read
    VMIB from file GTAPDATA header "VMIB";
Update (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VMIB(c,r,t) = pms(c,r,t) * qim(c,r,t);

!<  Domestic commodity purchases by investment agent at purchaser's prices >!
Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pid(c,r,t) # price of domestic com. c purchased by investment agent in r #;
Coefficient (ge 0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDIP(c,r,t) # investment expenditure on dom. c in r at purchaser's prices #; 
Read
    VDIP from file GTAPDATA header "VDIP";
Update (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDIP(c,r,t) = pid(c,r,t) * qid(c,r,t);

!<  Imported commodity purchases by investment agent at purchaser's prices >!
Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pim(c,r,t) # price of imported com. c purchased by investment agent in r #;
Coefficient (ge 0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VMIP(c,r,t) # investment expenditure on imp. c in r at purchaser's prices #;
Read
    VMIP from file GTAPDATA header "VMIP";
Update (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VMIP(c,r,t) = pim(c,r,t) * qim(c,r,t);

!<
    Saving
    ------
>!

Variable (all,r,REG)(all,t,ALLTIME)
    psave(r,t) # price of saving in region r #;
Variable (all,r,REG)(all,t,ALLTIME)
    qsave(r,t) # regional demand for NET saving #;
Coefficient (all,r,REG)(all,t,ALLTIME)
    SAVE(r,t) # NET saving in region r valued at purchaser's prices #;
Read
    SAVE from file GTAPDATA header "SAVE";
Update (all,r,REG)(all,t,ALLTIME)
    SAVE(r,t) = psave(r,t) * qsave(r,t);

!<
    Global bank
    -----------
>!

Variable (all,r,REG)(all,t,ALLTIME)
    pinv(r,t) # price index of investment goods #;
Variable (all,r,REG)(all,t,ALLTIME)
    kb(r,t) # beginning-of-period capital stock in r #;
Coefficient (ge 0)(all,r,REG)(all,t,ALLTIME)
    VDEP(r,t) # value of capital depeciation in r (exogenous) #;
Read
    VDEP from file GTAPDATA header "VDEP";
Update (all,r,REG)(all,t,ALLTIME)
    VDEP(r,t) = pinv(r,t) * kb(r,t);
!<
    Value of capital depreciation is used to compute the (exogenous)
    depreciation rate and therefore does not appear in update.
>!

!<
    International trade
    -------------------
>!

!<  Exports at basic prices >!
Variable (orig_level=VXSB)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    qxs(c,s,d,t) # export sales of commodity c from source s to destination d #;
Coefficient (ge 0)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VXSB(c,s,d,t) 
    # value of exports of  c from s to d at basic prices (tradeables only) #;
Read
    VXSB from file GTAPDATA header "VXSB";
Update (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VXSB(c,s,d,t) = pds(c,s,t) * qxs(c,s,d,t);

!<  Exports at FOB (i.e., exports tax inclusive) prices >!
Variable (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    pfob(c,s,d,t) # FOB world price of com. c from source s to destination d #;
Coefficient (ge 0)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VFOB(c,s,d,t) 
    # value of exports of c from s to d at FOB prices (tradeables only) #;
Read
    VFOB from file GTAPDATA header "VFOB";
Update (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VFOB(c,s,d,t) = pfob(c,s,d,t) * qxs(c,s,d,t);

!<  Imports at CIF prices >!
Variable (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    pcif(c,s,d,t) # CIF world price of imported com. c from source s to dest. d #;
Coefficient (ge 0)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VCIF(c,s,d,t) 
    # value of imports of c from s to d at CIF prices (tradeables only) #;
Read
    VCIF from file GTAPDATA header "VCIF";
Update (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VCIF(c,s,d,t) = pcif(c,s,d,t) * qxs(c,s,d,t);

!<  Imports at basic (import tariff inclusive) prices >!
Variable (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    pmds(c,s,d,t) # price of imported c supplied by source region s to dest. d #;
Coefficient (ge 0)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VMSB(c,s,d,t) 
    # value of imports of c from s to d at domestic (basic) prices #;
Read
    VMSB from file GTAPDATA header "VMSB";
Update (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VMSB(c,s,d,t) = pmds(c,s,d,t) * qxs(c,s,d,t);

!<
    International transport margins
    -------------------------------
>!

Variable (orig_level=VST)(all,m,MARG)(all,r,REG)(all,t,ALLTIME)
    qst(m,r,t) # supply of margin m from region r for international transport #;
Coefficient (ge 0)(all,m,MARG)(all,r,REG)(all,t,ALLTIME)
    VST(m,r,t) 
    # value of exports of margin m from r for int'l transport at basic prices #;
Read
    VST from file GTAPDATA header "VST";
Update (all,m,MARG)(all,r,REG)(all,t,ALLTIME)
    VST(m,r,t) = pds(m,r,t) * qst(m,r,t);

!<
    -------------------------------------
    A-3. Key derivatives of the Base Data
    -------------------------------------

    Key derivatives of the Base Data 
    Regional expenditure and income
    Indirect tax receipts
    Miscellaneous coefficients and parameters

>!

!<  Intermediate and endowment expenditure by firms at purchaser's prices >!
Coefficient (all,d,DEMD)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VFP(d,a,r,t) # expenditure on d by act. a in r valued at purchaser's prices #;
Formula (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VFP(e,a,r,t) = EVFP(e,a,r,t);
Formula (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VFP(c,a,r,t) = VDFP(c,a,r,t) + VMFP(c,a,r,t);

!<  Value of output at supplier's prices >!
Coefficient (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VOS(a,r,t) # output of act. a in r valued at supplier's prices #;
Formula (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VOS(a,r,t) = sum{d,DEMD, VFP(d,a,r,t)};

!<  Endowments >!
Coefficient (all,e,ENDW)(all,r,REG)(all,t,ALLTIME)
    VES(e,r,t) # endowment supply in region r, at supplier's (after tax) prices #;
Formula (all,e,ENDW)(all,r,REG)(all,t,ALLTIME)
    VES(e,r,t) = sum{a,ACTS, EVOS(e,a,r,t)};

!< Commodity supply >!
Coefficient (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)  
    MAKEBACT(a,r,t) # total output of activity a valued at basic prices #;
Formula (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)  
    MAKEBACT(a,r,t) = sum{c,COMM, MAKEB(c,a,r,t)};

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    MAKEBCOM(c,r,t) # supply of commodity c valued at basic prices #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME) 
    MAKEBCOM(c,r,t) = sum{a,ACTS, MAKEB(c,a,r,t)};

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDB(c,r,t) # domestic sales of c in r at basic prices (tradeables only) #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDB(c,r,t) = VDPB(c,r,t) + VDGB(c,r,t) + VDIB(c,r,t) + sum{a,ACTS, VDFB(c,a,r,t)};

!<  Commodity supply = Commodity demand >!
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VCB(c,r,t) # supply of commodity c in region r valued at basic prices #;
!Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VCB(c,r,t) = VDB(c,r,t) + sum{d,REG, VXSB(c,r,d)} + IF[c in MARG, VST(c,r,t)];!
Formula (all,c,NMRG)(all,r,REG)(all,t,ALLTIME)
    VCB(c,r,t) = VDB(c,r,t) + sum{d,REG, VXSB(c,r,d,t)};
Formula (all,c,MARG)(all,r,REG)(all,t,ALLTIME)
    VCB(c,r,t) = VDB(c,r,t) + sum{d,REG, VXSB(c,r,d,t)} + VST(c,r,t);


!<
    Regional expenditure and income
    -------------------------------

    Regional income is allocated between private consumption expenditure,
    government consumption expenditure, and saving.

    Expenditure of Regional household
    .................................

                   Regional household(h.h.)
                    Expenditure = Income
                             _/|\_
                           _/  |  \_
                         _/    |    \_
                       _/      |      \_
                     _/        |        \_
           Private h.h.        |        Government h.h.
           ( PRIVEXP )         |          ( GOVEXP )
              _/\_             |              _/\_  <---(CES: ESUBG)
            _/    \_           |            _/    \_
           /        \          |           /        \
        Domestic  Imported   Saving    Domestic    Imported
         Goods     Goods     ( SAVE )    Goods       Goods
        ( VDPP )  ( VMPP )              ( VDGP )    ( VMGP )

    Note: The coefficients at the ends of branches are
          Base Data, e.g., VDPP, SAVE.
>!

!< Government consumption expenditure, GOVEXP >!
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VGP(c,r,t) # government cons. expenditure on c in r at purchaser's prices #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VGP(c,r,t) = VDGP(c,r,t) + VMGP(c,r,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    GOVEXP(r,t) # aggregate government expenditure in region r #;
Formula (all,r,REG)(all,t,ALLTIME)
    GOVEXP(r,t) = sum{c,COMM, VGP(c,r,t)};

!< Private household consumption expenditure, PRIVEXP >!
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VPP(c,r,t) # private household expenditure on c in r at purchaser's prices #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VPP(c,r,t) = VDPP(c,r,t) + VMPP(c,r,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    PRIVEXP(r,t) # aggregate private consumption expenditure in region r #;
Formula (all,r,REG)(all,t,ALLTIME)
    PRIVEXP(r,t) = sum{c,COMM, VPP(c,r,t)};

!< Investment consumption expenditure >!
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VIP(c,r,t) # expenditure on investment c valued at purchaser's prices #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VIP(c,r,t) = VDIP(c,r,t) + VMIP(c,r,t);

!< Aggregate income = aggregate expenditure + saving >!
Coefficient (all,r,REG)(all,t,ALLTIME)
    INCOME(r,t) # level of expenditure, which equals NET income in region r #;
Formula (all,r,REG)(all,t,ALLTIME)
    INCOME(r,t) = PRIVEXP(r,t) + GOVEXP(r,t) + SAVE(r,t);

!<
    Indirect tax receipts
    ---------------------
>!

!< Production tax revenue >!
Coefficient (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    PTAX(c,a,r,t) # revenue from tax on commodity c produced by activity a in r #;
Formula (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    PTAX(c,a,r,t) = MAKEB(c,a,r,t) - MAKES(c,a,r,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    TAXROUT(r,t) # total revenue from production tax payments in region r #;
Formula (all,r,REG)(all,t,ALLTIME)
    TAXROUT(r,t) = sum{c,COMM, sum{a,ACTS, PTAX(c,a,r,t)}};

!< Government consumption tax revenue >!
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    DGTAX(c,r,t) # tax revenue from gov't cons. of domestic c in region r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    DGTAX(c,r,t) = VDGP(c,r,t) - VDGB(c,r,t);
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    MGTAX(c,r,t) # tax revenue from gov't consumption of imported c in region r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    MGTAX(c,r,t) = VMGP(c,r,t) - VMGB(c,r,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    TAXRGC(r,t) # total revenue from government consumption tax payments in r #;
Formula (all,r,REG)(all,t,ALLTIME)
    TAXRGC(r,t) = sum{c,COMM, DGTAX(c,r,t) + MGTAX(c,r,t)};

!< Private household consumption tax revenue >!
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    DPTAX(c,r,t) # tax revenue from priv. hhld cons. of domestic c in region r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    DPTAX(c,r,t) = VDPP(c,r,t) - VDPB(c,r,t);
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    MPTAX(c,r,t) # tax revenue from priv. hhld cons. of imported c in region r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    MPTAX(c,r,t) = VMPP(c,r,t) - VMPB(c,r,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    TAXRPC(r,t) # total revenue from priv. hhld consumption tax payments in r #; 
Formula (all,r,REG)(all,t,ALLTIME)
    TAXRPC(r,t) = sum{c,COMM, DPTAX(c,r,t) + MPTAX(c,r,t)};

!< Investment consumption tax revenue >!
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    DITAX(c,r,t) # tax revenue from investment cons. of domestic c in region r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    DITAX(c,r,t) = VDIP(c,r,t) - VDIB(c,r,t);
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    MITAX(c,r,t) # tax revenue from investment cons. of imported c in region r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    MITAX(c,r,t) = VMIP(c,r,t) - VMIB(c,r,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    TAXRIC(r,t) # total revenue from investment consumption tax payments in r #;
Formula (all,r,REG)(all,t,ALLTIME)
    TAXRIC(r,t) = sum{c,COMM, DITAX(c,r,t) + MITAX(c,r,t)};

!< Intermediate consumption tax revenue >!
Coefficient (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    DFTAX(c,a,r,t) # tax revenue from use of dom. intermediate c by act. a in r #;
Formula (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    DFTAX(c,a,r,t) = VDFP(c,a,r,t) - VDFB(c,a,r,t);
Coefficient (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MFTAX(c,a,r,t) # tax revenue from use of imp. intermediate c by act. a in r #;
Formula (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MFTAX(c,a,r,t) = VMFP(c,a,r,t) - VMFB(c,a,r,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    TAXRIU(r,t) # total revenue from tax on intermediate goods usage in r #;
Formula (all,r,REG)(all,t,ALLTIME)
    TAXRIU(r,t) = sum{c,COMM, sum{a,ACTS, DFTAX(c,a,r,t) + MFTAX(c,a,r,t)}};

!< Endowment tax revenue >!
Coefficient (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    ETAX(e,a,r,t) # tax revenue from use of endowment e by act. a in region r #;
Formula (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    ETAX(e,a,r,t) = EVFP(e,a,r,t) - EVFB(e,a,r,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    TAXRFU(r,t) # total revenue from use of factor/endowment e by act. a in r #; 
Formula (all,r,REG)(all,t,ALLTIME)
    TAXRFU(r,t) = sum{e,ENDW, sum{a,ACTS, ETAX(e,a,r,t)}};

!< Endowment income tax revenue <!
Coefficient (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    INCTAX(e,a,r,t) # tax revenue from endowment income tax in region r #;
Formula (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    INCTAX(e,a,r,t) = EVFB(e,a,r,t) - EVOS(e,a,r,t);

!< Exports tax revenue <!
Coefficient (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    XTAXD(c,s,d,t) # tax rev. from exports of c from source s to destination d #;
Formula (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    XTAXD(c,s,d,t) = VFOB(c,s,d,t) - VXSB(c,s,d,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    TAXREXP(r,t) # total revenue from export tax payments in r #;
Formula (all,s,REG)(all,t,ALLTIME)
    TAXREXP(s,t) = sum{c,COMM, sum{d,REG, XTAXD(c,s,d,t)}};

!< Import tariff revenue >!
Coefficient (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    MTAX(c,s,d,t) # tax rev from imports of c from source s to destination d #;
Formula (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    MTAX(c,s,d,t) = VMSB(c,s,d,t) - VCIF(c,s,d,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    TAXRIMP(r,t) # total revenue from import tax payments in r #;
Formula (all,d,REG)(all,t,ALLTIME)
    TAXRIMP(d,t) = sum{c,COMM, sum{s,REG, MTAX(c,s,d,t)}};

!<
    -----------------------------------
    A-4. Commom COEFFICIENTS/PARAMETERS
    -----------------------------------
    Common coefficients are defined as coefficients which are used in more
    than one module. For example, ESUBD(c,r,t) is used in the goverment household,
    private household, and firms modules.
>!

!< Regional investment expenditure >!
Coefficient (ge 0)(all,r,REG)(all,t,ALLTIME)
    VKB(r,t) # value of beginning-of-period capital stock in region r #;
Read
    VKB from file GTAPDATA header "VKB";
Update (all,r,REG)(all,t,ALLTIME)
    VKB(r,t) = pinv(r,t) * kb(r,t);
Coefficient (parameter)
    DELTAKADJ # Switch coefficient to turn off convex adjustment cost function #;
Formula (initial)
    DELTAKADJ = 1;
Coefficient (parameter)(all,r,REG)(all,t,ALLTIME)
    CPHI(r,t) # investment parameter #;
Formula (all,r,REG)(all,t,ALLTIME)
    CPHI(r,t) = 0.1;
Coefficient (parameter)(all,r,REG)(all,t,ALLTIME)
    KAPPA(r,t) # depreciation rate #;
Formula (all,r,REG)(all,t,ALLTIME)
    KAPPA(r,t) = 0.05;

Coefficient (parameter)(all,r,REG)(all,t,ALLTIME)
    LTGR(r,t) # discount coefficient #;
Coefficient (all,r,REG)(all,t,ALLTIME)
    VCAPI(r,t) # Value of real capital increment #;
Formula (all,r,REG)(all,t,ALLTIME)
    LTGR(r,t) = 0.04;
Coefficient (all,r,REG)(all,t,ALLTIME)
    REGINV(r,t) # regional GROSS investment in r #;
Formula (all,r,REG)(all,t,ALLTIME)
    REGINV(r,t) = sum{c,COMM, VIP(c,r,t)};
Formula (initial)(all,r,REG)(all,t,ALLTIME)
    VCAPI(r,t) = DELTAKADJ*[(VKB(r,t)^2+2*CPHI(r,t)*VKB(r,t)*REGINV(r,t))^0.5-VKB(r,t)]/CPHI(r,t)
                                                + [1-DELTAKADJ]*REGINV(r,t);
Variable (all,r,REG)(all,t,ALLTIME)
    capi(r,t) #Increase in capital stock#;
Variable (all,r,REG)(all,t,ALLTIME)
    qinv(r,t) # demand for investment/capital goods in region r #;
Update (all,r,REG)(all,t,ALLTIME)
    VCAPI(r,t) = capi(r,t)*pinv(r,t);
Equation
E_inv #Investment function# (all,r,REG)(all,t,ALLTIME)
   qinv(r,t)=capi(r,t)+DELTAKADJ*CPHI(r,t)*VCAPI(r,t)
      /(2*VKB(r,t)+CPHI(r,t)*VCAPI(r,t))*(capi(r,t)-kb(r,t));
Coefficient (all,r,REG)(all,t,ALLTIME)
    NETINV(r,t) # regional NET investment in region r #;
Formula (all,r,REG)(all,t,ALLTIME)
    NETINV(r,t) = VCAPI(r,t)!REGINV(r,t)! - VDEP(r,t);

!< Net global investment expenditure >!
Coefficient (all,t,ALLTIME)
    GLOBINV(t) # global expenditures on net investment #;
Formula (all,t,ALLTIME)
    GLOBINV(t) = sum{r,REG, NETINV(r,t)};

Zerodivide default RNREG;
!< Elasticity of cost with respect to utility from private consumption >!
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CONSHR(c,r,t) # share of private hhld consumption devoted to good c in r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CONSHR(c,r,t) = VPP(c,r,t) / PRIVEXP(r,t);
Zerodivide off;
Coefficient (parameter)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    INCPAR(c,r,t) # expansion parameter in the CDE minimum expenditure function #;
Read
    INCPAR from file GTAPPARM header "INCP";
Coefficient (all,r,REG)(all,t,ALLTIME)
    UELASPRIV(r,t)
    # elasticity of cost wrt utility from private consumption #;
Formula (all,r,REG)(all,t,ALLTIME)
    UELASPRIV(r,t) = sum{c,COMM, CONSHR(c,r,t) * INCPAR(c,r,t)};

!<  Domestic/imported Armington elasticity >!
Coefficient (parameter)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    ESUBD(c,r,t) 
    # region-specific elast. of subst. for dom. and imp. goods for all agents #;
Read
    ESUBD from file GTAPPARM header "ESBD";
Assertion (all,c,COMM)(all,r,REG)(all,t,ALLTIME) ESUBD(c,r,t) ge 0;

!<
    ---------------------
    A-5. Common VARIABLES
    ---------------------

    Common variables are defined as variables which are used in more than one
    module. For example, the variable y(r,t) is used in the Goverment 
    Consumption, Private Consumption, Firms, Regional Household and
    Investment, Global Bank and Saving modules. 
    Appendices, e.g., Summary Indices, are not included in this definition.
>!

Variable (all,r,REG)(all,t,ALLTIME)
    y(r,t) # regional household income in region r #;
Variable (all,r,REG)(all,t,ALLTIME)
    pop(r,t) # regional population #;

Variable (all,r,REG)(all,t,ALLTIME)
    pgov(r,t) # price index for gov't expenditure in region r #;
Variable (all,r,REG)(all,t,ALLTIME)
    yg(r,t) # regional government consumption expenditure in region r #;
Variable (all,r,REG)(all,t,ALLTIME)
    ug(r,t) # per capita utility from gov't expend. in region r #;

Variable (all,r,REG)(all,t,ALLTIME)
    ppriv(r,t) # price index for priv. household cons. expenditure in region r #;
Variable (all,r,REG)(all,t,ALLTIME)
    yp(r,t) # regional private consumption expenditure in region r #;
Variable (all,r,REG)(all,t,ALLTIME)
    uepriv(r,t) # elasticity of cost wrt utility from private consumption #;
Variable (all,r,REG)(all,t,ALLTIME)
    up(r,t) # per capita utility from private expend. in region r #;

Variable (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    to(c,a,r,t) # power of tax on com. c supplied by act. a in region r #;
Variable (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    tinc(e,a,r,t) # power of income tax on endowment e supplied to act. a in r #;
Variable (all,e,ENDW)(all,r,REG)(all,t,ALLTIME)
    endwslack(e,r,t) # slack variable in endowment market clearing condition #;
!<
    endwslack is exogenous, unless the user wishes to employ a partial 
    equilibrium closure in which the price of one or more of the primary factors 
    is fixed.
>!

Variable (orig_level=VMB)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qms(c,r,t) # aggregate imports of c in region r, basic price weights #;
Variable (all,t,ALLTIME)
    globalcgds(t) # global supply of capital goods for NET investment #;
Variable (all,t,ALLTIME)
    pcgdswld(t) # world average price of capital goods (net investment weights) #;

!<
    ================
    Equation modules
    ================
    1.  Firms
    2.  Commodity supply
    3.  Income distribution
    4.  Allocation of income across expenditure categories
    5.  Domestic final demand
    6.  Trade, goods market equilibrium and prices
    7.  Factor market equilibrium
    8.  Allocation of global saving
    9.  Tax revenue streams
    10. Numeraire and Walras law
    11. Welfare measurement and decomposition 
>!

!<
    --------
    1. Firms
    --------

    We now turn to the behavioral equations for firms. The following picture
    describes the firms production structure.

                                 qo(a,r,t)  [ao(a,r,t)]
                                 /\
                                /  \  <----- CES[ESUBT]
                               /    \
                              /      \
                             /        \
            [ava(a,r,t)]  qva(a,r,t)     qint(a,r,t)  [aint(a,r,t)]
                        /|\            |   
    CES[ESUBVA]----->  / | \           |  <------ CES[ESUBC] 
                      /  |  \          |   
                     /   |   \         |  
                    /    |    \        | 
                Land  Labor  Capital  qfa(c,a,r,t)  [afa(c,a,r,t)] 
                   qfe(e,a,r,t)          /\
                  [afe(e,a,r,t)]        /  \  <----- CES[ESUBD] 
                                     /    \
                                    /      \
                                   /        \
                               Domestic    Foreign
                               qfd(c,a,r,t)  qfm(c,a,r,t)

    1-1. Top production nest
    1-2. Second level nests
    1-3. Sourcing of commodities by firms
    1-4. Technical change equations
>!

!<
    1-1. Top production nest
    ------------------------
>!

Variable (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    po(a,r,t) # unit cost/revenue of activity a in region r #;
Variable (orig_level=VOS)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qo(a,r,t) # output of activity a in region r #;
Variable (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    ao(a,r,t) # output augmenting technical change by activity a in region r #;
Variable (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pint(a,r,t) # Price of composite intermediate input c by activity a in r #;
Variable (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qint(a,r,t) # Composite intermediate input c by activity a in r #;
Variable (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    aint(a,r,t) # Composite interm. input augmenting tech change by act. a in r #;
Coefficient (parameter)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    ESUBT(a,r,t)
    # elast. of sub. bet. composite intermediate and factor inputs in prod'n #;
Read
    ESUBT from file GTAPPARM header "ESBT";
Assertion (all,a,ACTS)(all,r,REG)(all,t,ALLTIME) ESUBT(a,r,t) ge 0;

Equation E_qint
# sector demands for composite intermediate commodity inputs by act. a in r #
(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qint(a,r,t)
        = - aint(a,r,t) + qo(a,r,t) - ao(a,r,t)
        - ESUBT(a,r,t) * [pint(a,r,t) - aint(a,r,t) - po(a,r,t) - ao(a,r,t)];

Variable (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pva(a,r,t) # firms' price of value added in act. a of region r #;
Variable (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qva(a,r,t) # value added in act. a of region r #;
Variable (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    ava(a,r,t) # value added augmenting tech change by act. a in region r #;

Equation E_qva
# sector demands for primary factor composite #
(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qva(a,r,t)
        = -ava(a,r,t) + qo(a,r,t) - ao(a,r,t)
        - ESUBT(a,r,t) * [pva(a,r,t) - ava(a,r,t) - po(a,r,t) - ao(a,r,t)];

Variable (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pfa(c,a,r,t) # firms' price for commodity c for use by act. a in r #;
Variable (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qfa(c,a,r,t) # demand for commodity c for use by act. a in region r #;
Variable (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    afa(c,a,r,t) # composite intermed. inpt c augmenting tech ch. by act. a in r #;
Variable (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    afe(e,a,r,t) # primary factor e augmenting tech change by act. a in r #;
Variable (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    profitslack(a,r,t) # slack variable in the zero profit equation #;
!<
    profitslack is exogenous, unless the user wishes to specify output in a
    given region exogenously.
>!

Coefficient (all,d,DEMD)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    STC(d,a,r,t) # share of input d in total costs of act. a in r #;
Zerodivide default RNREG;
Formula (all,d,DEMD)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    STC(d,a,r,t) = VFP(d,a,r,t) / VOS(a,r,t); 
Zerodivide off;

Equation E_qo 
# industry zero pure profits condition #
(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    po(a,r,t) + ao(a,r,t)
        = sum{e,ENDW, STC(e,a,r,t) * [pfe(e,a,r,t) - afe(e,a,r,t) - ava(a,r,t)]}
        + sum{c,COMM, STC(c,a,r,t) * [pfa(c,a,r,t) - afa(c,a,r,t) - aint(a,r,t)]}
        + profitslack(a,r,t);
!<
    E_qo defines industry zero pure profits condition. This condition 
    permits us to determine the endogenous output level for each sector, 
    except when profitslack is itself endogenous.
>!

!<
    1-2. Second level nest
    ----------------------
>!

Coefficient (parameter)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME) 
    ESUBC(a,r,t) 
    # elasticity of substitution among intermediate inputs in production #;
Read
    ESUBC from file GTAPPARM header "ESBC";
Assertion (all,a,ACTS)(all,r,REG)(all,t,ALLTIME) ESUBC(a,r,t) ge 0;

Equation E_qfa
# industry demands for intermediate inputs c by act. a in region r #
(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qfa(c,a,r,t)
        = - afa(c,a,r,t) + qint(a,r,t)
        - ESUBC(a,r,t) * [pfa(c,a,r,t) - afa(c,a,r,t) - pint(a,r,t)];

Coefficient (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    TINTCOM(a,r,t) # total intermediate commodity inputs of act. a in r #;   
Formula (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    TINTCOM(a,r,t) = sum{c,COMM,VFP(c,a,r,t)};   
Coefficient (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    INTSHR(c,a,r,t) # share of intermed. c in total com. inputs of act. a in r #;   
Zerodivide default RNREG;
Formula (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    INTSHR(c,a,r,t) = VFP(c,a,r,t)/TINTCOM(a,r,t); 
Zerodivide off;

Equation E_pint
# price of composite intermediate commodity inputs by act. a in r #  
(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pint(a,r,t) = sum{c,COMM, INTSHR(c,a,r,t) * [pfa(c,a,r,t) - afa(c,a,r,t)]};
!<
    E_pint defines the average price of intermediate input composite. 
>!

Coefficient (parameter)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    ESUBVA(a,r,t)
    # elast. of sub. among capital/labor/land in value added of activity a #;
Read
    ESUBVA from file GTAPPARM header "ESBV";
Assertion (all,a,ACTS)(all,r,REG)(all,t,ALLTIME) ESUBVA(a,r,t) ge 0;

Coefficient (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VVA(a,r,t) # value added in act. a in region r #;
Formula (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VVA(a,r,t) = sum{e,ENDW, VFP(e,a,r,t)};
Coefficient (all,e,ENDW)(all,t,ALLTIME)
    DEFAULTVASHR(e,t) # zerodivide default for VASHR # ;
Formula (all,e,ENDW)(all,t,ALLTIME)
    DEFAULTVASHR(e,t)
        = sum{a,ACTS, sum{r,REG, VFP(e,a,r,t)}}
        / sum{a,ACTS, sum{r,REG, VVA(a,r,t)}};
Coefficient (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VASHR(e,a,r,t) # share of e in total value added in act. a in r #;
Formula (all,e,ENDW)(all,a,ACTS)(all,t,ALLTIME)(all,r,REG: VVA(a,r,t) <> 0)
    VASHR(e,a,r,t) = VFP(e,a,r,t) / VVA(a,r,t);
Formula (all,e,ENDW)(all,a,ACTS)(all,t,ALLTIME)(all,r,REG: VVA(a,r,t) = 0)
    VASHR(e,a,r,t) = DEFAULTVASHR(e,t);

Equation E_qfe
# demands for endowment commodities #
(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qfe(e,a,r,t)
        = - afe(e,a,r,t) + qva(a,r,t)
        - ESUBVA(a,r,t) * [pfe(e,a,r,t) - afe(e,a,r,t) - pva(a,r,t)];

Equation E_pva 
# effective price of primary factor composite in each sector/region #
(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pva(a,r,t) = sum{e,ENDW, VASHR(e,a,r,t) * [pfe(e,a,r,t) - afe(e,a,r,t)]};

!<
    1-3. Sourcing of commodities by firms
    -------------------------------------
>!

Equation E_qfd
# act. a demands for domestic good c #
(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qfd(c,a,r,t) = qfa(c,a,r,t) - ESUBD(c,r,t) * [pfd(c,a,r,t) - pfa(c,a,r,t)];

Equation E_qfm
# act. a demands for composite import c #
(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qfm(c,a,r,t) = qfa(c,a,r,t) - ESUBD(c,r,t) * [pfm(c,a,r,t) - pfa(c,a,r,t)];

Coefficient (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    FMSHR(c,a,r,t) # share of firms' imports in dom. composite, purch. prices #;
Zerodivide default RNREG;
Formula (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    FMSHR(c,a,r,t) = VMFP(c,a,r,t) / VFP(c,a,r,t);
Zerodivide off;

Equation E_pfa 
# industry price for composite commodities #
(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pfa(c,a,r,t) = [1 - FMSHR(c,a,r,t)] * pfd(c,a,r,t) + FMSHR(c,a,r,t) * pfm(c,a,r,t);

!<
    1-4. Technical change equations 
    -------------------------------
>!

!< Hicks-neutral technical change shifters >!
Variable (all,a,ACTS)
    aosec(a) # output tech change for act. a, worldwide #;
Variable (all,r,REG)(all,t,ALLTIME)
    aoreg(r,t) # specific output tech change in region r #;
Variable (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    aoall(a,r,t) # output augmenting technical change in act. a of r #;
Equation E_ao
# sector/region specific average rate of output augmenting tech change #
(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    ao(a,r,t) = aosec(a) + aoreg(r,t) + aoall(a,r,t);

!< Intermediate input technical change and shifters >!
Variable (all,c,COMM)(all,t,ALLTIME)
    afcom(c,t) # intermediate tech change of input c, worldwide #;
Variable (all,a,ACTS)(all,t,ALLTIME)
    afsec(a,t) # intermediate tech change of act. a, worldwide #;
Variable (all,r,REG)(all,t,ALLTIME)
    afreg(r,t) # intermediate tech change in region r #;
Variable (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    afall(c,a,r,t) # intermediate input c augmenting tech change by act. a in r #;
Equation E_afa
# sector/region specific average rate of intermediates augmenting tech change #
(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    afa(c,a,r,t) = afcom(c,t) + afsec(a,t) + afreg(r,t) + afall(c,a,r,t);

!< Composite value-added technical change and shifters >!
Variable (all,a,ACTS)(all,t,ALLTIME)
    avasec(a,t) # value added tech change for act. a, worldwide #;
Variable (all,r,REG)(all,t,ALLTIME)
    avareg(r,t) # value added tech change in region r #;
Variable (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    avaall(a,r,t) # value added augmenting technical change in act. a of r #;
Equation E_ava
# sector/region specific average rate of value added augmenting tech change #
(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    ava(a,r,t) = avasec(a,t) + avareg(r,t) + avaall(a,r,t);

!< Factor input technical change and shifters  >!
Variable (all,e,ENDW)(all,t,ALLTIME)
    afecom(e,t) # factor input tech change of endowwment e, worldwide #;
Variable (all,a,ACTS)(all,t,ALLTIME)
    afesec(a,t) # factor input tech change of act. a, worldwide #;
Variable (all,r,REG)(all,t,ALLTIME)
    afereg(r,t) # factor input tech change in region r #;
Variable (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    afeall(e,a,r,t) # primary factor e augmenting tech change for act. a in r #;
Equation E_afe 
# sector/region specific average rate of prim. factor e augmenting tech change #
(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    afe(e,a,r,t) = afecom(e,t) + afesec(a,t) + afereg(r,t) + afeall(e,a,r,t);

!< Composite intermediate input technical change and shifters >!
Variable (all,a,ACTS)(all,t,ALLTIME)
    aintsec(a,t) # composite interm. input augmenting tech change, worldwide #;
Variable (all,r,REG)(all,t,ALLTIME)
    aintreg(r,t) # composite interm. input augmenting tech change in region r #;
Variable (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    aintall(a,r,t) # comp. interm. input augmenting tech change of act. a in r #;
Equation E_aint
# sector/region specific Composite intermediate input augmenting tech change #
(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    aint(a,r,t) = aintsec(a,t) + aintreg(r,t) + aintall(a,r,t);

!<
    ---------------------
    2-0. Commodity supply
    ---------------------

    The following picture describes commodity supply and sourcing. On the supply 
    side, activities with multiple outputs are given a CET specification wherein 
    they maximize their total revenue stream subject to being on the constant 
    elasticity of transformation frontier. On the demand side, buyers of a 
    commodity produced by multiple activities wish to minimize the total cost 
    of supply subject to a CES preference function.

                                 qo(a,r,t)  [ao(a,r,t)]
                                  |
               CET[ETRAQ] ----->  | 'make'
                                  |
                               qca(c,a,r,t)
                                  |
               CES[ESUBQ] ----->  |  'sourcing' 
                                  |
                                qc(c,r,t)  
>!

Coefficient (parameter)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    ETRAQ(a,r,t) 
    # elasticity of transformation among commodities produced by act. a #;
Read   
    ETRAQ from file GTAPPARM header "ETRQ";
Assertion (all,a,ACTS)(all,r,REG)(all,t,ALLTIME) ETRAQ(a,r,t) lt 0;

Coefficient (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MAKESCOM(a,r,t) # pre-tax output of activity a in r #;
Formula (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MAKESCOM(a,r,t) = sum{c,COMM, MAKES(c,a,r,t)};
Coefficient (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MAKESACTSHR(c,a,r,t) # share of c and a in output of a at supplier prices #;
Zerodivide default RNREG;
Formula (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MAKESACTSHR(c,a,r,t) = MAKES(c,a,r,t) / MAKESCOM(a,r,t);
Zerodivide off;

!change to avoid complicated if() operator in equation!
Coefficient (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MAKESUNIT(c,a,r,t) # make unit #;
Zerodivide (zero_by_zero) default 0;
Formula (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MAKESUNIT(c,a,r,t)=MAKES(c,a,r,t)/MAKES(c,a,r,t);
Zerodivide off;
Formula (all,c,COMM)(all,a,ACTS)(all,t,ALLTIME)(all,r,REG:MAKES(c,a,r,t)<0)
    MAKESUNIT(c,a,r,t)=0;
Equation E_qca
# supply of commodities by act. a #
(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME) 
    qca(c,a,r,t) = !IF[MAKES(c,a,r,t) gt 0,! 
       MAKESUNIT(c,a,r,t)*qo(a,r,t) 
           - MAKESUNIT(c,a,r,t)*ETRAQ(a,r,t) * [ps(c,a,r,t) - po(a,r,t)]!]!;

Equation E_po 
# average unit (tax-exclusive) cost of output of act. a #
(all,a,ACTS)(all,r,REG)(all,t,ALLTIME) 
     po(a,r,t) = sum{c,COMM, MAKESACTSHR(c,a,r,t) * ps(c,a,r,t)};

Equation E_ps
# links basic and supply price of commodity c produced by activity a in r #
(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pca(c,a,r,t) = ps(c,a,r,t) + to(c,a,r,t);
!<
    E_ps links supplier/producer (pre-) and basic (post-tax) prices for firms.
    This captures the effect of output taxes or subsidies.  
    Note: The power of activity tax, to, is commodity- and activity-specific. 
          to(c,a,r,t) > 1 in the case of a tax 
          to(c,a,r,t) < 1 in the case of a subsidy. 
>!

Variable (all,a,ACTS)(all,r,REG)(all,t,ALLTIME) 
    pb(a,r,t) # price index: basic (tax-inclusive) price of output of act. a #;   
Coefficient (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MAKEBACTSHR(c,a,r,t) # share of c and a in output of act. a at basic prices #;
Zerodivide default RNREG;
Formula (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MAKEBACTSHR(c,a,r,t) = MAKEB(c,a,r,t) / MAKEBACT(a,r,t);
Zerodivide off;

Equation E_pb  
# price index: basic (tax-inclusive) price of output of act. a #
(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
     pb(a,r,t) = sum{c,COMM, MAKEBACTSHR(c,a,r,t) * pca(c,a,r,t)};

Coefficient (parameter)(all,c,COMM)(all,r,REG)(all,t,ALLTIME) 
    ESUBQ(c,r,t) 
    # 1/CES elast. for sourcing of commodity c produced by various activities #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME) 
    ESUBQ(c,r,t) = 0.0; ! ie, Default 0.0 means perfect substitutes ! 
!change for compatibility!
Assertion (all,c,COMM)(all,r,REG)(all,t,ALLTIME) ESUBQ(c,r,t) ge 0; 
!< 
    ESUBQ is 1/CES elasticity. ESUBQ=0.0 means that commodity c produced by 2 
    or more activities are perfect substitutes--i.e., each activity receives the 
    same price (i.e., the law of one price holds) for a given commodity. 
    In the equation E_pca below,  pca(c,a,r,t) = pds(c,r,t) if ESUBQ = 0.0  
    But this will not work well if two or more activities each only produce the 
    same good (e.g., CoalElec and NuclearElec each only produce electricity), 
    resulting in structurally singular matrix problems, especially under the 
    standard GTAP closure, where most factors used by these activitiesare 
    perfectly mobile. In such cases, capital could be set as a sluggish 
    factor (note: if ETRAE=-0.000001, capital becomes a sector-specific factor); 
    or alternatively, capital could be perfectfly mobile across sectors but with 
    ESUBQ set to allow for a degree of commodity sourcing differentiation 
    (i.e., commodity c produced by diff activities are imperfect substitutes). 
    For example, ESUBQ could be set to 0.5 giving an elasticity of substitution 
    of 2.0 = 1/ESUBQ = 1/0.5. Alternative values for ESUBQ could be defined by 
    the user in the parameter input file.  
>!

Variable (orig_level=VCB)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qc(c,r,t) # total commodity supply in region r #; 
Coefficient (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MAKEBCOMSHR(c,a,r,t) # share of c by a in commodity supply at basic prices #;
Zerodivide default RNREG;
Formula (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MAKEBCOMSHR(c,a,r,t) = MAKEB(c,a,r,t) / MAKEBCOM(c,r,t);
Zerodivide off;

!change to avoid complicated if()!
Coefficient (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MAKEBUNIT(c,a,r,t) # make unit #;
Zerodivide (zero_by_zero) default 0;
Formula (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    MAKEBUNIT(c,a,r,t)=0;
Formula (all,c,COMM)(all,a,ACTS)(all,t,ALLTIME)(all,r,REG:MAKEB(c,a,r,t)>0)
    MAKEBUNIT(c,a,r,t)=1;
Zerodivide off;
Equation E_pca  
# CES allocation of commodity output by activity (ESUBQ(c,r,t) is 1/CES elast.) #
(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME) 
    pca(c,a,r,t) = !IF[MAKEB(c,a,r,t) gt 0,! 
                    MAKEBUNIT(c,a,r,t)*pds(c,r,t) 
                      - MAKEBUNIT(c,a,r,t)*ESUBQ(c,r,t) * [qca(c,a,r,t) - qc(c,r,t)]!]!;

Equation E_qc
# market clearing condition for total commodity supply #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
     qc(c,r,t) = sum{a,ACTS, MAKEBCOMSHR(c,a,r,t) * qca(c,a,r,t)};       

!<
    ------------------------
    3-0. Income distribution
    ------------------------
>!

Variable (all,r,REG)(all,t,ALLTIME)
    fincome(r,t) # factor income at basic prices net of depreciation #;
Coefficient (all,r,REG)(all,t,ALLTIME)
    FY(r,t) # primary factor income in r net of depreciation #;
Formula (all,r,REG)(all,t,ALLTIME)
    FY(r,t) = sum{e,ENDW, sum{a,ACTS, EVFB(e,a,r,t)}} - REGINV(r,t) + VCAPI(r,t)
            - VDEP(r,t);

Equation E_fincome
# factor income at basic prices net of depreciation #
(all,r,REG)(all,t,ALLTIME)
    FY(r,t) * fincome(r,t)
        = sum{e,ENDW, sum{a,ACTS, EVFB(e,a,r,t) * [peb(e,a,r,t) + qes(e,a,r,t)]}}
        - REGINV(r,t)*[pinv(r,t)+qinv(r,t)] + VCAPI(r,t)*[capi(r,t)+pinv(r,t)]        
        - VDEP(r,t)  * [pinv(r,t) + kb(r,t)];

!< Computation of Regional Income >!
Variable (all,r,REG)(all,t,ALLTIME)
    incomeslack(r,t) # slack variable in the expression for regional income #;
    !< This is exogenous, unless the user wishes to fix regional income. >!
Variable (change)(all,r,REG)(all,t,ALLTIME)
    del_indtaxr(r,t) # change in ratio of indirect taxes to INCOME in r #;
Coefficient (all,r,REG)(all,t,ALLTIME)
    INDTAX(r,t) # indirect tax receipts in r #;
Formula (all,r,REG)(all,t,ALLTIME)
    INDTAX(r,t) = TAXRPC(r,t) + TAXRGC(r,t) + TAXRIC(r,t) + TAXRIU(r,t) + TAXRFU(r,t)
              + TAXROUT(r,t) + TAXREXP(r,t) + TAXRIMP(r,t);

Equation E_y
# regional income = sum of primary factor income and indirect tax receipts #
(all,r,REG)(all,t,ALLTIME)
    INCOME(r,t) * y(r,t)
        = FY(r,t) * fincome(r,t)
        + 100.0 * INCOME(r,t) * del_indtaxr(r,t)
        + INDTAX(r,t) * y(r,t)
        + INCOME(r,t) * incomeslack(r,t);

!<
    -------------------------------------------------------
    4-0. Allocation of income across expenditure categories
    -------------------------------------------------------
>!

Variable (all,r,REG)(all,t,ALLTIME)
    uelas(r,t) # elasticity of cost of utility wrt utility #;
Variable (all,r,REG)(all,t,ALLTIME)
    dpsave(r,t) # saving distribution parameter #;
Variable (all,r,REG)(all,t,ALLTIME)
    dpgov(r,t) # government consumption distribution parameter #;
Variable (all,r,REG)(all,t,ALLTIME)
    dppriv(r,t) # private consumption distribution parameter #;

Equation E_qsave
# saving #
(all,r,REG)(all,t,ALLTIME)
    psave(r,t) + qsave(r,t) - y(r,t) = uelas(r,t) + dpsave(r,t);

Equation E_yg
# government consumption expenditure #
(all,r,REG)(all,t,ALLTIME)
    yg(r,t) - y(r,t) = uelas(r,t) + dpgov(r,t);

Equation E_yp
# private consumption expenditure #
(all,r,REG)(all,t,ALLTIME)
    yp(r,t) - y(r,t) = -[uepriv(r,t) - uelas(r,t)] + dppriv(r,t);

Variable (all,r,REG)(all,t,ALLTIME)
    dpav(r,t) # average distribution parameter shift, for EV calc. #;
Coefficient (all,r,REG)(all,t,ALLTIME)
    XSHRPRIV(r,t) # private expenditure share in regional income #;
Formula (all,r,REG)(all,t,ALLTIME)
    XSHRPRIV(r,t) = PRIVEXP(r,t) / INCOME(r,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    XSHRGOV(r,t) # government expenditure share in regional income #;
Formula (all,r,REG)(all,t,ALLTIME)
    XSHRGOV(r,t) = GOVEXP(r,t) / INCOME(r,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    XSHRSAVE(r,t) # saving share in regional income #;
Formula (all,r,REG)(all,t,ALLTIME)
    XSHRSAVE(r,t) = SAVE(r,t) / INCOME(r,t);

Equation E_uelas
# elasticity of cost of utility wrt utility #
(all,r,REG)(all,t,ALLTIME)
    uelas(r,t) = XSHRPRIV(r,t) * uepriv(r,t) - dpav(r,t);

Equation E_dpav
# average distribution parameter shift #
(all,r,REG)(all,t,ALLTIME)
    dpav(r,t)
        = XSHRPRIV(r,t) * dppriv(r,t)
        + XSHRGOV(r,t)  * dpgov(r,t)
        + XSHRSAVE(r,t) * dpsave(r,t);

Variable (all,r,REG)(all,t,ALLTIME)
    p(r,t) # price index for disposition of income by regional household #;

Equation E_p
# price index for disposition of income by regional household #
(all,r,REG)(all,t,ALLTIME)
    p(r,t) = XSHRPRIV(r,t) * ppriv(r,t) + XSHRGOV(r,t) * pgov(r,t)
         + XSHRSAVE(r,t) * psave(r,t);

Variable (all,r,REG)(all,t,ALLTIME)
    au(r,t) # input-neutral shift in utility function #;
Variable (all,r,REG)(all,t,ALLTIME)
    dpsum(r,t) # sum of the distribution parameters #;
Variable (all,r,REG)(all,t,ALLTIME)
    u(r,t) # per capita utility from aggregate hhld expend. in region r #;
Coefficient (all,r,REG)(all,t,ALLTIME)
    DPARSUM(r,t) # sum of distribution parameters #;
Read
    DPARSUM from file GTAPDATA header "DPSM";
Update (all,r,REG)(all,t,ALLTIME)
    DPARSUM(r,t) = dpsum(r,t);

Coefficient (all,r,REG)(all,t,ALLTIME)
    UTILELAS(r,t) # elasticity of cost of utility wrt utility #;
Formula (all,r,REG)(all,t,ALLTIME)
    UTILELAS(r,t)
        = [UELASPRIV(r,t) * XSHRPRIV(r,t) + XSHRGOV(r,t) + XSHRSAVE(r,t)] / DPARSUM(r,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    DPARPRIV(r,t) # private consumption distribution parameter #;
Formula (all,r,REG)(all,t,ALLTIME)
    DPARPRIV(r,t) = UELASPRIV(r,t) * XSHRPRIV(r,t) / UTILELAS(r,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    DPARGOV(r,t) # government consumption distribution parameter #;
Formula (all,r,REG)(all,t,ALLTIME)
    DPARGOV(r,t) = XSHRGOV(r,t) / UTILELAS(r,t);

Coefficient (all,r,REG)(all,t,ALLTIME)
    DPARSAVE(r,t) # saving distribution parameter #;
Formula (all,r,REG)(all,t,ALLTIME)
    DPARSAVE(r,t) = XSHRSAVE(r,t) / UTILELAS(r,t);

Coefficient (all,r,REG)(all,t,ALLTIME)
    UTILPRIV(r,t) # utility from private consumption #;
Formula (initial)(all,r,REG)(all,t,ALLTIME)
    UTILPRIV(r,t) = 1.0;
Update (all,r,REG)(all,t,ALLTIME)
    UTILPRIV(r,t) = up(r,t);

Coefficient (all,r,REG)(all,t,ALLTIME)
    UTILGOV(r,t) # utility from government consumption #;
Formula (initial)(all,r,REG)(all,t,ALLTIME)
    UTILGOV(r,t) = 1.0;
Update (all,r,REG)(all,t,ALLTIME)
    UTILGOV(r,t) = ug(r,t);

Coefficient (all,r,REG)(all,t,ALLTIME)
    UTILSAVE(r,t) # utility from saving #;
Formula (initial)(all,r,REG)(all,t,ALLTIME)
    UTILSAVE(r,t) = 1.0;
Update (change) (all,r,REG)(all,t,ALLTIME)
    UTILSAVE(r,t) = [[qsave(r,t) - pop(r,t)] / 100] * UTILSAVE(r,t);

Equation E_u
# regional household utility #
(all,r,REG)(all,t,ALLTIME)
    u(r,t) = au(r,t) + DPARPRIV(r,t) * loge(UTILPRIV(r,t)) * dppriv(r,t)
         + DPARGOV(r,t) * loge(UTILGOV(r,t)) * dpgov(r,t)
         + DPARSAVE(r,t) * loge(UTILSAVE(r,t)) * dpsave(r,t)
         + [1.0 / UTILELAS(r,t)] * [y(r,t) - pop(r,t) - p(r,t)];

Equation E_dpsum
# sum of the distribution parameters #
(all,r,REG)(all,t,ALLTIME)
    DPARSUM(r,t) * dpsum(r,t)
        = DPARPRIV(r,t) * dppriv(r,t)
        + DPARGOV(r,t) * dpgov(r,t)
        + DPARSAVE(r,t) * dpsave(r,t);

!<
    --------------------------
    5-0. Domestic final demand
    --------------------------
>!

!<
    5-1. Private expenditures
    -------------------------
>!

!<  We first compute for the Allen Partials, Price and Income Elasticities 
    then derive Private household's Composite Demand >!

Coefficient (parameter)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    SUBPAR(c,r,t) 
    # substitution parameter in CDE minimum expenditure function #;
Read
    SUBPAR from file GTAPPARM header "SUBP";
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    ALPHA(c,r,t) # 1 - sub. parameter in the CDE minimum expenditure function #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    ALPHA(c,r,t) = 1 - SUBPAR(c,r,t);
Coefficient (all,c,COMM)(all,k,COMM)(all,r,REG)(all,t,ALLTIME)
    APE(c,k,r,t) # Allen partial elast. of sub. between composite c and k in r #;
Formula (all,c,COMM)(all,k,COMM)(all,r,REG)(all,t,ALLTIME)
    APE(c,k,r,t)
        = ALPHA(c,r,t) + ALPHA(k,r,t) - sum{n,COMM, CONSHR(n,r,t) * ALPHA(n,r,t)};
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    APE(c,c,r,t)
        = 2.0 * ALPHA(c,r,t)
        - sum{n,COMM, CONSHR(n,r,t) * ALPHA(n,r,t)}
        - ALPHA(c,r,t) / CONSHR(c,r,t);

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    EY(c,r,t) # income elast. of private hhld demand for c in r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    EY(c,r,t)
        =   [1.0 / sum{n,COMM, CONSHR(n,r,t) * INCPAR(n,r,t)}]
            * [INCPAR(c,r,t) * [1.0 - ALPHA(c,r,t)]
                + sum{n,COMM, CONSHR(n,r,t) * INCPAR(n,r,t) * ALPHA(n,r,t)}]
        + [ALPHA(c,r,t) - sum{n,COMM, CONSHR(n,r,t) * ALPHA(n,r,t)}];

Coefficient (all,c,COMM)(all,k,COMM)(all,r,REG)(all,t,ALLTIME)
    EP(c,k,r,t)
    # uncomp. elast. of private hhld demand for c wrt price of k in r #;
Formula (all,c,COMM)(all,k,COMM)(all,r,REG)(all,t,ALLTIME)
    EP(c,k,r,t) = 0;
Formula (all,c,COMM)(all,k,COMM)(all,r,REG)(all,t,ALLTIME)
    EP(c,k,r,t) = [APE(c,k,r,t) - EY(c,r,t)] * CONSHR(k,r,t);

Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    ppa(c,r,t) # private consumption price for commodity c in region r #;
Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qpa(c,r,t) # private hhld demand for commodity c in region r #;

Equation E_qpa
# private consumption demands for composite commodities #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qpa(c,r,t) - pop(r,t)
        = sum{k,COMM, EP(c,k,r,t) * ppa(k,r,t)} + EY(c,r,t) * [yp(r,t) - pop(r,t)];
!<
    E_qpa defines private consumption demands for composite commodities.  
    Demand system is on a per capita basis. Here, yp(r,t) - pop(r,t) is % change in 
    per capita income.  
>!

!< Utility from Private Consumption >!
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    XWCONSHR(c,r,t) # expansion-parameter-weighted consumption share #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    XWCONSHR(c,r,t) = CONSHR(c,r,t) * INCPAR(c,r,t) / UELASPRIV(r,t);

Equation E_uepriv
# elasticity of expenditure wrt utility from private consumption #
(all,r,REG)(all,t,ALLTIME)
    uepriv(r,t) = sum{c,COMM, XWCONSHR(c,r,t) * [ppa(c,r,t) + qpa(c,r,t) - yp(r,t)]};

Equation E_ppriv
# price index for aggregate private consumption expenditure #
(all,r,REG)(all,t,ALLTIME)
    ppriv(r,t) = sum{c,COMM, CONSHR(c,r,t) * ppa(c,r,t)};

Variable (all,r,REG)(all,t,ALLTIME)
    qpriv(r,t) # quantity index for aggregate private expenditure in region r #;
Equation E_qpriv
# price index for private consumption expenditure #
(all,r,REG)(all,t,ALLTIME)
    qpriv(r,t) = sum{c,COMM, CONSHR(c,r,t) * qpa(c,r,t)};

Equation E_up
# computation of utility from private consumption in r #
(all,r,REG)(all,t,ALLTIME)
    UELASPRIV(r,t) * up(r,t) = yp(r,t) - ppriv(r,t) - pop(r,t) ;
!<
    E_up determines private consumption utility for a representative
    household in region r, based on the per capita private expenditure
    function.  
>!

Equation E_qpd
# private consumption demand for domestic goods #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qpd(c,r,t) = qpa(c,r,t) - ESUBD(c,r,t) * [ppd(c,r,t) - ppa(c,r,t)];

Zerodivide default RNREG;
!<  Composite Tradeables >!
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    PMSHR(c,r,t) # share of imports in private hhld cons. at purchaser's prices #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    PMSHR(c,r,t) = VMPP(c,r,t) / VPP(c,r,t);
Zerodivide off;

Equation E_qpm
# private consumption demand for aggregate imports #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qpm(c,r,t) = qpa(c,r,t) - ESUBD(c,r,t) * [ppm(c,r,t) - ppa(c,r,t)];

Equation E_ppa
# private consumption price for composite commodities #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    ppa(c,r,t) = [1 - PMSHR(c,r,t)] * ppd(c,r,t) + PMSHR(c,r,t) * ppm(c,r,t);

!<
    5-2. Public expenditures
    -------------------------
>!

Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pga(c,r,t) # government consumption price for commodity c in region r #;
Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qga(c,r,t) # government hhld demand for commodity c in region r #;
Coefficient (parameter)(all,r,REG)(all,t,ALLTIME)
    ESUBG(r,t)
    # region-specific elast. of subst. for composite government consumption #;
Read
    ESUBG from file GTAPPARM header "ESBG"; 
Assertion (all,r,REG)(all,t,ALLTIME) ESUBG(r,t) ge 0;

Equation E_qga
# government consumption demands for composite commodities #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qga(c,r,t) = yg(r,t) - pgov(r,t) - ESUBG(r,t) * [pga(c,r,t) - pgov(r,t)];

Equation E_pgov  
# price index for aggregate gov't purchases #
(all,r,REG)(all,t,ALLTIME)
    pgov(r,t) = sum{c,COMM, [VGP(c,r,t) / GOVEXP(r,t)] * pga(c,r,t)};

Variable (all,r,REG)(all,t,ALLTIME)
    qgov(r,t) # quantity index for aggregate gov't purchases #;
Equation E_qgov  
# quantity index for aggregate gov't purchases #
(all,r,REG)(all,t,ALLTIME)
    qgov(r,t) = sum{c,COMM, [VGP(c,r,t) / GOVEXP(r,t)] * qga(c,r,t)};

Equation E_ug
# utility from government consumption in r #
(all,r,REG)(all,t,ALLTIME)
    ug(r,t) = yg(r,t) - pgov(r,t) - pop(r,t);

Zerodivide default RNREG;
!<  Composite tradeables >!
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    GMSHR(c,r,t) # share of imports for gov't hhld at purchaser's prices #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    GMSHR(c,r,t) = VMGP(c,r,t) / VGP(c,r,t);
Zerodivide off;

Equation E_qgd
# government consumption demand for domestic goods #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qgd(c,r,t) = qga(c,r,t) - ESUBD(c,r,t) * [pgd(c,r,t) - pga(c,r,t)];

Equation E_qgm
# government consumption demand for aggregate imports #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qgm(c,r,t) = qga(c,r,t) - ESUBD(c,r,t) * [pgm(c,r,t) - pga(c,r,t)];

Equation E_pga 
# government consumption price for composite commodities #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pga(c,r,t) = [1 - GMSHR(c,r,t)] * pgd(c,r,t) + GMSHR(c,r,t) * pgm(c,r,t);

!<
    5-3. Investment expenditures
    ----------------------------
>!

Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pia(c,r,t) # price of investment commodity in region r #;
Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qia(c,r,t) # demand for investment commodity c in region r #;

Equation E_qia  
# Top level (Leontief) demand for investment goods #  
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qia(c,r,t) = qinv(r,t);

Equation E_pinv
# defines the price of investment #
(all,r,REG)(all,t,ALLTIME)
    pinv(r,t) = sum{c,COMM, [VIP(c,r,t) / REGINV(r,t)] * pia(c,r,t)};

Equation E_qid 
# demand for domestic investment commodity c #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qid(c,r,t) = qia(c,r,t) - ESUBD(c,r,t) * [pid(c,r,t) - pia(c,r,t)];

Equation E_qim 
# demand for imported investment commodity c #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qim(c,r,t) = qia(c,r,t) - ESUBD(c,r,t) * [pim(c,r,t) - pia(c,r,t)];

Zerodivide default RNREG;
!<  Composite tradeables >!
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    IMSHR(c,r,t) # share of imports for investment at purchaser's prices #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    IMSHR(c,r,t) = VMIP(c,r,t) / VIP(c,r,t);
Zerodivide off;

Equation E_pia 
# investment price for composite commodities #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pia(c,r,t) = [1 - IMSHR(c,r,t)] * pid(c,r,t) + IMSHR(c,r,t) * pim(c,r,t);

!<
    -----------------------------------------------
    6-0. Trade, goods market equilibrium and prices
    -----------------------------------------------
>!

!<
    6-1. Sourcing of imports
    ------------------------
>!

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VMB(c,r,t) # value of aggregate imports of commodity c in r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VMB(c,r,t) = sum{a,ACTS, VMFB(c,a,r,t)} + VMIB(c,r,t)
             + VMPB(c,r,t) + VMGB(c,r,t);

Coefficient (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    FMCSHR(c,a,r,t) # share of import c used by act. a in r #;
Formula (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    FMCSHR(c,a,r,t) = VMFB(c,a,r,t) / VMB(c,r,t);

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    PMCSHR(c,r,t) # share of import c used by priv. hhlds in total imports in r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    PMCSHR(c,r,t) = VMPB(c,r,t) / VMB(c,r,t);

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    GMCSHR(c,r,t) # the share of import c by gov't hhlds in total imports in r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    GMCSHR(c,r,t) = VMGB(c,r,t) / VMB(c,r,t);

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    IMCSHR(c,r,t) # share of import c by investment agent in total imports in r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    IMCSHR(c,r,t) = VMIB(c,r,t) / VMB(c,r,t);

Equation E_qms
# assures mkt clearing for imported goods entering each region #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qms(c,r,t)
        = sum{a,ACTS, FMCSHR(c,a,r,t) * qfm(c,a,r,t)}
        + PMCSHR(c,r,t) * qpm(c,r,t)
        + GMCSHR(c,r,t) * qgm(c,r,t)
        + IMCSHR(c,r,t) * qim(c,r,t);

Variable (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    ams(c,s,d,t) # commodity c augmenting tech change from s to d #;
Coefficient (parameter)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    ESUBM(c,r,t)
    # region-specific elast. of sub. among imports c in Armington structure #;
Read
    ESUBM from file GTAPPARM header "ESBM";
Assertion (all,c,COMM)(all,r,REG)(all,t,ALLTIME) ESUBM(c,r,t) ge 0;

Equation E_qxs
# regional demand for disaggregated imported commodities by source #
(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    qxs(c,s,d,t)
        = -ams(c,s,d,t) + qms(c,d,t) 
        - ESUBM(c,d,t) * [pmds(c,s,d,t) - ams(c,s,d,t) - pms(c,d,t)];

Coefficient (all,c,COMM)(all,d,REG)(all,t,ALLTIME)
    IMPBASIC(c,d,t) # total imports of good c by DEST region d, at basic prices #;
Formula (all,c,COMM)(all,d,REG)(all,t,ALLTIME)
    IMPBASIC(c,d,t) = sum{s,REG, VMSB(c,s,d,t)};
Coefficient (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    MSHRS(c,s,d,t) # share of imports from s in imp. bill of r at basic prices #;
Formula (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    MSHRS(c,s,d,t) = VMSB(c,s,d,t) / IMPBASIC(c,d,t);

Equation E_pms
# price for aggregate imports #
(all,c,COMM)(all,d,REG)(all,t,ALLTIME)
    pms(c,d,t) = sum{s,REG, MSHRS(c,s,d,t) * [pmds(c,s,d,t) - ams(c,s,d,t)]};

!<
    6-2. International trade and transport margins
    ----------------------------------------------
>!

!< 
    6-2-1. Demand for Global Transport Services
    ------------------------------------------- 
>!

Variable (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    ptrans(c,s,d,t) # cost index for international transport of c from s to d #;
Variable (all,m,MARG)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    qtmfsd(m,c,s,d,t) # international usage margin m on c from s to d #;
!< 
    International margin usage, by Margin, Freight, Source, and Destination,
    i.e., the percent change in usage of m in transport of c from s to d.
>!

Variable (all,m,MARG)(all,t,ALLTIME)  
    pt(m,t) # price index of composite margins services, by margin mode m #;
Variable (all,m,MARG)(all,t,ALLTIME)
    qtm(m,t) # global margin usage #;
Variable (all,m,MARG)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    atmfsd(m,c,s,d,t) # tech change in m's shipping of c from region s to d #;
!<
    Technical progress in shipping by Margin, Freight, Source, and
    Destination.  This is endogenous and driven by the following mode-,
    commodity-, source-, and destination-specific determinants.
>!

Equation E_qtmfsd
# bilateral demand for transport services #
(all,m,MARG)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    qtmfsd(m,c,s,d,t) = qxs(c,s,d,t) - atmfsd(m,c,s,d,t);
!<
    E_qtmfsd equation computes the bilateral demand for international
    transportation services.  It reflects the fact that the demand for
    services along any particular route is proportional to the quantity of
    merchandise shipped [i.e., QXS(c,s,d)].  It is here that we introduce the
    potential for input-augmenting tech change, atmfsd(m,c,s,d), which is
    commodity- and route-specific.  Thus, in the levels:
            ATMFSD(m,c,s,d) * QTMFSD(m,c,s,d) = QXS(c,s,d)
    where QTMFSD is the amount of composite margins services m used along this
    route.  Technological improvements are reflected by atmfsd(c,s,d) > 0, and
    these reduce the margins services required for this c,s,d triplet.  Tech.
    change also dampens the cost of shipping, thereby lowering the CIF price
    implied by a given FOB value (see 6-2-2).
>!

Coefficient (ge 0) (all,m,MARG)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VTMFSD(m,c,s,d,t)
    # int'l margin usage, by margin, freight, source, and destination #;
Read
    VTMFSD from file GTAPDATA header "VTWR";
Update (all,m,MARG)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VTMFSD(m,c,s,d,t) = pt(m,t) * qtmfsd(m,c,s,d,t);

Coefficient (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VTFSD(c,s,d,t) # aggregate value of svces in the shipment of c from s to d #;
Formula (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VTFSD(c,s,d,t) = sum{m,MARG, VTMFSD(m,c,s,d,t)};
!<
    In a balanced data base, (all,c,COMM)(all,s,REG)(all,d,REG),
    VCIF(c,s,d) = VFOB(c,s,d) + VTFSD(c,s,d).
>!

Coefficient (all,t,ALLTIME)
    VTUSE(t) # international margin services usage #;
Formula (all,t,ALLTIME)
    VTUSE(t) = sum{m,MARG, sum{c,COMM, sum{s,REG, sum{d,REG, VTMFSD(m,c,s,d,t)}}}};
Coefficient (all,m,MARG)(all,t,ALLTIME)
    VTMUSE(m,t) # international margin services usage, by type #;
Formula (all,m,MARG)(all,t,ALLTIME)
    VTMUSE(m,t) = sum{c,COMM, sum{s,REG, sum{d,REG, VTMFSD(m,c,s,d,t)}}};

Coefficient (all,m,MARG)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VTFSD_MSH(m,c,s,d,t) # share of margin m in cost of getting c from s to d #;
Formula (all,m,MARG)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
        (all,d,REG: VTFSD(c,r,d,t) > 0.0)
    VTFSD_MSH(m,c,r,d,t) = VTMFSD(m,c,r,d,t) / VTFSD(c,r,d,t);
Formula (all,m,MARG)(all,c,COMM)(all,s,REG)(all,t,ALLTIME)
        (all,d,REG: VTFSD(c,s,d,t) = 0.0)
    VTFSD_MSH(m,c,s,d,t) = VTMUSE(m,t) / VTUSE(t);

Equation E_ptrans
#  generates flow-specific modal average cost of transport index (cf. HT7) #
(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    ptrans(c,s,d,t)
        = sum{m,MARG, VTFSD_MSH(m,c,s,d,t) * [pt(m,t) - atmfsd(m,c,s,d,t)]};
!<
    average cost index for margin services used in getting c from s to d
>!

Coefficient (all,m,MARG)(all,t,ALLTIME)
    VTMPROV(m,t) # international margin services provision #;
Formula (all,m,MARG)(all,t,ALLTIME)
    VTMPROV(m,t) = sum{r,REG, VST(m,r,t)};
!<
    In a balanced data base, VTMPROV = VTMUSE.
>!
Coefficient (all,r,REG)(all,t,ALLTIME)
    VTRPROV(r,t) # international margin supply, by region #;
Formula (all,r,REG)(all,t,ALLTIME)
    VTRPROV(r,t) = sum{m,MARG, VST(m,r,t)};
Coefficient (all,t,ALLTIME)
    VT(t) # international margin supply #;
Formula (all,t,ALLTIME)
    VT(t) = sum{m,MARG, sum{r,REG, VST(m,r,t)}};

Coefficient (all,m,MARG)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VTMUSESHR(m,c,s,d,t) # share of c,s,d usage in global demand for m #;
Formula (all,m,MARG)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VTMUSESHR(m,c,s,d,t) = VTFSD(c,s,d,t) / VT(t);
Formula (all,t,ALLTIME)
    (all,m,MARG: VTMUSE(m,t) <> 0.0)(all,c,COMM)(all,s,REG)(all,d,REG)
    VTMUSESHR(m,c,s,d,t) = VTMFSD(m,c,s,d,t) / VTMUSE(m,t);

Equation E_qtm
# global demand for margin m #
(all,m,MARG)(all,t,ALLTIME)
    qtm(m,t)
        = sum{c,COMM, sum{s,REG, sum{d,REG,
          VTMUSESHR(m,c,s,d,t) * qtmfsd(m,c,s,d,t)}}};

Coefficient (parameter)(all,m,MARG)(all,t,ALLTIME)
    ESUBS(m,t)
    # elasticity of sub. among transportation service inputs #;
Read
    ESUBS from file GTAPPARM header "ESBS"; 
Assertion (all,m,MARG)(all,t,ALLTIME) ESUBS(m,t) ge 0; 

Equation E_qst
# generate demand for regional supply of global transportation service #
(all,m,MARG)(all,r,REG)(all,t,ALLTIME)
    qst(m,r,t) = qtm(m,t) - ESUBS(m,t) * [pds(m,r,t) - pt(m,t)];

!< 
    6-2-2. Supply of Transport Services
    -----------------------------------
>!

Coefficient (all,m,MARG)(all,r,REG)(all,t,ALLTIME)
    VTSUPPSHR(m,r,t) # share of region r in global supply of margin m #;
Formula (all,m,MARG)(all,r,REG)(all,t,ALLTIME)
    VTSUPPSHR(m,r,t) = VTRPROV(r,t) / VT(t);
Formula (all,t,ALLTIME)(all,m,MARG: VTMPROV(m,t) <> 0.0)(all,r,REG)
    VTSUPPSHR(m,r,t) = VST(m,r,t) / VTMPROV(m,t);

Equation E_pt
# generate price index for composite transportation services #
(all,m,MARG)(all,t,ALLTIME)
    pt(m,t) = sum{r,REG, VTSUPPSHR(m,r,t) * pds(m,r,t)};
!<
    E_pt equation generates a price index for transportation services based on
    zero profits.  NOTE:
    (1) Sales to international transportation are not subject to export tax.
        This is why we base the costs to the transport sector at basic prices
        of the goods sold to international transportation.
    (2) We assume that the supply shares for margin services are uniform
        across freight, source of freight, and destination.
>!

Variable (all,m,COMM)(all,t,ALLTIME)
    atm(m,t) # tech change in mode m, worldwide #;
Variable (all,c,COMM)(all,t,ALLTIME)
    atf(c,t) # tech change shipping of c, worldwide #;
Variable (all,r,REG)(all,t,ALLTIME)
    ats(r,t) # tech change shipping from region r #;
Variable (all,d,REG)(all,t,ALLTIME)
    atd(d,t) # tech change shipping to d #;
Variable (all,m,MARG)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    atall(m,c,s,d,t) # tech change in m's shipping of c from region s to d #;

Equation E_atmfsd
#  generates flow-specific average rate of technical change #
(all,m,MARG)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    atmfsd(m,c,s,d,t) = atm(m,t) + atf(c,t) + ats(s,t) + atd(d,t) + atall(m,c,s,d,t);

!<
    6-3. Trade prices
    -----------------
>!

!<
    6-3-1. Export Prices
    --------------------
>!

Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    tx(c,r,t) # dest.-gen. change in subsidy on exports of c from r #;
Variable (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    txs(c,s,d,t) # dest.-spec. change in subsidy on exports of c from s to d #;
!<
    The variable txs captures changes in the power of bilateral export taxes.
    However, the presence of a destination-generic export subsidy shift (tx)
    also permits the user to swap a single export tax shock with another
    target variable.  It is most naturally swapped with the variable qo to
    insulate domestic producers from the world market.

    The sign of tx(c,r,t) and txs(c,s,d) has been CHANGED in GTAP model version 7
    tx(c,r,t)  > 1 in the case of a tax 
    txs(c,r,t) > 1 in the case of a tax 
    tx(c,r,t)  < 1 in the case of a subsidy. 
    txs(c,r,t) < 1 in the case of a subsidy. 
>!

Equation E_pfob
# links basic and FOB exports prices #
(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    pfob(c,s,d,t) = pds(c,s,t) + tx(c,s,t) + txs(c,s,d,t);

Coefficient (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VCIFCOST(c,s,d,t) # value of imports calculated as total cost of imports #;
Formula (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    VCIFCOST(c,s,d,t) = VFOB(c,s,d,t) + VTFSD(c,s,d,t);

Zerodivide default RNREG;
Coefficient (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    FOBSHR(c,s,d,t) # FOB share in (com. and margin) imports at CIF prices #;
Formula (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    FOBSHR(c,s,d,t) = VFOB(c,s,d,t) / VCIFCOST(c,s,d,t);
Zerodivide off;

Coefficient (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    TRNSHR(c,s,d,t) # Intl. transp. share in (com. and marg) imp. at CIF prices #;
Formula (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    TRNSHR(c,s,d,t) = 1 - FOBSHR(c,s,d,t);

Equation E_pcif
# links FOB and CIF prices for good c shipped from region s to d #
(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    pcif(c,s,d,t) = FOBSHR(c,s,d,t) * pfob(c,s,d,t) + TRNSHR(c,s,d,t) * ptrans(c,s,d,t);
!<
    This equation links export and import prices for each commodity/route
    triplet.  Note that technical change is embodied in ptrans(c,s,d) which is
    a cost index.
>!

Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    tm(c,r,t) # source-gen. change in tax on imports of c into r #;
Variable (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    tms(c,s,d,t) # source-spec. change in tax on imports of c from s to d #;
!<
    The variable tms captures changes in the power of bilateral import taxes.
    However, the presence of a source-generic import tariff shift (tm) also
    permits the user to swap a single import tariff shock with another target
    variable.  In particular, to insulate domestic producers from import price
    changes, it may be swapped with the relative price variable pr -- see
    below.
>!

Equation E_pmds
# links basic domestic import prices and CIF import prices #
(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    pmds(c,s,d,t) = pcif(c,s,d,t) + tm(c,d,t) + tms(c,s,d,t);

Variable (orig_level=1.0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pr(c,r,t) # ratio of domestic to imported prices in r #;
Equation E_pr
# defines target price ratio to be attained via the variable levy #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pr(c,r,t) = pds(c,r,t) - pms(c,r,t);
!<
    E_pr equation defines the target price ratio to be attained via the
    variable levy.  This price ratio is the ratio of domestic to average
    imported goods' price.  Note that the way this price ratio is defined, it
    includes intraregional imports as well.  In most applications, regions
    will represent groups of individual countries.  However, in the case of
    the EU, this is problematic, since recent versions of the database have
    incorporated intra-EU trade flows.  Therefore, when aggregated to the EU
    level, the composite import price includes both intra-EU and outside
    imports.  So some modification is needed to handle the EU case.
>!

!<
    6-4. Goods market equilibrium
    -----------------------------
>!
Coefficient (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    FDCSHR(c,a,r,t) # share of dom. prod. c used by act. a in r #;
Formula (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    FDCSHR(c,a,r,t) = VDFB(c,a,r,t) / VDB(c,r,t);
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    PDCSHR(c,r,t) # share of domestic prod. of c used by private hhlds in r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    PDCSHR(c,r,t) = VDPB(c,r,t) / VDB(c,r,t);
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    GDCSHR(c,r,t) # share of imports of c used by gov't hhlds in r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    GDCSHR(c,r,t) = VDGB(c,r,t) / VDB(c,r,t);
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    IDCSHR(c,r,t) # share of domestic prod. of c used by investment in r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    IDCSHR(c,r,t) = VDIB(c,r,t) / VDB(c,r,t);

Variable (orig_level=VDB)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qds(c,r,t) # domestic sales of commodity c in r #;
Equation E_qds
# assures market clearing for domestic sales #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qds(c,r,t) = sum{a,ACTS, FDCSHR(c,a,r,t) * qfd(c,a,r,t)}
             + PDCSHR(c,r,t) * qpd(c,r,t)
             + GDCSHR(c,r,t) * qgd(c,r,t)
             + IDCSHR(c,r,t) * qid(c,r,t);

Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    tradslack(c,r,t) # slack variable in tradeables market clearing condition #;
!<
    tradslack is exogenous unless the user wishes to specify the price of
    tradeables exogenously, in which case the analysis becomes partial
    equilibrium and walraslack must be exogenized.
>!
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    DSSHR(c,r,t) # share of domestic sales of c in r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    DSSHR(c,r,t) = VDB(c,r,t) / VCB(c,r,t);
Coefficient (all,m,MARG)(all,r,REG)(all,t,ALLTIME)
    STSHR(m,r,t) # share of sales of m to global transport services in r #;
Formula (all,m,MARG)(all,r,REG)(all,t,ALLTIME)
    STSHR(m,r,t) = VST(m,r,t) / VCB(m,r,t);
Coefficient (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    XSSHR(c,s,d,t) # share of export sales of c to s in r #;
Formula (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    XSSHR(c,s,d,t) = VXSB(c,s,d,t) / VCB(c,s,t);

!change to avoid complicated if()!
Equation E_pdsnmrg
# assures market clearing for commodities #
(all,c,NMRG)(all,r,REG)(all,t,ALLTIME)
    qc(c,r,t) = DSSHR(c,r,t) * qds(c,r,t) + sum(d,REG, XSSHR(c,r,d,t) * qxs(c,r,d,t)) 
            !+ IF[c in MARG, STSHR(c,r,t) * qst(c,r,t)]! 
            + tradslack(c,r,t);
Equation E_pdsmarg
# assures market clearing for commodities #
(all,c,MARG)(all,r,REG)(all,t,ALLTIME)
    qc(c,r,t) = DSSHR(c,r,t) * qds(c,r,t) + sum(d,REG, XSSHR(c,r,d,t) * qxs(c,r,d,t)) 
            + !IF[c in MARG, !STSHR(c,r,t) * qst(c,r,t)!]! 
            + tradslack(c,r,t);

!<
    6-5. Agents' prices for goods
    -----------------------------
>!
Variable (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    tfd(c,a,r,t) # tax on domestic c purchased by act. a in r #;
Variable (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    tfm(c,a,r,t) # tax on imported c purchased by act. a in r #;
Equation E_pfd
# links domestic basic and firm prices #
(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pfd(c,a,r,t) = pds(c,r,t) + tfd(c,a,r,t);
!<
    E_pfd  links domestic basic and firm prices. It holds only for domestic 
    goods and it captures the effect of commodity taxation of firms.   
>!

Equation E_pfm
# links domestic basic and firm prices #
(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pfm(c,a,r,t) = pms(c,r,t) + tfm(c,a,r,t);
!<
    E_pfm links domestic basic and firm prices.  It holds only for imported 
    goods and it captures the effect of commodity taxation of firms.
>!

Variable (orig_level=LevTPD)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    tpd(c,r,t) # power of tax on domestic c purchased by private hhld in r #;
Variable (orig_level=LevTPM)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    tpm(c,r,t) # power of tax on imported c purchased by private hhld in r #;
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME) 
    LevTPD(c,r,t) # levels TPD #;
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    LevTPM(c,r,t) # levels TPM #;
Zerodivide default 0.0;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    LevTPD(c,r,t)  =  VDPP(c,r,t) / VDPB(c,r,t);
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    LevTPM(c,r,t)  =  VMPP(c,r,t) / VMPB(c,r,t);
Zerodivide off;

Equation E_ppd
# links basic and private household consumption prices for domestic com. c #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    ppd(c,r,t) = pds(c,r,t) + tpd(c,r,t); 

Equation E_ppm
# links basic and private household consumption prices for imported com. c #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    ppm(c,r,t) = pms(c,r,t) + tpm(c,r,t);

Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    tgd(c,r,t) # power of tax on domestic c purchased by government hhld in r #;
Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    tgm(c,r,t) # power of tax on imported c purchased by gov't hhld in r #;

Equation E_pgd 
# links basic and government consumption prices for domestic com. c #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pgd(c,r,t) = pds(c,r,t) + tgd(c,r,t);

Equation E_pgm
# links basic and government consumption prices for imported com. c #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pgm(c,r,t) = pms(c,r,t) + tgm(c,r,t);

Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    tid(c,r,t) # power of tax on domestic investment commodity c in region r #;
Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    tim(c,r,t) # power of tax on imported investment commodity c in region r #;

Equation E_pid  
# links basic and investment consumption prices for domestic com. c #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pid(c,r,t) = pds(c,r,t) + tid(c,r,t);

Equation E_pim 
# links basic and investment consumption prices for imported com. c #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pim(c,r,t) = pms(c,r,t) + tim(c,r,t);


!<
    6-6. Private hhld tax shifter
    -----------------------------
>!
Variable  (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    tpdall(c,r,t) # comm.-, source-spec. shifter in private cons. tax of dom. c #;
Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    tpmall(c,r,t) # comm.-, source-spec. shifter in private cons. tax of imp. c #;
Variable (all,r,REG)(all,t,ALLTIME)
    tpreg(r,t) # source-generic tax shifter on private cons. #;
!<
    The variable tpreg(r,t) can be swapped with del_ttaxr(r,t) in order to generate 
    a tax replacement scenario, whereby taxes remain a constant share of
    national income.
>!
Equation E_tpd
# permits uniform consumption tax change #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    tpd(c,r,t) = tpdall(c,r,t) + tpreg(r,t);

Equation E_tpm
# permits uniform consumption tax change #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    tpm(c,r,t) = tpmall(c,r,t) + tpreg(r,t);

!<
    ----------------------------
    7. Factor market equilibrium
    ----------------------------
>!

Variable (all,e,ENDWMS)(all,r,REG)(all,t,ALLTIME)
    pe(e,r,t) # price of mobile and sluggish endowment e in region r #;
Variable (all,e,ENDWMS)(all,r,REG)(all,t,ALLTIME)
    qe(e,r,t) # supply of mobile and sluggish endowment e in region r #;

!<
    7-1. Mobile endowments
    ----------------------
>!

Coefficient (all,e,ENDWM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    ENDWMSHR(e,a,r,t) # share of mobile endow. e used by act. a at supply prices #;
Formula (all,e,ENDWM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    ENDWMSHR(e,a,r,t) = EVOS(e,a,r,t) / VES(e,r,t);

Equation E_pe1
# mkt clearing for perfectly mobile endowments in each r #
(all,e,ENDWM)(all,r,REG)(all,t,ALLTIME)
    qe(e,r,t) = sum{a,ACTS, ENDWMSHR(e,a,r,t) * qfe(e,a,r,t)} + endwslack(e,r,t);

Equation E_qes1 
# basic price of mobile endowments in a in r #
(all,e,ENDWM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pes(e,a,r,t) = pe(e,r,t);  

!<
    7-2. Sluggish endowments
    ------------------------
>!

Coefficient (parameter)(all,e,ENDW)(all,r,REG)(all,t,ALLTIME)
    ETRAE(e,r,t)
    # region-specific elast. of transformation for sluggish factor endowments #;
Read
    ETRAE from file GTAPPARM header "ETRE";
Assertion (all,e,ENDWS)(all,r,REG)(all,t,ALLTIME) ETRAE(e,r,t) lt 0;

Equation E_qes2
# allocation of sluggish endowments across sectors #
(all,e,ENDWS)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qes(e,a,r,t) = qe(e,r,t) - ETRAE(e,r,t) * [pes(e,a,r,t) - pe(e,r,t)]
               - endwslack(e,r,t);

Zerodivide default RNREG;
Coefficient (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    REVSHR(e,a,r,t) # Share of endowment e in total endowment revenue/supply #;
Formula (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    REVSHR(e,a,r,t) = EVOS(e,a,r,t) / VES(e,r,t);
Zerodivide off;

Equation E_pe2
# composite price for sluggish endowments #
(all,e,ENDWS)(all,r,REG)(all,t,ALLTIME)
    pe(e,r,t) = sum{a,ACTS, REVSHR(e,a,r,t) * pes(e,a,r,t)};

!<
    7-3. Sector-specific endowments
    -------------------------------
>!

Variable (all,e,ENDWF)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qesf(e,a,r,t) # supply of fixed (natural resource) endowment e in a in r #;

Equation E_qes3 
# equation to assist use of TABmate's automatic closure tool #
(all,e,ENDWF)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME) 
    qes(e,a,r,t) = qesf(e,a,r,t); 
!< 
    For convenience, variable qesf and equation E_qesf are added to assist use 
   of TABmate's automatic closure tool
>!

!<
    7-4. Price of endowments
    ------------------------
>!
Variable (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    tfe(e,a,r,t) # tax on primary factor e used by act. a in region r #;

Equation E_pfe 
# links basic and firm demand prices for mobile endowments #
(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pfe(e,a,r,t) = peb(e,a,r,t) + tfe(e,a,r,t);  

Equation E_pes
# links supply (pre-) and basic (post-tax) endowment prices #
(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    peb(e,a,r,t) = pes(e,a,r,t) + tinc(e,a,r,t);

Equation E_peb !< This equation assures market clearing for all endowments >!
# market clearing for endowments in each r #
(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    qfe(e,a,r,t) = qes(e,a,r,t);

!<
    8. Allocation of global saving 
    -------------------------------
>!

!<
    8-1. Investment preliminaries
    -----------------------------
>!
Variable (all,r,REG)(all,t,ALLTIME)
    ke(r,t) # end-of-period capital stock in r #;
Coefficient (ge 0)(all,r,REG)(all,t,FWDTIME)
    VKDELTA(r,t) # value of beginning-of-period capital stock in region r #;
Variable (all,r,REG)(all,t,FWDTIME)
    kdelta(r,t) # end-of-period capital stock in r #;
Coefficient
 (all,r,REG)(all,t,ALLTIME) VPINV(r,t) #Value of capital investment price#;
Formula
 (initial)(all,r,REG)(all,t,ALLTIME) VPINV(r,t) = 1;
Update
 (all,r,REG)(all,t,ALLTIME) VPINV(r,t) = pinv(r,t);
!<
    VKB(r,t) is used only in this sub-module, so its data are read here.  The
    associated variables, pinv(r,t) and kb(r,t), are used across modules, so they
    have been defined as common variables.
>!

Coefficient (all,r,REG)(all,t,ALLTIME)
    INVKERATIO(r,t)
    # ratio of gross investment to end-of-period capital stock in r #;
Formula 
 (all,r,REG)(all,t,FWDTIME) INVKERATIO(r,t)=[(Year(t+1)-Year(t))*VCAPI(r,t)]
   /[(Year(t+1)-Year(t))*VCAPI(r,t)+(1-(KAPPA(r,t)+LTGR(r,t))*(Year(t+1)-Year(t)))*VKB(r,t)];
 (all,r,REG)(all,t,ENDTIME) INVKERATIO(r,t)=[(Year(t)-Year(t-1))*VCAPI(r,t)]
   /[(Year(t)-Year(t-1))*VCAPI(r,t)+(1-(KAPPA(r,t)+LTGR(r,t))*(Year(t)-Year(t-1)))*VKB(r,t)];
 (all,r,REG)(all,t,FWDTIME) 
 VKDELTA(r,t)=VKB(r,t+1)/VPINV(r,t+1)/
       [(Year(t+1)-Year(t))*VCAPI(r,t)/VPINV(r,t)+(1-(KAPPA(r,t)+LTGR(r,t))*(Year(t+1)-Year(t)))*VKB(r,t)/VPINV(r,t)];
Equation E_ke
# ending capital stock equals beginning stock plus net investment #
(all,r,REG)(all,t,ALLTIME)
    ke(r,t) = INVKERATIO(r,t) * capi(r,t) + [1.0 - INVKERATIO(r,t)] * kb(r,t);
Equation E_kslack
# ending capital stock equals beginning stock plus net investment #
(all,r,REG)(all,t,FWDTIME)
    kb(r,t+1) = ke(r,t)+kdelta(r,t);

Coefficient (all,r,REG)(all,t,ALLTIME)
    GROSSCAP(r,t) # gross return to capital #;
Formula (all,r,REG)(all,t,ALLTIME)
    GROSSCAP(r,t) = sum{e,ENDWC, VES(e,r,t)};

Coefficient (all,r,REG)(all,t,ALLTIME)
    GRNETRATIO(r,t) # ratio of GROSS/NET rates of return on capital in r #;
Formula (all,r,REG)(all,t,ALLTIME)
    GRNETRATIO(r,t) = GROSSCAP(r,t) / [GROSSCAP(r,t) - VDEP(r,t)];
!<
    NOTE: [GROSSCAP(r,t) - VDEP(r,t)] is net returns to capital.
>!

Variable (all,r,REG)(all,t,ALLTIME)
    rore(r,t) # expected net rate of return on capital stock in r #;
Variable (all,r,REG)(all,t,ALLTIME)
    rorc(r,t) # current net rate of return on capital stock in r #;
Variable (all,r,REG)(all,t,ALLTIME)
    rental(r,t) # rental rate on capital = ps("capital",r,t) #;

Equation E_rental
# defines a variable for capital rental rate #
(all,r,REG)(all,t,ALLTIME)
    rental(r,t) = sum{e,ENDWC, [VES(e,r,t) / GROSSCAP(r,t)] * pe(e,r,t)};

Equation E_rorc
# current rate of return on capital in region r #
(all,r,REG)(all,t,ALLTIME)
    rorc(r,t) = GRNETRATIO(r,t) * [rental(r,t) - pinv(r,t)];

Equation E_kb
# associates change in cap. services w/ change in cap. stock #
(all,r,REG)(all,t,ALLTIME)
    kb(r,t) = sum{e,ENDWC, [VES(e,r,t) / GROSSCAP(r,t)] * qe(e,r,t)};
!<
    E_kb equation associates any change in capital services during the period
    with a change in capital stock.  Full capacity utilization is assumed.
>!

!<
    8-2. Rate-of-return sensitive investment allocation
    ---------------------------------------------------
>!

Coefficient (parameter)(all,r,REG)(all,t,ALLTIME)
    RORFLEX(r,t)
    # flexibility of expected net ROR on capital stock in r wrt investment #;
Read
    RORFLEX from file GTAPPARM header "RFLX";
!<
    RORFLEX is the flexibility of the expected net rate of return on the
    capital stock, in region r, with respect to investment.  If a region's
    capital stock increases by 1%, then it is expected that the net rate of
    return on capital will decline by RORFLEX %.  A larger absolute value for
    this parameter will reduce the tendency of international investment flows
    to respond to changes in expected rates of return.
>!

!<
    Rational expectation extension:
      (1) Set REEXODELTA=0, REDELTA=0 and RESEDELTA=0 to simulate the conventional adaptive
          recursive expectation results;
      (2) Set REEXODELTA=0, REDELTA=1 and RESEDELTA=1 to simulate the iterative rational
          expectation results;
      (3) Set REEXODELTA=0, REDELTA=1 and RESEDELTA=0 to simulate the rational expectation
          results with non-recursive solution method;
      (4) Set REEXODELTA=1 in a multi-steps approach to simulate the iterative rational expectation
          results with non-recursive solution method (need run_me.sh file and Python script extension);
>!

Coefficient (parameter)
    REDELTA # binary coefficient to switch rational expectation mechanism #;
Formula (initial)
    REDELTA = 1;
Coefficient (parameter)
    RESEDELTA # binary coefficient to switch to recursive rational expectation mechanism #;
Formula (initial)
    RESEDELTA = 0; 
Coefficient (parameter)
    REEXODELTA # binary coefficient to switch to exogenous RORE for iterative RE approach #;
Formula (initial)
    REEXODELTA = 0;
Coefficient (all,r,REG)(all,t,ALLTIME)
    VRENTAL(r,t) # capital rental price or gross rate of return #;
Formula (all,r,REG)(all,t,ALLTIME)
    VRENTAL(r,t) = sum{e,ENDWC, [VES(e,r,t) / GROSSCAP(r,t)]};
Coefficient (all,t,ALLTIME)
    VRORG(t) # value of global net rate of return on capital stock #;
Formula (all,t,ALLTIME)
    VRORG(t) = 0.04;
!Read
    VRORG from file GTAPDATA header "RORG";!

Variable (all,r,REG)(all,t,ALLTIME)
    pval(r,t) # present value of a unit of capital #;
Variable (all,r,REG)(all,t,ALLTIME)
    pval_se(r,t) # present value of a unit of capital #;
Variable (all,r,REG)(all,t,ALLTIME)
    ror_act(r,t) # actual rate of return #;
Variable (all,r,REG)(all,t,ALLTIME)
    ror_exo(r,t) # actual rate of return #;
Variable (all,t,ALLTIME)
    rorg(t) # global net rate of return on capital stock #;

Update (all,t,ALLTIME)
    VRORG(t) = rorg(t); 

Equation PVALFWDTIME
# present value of a unit of capital #
(all,r,REG)(all,t,FWDTIME)
    pval(r,t) = 1/[VRENTAL(r,t+1)+VPINV(r,t+1)*(1-KAPPA(r,t)*(Year(t+1)-Year(t)))-VPINV(r,t)*(1+VRORG(t)*(Year(t+1)-Year(t)))]*
                [VRENTAL(r,t+1)*rental(r,t+1)+VPINV(r,t+1)*(1-KAPPA(r,t)*(Year(t+1)-Year(t)))*pinv(r,t+1)
                -VPINV(r,t)*(1+VRORG(t)*(Year(t+1)-Year(t)))*[pinv(r,t)+VRORG(t)*(Year(t+1)-Year(t))/[1+VRORG(t)*(Year(t+1)-Year(t))]*rorg(t)]]
                -VRORG(t)/[1+VRORG(t)]*rorg(t);
Equation PVALENDTIME 
# present value of a unit of capital #
(all,r,REG)(all,t,ENDTIME)
    pval(r,t) = 1/[VRENTAL(r,t)-VPINV(r,t)*(Year(t)-Year(t-1))*(KAPPA(r,t)+VRORG(t))]*
                [VRENTAL(r,t)*rental(r,t)
                -VPINV(r,t)*(Year(t)-Year(t-1))*(KAPPA(r,t)+VRORG(t))*pinv(r,t)
                -VPINV(r,t)*(Year(t)-Year(t-1))*VRORG(t)*rorg(t)]
                -VRORG(t)*(Year(t)-Year(t-1))/[1+VRORG(t)*(Year(t)-Year(t-1))]*rorg(t);

Equation PVALSE
# present value of a unit of capital #
(all,r,REG)(all,t,ALLTIME)
    pval_se(r,t) = 1/[VRENTAL(r,t)-VPINV(r,t)*(KAPPA(r,t)+VRORG(t))]*
                [VRENTAL(r,t)*rental(r,t)-VPINV(r,t)*[KAPPA(r,t)+VRORG(t)]*pinv(r,t)-VPINV(r,t)*VRORG(t)*rorg(t)]
                -VRORG(t)/[1+VRORG(t)]*rorg(t);

Equation EQROR_ACT
# actual rate of return #
(all,r,REG)(all,t,ALLTIME)
    ror_act(r,t) = [1-RESEDELTA]*pval(r,t)+RESEDELTA*pval_se(r,t)-pinv(r,t);
 
Equation ROREXPECTED
# expected rate of return depends on the current return and investment (HT 58) #
(all,r,REG)(all,t,ALLTIME)
    rore(r,t) = (1-REDELTA)*[rorc(r,t) - RORFLEX(r,t) * INVKERATIO(r,t) * [capi(r,t) - kb(r,t)]]
                + (1-REEXODELTA)*REDELTA*ror_act(r,t) + REEXODELTA*ror_exo(r,t);

Coefficient (integer,parameter)
    RORDELTA
    # binary coefficient to switch mechanism of allocating investment funds #;
Formula (initial)
    RORDELTA = 1;
!<
    RORDELTA is a binary coefficient which determines the mechanism of
    allocating investment funds across regions.  When RORDELTA = 1, investment
    funds are allocated across regions to equate the change in the expected
    rates of return (i.e., rore(r,t)).  When RORDELTA = 0, investment funds are
    allocated across regions to maintain the existing composition of capital
    stocks.
>!

Variable (all,r,REG)(all,t,ALLTIME)
    cgdslack(r,t) # slack variable for qinv(r,t) #;
!<
    cgdslack is exogenous, unless the user wishes to exogenously fix the level 
    of gross investment in a region, in which case it can be swapped with
    cgdslack.
>!

Equation E_qinv
# either gross investment or expected rate of return in region r #
(all,r,REG)(all,t,ALLTIME)
    RORDELTA * rore(r,t)
    + [1 - RORDELTA]
    * [[!REGINV(r,t)!VCAPI(r,t) / NETINV(r,t)] * capi(r,t)!qinv(r,t)! - [VDEP(r,t) / NETINV(r,t)] * kb(r,t)]
        = RORDELTA * rorg(t) + [1 - RORDELTA] * globalcgds(t) + cgdslack(r,t);
!<
    This equation determines either gross investment or the expected rate of
    return in each region, depending on the setting for the binary RORDELTA
    parameter.
>!

Variable (all,e,ENDWC)(all,r,REG)(all,t,ALLTIME)
    expand(e,r,t) # change in investment relative to endowment stock #;
Equation E_expand
# change in investment relative to endowment stock #
(all,e,ENDWC)(all,r,REG)(all,t,ALLTIME)
    expand(e,r,t) = qinv(r,t) - qe(e,r,t);
!<
    Capital Accumulation 
    (based on the theory laid out in GTAP Technical Paper #7)
>!

!<
    8-3. Investment allocation based on initial capital shares
    ----------------------------------------------------------
>!

Equation E_globalcgds
# either expected global rate of return or global net investment # (all,t,ALLTIME)
    RORDELTA * globalcgds(t) + [1 - RORDELTA] * rorg(t)
        = RORDELTA
        * sum{r,REG,
            [VCAPI(r,t)!REGINV(r,t)! / GLOBINV(t)] * capi(r,t)!qinv(r,t)! - [VDEP(r,t) / GLOBINV(t)] * kb(r,t)}
        + [1 - RORDELTA] * sum{r,REG, [NETINV(r,t) / GLOBINV(t)] * rore(r,t)};
!<
    E_globalcgds equation computes either the change in global net investment 
    (when RORDELTA = 1), or the change in the expected global rate of return on
    capital (when RORDELTA = 0).
>!

!<
    8-4. Price of saving
    ---------------------
>!

Variable (all,r,REG)(all,t,ALLTIME)
    psaveslack(r,t) # slack variable for the saving price equation #;
!<
    psaveslack is exogenous under the normal closure.  However, in order to
    replicate simulations from the GTAP book, where there was a single saving
    price, psaveslack may be swapped with psave in order to fix the latter.
    In this case, pcgdswld must be the numeraire so that each region faces the
    same price of saving.
>!

Equation E_psave
# price of saving #
(all,r,REG)(all,t,ALLTIME)
    psave(r,t)
        = pinv(r,t)
        + sum{s,REG, [[NETINV(s,t) - SAVE(s,t)] / GLOBINV(t)] * pinv(s,t)}
        + psaveslack(r,t);
!<
    In contrast to the GTAP book, the price of saving is now region-specific
    and it changes at the same rate as the price of regional investment, plus
    an adjustment factor which accounts for the fact that saving and
    investment are not equal at the regional level.
>!

Equation E_pcgdswld
# price index for the aggregate global cgds composite # (all,t,ALLTIME)
    pcgdswld(t) = sum{r,REG, [NETINV(r,t) / GLOBINV(t)] * pinv(r,t)};

!<
    9. Tax revenue streams
    ----------------------
>!

!<
    9-1. Tax revenues generated in production
    -----------------------------------------
>!

!<
    The following variables could be dropped when converting to levels
    equation for income.  They are only needed for the linearized equation.
    The idea here is to look at the ratio of taxes to income in order to
    preserve homogeneity in prices.  (We could also look at changes in tax
    revenue, but then a uniform price increase would change this variable.)
    Obviously a simple percentage change variable doesn't work, since many
    taxes are initially zero.  The basic logic of this approach is as follows:

    Let R be the ratio of taxes to income: R = T/Y, then:
        dR = d(T/Y) = R(t - y)/100
    multiply through by Y to get:
        YdR = dT - Ty/100
    This ratio change is computed for each tax type and for total taxes.  Then
    the change in tax revenue itself may be computed as:
        dT = YdR + Ty/100
    in order to determine regional income.
>!

Variable (change) (all,r,REG)(all,t,ALLTIME)
    del_taxrout(r,t) # change in ratio of output tax to INCOME #;
Variable (change) (all,r,REG)(all,t,ALLTIME)
    del_taxrfu(r,t) # change in ratio of tax on primary factor usage to INCOME #;
Variable (change) (all,r,REG)(all,t,ALLTIME)
    del_taxriu(r,t) # change in ratio of tax on intermediate usage to INCOME #;
Variable (change) (all,r,REG)(all,t,ALLTIME)
    del_taxrpc(r,t) # change in ratio of private consumption tax to INCOME #;
Variable (change) (all,r,REG)(all,t,ALLTIME)
    del_taxrgc(r,t) # change in ratio of government consumption tax to INCOME #;
Variable (change) (all,r,REG)(all,t,ALLTIME)
    del_taxric(r,t) # change in ratio of investment consumption tax to INCOME #;
Variable (change) (all,r,REG)(all,t,ALLTIME)
    del_taxrexp(r,t) # change in ratio of export tax to INCOME #;
Variable (change) (all,r,REG)(all,t,ALLTIME)
    del_taxrimp(r,t) # change in ratio of import tax to INCOME #;
Variable (change) (all,r,REG)(all,t,ALLTIME)
    del_taxrinc(r,t) # change in ratio of income tax to INCOME #;

Equation E_del_taxrout
# change in ratio of output tax payments to regional income #
(all,r,REG)(all,t,ALLTIME)
    100.0 * INCOME(r,t) * del_taxrout(r,t) + TAXROUT(r,t) * y(r,t)
        = sum{c,COMM, sum{a,ACTS, 
           MAKEB(c,a,r,t) * to(c,a,r,t) + PTAX(c,a,r,t) * [ps(c,a,r,t) + qca(c,a,r,t)]}};

Equation E_del_taxrfu
# change in ratio of tax payments on factor usage to regional income #
(all,r,REG)(all,t,ALLTIME)
    100.0 * INCOME(r,t) * del_taxrfu(r,t) + TAXRFU(r,t) * y(r,t)
        = sum{e,ENDW, sum{a,ACTS,
           VFP(e,a,r,t) * tfe(e,a,r,t) + ETAX(e,a,r,t) * [peb(e,a,r,t) + qfe(e,a,r,t)]}};

Equation E_del_taxriu
# change in ratio of tax payments on intermediate goods to regional income #
(all,r,REG)(all,t,ALLTIME)
    100.0 * INCOME(r,t) * del_taxriu(r,t) + TAXRIU(r,t) * y(r,t)
        = sum{c,COMM, sum{a,ACTS,
            VDFP(c,a,r,t) * tfd(c,a,r,t) + DFTAX(c,a,r,t) * [pds(c,r,t) + qfd(c,a,r,t)]}}
        + sum{c,COMM, sum{a,ACTS,
            VMFP(c,a,r,t) * tfm(c,a,r,t) + MFTAX(c,a,r,t) * [pms(c,r,t) + qfm(c,a,r,t)]}};

!<
    9-2. Tax revenues generated in domestic final demand
    ----------------------------------------------------
>!

Equation E_del_taxrpc
# change in ratio of private consumption tax payments to regional income #
(all,r,REG)(all,t,ALLTIME)
    100.0 * INCOME(r,t) * del_taxrpc(r,t) + TAXRPC(r,t) * y(r,t)
        = sum{c,COMM,
            VDPP(c,r,t) * tpd(c,r,t) + DPTAX(c,r,t) * [pds(c,r,t) + qpd(c,r,t)]}
        + sum{c,COMM,
            VMPP(c,r,t) * tpm(c,r,t) + MPTAX(c,r,t) * [pms(c,r,t) + qpm(c,r,t)]};

Equation E_del_taxrgc 
# change in ratio of government consumption tax payments to regional income #
(all,r,REG)(all,t,ALLTIME)
    100.0 * INCOME(r,t) * del_taxrgc(r,t) + TAXRGC(r,t) * y(r,t)
        = sum{c,COMM,
            VDGP(c,r,t) * tgd(c,r,t) + DGTAX(c,r,t) * [pds(c,r,t) + qgd(c,r,t)]}
        + sum{c,COMM,
            VMGP(c,r,t) * tgm(c,r,t) + MGTAX(c,r,t) * [pms(c,r,t) + qgm(c,r,t)]};

Equation E_del_taxric  
# change in ratio of investment tax payments to regional income #
(all,r,REG)(all,t,ALLTIME)
    100.0 * INCOME(r,t) * del_taxric(r,t) + TAXRIC(r,t) * y(r,t)
        = sum{c,COMM,
            VDIP(c,r,t) * tid(c,r,t) + DITAX(c,r,t) * [pds(c,r,t) + qid(c,r,t)]}
        + sum{c,COMM,
            VMIP(c,r,t) * tim(c,r,t) + MITAX(c,r,t) * [pms(c,r,t) + qim(c,r,t)]};

!<
    9-3. Tax revenues generated in international trade
    --------------------------------------------------
>!

Equation E_del_taxrexp
# change in ratio of export tax payments to regional income #
(all,s,REG)(all,t,ALLTIME)
    100.0 * INCOME(s,t) * del_taxrexp(s,t) + TAXREXP(s,t) * y(s,t)
        = sum{c,COMM, sum{d,REG, VFOB(c,s,d,t) * [tx(c,s,t) + txs(c,s,d,t)]
        + XTAXD(c,s,d,t) * [pds(c,s,t) + qxs(c,s,d,t)]}};

Equation E_del_taxrimp
# change in ratio of import tax payments to regional income #
(all,d,REG)(all,t,ALLTIME)
    100.0 * INCOME(d,t) * del_taxrimp(d,t) + TAXRIMP(d,t) * y(d,t)
        = sum{c,COMM, sum{s,REG,
            VMSB(c,s,d,t) * [tm(c,d,t) + tms(c,s,d,t)]
            + MTAX(c,s,d,t) * [pcif(c,s,d,t) + qxs(c,s,d,t)]}};

!<
    9-4. Income taxes and other tax identities
    ------------------------------------------
>!

Coefficient (all,r,REG)(all,t,ALLTIME)
    TAXRINC(r,t) # income tax payments in r #;
Formula (all,r,REG)(all,t,ALLTIME)
    TAXRINC(r,t) = sum{e,ENDW, sum{a,ACTS, INCTAX(e,a,r,t)}};

Equation E_del_taxrinc
# change in ratio of income tax payments to regional income #
(all,r,REG)(all,t,ALLTIME)
    100.0 * INCOME(r,t) * del_taxrinc(r,t) + TAXRINC(r,t) * y(r,t)
        = sum{e,ENDW, sum{a,ACTS, EVFB(e,a,r,t) * [tinc(e,a,r,t)] 
        + INCTAX(e,a,r,t) * [pes(e,a,r,t) + qfe(e,a,r,t)]}};

Equation E_del_indtaxr
# change in ratio of indirect taxes to INCOME in r #
(all,r,REG)(all,t,ALLTIME)
    del_indtaxr(r,t)
        = del_taxrout(r,t) + del_taxrfu(r,t)
        + del_taxriu(r,t)  + del_taxrpc(r,t) + del_taxrgc(r,t) + del_taxric(r,t)
        + del_taxrimp(r,t) + del_taxrexp(r,t); 

Variable (change)(all,r,REG)(all,t,ALLTIME)
    del_ttaxr(r,t) # change in ratio of taxes to INCOME in r #;
Equation E_del_ttaxr
# change in ratio of taxes to INCOME in r #
(all,r,REG)(all,t,ALLTIME)
    del_ttaxr(r,t)
        = del_indtaxr(r,t) + del_taxrinc(r,t);
!<
   The del_ttaxr variable can be swapped with the commodity- and source-generic
   consumption tax shift, tp(r,t), in order to generate a tax replacement
   scenario, whereby taxes remain a constant share of national income.
>!

!<
    10. Numeraire and closure
    -------------------------
>!

Variable (orig_level=1.0)(all,r,REG)(all,t,ALLTIME)
    pfactor(r,t) # price index (basic price weights) of primary factors, by region #;
Coefficient (all,r,REG)(all,t,ALLTIME)
    VENDWREG(r,t) # value of primary factors, at basic prices, by region #;
Formula (all,r,REG)(all,t,ALLTIME)
    VENDWREG(r,t) = sum{e,ENDW, sum{a,ACTS, EVFB(e,a,r,t)}};

Equation E_pfactor
# computes % change in price index of primary factors, by region #
(all,r,REG)(all,t,ALLTIME)
    VENDWREG(r,t) * pfactor(r,t) 
        = sum{e,ENDW, sum{a,ACTS, EVFB(e,a,r,t) * peb(e,a,r,t)}};

Variable (orig_level=1.0)(all,t,ALLTIME)
    pfactwld(t) # world price index of primary factors #;
Coefficient (all,t,ALLTIME)
    VENDWWLD(t) # value of primary factors, at basic prices, worldwide #;
Formula (all,t,ALLTIME)
    VENDWWLD(t) = sum{r,REG, VENDWREG(r,t)};

Equation E_rorg 
# computes % change in global price index of primary factors # (all,t,ALLTIME)
    VENDWWLD(t) * pfactwld(t) = sum{r,REG, VENDWREG(r,t) * pfactor(r,t)};
!<  This equation derives the price index of primary factors. Note that this is
    the only instance where an equation name breaks the GTAP model's naming 
    convention (i.e., equation name does directly not relate to variable being 
    derived). This is because PFACTWLD is exogenous as the model's price 
    anchor (numeraire) and thus this equation explains RORG which has no 
    separate equation (which has been dropped due to Walras' law). Note as well 
    that the equation is separated into two. The first E_pfactor defines a 
    regional index for factor prices, and the second defines the global index. 
    By naming this equation E_rorg and because pfactwld is exogenous, we can
    for convenience, use TABmate's automatic closure tool to list down all 
    exogenous and endogenous variable split (i.e., closure) that is consistent 
    with the standard GTAP closure. Using TABmate's automatic closure tool is 
    beneficial especially during model development or extension. 
>!

Variable (all,t,ALLTIME)
    walras_sup(t) # supply in omitted market--global supply of cgds composite #;
Variable (all,t,ALLTIME)
    walras_dem(t) # demand in the omitted market--global demand for saving #;
Variable (all,t,ALLTIME)
    walraslack(t) # slack variable in the omitted market #;

Equation E_walras_sup
# extra equation: computes change in supply in the omitted market # (all,t,ALLTIME)
    walras_sup(t) = pcgdswld(t) + globalcgds(t);
!<
    This is an extra equation which simply computes change in supply in the
    omitted market.  (modified from HT 12 to reflect the value as opposed to
    quantity change, in light of the new treatment of psave(r,t))
>!

Equation E_walras_dem
# extra equation: computes change in demand in the omitted market # (all,t,ALLTIME)
    GLOBINV(t) * walras_dem(t) = sum{r,REG, SAVE(r,t) * [psave(r,t) + qsave(r,t)]};
!<
    E_walras_dem is an extra equation which simply computes change in demand in 
    the omitted market.  (modified from HT 13 to reflect the value as opposed to
    quantity change)
>!

Equation E_walraslack
# Check Walras' Law.  Value of "walraslack" should be zero # (all,t,ALLTIME)
    walras_sup(t) = walras_dem(t) + walraslack(t);
!<
    E_walraslack allows us to verify that Walras' Law holds. The value of 
    walraslack should be zero in any GE simulation. The variable walraslack is 
    endogenous under normal, GE closure.  If the GE links are broken, then  
    walraslack must be swapped with the numeraire, thereby forcing global
    saving to explicitly equal global investment.
>!

!<
    ---------------------------------------------------
    B. Summary Indices (for use in welfare measurement)
    ---------------------------------------------------

    We first calculate a number of useful summary statistics, including 
    terms of trade variables/coefficients which are used in the 
    Welfare Measurement and Decomposition section (Section 11)
 
    The following equations do not generally affect the equilibrium structure 
    of the model, although they do include the equation for the usual numeraire 
    variable, "pfactwld". 

    B-0. Variables and coefficients for summary indices
    B-1. Factor price indices
    B-2. Regional terms of trade (ToT)
    B-3. GDP indices (value, price and quantity)
    B-4. Aggregate trade indices (value, price and quantity)
    B-5. Trade balance indices
    B-6. Terms of trade (ToT) decomposition 
>!

!<
    B-0. Appendix-specific variables and coefficients
    -------------------------------------------------
    only used in this summary indices appendix
>!

Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    vxwfob(c,r,t) # value of merchandise regional exports, by commodity, FOB #;
Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    vmwcif(c,r,t) # value of merchandise regional imports, by commodity, CIF #;
Variable (all,r,REG)(all,t,ALLTIME)
    vxwreg(r,t) # value of merchandise exports, by region #;
Variable (all,r,REG)(all,t,ALLTIME)
    vmwreg(r,t) # value of merchandise imports, by region, at world prices #;

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VXDFOB(c,r,t) # FOB value of com. c exports to all dest. (tradeables only) #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VXDFOB(c,r,t) = sum{d,REG, VFOB(c,r,d,t)};

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VXW(c,r,t) # value of exports by commodity c and region r at FOB prices #;
!change to avoid complicated if()!
Formula (all,c,NMRG!COMM!)(all,r,REG)(all,t,ALLTIME)
    VXW(c,r,t) = VXDFOB(c,r,t) !+ IF[c in MARG, VST(c,r,t)]!;
Formula (all,c,MARG!COMM!)(all,r,REG)(all,t,ALLTIME)
    VXW(c,r,t) = VXDFOB(c,r,t) + !IF[c in MARG, !VST(c,r,t)!]!;

Coefficient (all,r,REG)(all,t,ALLTIME)
    VXWREGION(r,t) # value of exports by region r at FOB prices #;
Formula (all,r,REG)(all,t,ALLTIME)
    VXWREGION(r,t) = sum{c,COMM, VXW(c,r,t)};

Coefficient (all,c,COMM)(all,d,REG)(all,t,ALLTIME)
    VMCIF(c,d,t) # value of commodity imports c by DEST. d at CIF prices #;
Formula (all,c,COMM)(all,d,REG)(all,t,ALLTIME)
    VMCIF(c,d,t) = sum{s,REG, VCIF(c,s,d,t)};

Coefficient (all,r,REG)(all,t,ALLTIME)
    VMWREGION(r,t) # value of commodity imports by region r at CIF prices #;
Formula (all,r,REG)(all,t,ALLTIME)
    VMWREGION(r,t) = sum{c,COMM, VMCIF(c,r,t)};

!<
    B-1. Factor price indices
    -------------------------
>!

Variable (orig_level=1.0)(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pfactreal(e,a,r,t) # ratio of return to primary factor e to CPI in r #;
Equation E_pfactreal
# defines the real rate of return to primary factor e in region r #
(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    pfactreal(e,a,r,t) = pes(e,a,r,t) - ppriv(r,t);
!<
    This equation defines the real rate of return to primary factor e in
    region r (new).
>!

Variable (orig_level=1.0)(all,e,ENDWMS)(all,r,REG)(all,t,ALLTIME)
    pebfactreal(e,r,t) 
    # ratio of (tax-inclusive) return to mobile and sluggish factor e in r #;
Coefficient (all,e,ENDWMS)(all,r,REG)(all,t,ALLTIME)
    VENDWMS(e,r,t) # value of mobile and sluggish e in r at basic prices #;
Coefficient (all,e,ENDWMS)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    ENDWMSSHR(e,a,r,t) # share of mobile and sluggish e usage by act a in reg r #;
Zerodivide default RNREG;
Formula (all,e,ENDWMS)(all,r,REG)(all,t,ALLTIME)
    VENDWMS(e,r,t) = sum{a,ACTS, EVFB(e,a,r,t)};
Formula (all,e,ENDWMS)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    ENDWMSSHR(e,a,r,t) = EVFB(e,a,r,t) / VENDWMS(e,r,t);
Zerodivide off;

Equation E_pebfactreal
# defines the real (tax-inclusive) return to mobile and sluggish factor e in r #
(all,e,ENDWMS)(all,r,REG)(all,t,ALLTIME)
    pebfactreal(e,r,t) = sum{a, ACTS, ENDWMSSHR(e,a,r,t) *  peb(e,a,r,t)} - ppriv(r,t);

Variable (orig_level=1.0)(all,e,ENDWMS)(all,r,REG)(all,t,ALLTIME)
    pefactreal(e,r,t) 
    # ratio of (tax-exclusive) return to mobile and sluggish factor e in r #;
Equation E_pefactreal
# defines the real (tax-exclusive) return to mobile and sluggish factor e in r #
(all,e,ENDWMS)(all,r,REG)(all,t,ALLTIME)
    pefactreal(e,r,t) = pe(e,r,t) - ppriv(r,t);

!<
    B-2. Regional terms of trade (ToT)
    ----------------------------------

    The next three equations correspond to Table 10 of Hertel and Tsigas on
    Regional Terms of Trade.
>!

Variable (orig_level=1.0)(all,r,REG)(all,t,ALLTIME)
    psw(r,t) # index of prices received for tradeables produced in region r #;
Equation E_psw
# estimate change in index of prices received for tradeables c produced in r #
(all,r,REG)(all,t,ALLTIME)
    VXWREGION(r,t) * psw(r,t)
        = sum{c,COMM, sum{d,REG, VFOB(c,r,d,t) * pfob(c,r,d,t)}}
        + sum{m,MARG, VST(m,r,t) * pds(m,r,t)};
!<
    This equation estimates the change in the index of prices received for
    tradeable products produced in r.  (modified from HT 64 to eliminate the
    investment component)
>!

Variable (orig_level=1.0)(all,r,REG)(all,t,ALLTIME)
    pdw(r,t) # index of prices paid for tradeables used in importing region r #;
Equation E_pdw
# estimate change in index of prices paid for tradeable products used in r #
(all,r,REG)(all,t,ALLTIME)
    VMWREGION(r,t) * pdw(r,t)
        = sum{c,COMM, sum{s,REG, VCIF(c,s,r,t) * pcif(c,s,r,t)}};
!<
    This equation estimates the change in the index of prices paid for
    tradeable products used in r.  (modified from HT 65 to eliminate saving)
>!

Variable (orig_level=1.0)(all,r,REG)(all,t,ALLTIME)
    tot(r,t) # terms of trade for region r: tot(r,t) = psw(r,t) - pdw(r,t) #;
Equation E_tot
# terms of trade equation computed as difference in psw and pdw #
(all,r,REG)(all,t,ALLTIME)
    tot(r,t) = psw(r,t) - pdw(r,t);

!<
    B-3. GDP indices (value, price and quantity)
    --------------------------------------------
>!

! GDP expenditure side summary !
Set 
    GDPEX (Household,Investment,Government,Exports,IntnlMargins,Imports);
Coefficient (all,r,REG)(all,g,GDPEX)(all,t,ALLTIME)
    GDPEXP(r,g,t) # GDP expenditure side summary #;
Formula   
(all,r,REG)(all,t,ALLTIME) GDPEXP(r,"Household",t)    = sum{c,COMM, VPP(c,r,t)};  
(all,r,REG)(all,t,ALLTIME) GDPEXP(r,"Investment",t)   = sum{c,COMM, VIP(c,r,t)};  
(all,r,REG)(all,t,ALLTIME) GDPEXP(r,"Government",t)   = sum{c,COMM, VGP(c,r,t)};  
(all,s,REG)(all,t,ALLTIME) GDPEXP(s,"Exports",t)      = sum{c,COMM, sum{d,REG, VFOB(c,s,d,t)}};  
(all,r,REG)(all,t,ALLTIME) GDPEXP(r,"IntnlMargins",t) = sum{m,MARG, VST(m,r,t)};  
(all,d,REG)(all,t,ALLTIME) GDPEXP(d,"Imports",t)      = - sum{c,COMM, sum{s,REG, VCIF(c,s,d,t)}}; 

Variable (all,r,REG)(all,t,ALLTIME)
    vgdp(r,t) # change in value of GDP #;
Coefficient (all,r,REG)(all,t,ALLTIME)
    GDP(r,t) # gross domestic product in region r #;
Formula (all,r,REG)(all,t,ALLTIME)
    GDP(r,t) = sum{g,GDPEX, GDPEXP(r,g,t)};
!<
    Gross Domestic Product in region r. Trade is valued at FOB and CIF prices.
>!

Equation E_vgdp
# change in value of GDP #
(all,r,REG)(all,t,ALLTIME)
    GDP(r,t) * vgdp(r,t)
        = sum{c,COMM, VGP(c,r,t) * [qga(c,r,t) + pga(c,r,t)]}
        + sum{c,COMM, VPP(c,r,t) * [qpa(c,r,t) + ppa(c,r,t)]}
        + sum{c,COMM, VIP(c,r,t) * [qinv(r,t) + pinv(r,t)]}
        + sum{c,COMM, sum{d,REG, VFOB(c,r,d,t) * [qxs(c,r,d,t) + pfob(c,r,d,t)]}}
        + sum{m,MARG, VST(m,r,t) * [qst(m,r,t) + pds(m,r,t)]}
        - sum{c,COMM, sum{s,REG, VCIF(c,s,r,t) * [qxs(c,s,r,t) + pcif(c,s,r,t)]}};

Variable (orig_level=1.0)(all,r,REG)(all,t,ALLTIME)
    pgdp(r,t) # GDP price index #;
Variable (orig_level=GDP)(all,r,REG)(all,t,ALLTIME)
    qgdp(r,t) # GDP (expenditure-side) quantity index #;

Equation E_pgdp
# GDP price index #
(all,r,REG)(all,t,ALLTIME)
    GDP(r,t) * pgdp(r,t)
        = sum{c,COMM, VGP(c,r,t) * pga(c,r,t)}
        + sum{c,COMM, VPP(c,r,t) * ppa(c,r,t)}
        + sum{c,COMM, VIP(c,r,t) * pia(c,r,t)}
        + sum{c,COMM, sum{d,REG, VFOB(c,r,d,t) * pfob(c,r,d,t)}}
        + sum{m,MARG, VST(m,r,t) * pds(m,r,t)}
        - sum{c,COMM, sum{s,REG, VCIF(c,s,r,t) * pcif(c,s,r,t)}};

Equation E_qgdp
# GDP quantity index #
(all,r,REG)(all,t,ALLTIME)
    GDP(r,t) * qgdp(r,t)
        = sum{c,COMM, VGP(c,r,t) * qga(c,r,t)}
        + sum{c,COMM, VPP(c,r,t) * qpa(c,r,t)}
        + sum{c,COMM, VIP(c,r,t) * qia(c,r,t)}
        + sum{c,COMM, sum{d,REG, VFOB(c,r,d,t) * qxs(c,r,d,t)}}
        + sum{m,MARG, VST(m,r,t) * qst(m,r,t)}
        - sum{c,COMM, sum{s,REG, VCIF(c,s,r,t) * qxs(c,s,r,t)}};


!< Global GDP indices >!
Variable (orig_level=GDPWLD)(all,t,ALLTIME)
    qgdpwld(t) # percent change in world real GDP #;
Variable (orig_level=1.0)(all,t,ALLTIME)
    pgdpwld(t) # percent change in GDP price index #;
Variable (orig_level=GDPWLD)(all,t,ALLTIME)
    vgdpwld(t) # percent change in value of GDP #;
Coefficient (all,t,ALLTIME)
    GDPWLD(t) # global gross domestic product #;
Formula (all,t,ALLTIME)
    GDPWLD(t) = sum{r,REG, GDP(r,t)};

Equation E_qgdpwld
# percent change in world real GDP #(all,t,ALLTIME)
    GDPWLD(t) * qgdpwld(t) = sum{r,REG, GDP(r,t) * qgdp(r,t)};

Equation E_pgdpwld
# percent change in world real GDP price index # (all,t,ALLTIME)
    GDPWLD(t) * pgdpwld(t) = sum{r,REG, GDP(r,t) * pgdp(r,t)};

Equation E_vgdpwld
# percent change in world real GDP price index # (all,t,ALLTIME)
    vgdpwld(t) = pgdpwld(t) + qgdpwld(t);

!<
    modified from HT 72 for use with AnalyseGE
>!
Variable (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    compvalad(a,r,t) # composition of value added for good c and region r #;

Equation E_compvalad
# track change in composition of value added #
(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    compvalad(a,r,t) = qo(a,r,t) - qgdp(r,t);

!<
    B-4. Aggregate trade indices (value, price and quantity)
    --------------------------------------------------------
>!

!<
    Common variables and coefficients
    Value indices for aggregate trade
    Price indices for aggregate trade
    Quantity indices for aggregate trade
>!

!<
    Common variables and coefficients
    .................................

    only used in this aggregate trade indices section
>!

Variable (orig_level=1.0)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pxw(c,r,t) # aggregate exports price index of c from region r #;
Coefficient (all,c,COMM)(all,t,ALLTIME)
    VXWCOMMOD(c,t) # value of world exports by commodity c at FOB prices #;
Formula (all,c,COMM)(all,t,ALLTIME)
    VXWCOMMOD(c,t) = sum{r,REG, VXW(c,r,t)};
Coefficient (all,t,ALLTIME)
    VXWLD(t) # value of commodity exports, FOB, globally #;
Formula (all,t,ALLTIME)
    VXWLD(t) = sum{r,REG, VXWREGION(r,t)};

Coefficient (all,c,COMM)(all,t,ALLTIME)
    VMWCOMMOD(c,t) # global value of commodity imports, CIF, by commodity #;
Formula (all,c,COMM)(all,t,ALLTIME)
    VMWCOMMOD(c,t) = sum{r,REG, VMCIF(c,r,t)};

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME) 
    VXDXSB(c,r,t) # basic value of com. c exports to all dest. (tradeables only) #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME) 
    VXDXSB(c,r,t) = sum{d,REG, VXSB(c,r,d,t)};

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    PW_PM(c,r,t) # ratio of world to domestic prices #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    PW_PM(c,r,t) = VXDFOB(c,r,t) / VXDXSB(c,r,t);

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VOW(c,r,t) # value of commodity output in r at FOB incl transp. services #;
!change to avoid complicated if()!
Formula (all,c,NMRG!COMM!)(all,r,REG)(all,t,ALLTIME)
    VOW(c,r,t) = VDB(c,r,t) * PW_PM(c,r,t) + VXDFOB(c,r,t) !+ IF[c in MARG, + VST(c,r,t)]!;
Formula (all,c,MARG!COMM!)(all,r,REG)(all,t,ALLTIME)
    VOW(c,r,t) = VDB(c,r,t) * PW_PM(c,r,t) + VXDFOB(c,r,t) + !IF[c in MARG, + !VST(c,r,t)!]!;

Coefficient (all,c,COMM)(all,t,ALLTIME)
    VWOW(c,t) # value of world supply at world prices for c #;
Formula (all,c,COMM)(all,t,ALLTIME)
    VWOW(c,t) = sum{r,REG, VOW(c,r,t)};

Coefficient (all,c,COMM)(all,t,ALLTIME)
    VWOU(c,t) # value of world output of c at user prices #;
Formula (all,c,COMM)(all,t,ALLTIME)
    VWOU(c,t) = sum{r,REG, VPP(c,r,t) + VGP(c,r,t) + VIP(c,r,t) 
                  + sum{a,ACTS, VFP(c,a,r,t)}};

!<
    Value indices for aggregate trade
    .................................
>!

!change to avoid complicated if()!
Equation E_vxwfobnmrg
# the change in FOB value of exports of m from r #
(all,c,NMRG!COMM!)(all,r,REG)(all,t,ALLTIME)
    VXW(c,r,t) * vxwfob(c,r,t)
        = sum{d,REG, VFOB(c,r,d,t) * [qxs(c,r,d,t) + pfob(c,r,d,t)]}
        !+ IF[c in MARG, VST(c,r,t) * [qst(c,r,t) + pds(c,r,t)]]!;
Equation E_vxwfobmarg
# the change in FOB value of exports of m from r #
(all,c,MARG!COMM!)(all,r,REG)(all,t,ALLTIME)
    VXW(c,r,t) * vxwfob(c,r,t)
        = sum{d,REG, VFOB(c,r,d,t) * [qxs(c,r,d,t) + pfob(c,r,d,t)]}
        + !IF[c in MARG, !VST(c,r,t) * [qst(c,r,t) + pds(c,r,t)]!]!;

Equation E_vxwreg
# computes % change in value of merchandise exports, by region #
(all,r,REG)(all,t,ALLTIME)
    VXWREGION(r,t) * vxwreg(r,t) = sum{c,COMM, VXW(c,r,t) * vxwfob(c,r,t)};

Variable (all,c,COMM)(all,t,ALLTIME)
    vxwcom(c,t) # value of global merchandise exports by commodity #;
Equation E_vxwcom
# computes % change in FOB value of global exports, by commodity #
(all,c,COMM)(all,t,ALLTIME)
    VXWCOMMOD(c,t) * vxwcom(c,t) = sum{r,REG, VXW(c,r,t) * vxwfob(c,r,t)};

Variable (all,t,ALLTIME)
    vxwwld(t) # value of world trade #;
Equation E_vxwwld
# computes % change in value of global exports # (all,t,ALLTIME)
    VXWLD(t) * vxwwld(t) = sum{r,REG, VXWREGION(r,t) * vxwreg(r,t)};

Equation E_vmwcif
# the change in CIF value of imports of commodity c into r #
(all,c,COMM)(all,d,REG)(all,t,ALLTIME)
    VMCIF(c,d,t) * vmwcif(c,d,t)
        = sum{s,REG, VCIF(c,s,d,t) * [pcif(c,s,d,t) + qxs(c,s,d,t)]};

Equation E_vmwreg
# computes % change in value of imports, CIF basis, by region #
(all,r,REG)(all,t,ALLTIME)
    VMWREGION(r,t) * vmwreg(r,t) = sum{c,COMM, VMCIF(c,r,t) * vmwcif(c,r,t)};

Variable (all,c,COMM)(all,t,ALLTIME)
    vmwcom(c,t) # value of global merchandise imports c, at world prices #;
Equation E_vmwcom
# computes % change in value of global imports, by commodity #
(all,c,COMM)(all,t,ALLTIME)
    VMWCOMMOD(c,t) * vmwcom(c,t) = sum{r,REG, VMCIF(c,r,t) * vmwcif(c,r,t)};

Variable (all,c,COMM)(all,t,ALLTIME)
    valuew(c,t) # value of world supply of good c #;
Equation E_valuew
# change in value of world output of comm. c at FOB prices #
(all,c,COMM)(all,t,ALLTIME)
    VWOW(c,t) * valuew(c,t) = sum{r,REG, VOW(c,r,t) * [pxw(c,r,t) + qc(c,r,t)]};

Variable (all,c,COMM)(all,t,ALLTIME)
    valuewu(c,t) # value of world supply of good c at user prices #;
Equation E_valuewu
# change in value of world output of commodity c at user prices #
(all,c,COMM)(all,t,ALLTIME)
    VWOU(c,t) * valuewu(c,t)
        = sum{r,REG, VPP(c,r,t) * [ppa(c,r,t) + qpa(c,r,t)]
        + VGP(c,r,t) * [pga(c,r,t) + qga(c,r,t)]
        + VIP(c,r,t) * [pinv(r,t) + qia(c,r,t)]
        + sum{a,ACTS, VFP(c,a,r,t) * [pfa(c,a,r,t) + qfa(c,a,r,t)]}};

!<
    Price indices for aggregate trade
    .................................
>!

!change to avoid complicated if()!
Equation E_pxwnmrg
# change in FOB price index of exports of m from r #
(all,C,NMRG!COMM!)(all,r,REG)(all,t,ALLTIME)
    VXW(c,r,t) * pxw(c,r,t)
        = sum{d,REG, VFOB(c,r,d,t) * pfob(c,r,d,t)} 
        !+ IF[c in MARG, VST(c,r,t) * pds(c,r,t)]!;
Equation E_pxwmarg
# change in FOB price index of exports of m from r #
(all,C,MARG!COMM!)(all,r,REG)(all,t,ALLTIME)
    VXW(c,r,t) * pxw(c,r,t)
        = sum{d,REG, VFOB(c,r,d,t) * pfob(c,r,d,t)} 
        + !IF[c in MARG, !VST(c,r,t) * pds(c,r,t)!]!;

Variable (orig_level=1.0)(all,r,REG)(all,t,ALLTIME)
    pxwreg(r,t) # price index of merchandise exports, by region #;
Equation E_pxwreg
# computes % change in price index of exports, by region #
(all,r,REG)(all,t,ALLTIME)
    VXWREGION(r,t) * pxwreg(r,t) = sum{c,COMM, VXW(c,r,t) * pxw(c,r,t)};

Variable (orig_level=1.0)(all,c,COMM)(all,t,ALLTIME)
    pxwcom(c,t) # price index of global merchandise exports by commodity #;
Equation E_pxwcom
# computes % change in price index of exports, by commodity #
(all,c,COMM)(all,t,ALLTIME)
    VXWCOMMOD(c,t) * pxwcom(c,t) = sum{r,REG, VXW(c,r,t) * pxw(c,r,t)};

Variable (orig_level=1.0)(all,t,ALLTIME)
    pxwwld(t) # price index of world trade #;
Equation E_pxwwld
# computes % change in price index of global exports # (all,t,ALLTIME)
    VXWLD(t) * pxwwld(t) = sum{r,REG, VXWREGION(r,t) * pxwreg(r,t)};

Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    pmw(c,r,t) # world price of composite import c in region r #;
Equation E_pmw
# computes % change in CIF price index of imports of c into d #
(all,c,COMM)(all,d,REG)(all,t,ALLTIME)
    VMCIF(c,d,t) * pmw(c,d,t) = sum{s,REG, VCIF(c,s,d,t) * pcif(c,s,d,t)};

Variable (orig_level=1.0)(all,r,REG)(all,t,ALLTIME)
    pmwreg(r,t) # price index of merchandise imports, by region #;
Equation E_pmwreg
# computes % change in price index of imports, by region #
(all,r,REG)(all,t,ALLTIME)
    VMWREGION(r,t) * pmwreg(r,t) = sum{c,COMM, VMCIF(c,r,t) * pmw(c,r,t)};

Variable (orig_level=1.0)(all,c,COMM)(all,t,ALLTIME)
    pmwcom(c,t) # price index of global merchandise imports by commodity #;
Equation E_pmwcom
# computes % change in price index of imports, by commodity #
(all,c,COMM)(all,t,ALLTIME)
    VMWCOMMOD(c,t) * pmwcom(c,t) = sum{r,REG, VMCIF(c,r,t) * pmw(c,r,t)};

Variable (all,c,COMM)(all,t,ALLTIME)
    pw(c,t) # world price index for total good c supplies #;
Equation E_pw
# change in index of world prices, FOB, for total production of c #
(all,c,COMM)(all,t,ALLTIME)
    VWOW(c,t) * pw(c,t) = sum{r,REG, VOW(c,r,t) * pxw(c,r,t)};

Variable (orig_level=1.0)(all,c,COMM)(all,t,ALLTIME)
    pwu(c,t) # world price index for total good c supplies at user prices #;
Equation E_pwu
# change in index of user prices for deflating world production of c #
(all,c,COMM)(all,t,ALLTIME)
    VWOU(c,t) * pwu(c,t)
        = sum{r,REG, VPP(c,r,t) * ppa(c,r,t)
        + VGP(c,r,t) * pga(c,r,t)
        + VIP(c,r,t) * pinv(r,t)
        + sum{a,ACTS, VFP(c,a,r,t) * pfa(c,a,r,t)}};

!<
    Quantity indices for aggregate trade
    ....................................
>!

Variable (orig_level=VXW)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qxw(c,r,t) # aggregate exports of c from region r, FOB weights #;
!change to avoid complicated if()!
Equation E_qxwnmrg
# change in volume of exports of (margin and non-margin) commodity c from r #
(all,c,NMRG!COMM!)(all,r,REG)(all,t,ALLTIME)
    VXW(c,r,t) * qxw(c,r,t)
        = sum{d,REG, VFOB(c,r,d,t) * qxs(c,r,d,t)} 
        !+ IF[c in MARG, VST(c,r,t) * qst(c,r,t)]!;
Equation E_qxwmarg
# change in volume of exports of (margin and non-margin) commodity c from r #
(all,c,MARG!COMM!)(all,r,REG)(all,t,ALLTIME)
    VXW(c,r,t) * qxw(c,r,t)
        = sum{d,REG, VFOB(c,r,d,t) * qxs(c,r,d,t)} 
        + !IF[c in MARG, !VST(c,r,t) * qst(c,r,t)!]!;
!<
    modified from HT 89 for use with AnalyseGE
>!

Variable (orig_level=VXWREGION)(all,r,REG)(all,t,ALLTIME)
    qxwreg(r,t) # volume of merchandise exports, by region #;
Equation E_qxwreg
# computes % change in quantity index of exports, by region #
(all,r,REG)(all,t,ALLTIME)
    VXWREGION(r,t) * qxwreg(r,t) = sum{c,COMM, VXW(c,r,t) * qxw(c,r,t)};
!<
    modified from HT 91 for use with AnalyseGE
>!

Variable (orig_level=VXWCOMMOD)(all,c,COMM)(all,t,ALLTIME)
    qxwcom(c,t) # volume of global merchandise exports by commodity #;
Equation E_qxwcom
# computes % change in quantity index of exports, by commodity #
(all,c,COMM)(all,t,ALLTIME)
    VXWCOMMOD(c,t) * qxwcom(c,t) = sum{r,REG, VXW(c,r,t) * qxw(c,r,t)};
!<
    modified from HT 93 for use with AnalyseGE
>!

Variable (orig_level=VXWLD)(all,t,ALLTIME)
    qxwwld(t) # volume of world trade #;
Equation E_qxwwld
# computes % change in quantity index of global exports # (all,t,ALLTIME)
    VXWLD(t) * qxwwld(t) = sum{r,REG, VXWREGION(r,t) * qxwreg(r,t)};
!<
    modified from HT 95 for use with AnalyseGE
>!

Variable (all,c,COMM)(all,d,REG)(all,t,ALLTIME)
    qmw(c,d,t) # aggregate imports of c into region s, CIF weights #;
Equation E_qmw
# change in volume of imports of commodity c into d #
(all,c,COMM)(all,d,REG)(all,t,ALLTIME)
    VMCIF(c,d,t) * qmw(c,d,t) = sum{s,REG, VCIF(c,s,d,t) * qxs(c,s,d,t)};
!<
    modified from HT 90 for use with AnalyseGE
>!

Variable (orig_level=VMWREGION)(all,r,REG)(all,t,ALLTIME)
    qmwreg(r,t) # volume of merchandise imports, by region #;
Equation E_qmwreg
# computes % change in quantity index of imports, by region #
(all,r,REG)(all,t,ALLTIME)
    VMWREGION(r,t) * qmwreg(r,t) = sum{c,COMM, VMCIF(c,r,t) * qmw(c,r,t)};
!<
    modified from HT 92 for use with AnalyseGE
>!

Variable (orig_level=VMWCOMMOD)(all,c,COMM)(all,t,ALLTIME)
    qmwcom(c,t) # volume of global merchandise imports by commodity #;
Equation E_qmwcom
# computes % change in quantity index of imports, by commodity #
(all,c,COMM)(all,t,ALLTIME)
    VMWCOMMOD(c,t) * qmwcom(c,t) = sum{r,REG, VMCIF(c,r,t) * qmw(c,r,t)};
!<
    modified from HT 94 for use with AnalyseGE
>!

Variable (all,c,COMM)(all,t,ALLTIME)
    qow(c,t) # quantity index for world supply of good c #;
Equation E_qow
# change in index of world production of c #
(all,c,COMM)(all,t,ALLTIME)
    VWOW(c,t) * qow(c,t) = sum{r,REG, VOW(c,r,t) * qc(c,r,t)};
!<
    modified from HT 96 for use with AnalyseGE
>!

Variable (orig_level=VWOU)(all,c,COMM)(all,t,ALLTIME)
    qowu(c,t) # quantity index for world supply of good c at user prices #;
Equation E_qowu
# change in index of world production of c evaluated at user prices #
(all,c,COMM)(all,t,ALLTIME)
    VWOU(c,t) * qowu(c,t)
        = sum{r,REG, VPP(c,r,t) * qpa(c,r,t)
        + VGP(c,r,t) * qga(c,r,t)
        + VIP(c,r,t) * qia(c,r,t)
        + sum{a,ACTS, VFP(c,a,r,t) * qfa(c,a,r,t)}};

!<
    B-5. Trade balance indices
    --------------------------
>!

Variable (change)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    del_tbalc(c,r,t) # change in trade balance by c and by r, $ US million #;
!<
    A positive value indicates that the change in exports exceeds the change
    in imports.
>!
Equation E_del_tbalc
# computes change in trade balance by commodity and by region #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    del_tbalc(c,r,t)
        = [VXW(c,r,t) / 100] * vxwfob(c,r,t) - [VMCIF(c,r,t) / 100] * vmwcif(c,r,t);

Variable (change)(all,r,REG)(all,t,ALLTIME)
    del_tbal(r,t) # change in trade balance X - M, $ US million #;
Equation E_del_tbal
# computes change in trade balance (X - M), by region #
(all,r,REG)(all,t,ALLTIME)
    del_tbal(r,t)
        = [VXWREGION(r,t) / 100] * vxwreg(r,t) - [VMWREGION(r,t) / 100] * vmwreg(r,t);

!<
    In order to maintain homogeneity in the presence of a fixed trade balance,
    it is useful to have a nominal variable which this is measured against.
    The next equation provides this, and we recommend users fix del_tbalry 
    instead of fixing del_tbal in future simulations.  The strategy is the same 
    one used above for taxes.
>!

Variable (all,t,ALLTIME)
    ywld(t) # world income #;     
Coefficient (all,t,ALLTIME) 
    INCOMEWLD(t) # World income #;
Formula (all,t,ALLTIME)
    INCOMEWLD(t) = sum{r,REG, INCOME(r,t)};

Equation E_ywld 
# world income # (all,t,ALLTIME)
    INCOMEWLD(t) * ywld(t) = sum{r,REG, INCOME(r,t) * y(r,t)};

Variable (change)(all,r,REG)(all,t,ALLTIME)
    del_tbalry(r,t) # change in trade bal. of r as a percentage of world income #;
Coefficient (all,r,REG)(all,t,ALLTIME)
    TBAL(r,t) # trade balance for region r #;
Formula (all,r,REG)(all,t,ALLTIME)
    TBAL(r,t) = VXWREGION(r,t) - VMWREGION(r,t);

Equation E_del_tbalry
# change in trade balance of region r as a percentage of world income #
(all,r,REG)(all,t,ALLTIME)
    INCOMEWLD(t) * 100 * del_tbalry(r,t)
        = VXWREGION(r,t) * vxwreg(r,t) - VMWREGION(r,t) * vmwreg(r,t)
        - TBAL(r,t) * ywld(t);

!<
    B-6. Terms of trade (ToT) decomposition
    ---------------------------------------
    Computations for decomposition of the terms-of-trade effect
    Reference: Robert McDougall, SALTER No. 12 Working Paper
>!

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    SX_CR(c,r,t) # share of good c in total exports from r #;
Formula (all,m,MARG)(all,r,REG)(all,t,ALLTIME)
    SX_CR(m,r,t)
        = [sum{d,REG, VFOB(m,r,d,t)} + VST(m,r,t)]
        / [sum{c,COMM, sum{d,REG, VFOB(c,r,d,t)}}
            + sum{k,MARG, VST(k,r,t)}];
Formula (all,n,NMRG)(all,r,REG)(all,t,ALLTIME)
    SX_CR(n,r,t)
        = sum{d,REG, VFOB(n,r,d,t)}
        / [sum{c,COMM, sum{d,REG, VFOB(c,r,d,t)}}
            + sum{m,MARG, VST(m,r,t)}];

Coefficient (all,m,MARG)(all,d,REG)(all,t,ALLTIME)
    VTMCOMM(m,d,t) # margin usage of m in getting imports to dest. region d #;
Formula (all,m,MARG)(all,d,REG)(all,t,ALLTIME)
    VTMCOMM(m,d,t) = sum{c,COMM, sum{s,REG, VTMFSD(m,c,s,d,t)}};

Coefficient (all,c,COMM)(all,d,REG)(all,t,ALLTIME)
    VMWDCRALL(c,d,t) # imports of c into d, with direct allocation of margins #;
!change to avoid complicated if()!
Formula (all,c,NMRG!COMM!)(all,s,REG)(all,t,ALLTIME)
    VMWDCRALL(c,s,t) = sum{r,REG, VFOB(c,r,s,t)}! + IF[c in MARG, VTMCOMM(c,s)]!;
Formula (all,c,MARG!COMM!)(all,s,REG)(all,t,ALLTIME)
    VMWDCRALL(c,s,t) = sum{r,REG, VFOB(c,r,s,t)} + !IF[c in MARG, !VTMCOMM(c,s,t)!]!;

Coefficient (all,r,REG)(all,t,ALLTIME)
    VMWDATOT(r,t) # total imports into r, calculated on direct allocation basis #;
Formula (all,r,REG)(all,t,ALLTIME)
    VMWDATOT(r,t) = sum{c,COMM, VMWDCRALL(c,r,t)};

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    SM_CR(c,r,t)  # share of good c in total imports into r #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    SM_CR(c,r,t) = VMWDCRALL(c,r,t) / VMWDATOT(r,t);

Coefficient (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    SM_CRS(c,s,d,t) # share of imports of good c into d from s at FOB prices #;
Formula (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    SM_CRS(c,s,d,t) = VFOB(c,s,d,t) / VMWDCRALL(c,d,t);

Coefficient (all,m,MARG)(all,d,REG)(all,t,ALLTIME)
    SMT_CR(m,d,t) # share of transport cost in imports of margin m in region d #;
Formula (all,m,MARG)(all,d,REG)(all,t,ALLTIME)
    SMT_CR(m,d,t) = VTMCOMM(m,d,t) / VMWDCRALL(m,d,t);

Variable (all,c,COMM)(all,d,REG)(all,t,ALLTIME)
    pm_cr(c,d,t) # imports price index for good c and importing region d #;
!change to avoid complicated if()!
Equation E_pm_crnmrg
# price index for total imports of m in s -- margins commodities #
(all,c,NMRG!COMM!)(all,s,REG)(all,t,ALLTIME)
    pm_cr(c,s,t)
        = sum{r,REG, SM_CRS(c,r,s,t) * pfob(c,r,s,t)} 
        !+ IF[c in MARG, SMT_CR(c,s) * pt(c)]!;
Equation E_pm_crmarg
# price index for total imports of m in s -- margins commodities #
(all,c,MARG!COMM!)(all,s,REG)(all,t,ALLTIME)
    pm_cr(c,s,t)
        = sum{r,REG, SM_CRS(c,r,s,t) * pfob(c,r,s,t)} 
        + !IF[c in MARG, !SMT_CR(c,s,t) * pt(c,t)!]!;

Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    c1_cr(c,r,t) # contribution of world price, px_c, to ToT #;
Equation E_c1_cr
# contribution of world export price index of good c to ToT for region r #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    c1_cr(c,r,t) = [SX_CR(c,r,t) - SM_CR(c,r,t)] * [pxwcom(c,t) - pxwwld(t)];

Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    c2_cr(c,r,t) # contribution of regional export price, px_cr, to ToT #;
Equation E_c2_cr
# contribution of regional export price of good c for region r #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    c2_cr(c,r,t) = SX_CR(c,r,t) * [pxw(c,r,t) - pxwcom(c,t)];

Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    c3_cr(c,r,t) # contribution of regional import price, pm_cr, to ToT #;
Equation E_c3_cr
# contribution of imports price index of good c for region r #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    c3_cr(c,r,t) = SM_CR(c,r,t) * [pm_cr(c,r,t) - pxwcom(c,t)];

Variable (all,r,REG)(all,t,ALLTIME)
    c1_r(r,t) # contribution of world prices for all goods to ToT #;
Equation E_c1_r
# contribution of world price indexes of all goods to ToT for r #
(all,r,REG)(all,t,ALLTIME)
    c1_r(r,t) = sum{c,COMM, c1_cr(c,r,t)};

Variable (all,r,REG)(all,t,ALLTIME)
    c2_r(r,t) # contribution of regional export prices to ToT #;
Equation E_c2_r
# contribution of regional exports prices to ToT for r #
(all,r,REG)(all,t,ALLTIME)
    c2_r(r,t) = sum{c,COMM, c2_cr(c,r,t)};

Variable (all,r,REG)(all,t,ALLTIME)
    c3_r(r,t) # contribution of regional import prices to ToT #;
Equation E_c3_r
# contribution of regional import prices to ToT for r #
(all,r,REG)(all,t,ALLTIME)
    c3_r(r,t) = sum{c,COMM, c3_cr(c,r,t)};

Variable (all,r,REG)(all,t,ALLTIME)
    tot2(r,t) # trade terms for region r, computed from components #;
Equation E_tot2
# trade terms for region r, computed from components #
(all,r,REG)(all,t,ALLTIME)
    tot2(r,t) = c1_r(r,t) + c2_r(r,t) - c3_r(r,t);

!<
    --------------------------------------------
    11. Measurement and decomposition of welfare
    --------------------------------------------

    11-0. Variables and coefficients
    11-1. Government consumption shadow demand system
    11-2. Private consumption shadow demand dystem
    11-3. Regional Household shadow demand system
    11-4. Equivalent Variation
    11-5. Decomposition of welfare [Section 3.11 in JGEA paper]

    This section calculates equivalent variation "EV" and world equivalent
    variation, "WEV", by determining the income "yev" that would be required
    to achieve the current actual utility level "u" in a shadow demand system
    in which prices are fixed.

    Section 11-2 calculates the utility elasticity of private consumption
    expenditure, "ueprivev", within a shadow demand system for private
    consumption, for use in section 11-3. Section 11-3 calculates private 
    consumption expenditure "ypev" for use in 11-2, and regional income "yev" 
    for use in 11-4, within a shadow demand system for the regional household.  
    Section 11-4 calculates "EV" and "WEV". 

    Section 11-5 provides a decomposition of welfare changes in the model as
    explained in the GTAP model (JGEA) paper. 
>!

!<
    11-0. Variables and coefficients
    --------------------------------
    only used in this Equivalent Variation section of the summary indices
    appendix
>!

Variable (all,r,REG)(all,t,ALLTIME)
    uelasev(r,t) # elasticity of cost of utility wrt utility, for EV calc. #;
Variable (all,r,REG)(all,t,ALLTIME)
    ueprivev(r,t) # utility elast. of private consn expenditure, for EV calc. #;
Variable (all,r,REG)(all,t,ALLTIME)
    ugev(r,t) # per capita utility from gov't expend., for EV calc. #;
Variable (all,r,REG)(all,t,ALLTIME)
    upev(r,t) # per capita utility from private expend., for EV calc. #;
Variable (all,r,REG)(all,t,ALLTIME)
    qsaveev(r,t) # total quantity of saving demanded, for EV calc. #;
Variable (all,r,REG)(all,t,ALLTIME)
    yev(r,t) # regional household income in region r, for EV calc. #;
Variable (all,r,REG)(all,t,ALLTIME)
    ypev(r,t) # private consumption expenditure in region r, for EV calc. #;
Variable (all,r,REG)(all,t,ALLTIME)
    ygev(r,t) # government consumption expenditure in region r, for EV calc. #;

Coefficient (all,r,REG)(all,t,ALLTIME)
    INCOMEEV(r,t) # regional income, for EV calc. #;
Formula (initial) (all,r,REG)(all,t,ALLTIME)
    INCOMEEV(r,t) = INCOME(r,t);
Update (all,r,REG)(all,t,ALLTIME)
    INCOMEEV(r,t) = yev(r,t);

Coefficient (all,r,REG)(all,t,ALLTIME)
    UTILPRIVEV(r,t) # utility from private consumption, for EV calcs #;
Formula (initial) (all,r,REG)(all,t,ALLTIME)
    UTILPRIVEV(r,t) = UTILPRIV(r,t);
Update (all,r,REG)(all,t,ALLTIME)
    UTILPRIVEV(r,t) = upev(r,t);

Coefficient (all,r,REG)(all,t,ALLTIME)
    UTILGOVEV(r,t) # utility from private consumption, for EV calcs #;
Formula (initial) (all,r,REG)(all,t,ALLTIME)
    UTILGOVEV(r,t) = UTILGOV(r,t);
Update (all,r,REG)(all,t,ALLTIME)
    UTILGOVEV(r,t) = ugev(r,t);

Coefficient (all,r,REG)(all,t,ALLTIME)
    UTILSAVEEV(r,t) # utility from private consumption, for EV calcs #;
Formula (initial) (all,r,REG)(all,t,ALLTIME)
    UTILSAVEEV(r,t) = UTILSAVE(r,t);
Update (change) (all,r,REG)(all,t,ALLTIME)
    UTILSAVEEV(r,t) = [[qsaveev(r,t) - pop(r,t)] / 100] * UTILSAVEEV(r,t);

!<
    11-1. Government consumption shadow demand system
    -------------------------------------------------
>!

Equation E_ugev
# utility from government consumption in r #
(all,r,REG)(all,t,ALLTIME)
    ygev(r,t) - pop(r,t) = ugev(r,t);

!<
    11-2. Private consumption shadow demand system
    ----------------------------------------------
>!

Variable (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qpev(c,r,t)
    # private hhld demand for commodity c in region r, for EV calc. #;

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VPPEV(c,r,t)
    # private hhld expend. on c in r valued at purch. prices, for EV calc. #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VPPEV(c,r,t) = VPP(c,r,t);
Update (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VPPEV(c,r,t) = qpev(c,r,t);

Coefficient (all,r,REG)(all,t,ALLTIME)
    VPPREGEV(r,t) # private consumption expenditure in region r, for EV calc. #;
Formula (all,r,REG)(all,t,ALLTIME)
    VPPREGEV(r,t) = sum{c,COMM, VPPEV(c,r,t)};
!<
    VPPREGEV should agree with PRIVEXPEV.
>!

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CONSHREV(c,r,t)
    # share of private hhld consn devoted to good c in r, for EV calc. #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CONSHREV(c,r,t) = VPPEV(c,r,t) / VPPREGEV(r,t);
Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    EYEV(c,r,t)
    # expend. elast. of private hhld demand for c in r, for EV calc. #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    EYEV(c,r,t)
        = [1.0 / sum{n,COMM, CONSHREV(n,r,t) * INCPAR(n,r,t)}]
        * [INCPAR(c,r,t) * [1.0 - ALPHA(c,r,t)]
            + sum{n,COMM, CONSHREV(n,r,t) * INCPAR(n,r,t) * ALPHA(n,r,t)}]
        + ALPHA(c,r,t)
        - sum{n,COMM, CONSHREV(n,r,t) * ALPHA(n,r,t)};

Equation E_qpev
    # private hhld demands for composite commodities, for EV calc. #
    (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    qpev(c,r,t) - pop(r,t) = EYEV(c,r,t) * [ypev(r,t) - pop(r,t)];
!<
    Prices are held constant for the EV calculation and so do not appear here.
>!

Coefficient (all,r,REG)(all,t,ALLTIME)
    UELASPRIVEV(r,t)
    # elast. of cost wrt utility from private consn, for EV calc. #;
Formula (all,r,REG)(all,t,ALLTIME)
    UELASPRIVEV(r,t) = sum{c,COMM, CONSHREV(c,r,t) * INCPAR(c,r,t)};

Equation E_upev
# computation of utility from private consumption in r #
(all,r,REG)(all,t,ALLTIME)
    ypev(r,t) - pop(r,t) = UELASPRIVEV(r,t) * upev(r,t);

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    XWCONSHREV(c,r,t)
    # expansion-parameter-weighted consumption share, for EV calc. #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    XWCONSHREV(c,r,t) = CONSHREV(c,r,t) * INCPAR(c,r,t) / UELASPRIVEV(r,t);

Equation E_ueprivev
    # elasticity of cost wrt utility from private consn, for EV calc. #
    (all,r,REG)(all,t,ALLTIME)
    ueprivev(r,t)
        = sum{c,COMM, XWCONSHREV(c,r,t) * [qpev(c,r,t) - ypev(r,t)]};
!<
    Prices are held constant for the EV calculation and so do not appear here.
>!

!<

    11-3. Regional Household shadow demand system
    ---------------------------------------------
>!

Variable (all,r,REG)(all,t,ALLTIME)
    ysaveev(r,t) # NET saving expenditure, for EV calc. #;

Coefficient (all,r,REG)(all,t,ALLTIME)
    PRIVEXPEV(r,t)
    # private consumption expenditure in region r, for EV calc. #;
Formula (initial) (all,r,REG)(all,t,ALLTIME)
    PRIVEXPEV(r,t) = PRIVEXP(r,t);
Update (all,r,REG)(all,t,ALLTIME)
    PRIVEXPEV(r,t) = ypev(r,t);
!<
    PRIVEXPEV should agree with VPPREGEV.
>!

Coefficient (all,r,REG)(all,t,ALLTIME)
    GOVEXPEV(r,t)
    # government consumption expenditure in region r, for EV calc. #;
Formula (initial) (all,r,REG)(all,t,ALLTIME)
    GOVEXPEV(r,t) = GOVEXP(r,t);
Update (all,r,REG)(all,t,ALLTIME)
    GOVEXPEV(r,t) = ygev(r,t);

Coefficient (all,r,REG)(all,t,ALLTIME)
    SAVEEV(r,t)
    # saving in region r, for EV calc. #;
Formula (initial) (all,r,REG)(all,t,ALLTIME)
    SAVEEV(r,t) = SAVE(r,t);
Update (all,r,REG)(all,t,ALLTIME)
    SAVEEV(r,t) = ysaveev(r,t);

Coefficient (all,r,REG)(all,t,ALLTIME)
    XSHRPRIVEV(r,t)
    # private expenditure share in regional income, for EV calc. #;
Formula (all,r,REG)(all,t,ALLTIME)
    XSHRPRIVEV(r,t) = PRIVEXPEV(r,t) / INCOMEEV(r,t);

Coefficient (all,r,REG)(all,t,ALLTIME)
    XSHRGOVEV(r,t)
    # government expenditure share in regional income, for EV calc. #;
Formula (all,r,REG)(all,t,ALLTIME)
    XSHRGOVEV(r,t) = GOVEXPEV(r,t) / INCOMEEV(r,t);

Coefficient (all,r,REG)(all,t,ALLTIME)
    XSHRSAVEEV(r,t) # saving share in regional income, for EV calc. #;
Formula (all,r,REG)(all,t,ALLTIME)
    XSHRSAVEEV(r,t) = SAVEEV(r,t) / INCOMEEV(r,t);

Variable (all,r,REG)(all,t,ALLTIME)
    dpavev(r,t) # average distribution parameter shift, for EV calc. #;
Equation E_dpavev
# average distribution parameter shift, for EV calc. #
    (all,r,REG)(all,t,ALLTIME)
    dpavev(r,t)
        = XSHRPRIVEV(r,t) * dppriv(r,t)
        + XSHRGOVEV(r,t) * dpgov(r,t)
        + XSHRSAVEEV(r,t) * dpsave(r,t);

Equation E_uelasev
    # elasticity of cost of utility wrt utility, for EV calc. #
    (all,r,REG)(all,t,ALLTIME)
    uelasev(r,t) = XSHRPRIV(r,t) * ueprivev(r,t) - dpavev(r,t);

Equation E_ypev
# private consumption expenditure, for EV calc. #
    (all,r,REG)(all,t,ALLTIME)
    ypev(r,t) - yev(r,t) = -[ueprivev(r,t) - uelasev(r,t)] + dppriv(r,t);

Equation E_ygev
# government consumption expenditure #
(all,r,REG)(all,t,ALLTIME)
    ygev(r,t) - yev(r,t) = uelasev(r,t) + dpgov(r,t);

Equation E_ysaveev
# saving #
(all,r,REG)(all,t,ALLTIME)
    ysaveev(r,t) - yev(r,t) = uelasev(r,t) + dpsave(r,t);

Equation E_qsaveev
# saving #
(all,r,REG)(all,t,ALLTIME)
    qsaveev(r,t) = ysaveev(r,t);
!<
    Note that because psave doesn't change, qsaveev moves with ysaveev.
>!

Coefficient (all,r,REG)(all,t,ALLTIME)
    UTILELASEV(r,t)
    # elasticity of cost of utility wrt utility, for EV calc. #;
Formula (initial) (all,r,REG)(all,t,ALLTIME)
    UTILELASEV(r,t) = UTILELAS(r,t);
Update (all,r,REG)(all,t,ALLTIME)
    UTILELASEV(r,t) = uelasev(r,t);

Equation E_yev
# equivalent income #
(all,r,REG)(all,t,ALLTIME)
    u(r,t)
        = au(r,t)
        + DPARPRIV(r,t) * loge(UTILPRIVEV(r,t)) * dppriv(r,t)
        + DPARGOV(r,t) * loge(UTILGOVEV(r,t)) * dpgov(r,t)
        + DPARSAVE(r,t) * loge(UTILSAVEEV(r,t)) * dpsave(r,t)
        + [1.0 / UTILELASEV(r,t)] * [yev(r,t) - pop(r,t)];

!<
    11-4. Equivalent Variation
    --------------------------
>!

Variable (change)(all,r,REG)(all,t,ALLTIME)
    EV(r,t) # equivalent variation, $ US million #;
Equation E_EV
# regional EV #
(all,r,REG)(all,t,ALLTIME)
    EV(r,t) = [INCOMEEV(r,t) / 100] * yev(r,t);

Variable (change)(all,t,ALLTIME)
    WEV(t) # equivalent variation for the world #;
Equation E_WEV
# EV for the world # (all,t,ALLTIME)
    WEV(t) = sum{r,REG, EV(r,t)};

!<
    11-5. Welfare decomposition
    ---------------------------
    See GTAP Technical Paper No. 5 for derivation and interpretation. 
    See also "The Standard GTAP Model (Version 7)" paper.   
>!

!<
    Declare new sets for Welfare decomposition and for use in DECOMP.TAB.  
    Supplementary sets for "toggles" in VIEWHAR.
>!
Set
    DIR(domestic,imported);
Set
    ALLTAX(prodtax,pfacttax,inctax,inputtax,contax,invtax,govtax,xtax,mtax);
Set                             
    TECHTYPE(output,primfac,v_added,ininput,invest,transp,import);
Set
    COLUMN(alloc_A1,ENDWB1,tech_C1,pop_D1,tot_E1,IS_F1,pref_G1);

Coefficient (all,r,REG)(all,t,ALLTIME)
    EVSCALFACT(r,t) # equivalent variation scaling factor #;
Formula (all,r,REG)(all,t,ALLTIME)
    EVSCALFACT(r,t) = [UTILELASEV(r,t) / UTILELAS(r,t)] * [INCOMEEV(r,t) / INCOME(r,t)];

Coefficient (all,m,MARG)(all,d,REG)(all,t,ALLTIME)
    VTMD(m,d,t) # aggregate value of svce m in shipments to destination d #;
Formula (all,m,MARG)(all,d,REG)(all,t,ALLTIME)
    VTMD(m,d,t) = sum{c,COMM, sum{s,REG, VTMFSD(m,c,s,d,t)}};

Variable (linear,change)(all,r,REG)(all,t,ALLTIME)
    EV_ALT(r,t) # regional EV computed in alternative way #;
Equation E_EV_ALT
# decomposition of Equivalent Variation #
(all,r,REG)(all,t,ALLTIME)
    EV_ALT(r,t)
        !< Preference shifts >!
        = -[0.01 * UTILELASEV(r,t) * INCOMEEV(r,t)]
        * [DPARPRIV(r,t) * loge(UTILPRIVEV(r,t) / UTILPRIV(r,t)) * dppriv(r,t)
            + DPARGOV(r,t) * loge(UTILGOVEV(r,t) / UTILGOV(r,t)) * dpgov(r,t)
            + DPARSAVE(r,t) * loge(UTILSAVEEV(r,t) / UTILSAVE(r,t)) * dpsave(r,t)]
        !< Scaling factor >!
        + [0.01 * EVSCALFACT(r,t)]
        !< Changes in allocative efficiency >!
        * [sum{c,COMM, sum{a,ACTS, PTAX(c,a,r,t) * [qca(c,a,r,t) - pop(r,t)]}}
            + sum{e,ENDW, sum{a,ACTS, 
                INCTAX(e,a,r,t) * [qes(e,a,r,t) - pop(r,t)]}}
            + sum{e,ENDW, sum{a,ACTS,
                ETAX(e,a,r,t) * [qfe(e,a,r,t) - pop(r,t)]}}
            + sum{c,COMM, sum{a,ACTS, MFTAX(c,a,r,t) * [qfm(c,a,r,t) - pop(r,t)]}}
            + sum{c,COMM, sum{a,ACTS, DFTAX(c,a,r,t) * [qfd(c,a,r,t) - pop(r,t)]}}
            + sum{c,COMM, MPTAX(c,r,t) * [qpm(c,r,t) - pop(r,t)]}
            + sum{c,COMM, DPTAX(c,r,t) * [qpd(c,r,t) - pop(r,t)]}
            + sum{c,COMM, MGTAX(c,r,t) * [qgm(c,r,t) - pop(r,t)]}
            + sum{c,COMM, DGTAX(c,r,t) * [qgd(c,r,t) - pop(r,t)]}
            + sum{c,COMM, MITAX(c,r,t) * [qim(c,r,t) - pop(r,t)]}
            + sum{c,COMM, DITAX(c,r,t) * [qid(c,r,t) - pop(r,t)]}
            + sum{c,COMM, sum{d,REG, XTAXD(c,r,d,t) * [qxs(c,r,d,t) - pop(r,t)]}}
            + sum{c,COMM, sum{s,REG, MTAX(c,s,r,t) * [qxs(c,s,r,t) - pop(r,t)]}}
        !< Changes in endowments >!
        + sum{e,ENDW, sum{a,ACTS, EVOS(e,a,r,t) * [qes(e,a,r,t) - pop(r,t)]}}
            !< Depreciation >!
        - VDEP(r,t) * [kb(r,t) - pop(r,t)]
        !< Changes in technology >!
        + sum{a,ACTS, VOS(a,r,t) * ao(a,r,t)}
            + sum{a,ACTS, VVA(a,r,t) * ava(a,r,t)}
            + sum{c,COMM, sum{a,ACTS, VFP(c,a,r,t) * aint(a,r,t)}}
            + sum{a,ACTS, sum{e,ENDW, VFP(e,a,r,t) * afe(e,a,r,t)}}
            + sum{a,ACTS, sum{c,COMM, VFP(c,a,r,t) * afa(c,a,r,t)}}
            + sum{m,MARG, sum{c,COMM, sum{s,REG,
                VTMFSD(m,c,s,r,t) * atmfsd(m,c,s,r,t)}}}
            + sum{c,COMM, sum{s,REG, VMSB(c,s,r,t) * ams(c,s,r,t)}}
        !< Changes in terms of trade >!
        + sum{c,COMM, sum{d,REG, VFOB(c,r,d,t) * pfob(c,r,d,t)}}
            + sum{m,MARG, VST(m,r,t) * pds(m,r,t)}
            + NETINV(r,t) * pinv(r,t)
            - sum{c,COMM, sum{s,REG, VFOB(c,s,r,t) * pfob(c,s,r,t)}}
            - sum{m,MARG, VTMD(m,r,t) * pt(m,t)}
            - SAVE(r,t) * psave(r,t)]
        !< Changes in population >!
        + 0.01 * INCOMEEV(r,t) * pop(r,t);

Variable (linear,change)(all,t,ALLTIME)
    WEV_ALT(t) # expression for WEV computed in alternative way #;
Equation E_WEV_ALT
# Equivalent Variation for the world # (all,t,ALLTIME)
    WEV_ALT(t) = sum{r,REG, EV_ALT(r,t)};

!<
    11-5.1 Preference shifts (EV)
    -----------------------------
>!

Variable (linear,change) (all,r,REG)(all,t,ALLTIME)
    CNTdpar(r,t) # contribution to EV of change in distribution parameters #;
Equation E_CNTdpar
# contribution to EV of change in distribution parameters #
(all,r,REG)(all,t,ALLTIME)
    CNTdpar(r,t)
        = -0.01 * UTILELASEV(r,t) * INCOMEEV(r,t)
        * [DPARPRIV(r,t) * loge(UTILPRIVEV(r,t) / UTILPRIV(r,t)) * dppriv(r,t)
            + DPARGOV(r,t) * loge(UTILGOVEV(r,t) / UTILGOV(r,t)) * dpgov(r,t)
            + DPARSAVE(r,t) * loge(UTILSAVEEV(r,t) / UTILSAVE(r,t)) * dpsave(r,t)];

!<
    11-5.2 Allocative efficiency (EV)
    ---------------------------------
>!

!< Contribution to EV of changes in output >!
Variable (linear,change) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTqca(c,a,r,t)
    # contribution to EV of changes in output c of act. a in region r #;
Equation E_CNTqca
# contribution to EV of changes in industry output of act. a in region r #
(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTqca(c,a,r,t) = [0.01 * EVSCALFACT(r,t)] 
                    * PTAX(c,a,r,t) * [qca(c,a,r,t) - pop(r,t)];

Variable (linear,change) (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTqo(a,r,t)
    # contribution to EV of changes in industry output of act. a in region r #;
Equation E_CNTqo
# contribution to EV of changes in industry output of act. a in region r #
(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTqo(a,r,t) = [0.01 * EVSCALFACT(r,t)] 
                 * sum{c,COMM, PTAX(c,a,r,t) * [qca(c,a,r,t) - pop(r,t)]};

Variable (linear,change) (all,r,REG)(all,t,ALLTIME)
    CNTqor(r,t) # contribution to EV in region r of output changes #;
Equation E_CNTqor
# contribution to EV in region r of output changes #
(all,r,REG)(all,t,ALLTIME)
    CNTqor(r,t) = sum{a,ACTS, CNTqo(a,r,t)};

!< Contribution to EV of changes in supply of endowment >!
Variable (linear,change) (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTqea(e,a,r,t)
    # contribution to EV of changes in supply of ENDW e to act. a in reg. r #;
Equation E_CNTqea
# contribution to EV of changes in supply of ENDW e in reg. r #
(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTqea(e,a,r,t) = [0.01 * EVSCALFACT(r,t)]
                  * INCTAX(e,a,r,t) * [qes(e,a,r,t) - pop(r,t)];

Variable (linear,change) (all,e,ENDW)(all,r,REG)(all,t,ALLTIME)
    CNTqe(e,r,t)
    # contribution to EV of changes in supply of ENDW e in reg. r #;
Equation E_CNTqe
# contribution to EV of changes in supply of ENDW e in reg. r #
(all,e,ENDW)(all,r,REG)(all,t,ALLTIME)
    CNTqe(e,r,t) = sum{a,ACTS, CNTqea(e,a,r,t)};

Variable (linear,change) (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTqfe(e,a,r,t)
    # contribution to EV of changes in use of ENDW e in a in r #;
Equation E_CNTqfe
# contribution to EV of changes in use of ENDW e in a in r #
(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTqfe(e,a,r,t)
        = [0.01 * EVSCALFACT(r,t)] * ETAX(e,a,r,t) * [qfe(e,a,r,t) - pop(r,t)];

Variable (linear,change) (all,e,ENDW)(all,r,REG)(all,t,ALLTIME)
    CNTqfeer(e,r,t)
    # contribution to EV of changes in use of ENDW e in all firms in r #;
Equation E_CNTqfeer
# contribution to EV of changes in use of ENDW e in all firms in r #
(all,e,ENDW)(all,r,REG)(all,t,ALLTIME)
    CNTqfeer(e,r,t)
        = sum{a,ACTS, CNTqfe(e,a,r,t)};

Variable (linear,change) (all,r,REG)(all,t,ALLTIME)
    CNTqfer(r,t)
    # contribution to EV of changes in use of all ENDW in r #;
Equation E_CNTqfer
# contribution to EV of changes in use of all ENDW in r #
(all,r,REG)(all,t,ALLTIME)
    CNTqfer(r,t)
        = sum{e,ENDW, sum{a,ACTS, CNTqfe(e,a,r,t)}};

!< Contribution to EV of changes in commodity use by firms >!
Variable (linear,change) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTqfm(c,a,r,t)
    # cont. to EV of changes in use of imported intermediates by a in r #;
Equation E_CNTqfm
# cont. to EV of changes in use of imported intermediates in r #
(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTqfm(c,a,r,t)
        = [0.01 * EVSCALFACT(r,t)] * MFTAX(c,a,r,t) * [qfm(c,a,r,t) - pop(r,t)];

Variable (linear,change) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTqfd(c,a,r,t)
    # cont. to EV of changes in use of domestic intermediates by a in r #;
Equation E_CNTqfd
# cont. to EV of changes in use of domestic intermediates by a in r #
(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTqfd(c,a,r,t)
        = [0.01 * EVSCALFACT(r,t)] * DFTAX(c,a,r,t) * [qfd(c,a,r,t) - pop(r,t)];

Variable (linear,change) (all,r,REG)(all,d,DIR)(all,t,ALLTIME)
    CNTqfr(r,d,t)
    # cont. to EV of changes in use of dom. and imp. intermediates in r #;
!change to avoid complicated if()!
Equation E_CNTqfrdom
# cont. to EV of changes in use of dom. and imp. intermediates in r #
(all,r,REG)(all,t,ALLTIME)!(all,d,DIR)!
    CNTqfr(r,"domestic"!d!,t)
        = !IF[d="domestic",! sum{c,COMM, sum{a,ACTS, CNTqfd(c,a,r,t)}}!]!
        !+ IF[d="imported", sum{c,COMM, sum{a,ACTS, MFTAX(c,a,r,t) *  [qfm(c,a,r,t) - pop(r,t)]}}]!;
Equation E_CNTqfrimp
# cont. to EV of changes in use of dom. and imp. intermediates in r #
(all,r,REG)(all,t,ALLTIME)!(all,d,DIR)!
    CNTqfr(r,"imported"!d!,t)
        = !IF[d="domestic", sum{c,COMM, sum{a,ACTS, CNTqfd(c,a,r,t)}}]
        + IF[d="imported", ! sum{c,COMM, sum{a,ACTS, CNTqfm(c,a,r,t)}}!]!;
    
!< Contribution to EV of changes in commodity use by private households >!
Variable (linear,change) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CNTqpm(c,r,t)
    # contribution to EV of changes in consumption of imported good c in r #;
Equation E_CNTqpm
# contribution to EV of changes in consumption of imported good c in r #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CNTqpm(c,r,t) = [0.01 * EVSCALFACT(r,t)] * MPTAX(c,r,t) * [qpm(c,r,t) - pop(r,t)];

Variable (linear,change) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CNTqpd(c,r,t)
    # contribution to EV of changes in consumption of domestic good c in r #;
Equation E_CNTqpd
# contribution to EV of changes in consumption of domestic good c in r #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CNTqpd(c,r,t) = [0.01 * EVSCALFACT(r,t)] * DPTAX(c,r,t) * [qpd(c,r,t) - pop(r,t)];

Variable (linear,change) (all,r,REG)(all,d,DIR)(all,t,ALLTIME)
    CNTqpr(r,d,t)
    # cont. to EV of changes in consumption of dom. and imp. goods in r #;
!change to avoid complicated if()!
Equation E_CNTqprdom
# cont. to EV of changes in consumption of dom. and imp. goods in r #
(all,r,REG)(all,t,ALLTIME)!(all,d,DIR)!
    CNTqpr(r,"domestic"!d!,t)
        = !IF[d="domestic",! sum{c,COMM, CNTqpd(c,r,t)}!]!
        !+ IF[d="imported", sum{c,COMM, CNTqpm(c,r,t)}]!;
Equation E_CNTqprimp
# cont. to EV of changes in consumption of dom. and imp. goods in r #
(all,r,REG)(all,t,ALLTIME)!(all,d,DIR)!
    CNTqpr(r,"imported"!d!,t)
        = !IF[d="domestic", sum{c,COMM, CNTqpd(c,r,t)}]
        + IF[d="imported",! sum{c,COMM, CNTqpm(c,r,t)}!]!;

!< Contribution to EV of changes in commodity use by government >!
Variable (linear,change) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CNTqgm(c,r,t)
    # contribution to EV of changes in gov't consumption of import c in r #;
Equation E_CNTqgm
# contribution to EV of changes in gov't consumption of import c in r #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CNTqgm(c,r,t) =  [0.01 * EVSCALFACT(r,t)] * MGTAX(c,r,t) * [qgm(c,r,t) - pop(r,t)];

Variable (linear,change) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CNTqgd(c,r,t)
    # contribution to EV of changes in gov't consumption of domestic c in r #;
Equation E_CNTqgd
# contribution to EV of changes in gov't consumption of domestic c in r #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CNTqgd(c,r,t) = [0.01 * EVSCALFACT(r,t)] * DGTAX(c,r,t) * [qgd(c,r,t) - pop(r,t)];

Variable (linear,change) (all,r,REG)(all,d,DIR)(all,t,ALLTIME)
    CNTqgr(r,d,t)
    # cont. to EV of changes in gov't consumption of dom. and imp goods in r #;
Equation E_CNTqgrdom
# cont. to EV of changes in gov't consumption of dom. and imp goods in r #
(all,r,REG)(all,t,ALLTIME)!(all,d,DIR)!
    CNTqgr(r,"domestic"!d!,t)
        = sum{c,COMM, CNTqgd(c,r,t)};
Equation E_CNTqgrimp
# cont. to EV of changes in gov't consumption of dom. and imp goods in r #
(all,r,REG)(all,t,ALLTIME)!(all,d,DIR)!
    CNTqgr(r,"imported"!d!,t)
        =  sum{c,COMM, CNTqgm(c,r,t)};

!< Contribution to EV of changes in commodity use for investment >!
Variable (linear,change) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CNTqim(c,r,t)
    # contribution to EV of changes in imported investment good c in r #;
Equation E_CNTqim 
# contribution to EV of changes in imported investment good c in r #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CNTqim(c,r,t) = MITAX(c,r,t) * [0.01 * EVSCALFACT(r,t)] * [qim(c,r,t) - pop(r,t)];

Variable (linear,change) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CNTqid(c,r,t)
    # contribution. to EV of changes in domestic investment good c in r #;
Equation E_CNTqid
# contribution. to EV of changes in domestic investment good c in r #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CNTqid(c,r,t) = DITAX(c,r,t) * [0.01 * EVSCALFACT(r,t)] * [qid(c,r,t) - pop(r,t)];

Variable (linear,change) (all,r,REG)(all,d,DIR)(all,t,ALLTIME)
    CNTqia(r,d,t)
    # contribution to EV of changes in dom. and imp. investment goods in r #;
Equation E_CNTqiadom 
# contribution to EV of changes in dom. and imp. investment goods in r #
(all,r,REG)(all,t,ALLTIME)!(all,d,DIR)!
    CNTqia(r,"domestic"!d!,t)
        = sum{c,COMM, CNTqid(c,r,t)};
Equation E_CNTqiaimp 
# contribution to EV of changes in dom. and imp. investment goods in r #
(all,r,REG)(all,t,ALLTIME)!(all,d,DIR)!
    CNTqia(r,"imported"!d!,t)
        = sum{c,COMM, CNTqim(c,r,t)};

!< Contribution to EV of changes in commodity exports >!
Variable (linear,change) (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    CNTqxs(c,s,d,t)
    # contribution to EV of changes in exports of c from SRCE s to DEST d #;
Equation E_CNTqxs
# contribution to EV of changes in exports of c from SRCE s to DEST d #
(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    CNTqxs(c,s,d,t) = [0.01 * EVSCALFACT(s,t)]
                    * XTAXD(c,s,d,t) *  [qxs(c,s,d,t) - pop(s,t)];

Variable (linear,change) (all,r,REG)(all,t,ALLTIME)
    CNTqxsr(r,t)
    # cont. to EV of changes in exports of all goods from source s to all destination #;
Equation E_CNTqxsr
# cont. to EV of changes in exports of all goods from SRCE s to all destination #
(all,s,REG)(all,t,ALLTIME)
    CNTqxsr(s,t) = sum{c,COMM, sum{d,REG, CNTqxs(c,s,d,t)}};

!< Contribution to EV of changes in commodity imports >!
Variable (linear,change) (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    CNTqms(c,s,d,t)
    # contribution to EV of changes in imports of c from SRCE s to DEST d #;
Equation E_CNTqms
# contribution to EV of changes in imports of c from SRCE s to DEST d #
(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    CNTqms(c,s,d,t) = [0.01 * EVSCALFACT(d,t)] 
                    * MTAX(c,s,d,t) * [qxs(c,s,d,t) - pop(d,t)];

Variable (linear,change) (all,r,REG)(all,t,ALLTIME)
    CNTqmsr(r,t)
    # cont. to EV of changes in imports of all goods from all SRCE to DEST r #;
Equation E_CNTqmsr
# cont. to EV of changes in imports of all goods from all SRCE to DEST d #
(all,d,REG)(all,t,ALLTIME)
    CNTqmsr(d,t) = sum{c,COMM, sum{s,REG, CNTqms(c,s,d,t)}};

!<
    11-5.3 Endowments (EV)
    ----------------------
>!
Variable (linear,change) (all,r,REG)(all,t,ALLTIME)
    CNTendwr(r,t) # contribution to regional EV of changes in all ENDW #;
Equation E_CNTendwr
# contribution to regional EV of changes in all ENDW (INcludes depreciation) #
(all,r,REG)(all,t,ALLTIME)
    CNTendwr(r,t)
        = [0.01 * EVSCALFACT(r,t)]
        * [sum{e,ENDW, sum{a,ACTS, EVOS(e,a,r,t) * [qes(e,a,r,t) - pop(r,t)]}}
            - VDEP(r,t) * [kb(r,t) - pop(r,t)]];

Variable (linear,change) (all,e,ENDW)(all,r,REG)(all,t,ALLTIME)
    CNTendw(e,r,t) # contribution to regional EV of changes in ENDW e in r #;
Equation E_CNTendw
# contribution to regional EV of changes in all ENDW (EXcludes depreciation) #
(all,e,ENDW)(all,r,REG)(all,t,ALLTIME)
    CNTendw(e,r,t) = [0.01 * EVSCALFACT(r,t)] * 
                   sum{a,ACTS, [EVOS(e,a,r,t) * [qes(e,a,r,t) - pop(r,t)]]};

!<
    11-5.4 Technology (EV)
    ----------------------
>!

Variable (linear,change) (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTtech_ao(a,r,t)
    # cont. to regional EV of output augmenting tech change in a #;
Equation E_CNTtech_ao
# cont. to regional EV of output augmenting tech change in a #
(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTtech_ao(a,r,t) = [0.01 * EVSCALFACT(r,t)] * VOS(a,r,t) * ao(a,r,t);

Variable (linear,change) (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTtech_afe(e,a,r,t)
    # cont. to EV of primary factor e augmenting tech change in a #;
Equation E_CNTtech_afe
# cont. to EV of primary factor e augmenting tech change in a #
(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTtech_afe(e,a,r,t) = [0.01 * EVSCALFACT(r,t)] * VFP(e,a,r,t) * afe(e,a,r,t);

Variable (linear,change) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTtech_af(c,a,r,t)
    # cont. to EV of composite c input augmenting tech change in act. a #;
Equation E_CNTtech_af
# cont. to EV of composite c input augmenting tech change in act. a #
(all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTtech_af(c,a,r,t)
        = [0.01 * EVSCALFACT(r,t)] * [VMFP(c,a,r,t) + VDFP(c,a,r,t)] * afa(c,a,r,t);

Variable (linear,change) (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTtech_aint(a,r,t)
    # cont. to EV of composite c input augmenting tech change in act. a #;
Equation E_CNTtech_aint
# cont. to EV of composite c input augmenting tech change in act. a #
(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTtech_aint(a,r,t)
        = [0.01 * EVSCALFACT(r,t)]
        * sum{c,COMM, [VMFP(c,a,r,t) + VDFP(c,a,r,t)] * aint(a,r,t)};

Variable (linear,change) (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTtech_ava(a,r,t)
    # cont. to EV of value added augmenting tech change in act. a #;
Equation E_CNTtech_ava
# cont. to EV of value added augmenting tech change in act. a #
(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    CNTtech_ava(a,r,t) = [0.01 * EVSCALFACT(r,t)] * VVA(a,r,t) * ava(a,r,t);

Variable (linear,change)(all,m,MARG)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    CNTtech_atmfsd(m,c,s,d,t)
    # cont. to EV of tech change in transportation efficiency #;
Equation E_CNTtech_atmfsd
# cont. to EV of tech change in transportation efficiency #
(all,m,MARG)(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    CNTtech_atmfsd(m,c,s,d,t)
        = [0.01 * EVSCALFACT(d,t)] * VTMFSD(m,c,s,d,t) * atmfsd(m,c,s,d,t);

Variable (linear,change) (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    CNTtech_ams(c,s,d,t)
    # cont. to EV of bilateral import augmenting tech change for COMM c #;
Equation E_CNTtech_ams
# cont. to EV of bilateral import augmenting tech change for COMM c #
(all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    CNTtech_ams(c,s,d,t) = [0.01 * EVSCALFACT(s,t)] * VMSB(c,s,d,t) * ams(c,s,d,t);

!<
    11-5.5 Terms of Trade (EV)
    --------------------------
>!
Variable (linear,change) (all,r,REG)(all,t,ALLTIME)
    CNTtotr(r,t)
    # contribution to regional EV of changes in its terms of trade #;
Equation E_CNTtotr
# contribution to regional EV of changes in its terms of trade #
(all,r,REG)(all,t,ALLTIME)
    CNTtotr(r,t)
        = [0.01 * EVSCALFACT(r,t)]
        * [sum{c,COMM, sum{d,REG, VFOB(c,r,d,t) * [pfob(c,r,d,t) - pxwwld(t)]}}
            + sum{m,MARG, VST(m,r,t) * [pds(m,r,t) - pxwwld(t)]}
            - sum{c,COMM, sum{s,REG, VFOB(c,s,r,t) * [pfob(c,s,r,t) - pxwwld(t)]}}
            - sum{m,MARG, VTMD(m,r,t) * [pt(m,t) - pxwwld(t)]}];

Variable (linear,change) (all,r,REG)(all,t,ALLTIME)
    CNTpinv(r,t) # contribution to regional EV of changes in investment price #;
Equation E_CNTpinv
# contribution to regional EV of changes in investment price index #
(all,r,REG)(all,t,ALLTIME)
    CNTpinv(r,t)
        = [0.01 * EVSCALFACT(r,t)]
        * [NETINV(r,t) * [pinv(r,t) - pxwwld(t)] - SAVE(r,t) * [psave(r,t) - pxwwld(t)]];

!<
    11-5.6 Population (EV)
    ----------------------
>!
Variable (linear,change) (all,r,REG)(all,t,ALLTIME)
    CNTpop(r,t) # contribution to EV in region r of change in population #;
Equation E_CNTpop
# contribution to EV in region r of change in population #
(all,r,REG)(all,t,ALLTIME)
    CNTpop(r,t) = 0.01 * INCOMEEV(r,t) * pop(r,t);

!<
    11-5.7 Summary of contributions (EV) 
    ------------------------------------
>!

!< Allocative efficiency contributions >!
Variable (linear,change) (all,r,REG)(all,x,ALLTAX)(all,t,ALLTIME)
    CNTalleffr(r,x,t) # total contribution to regional EV of allocative effects #;
!Equation E_CNTalleffr
# total contribution to regional EV of allocative effects #
(all,r,REG)(all,t,ALLTIME)(all,t,ALLTAX)
    CNTalleffr(r,t)
        = IF[t="prodtax",  sum{c,COMM, sum{a,ACTS, CNTqca(c,a,r,t)}} ] 
        + IF[t="inctax",   sum{e,ENDW, sum{a,ACTS, CNTqea(e,a,r,t)}} ] 
        + IF[t="pfacttax", sum{e,ENDW, sum{a,ACTS, CNTqfe(e,a,r,t)}} ]
        + IF[t="inputtax", sum{c,COMM, sum{a,ACTS, CNTqfd(c,a,r,t)
                                                 + CNTqfm(c,a,r,t)}} ]
        + IF[t="contax",   sum{c,COMM, CNTqpd(c,r,t) + CNTqpm(c,r,t)}  ]
        + IF[t="govtax",   sum{c,COMM, CNTqgd(c,r,t) + CNTqgm(c,r,t)}  ]
        + IF[t="invtax",   sum{c,COMM, CNTqid(c,r,t) + CNTqim(c,r,t)}  ]
        + IF[t="xtax",     sum{c,COMM, sum{d,REG,  CNTqxs(c,r,d)}} ]
        + IF[t="mtax",     sum{c,COMM, sum{s,REG,  CNTqms(c,s,r,t)}} ];!
!change to avoid complicated if()!
Equation E_CNTalleffrpr
# total contribution to regional EV of allocative effects #
(all,r,REG)(all,t,ALLTIME)
    CNTalleffr(r,"prodtax",t)
        = sum{c,COMM, sum{a,ACTS, CNTqca(c,a,r,t)}};
Equation E_CNTalleffrinc
# total contribution to regional EV of allocative effects #
(all,r,REG)(all,t,ALLTIME)
    CNTalleffr(r,"inctax",t)
        = sum{e,ENDW, sum{a,ACTS, CNTqea(e,a,r,t)}};
Equation E_CNTalleffrpf
# total contribution to regional EV of allocative effects #
(all,r,REG)(all,t,ALLTIME)
    CNTalleffr(r,"pfacttax",t)
        = sum{e,ENDW, sum{a,ACTS, CNTqfe(e,a,r,t)}};
Equation E_CNTalleffrin
# total contribution to regional EV of allocative effects #
(all,r,REG)(all,t,ALLTIME)
    CNTalleffr(r,"inputtax",t)
        = sum{c,COMM, sum{a,ACTS,CNTqfd(c,a,r,t) + CNTqfm(c,a,r,t)}};
Equation E_CNTalleffrco
# total contribution to regional EV of allocative effects #
(all,r,REG)(all,t,ALLTIME)
    CNTalleffr(r,"contax",t)
        = sum{c,COMM, CNTqpd(c,r,t) + CNTqpm(c,r,t)};
Equation E_CNTalleffrgo
# total contribution to regional EV of allocative effects #
(all,r,REG)(all,t,ALLTIME)
    CNTalleffr(r,"govtax",t)
        = sum{c,COMM, CNTqgd(c,r,t) + CNTqgm(c,r,t)};
Equation E_CNTalleffrinv
# total contribution to regional EV of allocative effects #
(all,r,REG)(all,t,ALLTIME)
    CNTalleffr(r,"invtax",t)
        = sum{c,COMM, CNTqid(c,r,t) + CNTqim(c,r,t)};
Equation E_CNTalleffrxt
# total contribution to regional EV of allocative effects #
(all,r,REG)(all,t,ALLTIME)
    CNTalleffr(r,"xtax",t)
        = sum{c,COMM, sum{d,REG, CNTqxs(c,r,d,t)}};
Equation E_CNTalleffrmt
# total contribution to regional EV of allocative effects #
(all,r,REG)(all,t,ALLTIME)
    CNTalleffr(r,"mtax",t)
        = sum{c,COMM, sum{s,REG, CNTqms(c,s,r,t)}};

Variable (linear,change) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CNTalleffcr(c,r,t)
    # total contribution to regional EV of allocative effects #;
Equation E_CNTalleffcr
# total contribution to regional EV of allocative effects #
(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CNTalleffcr(c,r,t)
        = sum{a,ACTS, CNTqfd(c,a,r,t) + CNTqfm(c,a,r,t)}
        + CNTqpd(c,r,t) + CNTqpm(c,r,t)
        + CNTqgd(c,r,t) + CNTqgm(c,r,t)
        + CNTqid(c,r,t) + CNTqim(c,r,t)
        + sum{d,REG, CNTqxs(c,r,d,t)}
        + sum{s,REG, CNTqms(c,s,r,t)};

Variable (linear,change) (all,e,TECHTYPE)(all,r,REG)(all,t,ALLTIME)
    CNTtechr(e,r,t) # contribution to regional EV of all technical change #;
!Equation E_CNTtechr
# contribution to regional EV of all technical change #
(all,t,TECHTYPE)(all,r,REG)(all,t,ALLTIME)
    CNTtechr(t,r,t)
        = IF[t="output",   sum{a,ACTS, CNTtech_ao(a,r,t)}]
        + IF[t="ininput",  sum{a,ACTS, CNTtech_aint(a,r,t) 
                               + sum{c,COMM, CNTtech_af(c,a,r,t)}}]
        + IF[t="primfac", sum{e,ENDW, sum{a,ACTS, CNTtech_afe(e,a,r,t)}}] 
        + IF[t="v_added", sum{a,ACTS,CNTtech_ava(a,r,t)}]
        + IF[t="transp",  sum{m,MARG, sum{c,COMM, sum{s,REG,
                                CNTtech_atmfsd(m,c,s,r,t)}}}]
        + IF[t="import",  sum{c,COMM, sum{s,REG, CNTtech_ams(c,s,r,t)}}];!
!change to avoid complicated if()!
Equation E_CNTtechrout
# contribution to regional EV of all technical change #
(all,r,REG)(all,t,ALLTIME)
    CNTtechr("output",r,t)
        = sum{a,ACTS, CNTtech_ao(a,r,t)};
Equation E_CNTtechrini
# contribution to regional EV of all technical change #
(all,r,REG)(all,t,ALLTIME)
    CNTtechr("ininput",r,t)
        = sum{a,ACTS, CNTtech_aint(a,r,t)    
            + sum{c,COMM, CNTtech_af(c,a,r,t)}};
Equation E_CNTtechrpri
# contribution to regional EV of all technical change #
(all,r,REG)(all,t,ALLTIME)
    CNTtechr("primfac",r,t)
        = sum{a,ACTS,sum{e,ENDW, CNTtech_afe(e,a,r,t)}};
Equation E_CNTtechrv_a
# contribution to regional EV of all technical change #
(all,r,REG)(all,t,ALLTIME)
    CNTtechr("v_added",r,t)
        = sum{a,ACTS, CNTtech_ava(a,r,t)};
Equation E_CNTtechrtra
# contribution to regional EV of all technical change #
(all,r,REG)(all,t,ALLTIME)
    CNTtechr("transp",r,t)
        = sum{m,MARG, sum{c,COMM, sum{s,REG, CNTtech_atmfsd(m,c,s,r,t)}}};
Equation E_CNTtechrimp
# contribution to regional EV of all technical change #
(all,r,REG)(all,t,ALLTIME)
    CNTtechr("import",r,t)
        = sum{c,COMM,sum{s,REG, CNTtech_ams(c,s,r,t)}};

Equation E_CNTtechrinv
# contribution to regional EV of all technical change #
(all,r,REG)(all,t,ALLTIME)
    CNTtechr("invest",r,t) = 0;

!< Contributions to EV of changes in capital stock and depreciation >!
Variable (linear,change) (all,r,REG)(all,t,ALLTIME)
    CNTkb(r,t)
    # cont. to EV of changes to beg. period capital stock and depreciation #;
Equation E_CNTkb
# cont. to EV of changes to beg. period capital stock and depreciation #
(all,r,REG)(all,t,ALLTIME) 
    CNTkb(r,t) = - [0.01 * EVSCALFACT(r,t)] * VDEP(r,t) * [kb(r,t) - pop(r,t)];

!<  
    ===========================
    END OF GTAP model equations
    =========================== 
>!

!<  
    ================================================
    Welfare summary and post-simulation calculations
    ================================================
>!

!<
    --------------------------
    C. Welfare summary modules
    --------------------------
    C-A:  EV decomposition: Summary
    C-A1: Allocative efficiency effect: Commodity summary
    C-A2: Allocative efficiency effect: Tax type summary
    C-AX: Decomposition of allocative effect, by tax type and commodity
    C-B1: Endowment effect: Gross of depreciation
    C-B2: Endowment effect: Depreciation
    C-C1: Technical change effect
    C-D1: Population effect
    C-E1: Terms of trade (ToT) effect
    C-F1: I-S Effect: Explanatory factors
>!

!<
    Preliminaries: Assign initial values
    ------------------------------------
>!

Zerodivide default RNREG;

Coefficient (parameter) (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BEVFP(e,a,r,t) # producer expenditure on c by act. a #;
Formula (initial) (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BEVFP(e,a,r,t) = EVFP(e,a,r,t);

Coefficient (parameter) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BVMFP(c,a,r,t) # purchases of imported c r for use in a in region r #;
Formula (initial) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BVMFP(c,a,r,t) = VMFP(c,a,r,t);

Coefficient (parameter) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BVDFP(c,a,r,t) # purchases of domestic c r for use in a in region r #;
Formula (initial) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BVDFP(c,a,r,t) = VDFP(c,a,r,t);

Coefficient (parameter) (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BVOS(a,r,t) # value of commodity c output in region r #;
Formula (initial)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BVOS(a,r,t)
        = sum{e,ENDW, BEVFP(e,a,r,t)}
        + sum{c,COMM, BVMFP(c,a,r,t) + BVDFP(c,a,r,t)};        

Coefficient (parameter) (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    BVXSB(c,s,d,t)
    # exports of c from r to s at basic prices (tradeables only) #;
Formula (initial) (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    BVXSB(c,s,d,t) = VXSB(c,s,d,t); 

Coefficient (parameter)(all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVDPB(c,r,t) # private household expenditure on domestic c in r #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVDPB(c,r,t) = VDPB(c,r,t);

Coefficient (parameter) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVDGB(c,r,t) # government household expenditure on domestic c in r #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVDGB(c,r,t) = VDGB(c,r,t);

Coefficient (parameter) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BVDFB(c,a,r,t) # purchases of domestic c for use in a in region r #;
Formula (initial) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BVDFB(c,a,r,t) = VDFB(c,a,r,t);

Coefficient (parameter) (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BEVFB(e,a,r,t) # producer expenditure on c by a in r at basic prices #;
Formula (initial)  (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BEVFB(e,a,r,t) = EVFB(e,a,r,t);

Coefficient (parameter) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVDB(c,r,t) # domestic sales of c in r at basic prices (tradeables only) #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVDB(c,r,t) =  VDB(c,r,t);

Coefficient (parameter) (all,m,MARG)(all,r,REG)(all,t,ALLTIME)
    BVST(m,r,t)
    # exports of m from r for int'l transp. at basic prices (tradeables only) #;
Formula (initial) (all,m,MARG)(all,r,REG)(all,t,ALLTIME)
    BVST(m,r,t) =  VST(m,r,t);

Coefficient (parameter) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVCB(c,r,t) # value of commodity c output in region r at basic prices #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVCB(c,r,t) = VCB(c,r,t);
!change to avoid complicated if()!
Formula (initial) (all,c,NMRG!COMM!)(all,r,REG)(all,t,ALLTIME)
    BVCB(c,r,t) = BVDB(c,r,t) + sum{s,REG, BVXSB(c,r,s,t)} 
              !+ IF[c in MARG, BVST(c,r,t)]!;
Formula (initial) (all,c,MARG!COMM!)(all,r,REG)(all,t,ALLTIME)
    BVCB(c,r,t) = BVDB(c,r,t) + sum{s,REG, BVXSB(c,r,s,t)} 
              + !IF[c in MARG, !BVST(c,r,t)!]!;

Coefficient (parameter) (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BVEB(e,a,r,t) # value of endowment e in region r at basic prices #;
Formula (initial) (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BVEB(e,a,r,t) = EVFB(e,a,r,t);

Coefficient (parameter) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BMAKEB(c,a,r,t) # value of total output of firm a at initial basic prices #;
Formula (initial) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BMAKEB(c,a,r,t) = MAKEB(c,a,r,t);

Coefficient (parameter) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BOUTAX(c,a,r,t) # power of activity output tax, base #;
Formula (initial) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BOUTAX(c,a,r,t) = [MAKEB(c,a,r,t) - MAKES(c,a,r,t)] / MAKES(c,a,r,t) * 100;

Coefficient (parameter) (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BEVOS(e,a,r,t) # initial endowment supply #;
Formula (initial) (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BEVOS(e,a,r,t) = EVOS(e,a,r,t);

Coefficient (parameter)(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BINCTAX(e,a,r,t) # initial income tax #;
Formula (initial) (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BINCTAX(e,a,r,t) = [[BVEB(e,a,r,t) - BEVOS(e,a,r,t)] / BEVOS(e,a,r,t)] * 100;

Coefficient (parameter) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BVMFB(c,a,r,t) # purchases of imports c for use in act. a in region r #;
Formula (initial) (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BVMFB(c,a,r,t) = VMFB(c,a,r,t);

Coefficient (parameter) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVMPB(c,r,t) # private household expenditure on c in r #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVMPB(c,r,t) = VMPB(c,r,t);

Coefficient (parameter) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVMPP(c,r,t) # private household expenditure on imported c #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVMPP(c,r,t) = VMPP(c,r,t);

Coefficient (parameter) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVDPP(c,r,t) # private household expenditure on domestic c in r #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVDPP(c,r,t) = VDPP(c,r,t);

Coefficient (parameter) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVMGB(c,r,t) # gov't household expenditure on c in r #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVMGB(c,r,t) = VMGB(c,r,t);

Coefficient (parameter) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVMGP(c,r,t) # government household expenditure on imported c #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVMGP(c,r,t) = VMGP(c,r,t);

Coefficient (parameter) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVDGP(c,r,t) # government household expenditure on domestic c in r #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVDGP(c,r,t) = VDGP(c,r,t);

Coefficient (parameter) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVMIB(c,r,t) # investment expenditure on c in r #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVMIB(c,r,t) = VMIB(c,r,t);

Coefficient (parameter) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVMIP(c,r,t) # investment expenditure on imported c #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVMIP(c,r,t) = VMIP(c,r,t);

Coefficient (parameter) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVDIP(c,r,t) # investment expenditure on domestic c in r #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVDIP(c,r,t) = VDIP(c,r,t);

Coefficient (parameter) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVDIB(c,r,t) # investment expenditure on domestic c in r #;
Formula (initial) (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    BVDIB(c,r,t) = VDIB(c,r,t);

Coefficient (parameter) (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    BVMSB(c,s,d,t) # imports of c from r to s at domestic basic prices #;
Formula (initial) (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    BVMSB(c,s,d,t) = VMSB(c,s,d,t);

Coefficient (parameter) (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    BVCIF(c,s,d,t) # imports of c from r to s valued cif (tradeables only) #;
Formula (initial) (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    BVCIF(c,s,d,t) = VCIF(c,s,d,t);

Coefficient (parameter) (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    BMTAX(c,s,d,t) # power of import tax, base #;
Formula (initial) (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    BMTAX(c,s,d,t) = [BVMSB(c,s,d,t) - BVCIF(c,s,d,t)] / BVCIF(c,s,d,t) * 100;

Coefficient (parameter) (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    BVFOB(c,s,d,t) # exports of c from r to s valued fob (tradeables only) #;
Formula (initial) (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    BVFOB(c,s,d,t) = VFOB(c,s,d,t);

Coefficient (parameter) (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    BXTAX(c,s,d,t) # power of exports tax, base #;
Formula (initial) (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    BXTAX(c,s,d,t) = [BVFOB(c,s,d,t) - BVXSB(c,s,d,t)] / BVXSB(c,s,d,t) * 100;

Coefficient (parameter) (all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BETAX(e,a,r,t) # power of exports tax, base #;
Formula (initial)(all,e,ENDW)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    BETAX(e,a,r,t) = [BEVFP(e,a,r,t) - BEVFB(e,a,r,t)] / BEVFB(e,a,r,t) * 100;

Coefficient (parameter) (all,r,REG)(all,t,ALLTIME)
    BSAVE(r,t) # expenditure on NET saving in region r at purchaser's prices #;
Formula (initial) (all,r,REG)(all,t,ALLTIME)
    BSAVE(r,t) = SAVE(r,t);

Coefficient (parameter) (all,r,REG)(all,t,ALLTIME)
    ISBAL(r,t) # I-S balance, NETINV(r,t) - SAVE(r,t) #;
Formula (initial) (all,r,REG)(all,t,ALLTIME)
    ISBAL(r,t) = NETINV(r,t) - BSAVE(r,t);
Zerodivide off;

!<
    ----------------------------------------------
    E. Data balance check and summary calculations 
    ----------------------------------------------
>!
!Set 
    COSTS # industry cost summary # = "IntDom" + "IntImp" + ENDW + "PTAX"  ;
Set 
    GDPIN # income-side GDP # = ENDW + "IndTaxes";!
Set 
    COST_TEMP # industry cost summary # (IntDom,IntImp,PTAX);
Set 
    COSTS # industry cost summary # = COST_TEMP + ENDW;
Set 
    IND_TAX # industry cost summary # (IndTaxes);
Set 
    GDPIN # income-side GDP # = ENDW + IND_TAX;
Set 
    SALES # Commodity Sales Summary # 
    (Intermediate,Household,Investment,Government,Exports,IntnlMargins);

Coefficient (all,a,ACTS)(all,r,REG)(all,c,COSTS)(all,t,ALLTIME)
    COSTSUM(a,r,c,t) # industry cost summary #;
Formula (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    COSTSUM(a,r,"IntDom",t) = sum{c,COMM, VDFP(c,a,r,t)}; 
Formula (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    COSTSUM(a,r,"IntImp",t) = sum{c,COMM, VMFP(c,a,r,t)}; 
Formula (all,a,ACTS)(all,r,REG)(all,e,ENDW)(all,t,ALLTIME)
    COSTSUM(a,r,e,t) = EVFP(e,a,r,t); 
Formula (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    COSTSUM(a,r,"PTAX",t) = sum{c,COMM, PTAX(c,a,r,t)};
Formula (all,a,ACTS)(all,r,REG)(all,e,ENDW)(all,t,ALLTIME)
    COSTSUM(a,r,e,t) = EVFP(e,a,r,t); 
Formula (all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    COSTSUM(a,r,"PTAX",t) = sum{c,COMM, PTAX(c,a,r,t)};
 
Coefficient (all,r,REG)(all,g,GDPIN)(all,t,ALLTIME)
   GDPINC(r,g,t) # income-side GDP #;
Formula (all,r,REG)(all,e,ENDW)(all,t,ALLTIME)
    GDPINC(r,e,t) = sum{a,ACTS, EVFP(e,a,r,t)};
Formula (all,r,REG)(all,t,ALLTIME)
    GDPINC(r,"IndTaxes",t) = INDTAX(r,t) - TAXRFU(r,t);

Coefficient (all,c,COMM)(all,r,REG)(all,sa,SALES)(all,t,ALLTIME)
    SALESUM(c,r,sa,t) # commodity sales summary #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    SALESUM(c,r,"Intermediate",t) = sum{a,ACTS, VDFB(c,a,r,t)};
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    SALESUM(c,r,"Household",t) = VDPB(c,r,t);
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    SALESUM(c,r,"Investment",t) = VDIB(c,r,t);
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    SALESUM(c,r,"Government",t) = VDGB(c,r,t);
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    SALESUM(c,r,"Exports",t) = VXDXSB(c,r,t);
Formula (all,c,MARG)(all,r,REG)(all,t,ALLTIME)
    SALESUM(c,r,"IntnlMargins",t) = VST(c,r,t);
Formula (all,c,NMRG)(all,r,REG)(all,t,ALLTIME)
    SALESUM(c,r,"IntnlMargins",t) = 0;

Zerodivide default RNREG;
Zerodivide (nonzero_by_zero) default RNREG;
 Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDBCHK(c,r,t) # VCB(c,r,t) - MAKEBCOM(c,r,t) should be tiny #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDBCHK(c,r,t) = VCB(c,r,t) - MAKEBCOM(c,r,t);
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    VDBCHK(c,r,t) = 100 * VDBCHK(c,r,t) / VCB(c,r,t);

Coefficient (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    TRDCHK(c,s,d,t) # VCIF(c,s,d) - [VFOB(c,s,d) + VTFSD(c,s,d)] should be tiny #;
Formula (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    TRDCHK(c,s,d,t) = VCIF(c,s,d,t) - [VFOB(c,s,d,t) + VTFSD(c,s,d,t)];
Formula (all,c,COMM)(all,s,REG)(all,d,REG)(all,t,ALLTIME)
    TRDCHK(c,s,d,t) = 100 * TRDCHK(c,s,d,t) / VCIF(c,s,d,t);

Coefficient (all,m,MARG)(all,t,ALLTIME)
    VTMCHK(m,t) # VTMUSE(m) - VTMPROV(m) should be tiny #;
Formula (all,m,MARG)(all,t,ALLTIME)
    VTMCHK(m,t) = VTMUSE(m,t) - VTMPROV(m,t);
Formula (all,m,MARG)(all,t,ALLTIME)
    VTMCHK(m,t) = 100 * VTMCHK(m,t) / VTMUSE(m,t);

Coefficient (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CHKMKClIMP(c,r,t) # Checking the accounting on imports supply and demand #;
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CHKMKClIMP(c,r,t)
        = sum{s,REG, VMSB(c,s,r,t)}
        - sum{a,ACTS, VMFB(c,a,r,t)}
        - VMPB(c,r,t) - VMGB(c,r,t) - VMIB(c,r,t);
Formula (all,c,COMM)(all,r,REG)(all,t,ALLTIME)
    CHKMKClIMP(c,r,t) = 100 * CHKMKClIMP(c,r,t) / [sum{s,REG, VMSB(c,s,r,t)}];
Coefficient (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VOSCHK(c,a,r,t) # MAKEB - [MAKES + PTAX] should be tiny #;
Formula (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VOSCHK(c,a,r,t) = MAKEB(c,a,r,t) - [MAKES(c,a,r,t) + PTAX(c,a,r,t)];
Formula (all,c,COMM)(all,a,ACTS)(all,r,REG)(all,t,ALLTIME)
    VOSCHK(c,a,r,t) = 100 * VOSCHK(c,a,r,t) / MAKEB(c,a,r,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    vroract(r,t) # vact #;
Formula (initial) (all,r,REG)(all,t,ALLTIME)
    vroract(r,t) = 0;
Update (change)(all,r,REG)(all,t,ALLTIME)
    vroract(r,t) = ror_act(r,t);
Coefficient (all,r,REG)(all,t,ALLTIME)
    vrore(r,t) # vact #;
Formula (initial) (all,r,REG)(all,t,ALLTIME)
    vrore(r,t) = 0;
Update (change)(all,r,REG)(all,t,ALLTIME)
    vrore(r,t) = rore(r,t);

Zerodivide off;

!<
    =====================
    END OF GTAP.TAB FILE
    =====================
>!
