* ======= Experiment file ================================================
* ----- DESCRIPTION OF EXPERIMENT -----
$ontext


$offtext
$ontext
 This file sets up and runs experiments on a model. It has a standard structure
 which is described below.

NB: 1) THE USER NEEDS TO SET (SECTION 3) AND IMPLEMENT THE SHOCKS (SECTION 5)
    2) THE USER SHOULD MAKE SURE THAT THE NAME OF THE OUTPUT FILEs - IN GDX -
       ARE THOSE DESIRED.
             DEFAULT NAMES ARE IMPOSED IN THE VARIOUS RESULT MODULES
                     - THESE CAN BE CHANGED BY THE USER.

 Structure
          1. Declare and Assign Simulation Set
          2. Define Result Parameters
          3. Setting up the sim shocks
                 3a. Declaring Parameters for Shocks
                 3b. Assigning Parameters for Shocks
          4. Setting up the Closures
                 4a. Declaring Parameters for Closure
                 4b. Assigning Parameters for Closure
          5. Runnin the experiments
                 5a. clos loop begins
                 5b. sim loop begins
                 5c. Implementing sim shocks
          6. Solve statement
          7. Storing results
          8. Terminating sim loop
          9. Terminating clos loop

The experiment code consists of a number of files; the relationships between
these files is illustrated below.

 glb_2.gms                                master programme file
     |
    .
     .
      .
       .
     |
     | 16. POLICY EXPERIMENTS
     |
     |<----- glb_2_expt_**.inc          Experiment files
                 |
                 |<----- glb_2_resparm.inc     Declare results params
                 |
                 |<----- glb_2_varinit2.inc    Reinitialise variables
                 |<----- glb_2_reset.inc       Reset closure variables
                 |
                 |<----- glb_2_***1.inc        Alternative closures
                 |<----- glb_2_cl***..inc                 .
                 |<----- glb_2_cl***..inc                 .
                 |<----- glb_2_cl***n.inc        Alternative closures
                 |
                 |
                 |<----- glb_2_resassign.inc   Assigning results params
                 |
                 |
      |
      |<----- glb_299_anal.inc         Result Analyses sub routine
      |          |
                 |
                 |<----- glb_2_reslevel.inc    Levels results saved
                 |
                 |<----- glb_2_resmacro.inc    Macroeconomic results
                 |
                 |<----- glb_2.inc     Welfare results
                 |
                 |<----- glb_2_resstruct.inc   Structural results
                 |
                 |<----- glb_2_resindex.inc    Price index results
                 |
                 |<----- glb_2_resperc.inc     Proportionate results

$offtext

* ------- 1. Declare and Assign Simulation Set ---------------------------

* By including a "base case" in the SIM set a comparator is produced

SETS
* Sets for simulations

 sim          simulations
 simc(sim)    CURRENT simulations - those actually done
 simr(simc)   REPORTED simulations - those run that are saved
 clos         closures
 elst         elasticities

* Sub Sets used in experiments

 l(f)         Labour Factors
 ls(l)        Skilled Labour Factors
 lu(l)        Unskilled Labour Factors
 k(f)         Capital Factors
 lnd(f)       Land factors

* Sub sets used in closures

 rerfx(r)     Regions where the exchange rate is fixed
 rerfxn(r)    Regions where the external balance is fixed

* Additional sets to control study specific experiments


* Sets used in reports

 ppric        Set of price variables
 qqunt        Set of quantity variables


  ;

ALIAS(l,lp),
     (cagr,cagrp),(cnat,cnatp),(cfd,cfdp),(cind,cindp),(cser,cserp),
     (aagr,aagrp),(anat,anatp),(afd,afdp),(aind,aindp),(aser,aserp),
     (l,lp),(ls,lsp),(lu,lup),(k,kp),(lnd,lndp)
   ;

* Convert Excel workbook data to GDX here
$CALL "GDXXRW i=data_expt_sc.xls o=expt_in.gdx INDEX=LAYOUT!A4"

* Loading sets from GDX data file

$GDXIN expt_in.GDX

$LOADdc rerfx
$LOADdc sim simc clos elst

$LOADdc ppric qqunt

$GDXIN

* Assigning membership to simc - default is all sim

* simc(sim)    = YES ;

* Assigning set members by reference to other sets

 rerfxn(r)     = not rerfx(r) ;
 rerfxn("glo") = no ;

* rluex(r)      = not rluen(r) ;


* Additional sets to control study specific experiments


DISPLAY sim, sim1, clos, elst,
        rerfx, rerfxn,
        ppric, qqunt
 ;

* ------- 2. Define Result Parameters ------------------------------------
* This section defines the result parameter that are used to store model
* results between experiments and sims.

* ------------------- RESULTS IN LEVELS -----------------------------------

* Declaring parameters for levels (and proportionate change) results

$INCLUDE glb_2_2_resparm.inc

