* -------------- ANAR1 results Analysis file ------------------------------

$ontext
The various files for the analysis of results can be called here or by using
programme analyse.gms to carry out the same actions using results stored
in GDX

EACH COMPONENT IS INDEPENDENT, i.e., each component only makes use of the
results saved into the standard GDX results file that is produced by the
simulations module. This includes the levels values for the model variables,
all the initial values of variables, all the model parameter values, all the
model and simulation sets

$offtext

* ------- WRITE OUT LEVELS RESULTS ---------------------------------------
$ontext
This $INCLUDE file exports the levels results to GDX as 'glb2_reslevel.gdx'

'womod_reslevel.gdx' is the default name for the results file
its name can be changed in the $INCLUDE file
$offtext

If(flow_cont("reslevel") = 1,

$INCLUDE anar1_reslevel.inc

  ) ;

* ------- New MicroSAM Results -------------------------------------------
$ontext
This $INCLUDE file generates and exports a global SAM for each experiment
to GDX as 'womod_ressamg.gdx'

'womod_ressamg.gdx' is the default name for the results file
its name can be changed in the $INCLUDE file
$offtext

Parameter
 SAMG3(sac,sacp,r,clos,sim)     New Global SAM for each simulation

 SAMG3CHK(sac,r,clos,sim)      CHK on row and column totals
 CNTSAMG3CHK(r,clos,sim)       Count of non zero entries in SAMG3CHK

   ;

If(flow_cont("ressamg") = 1,

$INCLUDE anar1_ressamg.inc

  ) ;
* ------- Macroeconomic Results -----------------------
$ontext
This $INCLUDE file generates and exports various summary macroeconomic
totals, shares and proportionate changes to GDX as 'womod_resmacro.gdx'

'womod_resmacro.gdx' is the default name for the results file
its name can be changed in the $INCLUDE file
$offtext

* ------- 1. Define Macroeconomic Tables -------------------------------------

* This section defines the Macroeconomic tables that are reported

PARAMETERS

* --- Macroeconomic Tables ---

*Macroeconomic tables - indexed on stab1
 nMACROTOT(stab1,r,clos,sim)      Nominal Macroeconomic totals
 nMACROSH1(stab1,r,clos,sim)      Nominal Macroeconomic shares in GDP Expenditure
 nMACROSH2(stab1,r,clos,sim)      Nominal Macroeconomic shares in Domestic Absorption

 rMACROTOT(stab1,r,clos,sim)      Real Macroeconomic totals

*Macroeconomic totals - percentage change
 rperMACROTOT(stab1,r,clos,sim)  Percentage changes in Real Macro totals
 nperMACROTOT(stab1,r,clos,sim)  Nominal Macroeconomic totals percentage change

  ;

If(flow_cont("resmacro") = 1,

$INCLUDE anar1_resmacro.inc

  ) ;
* ------- Structural Results -----------------------
$ontext
This $INCLUDE file generates and exports various summary structural
measures to GDX as 'womod_resstruct.gdx'

'womod_resstruct.gdx' is the default name for the results file
its name can be changed in the $INCLUDE file
$offtext

* ------- 1. Define Structural Tables -------------------------------------

* This section defines the structural tables that are used to report
* descriptive statistics for the database used for this model

PARAMETERS

* --- Commodity Tables ---

* Trade shares - indexed on stab2
 nIMPORTSH(stab2,w,c,r,clos,sim)  Import shares in c from w by reg
 nEXPORTSH(stab2,c,w,r,clos,sim)  Export shares in c to w by reg

* Commodity account shares - indexed on stab3
 nCOMMODSH(stab3,c,r,clos,sim)    Commodity shares in c by reg

* --- Activity Tables - indexed on stab4

 nACTIVSH(stab4,a,r,clos,sim)      Activity shares in a by reg

* --- Factor Tables - indexed on stab5

 nFACTUSESH(stab5,f,a,r,clos,sim)  factor use by activities and region

* ---Factor adjustment

 FACTADJ(f,r,clos,sim)              Factor adjustment across activities

* ---- Exports by aggregate commodities and/or regions

 EXPORT_TOT(w,r,clos,sim)           Export totals valued in world prices
 EXPORT_DIF(w,r,clos,sim)           Change in Exp totals valued in world prices
 EXPORT_DIF_AGG(wagg,ragg,clos,sim) Change in Exp totals to agg regions
 EXPORT_TOT_SH(w,r,clos,sim)        Export shares to wgn by region
 EXP_CAGG_TOT(cagg,w,r,clos,sim)    Export of commodity aggregates world pr

* ---- Imports by aggregate commodities and/or regions

 IMPORT_TOT(w,r,clos,sim)           Import totals valued in world prices
 IMPORT_TOT_SH(w,r,clos,sim)        Import shares to wgn by region
 IMP_CAGG_TOT(w,cagg,r,clos,sim)    Import of commodity aggregates world pr

* ---- Total Trade by aggregate commodities and/or regions

 tradetot(r,w,clos,sim)             total trade FOB
 test_tradepc(r,w,clos,sim)         percent change in total trade
 tradetot2(ragg,wagg,clos,sim)      total trade by aggregatre region FOB
 tradetotpc(ragg,wagg,clos,sim)     percent change in exports by agg region
 tradetotsh(ragg,wagg,clos,sim)     trade share by aggregatre region FOB
 tradeshdiff(ragg,wagg,clos,sim)    absolute change in trade shares

  ;

If(flow_cont("resstruct") = 1,

$INCLUDE anar1_resstruct.inc

  ) ;
