* ----------------- ANAR1 Tax Tables for Aggregates------------------------


* ------- 2. Assign Aggregate Tax Tables ------------------------------------

 TMWT(w,c,r)$(SUM(wp,PWM0(wp,c,r)*QMR0(wp,c,r)) )
                       = (PWM0(w,c,r)*QMR0(w,c,r))/
                         SUM(wp,PWM0(wp,c,r)*QMR0(wp,c,r)) ;

 AVGTM(c,r,clos,simr)   = SUM(w, resTM(w,c,r,clos,simr)*TMWT(w,c,r)) ;

 TMWTCHK(c,r)          = SUM(w, TMWT(w,c,r)) ;

 TEWT(c,w,r)$(SUM(wp,PWE0(c,wp,r)*QER0(c,wp,r)) )
                       = (PWE0(c,w,r)*QER0(c,w,r))/
                         SUM(wp,PWE0(c,wp,r)*QER0(c,wp,r)) ;
 AVGTE(c,r,clos,simr)   = SUM(w, resTE(c,w,r,clos,simr)*TEWT(c,w,r)) ;

 TEWTCHK(c,r)          = SUM(w, TEWT(c,w,r)) ;

 LTAXREV(a,r,clos,simr) = resTF("fland",a,r,clos,simr)*resWF("fland",r,clos,simr)
                      *resWFDIST("fland",a,r,clos,simr)*resFD("fland",a,r,clos,simr) ;

 LANDRATE(a,r,clos,simr)$(resPX(a,r,clos,simr)*resQX(a,r,clos,simr))
                       = LTAXREV(a,r,clos,simr)/
                         (resPX(a,r,clos,simr)*resQX(a,r,clos,simr)) ;

 TAXshares("stMTAX",r,clos,simr)$resYG(r,clos,simr)
                             = resMTAX(r,clos,simr)/resYG(r,clos,simr) ;
 TAXshares("stETAX",r,clos,simr)$resYG(r,clos,simr)
                             = resETAX(r,clos,simr)/resYG(r,clos,simr) ;
 TAXshares("stSTAX",r,clos,simr)$resYG(r,clos,simr)
                             = resSTAX(r,clos,simr)/resYG(r,clos,simr) ;
 TAXshares("stITAX",r,clos,simr)$resYG(r,clos,simr)
                             = resITAX(r,clos,simr)/resYG(r,clos,simr) ;
 TAXshares("stFYTAX",r,clos,simr)$resYG(r,clos,simr)
                             = resFYTAX(r,clos,simr)/resYG(r,clos,simr) ;
 TAXshares("stHTAX",r,clos,simr)$resYG(r,clos,simr)
                             = resHTAX(r,clos,simr)/resYG(r,clos,simr) ;
 TAXshares("stFTAX",r,clos,simr)$resYG(r,clos,simr)
                             = resFTAX(r,clos,simr)/resYG(r,clos,simr) ;

 Display TMWTCHK, TEWTCHK, TEWT, TMWT, TE.L, TAXshares ;

* ------- Exporting Aggregate Tax Tables to GDX -----------------------------

* This writes the results data to GDX

Execute_Unload  'results/anar1_restaxstr.gdx',

 AVGTM,
 AVGTE,
 LTAXREV,
 LANDRATE,
 TAXshares

   ;

* ----------------- End of anar1 Tax Tables for Aggregates-----------------