* ------- 3. Setting up the sim shocks -----------------------------------

* ------- 3a. Declaring Parameters for Shocks ----------------------------

Parameter
* Standard parameters for tax instrument shocks
 TESIM(c,w,r,sim)      Export taxes on exported comm'y c from r to w
 TMSIM(w,c,r,sim)      Ad valorem Tariff rates on imported comm'y c from w by r
 TMSSIM(w,c,r,sim)     Specific Tariff rates on imported comm'y c from w by r
 TSSIM(c,r,sim)        Sales tax rates
 TVSIM(c,r,sim)        VAT tax rates
 TXSIM(a,r,sim)        Indirect tax rates
 TYFSIM(f,r,sim)       Direct tax rates on factor income
 TYHSIM(h,r,sim)       Direct tax rates on households
 TFSIM(f,a,r,sim)      Tax rates on factor use

* Standard parameters for efficiency rate shocks
 ADXSIM(a,r,sim)       Shift parameter for CES production functions for QX in r
 ADVASIM(a,r,sim)      Shift parameter for CES production functions for QVA
 ADFDSIM(f,a,r,sim)    Shift parameter for factor and activity specific efficiency

* Standard parameters for factor demand and supply shocks
 FDSIM(f,a,r,sim)      Demand for factor f by activity a in r
 FSSIM(f,r,sim)        Supply of factor f in r

* Shocks data


  ;

* ------- 3b. Assigning Parameters for Shocks ----------------------------

* ------ Defining the shock parameters

Display popn ;

*---- 1. Setting tax rate shocks

*-- Ad valorem Tariff rates
 TMSIM(w,c,r,sim)               = TM0(w,c,r) ;

* SADC FTA

* sim01. SADC FTA
 TMSIM(wsad,c,rsad,"sim01")     = 0.0 ;

* SADC Customs Union

* sim02. SADC CU with 25% max CET
 TMSIM(wsad,c,rsad,"sim02")     = 0.0 ;
 TMSIM(wsadn,c,rsad,"sim02")    = (SMAX((wsadnp,rsadp),TM0(wsadnp,c,rsadp)))*0.25 ;

* sim03. SADC A PTA with EU - 90% liberalisation

 TMSIM("weu",c,"sada","sim03")  =  0.1 * TM0("weu",c,"sada") ;
 TMSIM("wsada",c,"eu","sim03")  =  0.1 * TM0("wsada",c,"eu") ;

*-- Specific Tariff rates
 TMSSIM(w,c,r,sim)              = TMS0(w,c,r) ;

*-- Export tax rates
 TESIM(c,w,r,sim)               = TE0(c,w,r) ;

*-- Sales tax rates
 TSSIM(c,r,sim)             = TS0(c,r) ;

*-- VAT tax rates
 TVSIM(c,r,sim)             = TV0(c,r) ;

*-- Production tax rates
 TXSIM(a,r,sim)             = TX0(a,r) ;

*-- Factor Use Taxes
 TFSIM(f,a,r,sim)           = TF0(f,a,r) ;

*-- Household Income Taxes
 TYHSIM(h,r,sim)            = TYH0(h,r) ;

*-- Factor Income Taxes
 TYFSIM(f,r,sim)            = TYF0(f,r) ;

*---- 2. Setting efficiency rate shocks

* Top level Hicks neutral efficiency parameter
 ADXSIM(a,r,sim)            = adx0(a,r) ;

* Aggregate value added Hicks neutral efficiency parameter
 ADVASIM(a,r,sim)           = adva0(a,r) ;

* Individual factor efficiency parameter
 ADFDSIM(f,a,r,sim)         = adfd0(f,a,r) ;


*---- 3. Setting factor supply shocks
* factor supply shocks
 FSSIM(f,r,sim)             = FS0(f,r) ;


*---- 4. Shocks data

*---- GDP calculations

Parameter
 GDPVA00(r)       Base values of GDPVA by region
 GDVCAP0(r)       GDPVA per capita by region
 ;

 GDPVA00(r) = SUM((f,a),WF0(f,r) * WFDIST0(f,a,r) * FD0(f,a,r))
               + MTAX0(r) + ETAX0(r) + STAX0(r) + ITAX0(r) + FTAX0(r) ;

 GDVCAP0(r)$rgn(r) = GDPVA00(r)/popn(r) ;

Display GDPVA00, GDVCAP0 ;


* Displaying shock parameters

Display  TMSIM, TESIM, TFSIM, TYHSIM, TYFSIM, TXSIM, TSSIM,
         ADXSIM, ADVASIM, ADFDSIM,
         FSSIM
  ;

Execute_Unload  'glb_shocks.gdx',
* Tax rate shocks
 TMSIM, TESIM, TFSIM, TYHSIM, TYFSIM, TXSIM, TSSIM,
 ADXSIM, ADVASIM, ADFDSIM,
 FDSIM, FSSIM

   ;