* ------- Welfare Results Analysis -----------------------------------
$ontext
This $INCLUDE file generates and exports various summary welfare
measures to GDX as 'womod_reswelf.gdx'

'womod_reswelf.gdx' is the default name for the results file
its name can be changed in the $INCLUDE file
$offtext

Parameter

 resEV(h,r,clos,sim)         EV by household on consumption
 resEV_cap(h,r,clos,sim)     EV per capita by household on consumption

 resIC(h,r,clos,sim)         LES Indirect compensation by h'hold on consumption
 resIC_cap(h,r,clos,sim)     LES IC per capita by h'hold on consumption

 resEV_alt(h,r,clos,sim)     LES Alternative EV by h'hold on consumption
 resEV_alt_cap(h,r,clos,sim) LES Alt EV per capita by h'hold on consumption

 pop(h,r)                    Population by household and region


 resEV_H_slut(h,r,clos,sim)  Slutsky approx EV by household on consumption
 resEV_R_slut(r,clos,sim)    Slutsky approx EV by region on consumption

   ;

 pop(h,r)     = 0.0 ;

If(flow_cont("reswelf") = 1,

$INCLUDE anar1_reswelf.inc

  ) ;
* ------- Price Indices Results --------------------------------------
$ontext
This $INCLUDE file generates and exports various price indices
to GDX as 'womod_resindex.gdx'

'womod_resindex.gdx' is the default name for the results file
its name can be changed in the $INCLUDE file
$offtext

Parameter
* ---- Terms of trade

 TOT(r,clos,sim)          Terms of trade
 TOTcagg(cagg,r,clos,sim)  terms of trade by commodity group and region r

 PWEAGG(c,r,clos,sim)     agg world export price by region (level)
 pPWEAGG(c,r,clos,sim)    agg world export price by region (percent change)
 REGXWTS(c,w,r)           export weights for each region by trade partner
 CHKREGXWTS(c,r)          Check on region weights REGXWTS

* Step two: construct a weighted average where the weights are each regions's
* share in world exports

 PWEAGG2(c,clos,sim)      aggregate world price (level)
 pPWEAGG2(c,clos,sim)     aggregate world price (percent change)
 REGXWTS2(c,r)            export weights for each region
 TOTALX(c)                total exports valued in world price (for conditioning only)
 CHKREGXWTS2(c)           Check on region weights REGXWTS2

* KT Feb 2007, create agg world import price by region valued in world currency
* using PWMFOB

 PWMAGG(c,r,clos,sim)     agg world price by region valued in world currency
 pPWMAGG(c,r,clos,sim)    agg world price by region valued in world currency
 REGMWTS(w,c,r)           import weights for each region by trade partner
 CHKREGMWTS(c,r)          Check on region weights REGMWTS

* Step two: construct a weighted average where the weights are each regions's
* share in world exports

 PWMAGG2(c,clos,sim)      aggregate world price (level)
 pPWMAGG2(c,clos,sim)     aggregate world price (percent change)
 REGMWTS2(c,r)            import weights for each region
 TOTALM(c)                total imports valued in world price (for conditioning only)
 CHKREGMWTS2(c)           Check on region weights REGMWTS2

* ---- Government and Investment Price Indices

 GPI(r,clos,sim)         Government consumption price index
 IPI(r,clos,sim)         Investment consumption price index

* Weights
 gcomtotsh(c,r)          Share of commodity c in Government commodity demand
 icomtotsh(c,r)          Share of commodity c in Investment commodity demand

    ;

If(flow_cont("resindex") = 1,

$INCLUDE anar1_resindex.inc

  ) ;
* ------- Tax Results ------------------------------------------------
$ontext
This $INCLUDE file generates and exports various summary tax rate and
revenues results to GDX as 'womod_restaxstr.gdx'

'womod_restaxstr.gdx' is the default name for the results file
its name can be changed in the $INCLUDE file
$offtext

* ------- 1. Define Aggregate Tax Tables -------------------------------------

* This section defines the aggregate tax tables that are used to report
* descriptive statistics for the database used for this model

PARAMETERS
* for average tariffs
 AVGTM(c,r,clos,sim)    Average commodity tariff rate weighted by trade partner
 TMWT(w,c,r)            Weights used to aggregate tariff rates
 TMWTCHK(c,r)           Check on weights computed
* for average export taxes or subsidies
* note, each country will have either an export tax or subsidy by commodity
 AVGTE(c,r,clos,sim)    Average commodity export tax rate weighted by trade partner
 TEWT(c,w,r)            Weights used to aggregate export tax rates
 TEWTCHK(c,r)           Check on weights computed

* for land subsidy rates
 LTAXREV(a,r,clos,sim)  Tax revenue or subsidy expenditure on land
 LANDRATE(a,r,clos,sim) Land tax as a share of output

 TAXshares(stab6,r,clos,sim)  Structure of tax revenue

 ;

If(flow_cont("restaxstr") = 1,

$INCLUDE anar1_restaxstr.inc

  ) ;
* ------- CALCULATE AND WRITE OUT PERCENTAGE CHANGE RESULTS ----------
$ontext
This $INCLUDE file generates and exports the proportionate change results
for ALL variables to GDX as 'womod_respercent.gdx'

NB The same parameter names are used as for the levels results

'womod_respercent.gdx' is the default name for the results file
its name can be changed in the $INCLUDE file
$offtext



*If(flow_cont("resperc") = 1,


$INCLUDE anar1_resperc.inc

*  ) ;

* -------------- END of ANAR1 results Analysis file -----------------------
