* ----------------- ANAR1 Welfare Results ---------------------------------


*--------- SUMMARY WELFARE MEASURES -------------

 resEV(h,r,clos,simr)$rgn(r)
      = (PROD(c,((PQD0(c,r)*(1+TV0(c,r)))
             /(resPQD(c,r,clos,simr)*(1+resTV(c,r,clos,simr))))**beta(c,h,r)))
             *(resHEXP(h,r,clos,simr) -SUM(c,qcdconst(c,h,r)
                  *(resPQD(c,r,clos,simr)*(1+resTV(c,r,clos,simr)))))
              -(HEXP0(h,r)-SUM(c,qcdconst(c,h,r)
                    * (PQD0(c,r))*(1+TV0(c,r)))) ;

 resEV_cap(h,r,clos,simr)$(pop(h,r) and rgn(r))
                   = resEV(h,r,clos,simr)/pop(h,r) ;

$ontext
IC and EV formulas from Blonigen, Bruce A., Joseph E. Flynn, and
Kenneth A. Reinert (1997) Sector-Focused General Equilibrium Modeling,
in eds. Joseph F. Francois and Kenneth A. Reinert, Applied Methods
for Trade Policy Analysis. Cambridge, MA: Cambridge University Press,
pp. 189-230.
$offtext

 resIC(h,r,clos,simr)$rgn(r)
      = ((resHEXP(h,r,clos,simr)
           - SUM(c,(resPQD(c,r,clos,simr)*(1+resTV(c,r,clos,simr)))
                   *qcdconst(c,h,r)))
                /(PROD(c,(resPQD(c,r,clos,simr)*(1+resTV(c,r,clos,simr)))
                         **beta(c,h,r))))
                   * (PROD(c,(PQD0(c,r)*(1+TV0(c,r)))**beta(c,h,r)))
                     + (SUM(c,(PQD0(c,r)*(1+TV0(c,r)))*qcdconst(c,h,r))) ;

 resIC_cap(h,r,clos,simr)$(pop(h,r) and rgn(r))
                    =  resIC(h,r,clos,simr)/pop(h,r) ;

 resEV_alt(h,r,clos,simr)$rgn(r)
                    = resIC(h,r,clos,simr) - HEXP0(h,r) ;

 resEV_alt_cap(h,r,clos,simr)$(pop(h,r) and rgn(r))
                    =  resEV_alt(h,r,clos,simr)/pop(h,r) ;

*--------- SLUTSKY WELFARE MEASURES -------------

 resEV_H_slut(h,r,clos,simr)$rgn(r)
      = SUM(c,(PQD0(c,r)*(1+TV0(c,r))) * resQCD(c,h,r,clos,simr))
          - HEXP0(h,r) ;

 resEV_R_slut(r,clos,simr)$rgn(r)
      = (SUM(c,(PQD0(c,r)*(1+TV0(c,r))) * SUM(h,resQCD(c,h,r,clos,simr)))
          + SUM(c,PQD0(c,r)
               * (resQGD(c,r,clos,simr) + resQINVD(c,r,clos,simr))))
          - (SUM(h,HEXP0(h,r))+ SUM(c,PQD0(c,r)*(QGD0(c,r)+QINVD0(c,r)))) ;

 resEV_H_slut(h,r,clos,simr)$rgn(r)
      = SUM(c,PQD0(c,r)*(1+TV0(c,r)) * resQCD(c,h,r,clos,simr))
          - HEXP0(h,r) ;

Display  resEV, resEV_cap, resIC, resIC_cap, resEV_alt, resEV_alt_cap,
         resEV_H_slut, resEV_R_slut ;


* ------- Exporting Welfare Results to GDX -------------------------------

* This writes the results data to GDX

Execute_Unload  'results/anar1_reswelf.gdx', resEV
                                     resEV_cap
                                     resIC
                                     resIC_cap
                                     resEV_alt
                                     resEV_alt_cap

                                     resEV_H_slut
                                     resEV_R_slut

  ;

* ----------------- End of anar1 Welfare Results --------------------------