* ------- 4. Setting up the Closures --------------------------------------


* ------- 4a. Declaring Parameters for Closure ----------------------------

Parameter

 closure(clos)    values that control choice of closure

  ;


* ------- 4b. Assigning Parameters for Closure ----------------------------

* Assign values to select closure INCLUDE file
 closure("clbase")   = 1 ;
* closure("clos02")   = 2 ;
* closure("clos03")   = 3 ;
* closure("clos04")   = 4 ;

* ------- 5. Runnin the experiments ---------------------------------------

* ------- 5a. elst loop begins --------------------------------------------

*LOOP(elst,


* ------- 5b. clos loop begins --------------------------------------------

LOOP(clos,

* First set .L values back to initial values for looping over diff closures

$INCLUDE glb_2_varinit2.inc

* Second, free all variables that are involved in any closure rule

$INCLUDE glb_2_reset.inc

* Third, select closure include files


IF(Closure(clos) = 1,

$INCLUDE glb_2_cl_sc.inc

$ontext
     glb_2_cl_sc.inc

Description
 Unemployed unskilled labour, investment fixed, Gvt expenditure share fixed
 Flexible exchanges rates
 Tax replacement via TYH in additive form

                     CONDITION                                 REGIONS

     FEX        - Exchange rate fixed                           rerfx
                - KAPWOR fixed                                  rerfxn

     Investment - investment volumes fixed                       All

     Government - absorption share fixed                         All
                - TYH flexible - Additive form                   All
                - CAPGOV fixed                                   All

     Factors    - Land sector - mobile & full                    All
                - Capital - mobile & full                        All
                - Unskilled labour - mobile & unemployed        rluen
                - Skilled labour - mobile & full                 All

     Numeraire  - CPI                                            All

$offtext

 ) ;


*IF(Closure(clos) = 2,

*$INCLUDE glb_2_cl_sacu_2.inc

$ontext
     womod99_cl_sacu_2.inc

Description
 Full employment, investment fixed, Gvt expenditure share fixed
 Flexible exchanges rates
 Tax replacement via TYH in additive form

                     CONDITION                                 REGIONS

     FEX        - Exchange rate fixed                           rerfx
                - KAPWOR fixed                                  rerfxn

     Investment - investment volumes fixed                       All

     Government - absorption share fixed                         All
                - TYH flexible - Additive form                   All
                - CAPGOV fixed                                   All

     Factors    - Land sector - mobile & full                    All
                - Capital - mobile & full                        All
                - Unskilled labour - mobile & full               ALL
                - Skilled labour - mobile & full                 All

     Numeraire  - CPI                                            All
$offtext

* ) ;



* ------- 5c. sim loop begins ---------------------------------------------

LOOP(sim1,

* ------- 5d. Implementing sim shocks -------------------------------------

*---- 1. Applying tax rate shocks

* Import duties

 tmb(w,c,r)    = TMSIM(w,c,r,sim1) ;

* Export taxes

 teb(c,w,r)    = TESIM(c,w,r,sim1) ;

* Factor Use taxes

 tfb(f,a,r)    = TFSIM(f,a,r,sim1) ;

* Household Income taxes

 tyhb(h,r)     = TYHSIM(h,r,sim1) ;

* Factor Income taxes

 tyfb(f,r)     = TYFSIM(f,r,sim1) ;

* Production taxes

 txb(a,r)      = TXSIM(a,r,sim1) ;

* Sales taxes

 tsb(c,r)      = TSSIM(c,r,sim1) ;

*---- 2. Applying efficiency rate shocks

* Top level Hicks neutral efficiency parameter
* adxb(a,r)     = ADXSIM(a,r,sim1) ;

* Aggregate value added Hicks neutral efficiency parameter
* advab(a,r)    = ADVASIM(a,r,sim1) ;

* Individual factor efficiency parameter
* adfdb(f,a,r)   = ADFDSIM(f,a,r,sim1) ;

*---- 3. Applying factor demand and supply shocks
* factor supply shocks
* FS.FX(f,r)     = FSSIM(f,r,sim1) ;



Display  tmb, teb, tfb, tyhb, tyfb, txb, tsb,
         adxb, advab, adfdb ;

* ------- 6. Solve statement ---------------------------------------------

 OPTION DECIMALS = 6 ;
 Options limrow=100,limcol=0;
 option iterlim = 15 ;

 Solve glb2 Using MCP ;

* ------- 7. Storing results ---------------------------------------------

* Assigning levels results to the result parameters for all variables

$INCLUDE GLB_2_resassign.inc


* ------- 8. Terminating sim loop ----------------------------------------

 ) ;


* ------- 9. Terminating clos loop ----------------------------------------

 ) ;

* ------- 10. Terminating elst loop ----------------------------------------

* ) ;

* ########### END OF EXPERIMENT FILE #####################################
