Help me in CES, CET estimate, please

Solver related questions
Nguyen Xuan
User
User
Posts: 6
Joined: 1 week ago

Help me in CES, CET estimate, please

Post by Nguyen Xuan » 1 week ago

123
Last edited by Nguyen Xuan 1 week ago, edited 1 time in total.

User avatar
Renger
Posts: 353
Joined: 2 years ago

Re: Help me in CES, CET estimate, please

Post by Renger » 1 week ago

Hi
It is hard to help you with your question as you don't post any code. Please read the rules of the forum.
Cheers
Renger
____________________________________
Enjoy modeling even more: The lazy economist

Nguyen Xuan
User
User
Posts: 6
Joined: 1 week ago

Re: Help me in CES, CET estimate, please

Post by Nguyen Xuan » 1 week ago

Code: Select all

option limcol=0, limrow=0;
$offsymxref offsymlist
$offlisting
option solprint = off;
option reslim = 20000;
option iterlim = 20000;


set   row        SAM row     /C1*C41,TOTAL_C,LABOR_1*LABOR_6,CAP,
                              HOH_1*HOH_20,VAT,DIR,M_TARIFF,X_DUTY,STATE,SAV_INV,
                              STOCK,EXPORT,TOTAL,EXP_TAX,IMP_TAX,IMPORT/
      col_para   Para col    /CES,CET/
      i(row)     sector      /C1*C41/
      nL(row)    labor_r     /LABOR_1*LABOR_6/
      nH(row)    household_r /HOH_1*HOH_20/
      z                      /LOW,CENTRAL,HIGH/
      zp                     /LOW,CENTRAL,HIGH/
*      t                      /2000,2003,2007,2011,2012/
      t                      /2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017/

      oth                    /G_revenue/
;
alias(row,col),(i,j),(nL,mL),(nH,mH);

table SAM(row,col)       SOCIAL ACCOUNTING MATRIX
(Here is Data of SAM )

;

table    PARA(i,col_para)    ELASTICITY PARAMETERS mozambique
                 CES             CET
C1               2.0             2.0
C2               2.0             2.0
C3               2.0             2.0
C4               2.0             2.0
C5               2.0             2.0
C6               2.0             2.0
C7               2.0             2.0
C8               2.0             2.0
C9               2.0             2.0
C10              2.0             2.0
C11              2.0             2.0
C12              2.0             2.0
C13              2.0             2.0
C14              2.0             2.0
C15              2.0             2.0
C16              2.0             2.0
C17              2.0             2.0
C18              2.0             2.0
C19              2.0             2.0
C20              2.0             2.0
C21              2.0             2.0
C22              2.0             2.0
C23              2.0             2.0
C24              2.0             2.0
C25              2.0             2.0
C26              2.0             2.0
C27              2.0             2.0
C28              2.0             2.0
C29              2.0             2.0
C30              2.0             2.0
C31              2.0             2.0
C32              2.0             2.0
C33              2.0             2.0
C34              2.0             2.0
C35              2.0             2.0
C36              2.0             2.0
C37              2.0             2.0
C38              2.0             2.0
C39              2.0             2.0
C40              2.0             2.0
C41              2.0             2.0


;

table    PRIOR_CES(i,zp)
           LOW                CENTRAL    HIGH
C1         0.262697051        0.5        0.049912434
C2         0.262697051        0.5        0.049912434
C3         0.262697051        0.5        0.049912434
C4         0.262697051        0.5        0.049912434
C5         0.262697051        0.5        0.049912434
C6         0.262697051        0.5        0.049912434
C7         0.262697051        0.5        0.049912434
C8         0.262697051        0.5        0.049912434
C9         0.262697051        0.5        0.049912434
C10        0.262697051        0.5        0.049912434
C11        0.262697051        0.5        0.049912434
C12        0.262697051        0.5        0.049912434
C13        0.262697051        0.5        0.049912434
C14        0.262697051        0.5        0.049912434
C15        0.262697051        0.5        0.049912434
C16        0.262697051        0.5        0.049912434
C17        0.262697051        0.5        0.049912434
C18        0.262697051        0.5        0.049912434
C19        0.262697051        0.5        0.049912434
C20        0.262697051        0.5        0.049912434
C21        0.262697051        0.5        0.049912434
C22        0.262697051        0.5        0.049912434
C23        0.262697051        0.5        0.049912434
C24        0.262697051        0.5        0.049912434
C25        0.262697051        0.5        0.049912434
C26        0.262697051        0.5        0.049912434
C27        0.262697051        0.5        0.049912434
C28        0.262697051        0.5        0.049912434
C29        0.262697051        0.5        0.049912434
C30        0.262697051        0.5        0.049912434
C31        0.262697051        0.5        0.049912434
C32        0.262697051        0.5        0.049912434
C33        0.262697051        0.5        0.049912434
C34        0.262697051        0.5        0.049912434
C35        0.262697051        0.5        0.049912434
C36        0.262697051        0.5        0.049912434
C37        0.262697051        0.5        0.049912434
C38        0.262697051        0.5        0.049912434
C39        0.262697051        0.5        0.049912434
C40        0.262697051        0.5        0.049912434
C41        0.262697051        0.5        0.049912434



;

table    PRIOR_CET(i,zp)
           LOW                CENTRAL    HIGH
C1         0.262697051        0.5        0.049912434
C2         0.262697051        0.5        0.049912434
C3         0.262697051        0.5        0.049912434
C4         0.262697051        0.5        0.049912434
C5         0.262697051        0.5        0.049912434
C6         0.262697051        0.5        0.049912434
C7         0.262697051        0.5        0.049912434
C8         0.262697051        0.5        0.049912434
C9         0.262697051        0.5        0.049912434
C10        0.262697051        0.5        0.049912434
C11        0.262697051        0.5        0.049912434
C12        0.262697051        0.5        0.049912434
C13        0.262697051        0.5        0.049912434
C14        0.262697051        0.5        0.049912434
C15        0.262697051        0.5        0.049912434
C16        0.262697051        0.5        0.049912434
C17        0.262697051        0.5        0.049912434
C18        0.262697051        0.5        0.049912434
C19        0.262697051        0.5        0.049912434
C20        0.262697051        0.5        0.049912434
C21        0.262697051        0.5        0.049912434
C22        0.262697051        0.5        0.049912434
C23        0.262697051        0.5        0.049912434
C24        0.262697051        0.5        0.049912434
C25        0.262697051        0.5        0.049912434
C26        0.262697051        0.5        0.049912434
C27        0.262697051        0.5        0.049912434
C28        0.262697051        0.5        0.049912434
C29        0.262697051        0.5        0.049912434
C30        0.262697051        0.5        0.049912434
C31        0.262697051        0.5        0.049912434
C32        0.262697051        0.5        0.049912434
C33        0.262697051        0.5        0.049912434
C34        0.262697051        0.5        0.049912434
C35        0.262697051        0.5        0.049912434
C36        0.262697051        0.5        0.049912434
C37        0.262697051        0.5        0.049912434
C38        0.262697051        0.5        0.049912434
C39        0.262697051        0.5        0.049912434
C40        0.262697051        0.5        0.049912434
C41        0.262697051        0.5        0.049912434



;

table    ACTUAL_YX(i,t)
           2006           2007           2008           2009           2010           2011           2012           2013           2014           2015           2016           2017
(Here is data of XY by 41 sector from 2006-2017)



;

table    SUPPORT_YX(j,z)
            LOW            CENTRAL        HIGH
C1         -1428546        0000000        1428546
C2         -0189448        0000000        0189448
C3         -0594594        0000000        0594594
C4         -0517112        0000000        0517112
C5         -0115906        0000000        0115906
C6         -0683572        0000000        0683572
C7         -0075375        0000000        0075375
C8         -1900290        0000000        1900290
C9         -0102939        0000000        0102939
C10        -1157664        0000000        1157664
C11        -0311135        0000000        0311135
C12        -0240718        0000000        0240718
C13        -0791460        0000000        0791460
C14        -0980967        0000000        0980967
C15        -0341973        0000000        0341973
C16        -0288737        0000000        0288737
C17        -0579508        0000000        0579508
C18        -0359111        0000000        0359111
C19        -1062173        0000000        1062173
C20        -0047416        0000000        0047416
C21        -0022091        0000000        0022091
C22        -0689911        0000000        0689911
C23        -0097750        0000000        0097750
C24        -0272812        0000000        0272812
C25        -0578489        0000000        0578489
C26        -0174857        0000000        0174857
C27        -0056445        0000000        0056445
C28        -0666721        0000000        0666721
C29        -0799246        0000000        0799246
C30        -0048025        0000000        0048025
C31        -0390120        0000000        0390120
C32        -0349408        0000000        0349408
C33        -0009799        0000000        0009799
C34        -0375074        0000000        0375074
C35        -0340141        0000000        0340141
C36        -0417092        0000000        0417092
C37        -0310356        0000000        0310356
C38        -0168606        0000000        0168606
C39        -0197886        0000000        0197886
C40        -0126485        0000000        0126485
C41        -0144843        0000000        0144843



;

table    ACTUAL_GDP(i,t)
           2006           2007           2008           2009           2010           2011           2012           2013           2014           2015           2016           2017
(Here is data of XY by 41 sector from 2006-2017)


;

table    SUPPORT_YGDP(j,z)
           LOW             CENTRAL        HIGH
C1        -0349013         0000000        0349013
C2        -0092663         0000000        0092663
C3        -0061735         0000000        0061735
C4        -0095491         0000000        0095491
C5        -0012578         0000000        0012578
C6        -0156869         0000000        0156869
C7        -0018804         0000000        0018804
C8        -0158545         0000000        0158545
C9        -0039780         0000000        0039780
C10       -0248104         0000000        0248104
C11       -0072606         0000000        0072606
C12       -0037453         0000000        0037453
C13       -0062284         0000000        0062284
C14       -0153977         0000000        0153977
C15       -0080094         0000000        0080094
C16       -0062601         0000000        0062601
C17       -0082462         0000000        0082462
C18       -0050104         0000000        0050104
C19       -0067024         0000000        0067024
C20       -0009306         0000000        0009306
C21       -0002501         0000000        0002501
C22       -0036791         0000000        0036791
C23       -0012750         0000000        0012750
C24       -0012684         0000000        0012684
C25       -0053900         0000000        0053900
C26       -0090576         0000000        0090576
C27       -0023141         0000000        0023141
C28       -0112462         0000000        0112462
C29       -0329165         0000000        0329165
C30       -0011518         0000000        0011518
C31       -0104513         0000000        0104513
C32       -0058124         0000000        0058124
C33       -0006185         0000000        0006185
C34       -0093218         0000000        0093218
C35       -0141990         0000000        0141990
C36       -0185278         0000000        0185278
C37       -0080389         0000000        0080389
C38       -0063697         0000000        0063697
C39       -0116029         0000000        0116029
C40       -0033832         0000000        0033832
C41       -0044257         0000000        0044257



;

table    ACTUAL_YM(i,t)
           2006           2007           2008           2009           2010           2011           2012           2013           2014           2015           2016           2017
(Here is data of YM by 41 sector from 2006-2017)
;
table    SUPPORT_YM(j,z)
           LOW             CENTRAL        HIGH
C1         -0175733        0000000        0175733
C2         -0.000108       0.00000        0.000108
C3         -0047392        0000000        0047392
C4         -0028614        0000000        0028614
C5         -0022892        0000000        0022892
C6         -0023926        0000000        0023926
C7         -0048427        0000000        0048427
C8         -0149740        0000000        0149740
C9         -0008045        0000000        0008045
C10        -0407924        0000000        0407924
C11        -0013696        0000000        0013696
C12        -0043021        0000000        0043021
C13        -0118107        0000000        0118107
C14        -0535956        0000000        0535956
C15        -0024168        0000000        0024168
C16        -0180811        0000000        0180811
C17        -0220743        0000000        0220743
C18        -0037869        0000000        0037869
C19        -0404939        0000000        0404939
C20        -0050577        0000000        0050577
C21        -0019575        0000000        0019575
C22        -0760474        0000000        0760474
C23        -0.000108       0.000000       0.000108
C24        -0124969        0000000        0124969
C25        -0542444        0000000        0542444
C26        -0004661        0000000        0004661
C27        -0000006        0000000        0000006
C28        -0.000108       0.000000       0.000108
C29        -0002923        0000000        0002923
C30        -0023067        0000000        0023067
C31        -0011440        0000000        0011440
C32        -0033778        0000000        0033778
C33        -0010771        0000000        0010771
C34        -0031819        0000000        0031819
C35        -0044548        0000000        0044548
C36        -0146508        0000000        0146508
C37        -0004376        0000000        0004376
C38        -0.000108       0.000000       0.000108
C39        -0043100        0000000        0043100
C40        -0019719        0000000        0019719
C41        -0008621        0000000        0008621


;

table    ACTUAL_YE(i,t)
           2006           2007           2008           2009           2010           2011           2012           2013           2014           2015           2016           2017
(Here is data of XE by 41 sector from 2006-2017)

;
table    SUPPORT_YE(j,z)
           LOW             CENTRAL        HIGH
C1         -0206528        0000000        0206528
C2         -0.000108       0.000000       0.000108
C3         -0182295        0000000        0182295
C4         -0100609        0000000        0100609
C5         -0028262        0000000        0028262
C6         -0109844        0000000        0109844
C7         -0024320        0000000        0024320
C8         -0170769        0000000        0170769
C9         -0014417        0000000        0014417
C10        -0706057        0000000        0706057
C11        -0291393        0000000        0291393
C12        -0012600        0000000        0012600
C13        -0031431        0000000        0031431
C14        -0211549        0000000        0211549
C15        -0056109        0000000        0056109
C16        -0075211        0000000        0075211
C17        -0079047        0000000        0079047
C18        -0155964        0000000        0155964
C19        -1047514        0000000        1047514
C20        -0018997        0000000        0018997
C21        -0015272        0000000        0015272
C22        -0363746        0000000        0363746
C23        -0.000108       0.000000       0.000108
C24        -0086865        0000000        0086865
C25        -0385656        0000000        0385656
C26        -2745518        0000000        2745518
C27        -0.000108       0.000000       0.000108
C28        -0.000108       0.000000       0.000108
C29        -0173700        0000000        0173700
C30        -0000673        0000000        0000673
C31        -0046683        0000000        0046683
C32        -0083825        0000000        0083825
C33        -0025639        0000000        0025639
C34        -0136514        0000000        0136514
C35        -0013449        0000000        0013449
C36        -0018406        0000000        0018406
C37        -0002045        0000000        0002045
C38        -0.000108       0.000000       0.000108
C39        -0011077        0000000        0011077
C40        -0011586        0000000        0011586
C41        -0005534        0000000        0005534


;


table    ACTUAL_YC(i,t)
           2006           2007           2008           2009           2010           2011           2012           2013           2014           2015           2016           2017
(Here is data of YC by 41 sector from 2006-2017)

;
table    SUPPORT_YC(j,z)
           LOW            CENTRAL        HIGH
C1        -0326085        0000168        0326085
C2        -0002797        0000169        0002797
C3        -0161329        0000170        0161329
C4        -0118668        0000171        0118668
C5        -0038595        0000172        0038595
C6        -0061541        0000173        0061541
C7        -0010853        0000174        0010853
C8        -0286464        0000175        0286464
C9        -0071100        0000176        0071100
C10       -0048409        0000177        0048409
C11       -0026608        0000178        0026608
C12       -0006281        0000179        0006281
C13       -0027491        0000180        0027491
C14       -0036636        0000181        0036636
C15       -0009299        0000182        0009299
C16       -0000998        0000183        0000998
C17       -0004544        0000184        0004544
C18       -0013991        0000185        0013991
C19       -0012671        0000186        0012671
C20       -0001280        0000187        0001280
C21       -0019404        0000188        0019404
C22       -0090758        0000189        0090758
C23       -0003364        0000190        0003364
C24       -0060754        0000191        0060754
C25       -0013799        0000192        0013799
C26       -0026328        0000193        0026328
C27       -0015701        0000194        0015701
C28       -0047643        0000195        0047643
C29       -0128209        0000196        0128209
C30       -0014176        0000197        0014176
C31       -0083942        0000198        0083942
C32       -0141547        0000199        0141547
C33       -0.000108       0.000000       0.000108
C34       -0123111        0000201        0123111
C35       -0071493        0000202        0071493
C36       -0123819        0000203        0123819
C37       -0169225        0000204        0169225
C38       -0006194        0000205        0006194
C39       -0190199        0000206        0190199
C40       -0105739        0000207        0105739
C41       -0116421        0000208        0116421



;

table    ACTUAL_YG(i,t)
           2006            2007            2008            2009            2010            2011            2012            2013            2014            2015            2016            2017
(Here is data of YG by 41 sector from 2006-2017)

;
table    SUPPORT_YG(j,z)
           LOW              CENTRAL         HIGH
C1         -0.000108        0.000000        0.000108
C2         -0.000108        0.000000        0.000108
C3         -0.000108        0.000000        0.000108
C4         -0.000108        0.000000        0.000108
C5         -0.000108        0.000000        0.000108
C6         -0.000108        0.000000        0.000108
C7         -0.000108        0.000000        0.000108
C8         -0.000108        0.000000        0.000108
C9         -0.000108        0.000000        0.000108
C10        -0.000108        0.000000        0.000108
C11        -0.000108        0.000000        0.000108
C12        -0.000108        0.000000        0.000108
C13        -0.000108        0.000000        0.000108
C14        -0.000108        0.000000        0.000108
C15        -0.000108        0.000000        0.000108
C16        -0.000108        0.000000        0.000108
C17        -0.000108        0.000000        0.000108
C18        -0.000108        0.000000        0.000108
C19        -0.000108        0.000000        0.000108
C20        -0.000108        0.000000        0.000108
C21        -0.000108        0.000000        0.000108
C22        -0.000108        0.000000        0.000108
C23        -0.000108        0.000000        0.000108
C24        -0.000108        0.000000        0.000108
C25        -0.000108        0.000000        0.000108
C26        -0.000108        0.000000        0.000108
C27        -0.000108        0.000000        0.000108
C28        -0.000108        0.000000        0.000108
C29        -0.000108        0.000000        0.000108
C30        -0.000108        0.000000        0.000108
C31        -0.000108        0.000000        0.000108
C32        -0032451         0000000         0032451
C33        -0.000108        0.000000        0.000108
C34        -0.000108        0.000000        0.000108
C35        -0009549         0000000         0009549
C36        -0.000108        0.000000        0.000108
C37        -0.000108        0.000000        0.000108
C38        -0161649         0000000         0161649
C39        -0036117         0000000         0036117
C40        -0022895         0000000         0022895
C41        -0013865         0000000         0013865



;

table    ACTUAL_YI(i,t)
           2006            2007            2008            2009            2010            2011            2012            2013            2014            2015            2016            2017
(Here is data of YI by 41 sector from 2006-2017)


;

table    SUPPORT_YI(j,z)
           LOW              CENTRAL         HIGH
C1         -0022508         0000000         0022508
C2         -0.000108        0.000000        0.000108
C3         -0.000108        0.000000        0.000108
C4         -0.000108        0.000000        0.000108
C5         -0.000108        0.000000        0.000108
C6         -0.000108        0.000000        0.000108
C7         -0.000108        0.000000        0.000108
C8         -0.000108        0.000000        0.000108
C9         -0.000108        0.000000        0.000108
C10        -0.000108        0.000000        0.000108
C11        -0.000108        0.000000        0.000108
C12        -0.000108        0.000000        0.000108
C13        -0.000108        0.000000        0.000108
C14        -0.000108        0.000000        0.000108
C15        -0.000108        0.000000        0.000108
C16        -0.000108        0.000000        0.000108
C17        -0.000108        0.000000        0.000108
C18        -0013272         0000000         0013272
C19        -0016659         0000000         0016659
C20        -0.000108        0.000000        0.000108
C21        -0.000108        0.000000        0.000108
C22        -0088093         0000000         0088093
C23        -0.000108        0.000000        0.000108
C24        -0120448         0000000         0120448
C25        -0018990         0000000         0018990
C26        -0.000108        0.000000        0.000108
C27        -0.000108        0.000000        0.000108
C28        -0484242         0000000         0484242
C29        -0017351         0000000         0017351
C30        -0001774         0000000         0001774
C31        -0003374         0000000         0003374
C32        -0000298         0000000         0000298
C33        -0.000108        0.000000        0.000108
C34        -0.000108        0.000000        0.000108
C35        -0.000108        0.000000        0.000108
C36        -0.000108        0.000000        0.000108
C37        -0.000108        0.000000        0.000108
C38        -0.000108        0.000000        0.000108
C39        -0.000108        0.000000        0.000108
C40        -0.000108        0.000000        0.000108
C41        -0.000108        0.000000        0.000108

;

table    Kstock(i,t)
           2006           2007           2008           2009           2010           2011           2012           2013           2014           2015           2016           2017
(Here is data of KSTOCK by 41 sector from 2006-2017)
;

table    Table_Lbar(nL,t)
               2006           2007           2008           2009           2010           2011           2012           2013           2014           2015           2016           2017
(Here is data of Lbar by 6 labors  from 2006-2017)
;

table    Other(oth,t)
                 2006           2007           2008           2009           2010           2011           2012           2013           2014           2015           2016           2017
(Here is data of G_revenue by   from 2006-2017)


;
*Loading the initial value-----------------------------------------------------

parameter        L_0(nL,j)       Labor factor used for production
                 K_0(j)          Capital factor used for production

                 M_value(j)      Import value before tax
                 E_value(j)      Export value
                 M_0(i)          Import amount
                 E_0(i)          Export

                 mtax_value(i)
                 etax_value(i)

                 Lbar(nL,t)      Labor supply
                 Fpbar(nH)       Foreign transfer to households

                 VA_0(j)         Value added
                 C_0(i,mH)       Household consumption
                 G_0(i)          Government consumption
                 X_0(j)          Total output
                 Inv_0(i)        Investment

                 Stock_0(j)      Changes in stock of curent aset

                 Q_0(i)          Total demand for domestic consumption

                 Interm_0(i,j)   Intermediate input
                 dtaxL(mL)       Direct tax rate on labor
                 dtaxK           Direct tax rate on capital
                 itax(j)         Initial Indirect tax rate
                 mtax(i,t)       Import tax rate
                 etax(i,t)       Export tax rate
                 D_0(i)          Total demand for domestic good
                 Y_0(mH)         Household income
                 dL(nH,mL)       Distribution rate for labor income
                 dK(nH)          Distribution rate for capital income
                 dT(nH)          Distribution rate for government transfer
                 Kbar(j,t)       Stock of capital
                 PWmbar(j)       World price of import good
                 PWebar(j)       World price of export good
                 H_DEB_bar(nH)   Foreign debt incurred by household




                 YX(j,t)
                 YGDP(j,t)
                 YM(j,t)
                 YE(j,t)
                 YC(j,t)
                 YG_budget(t)
                 YG(j,t)
                 YI(j,t)

;

scalar           Fgbar           Foreign transfer to government
                 FDIbar          Foreign investment
                 Tbar            Total government revenue
                 tr              Government transfer rate
                 T_inv_0         Total investment
                 T_itax_0        Total VAT
                 istar

                 TotalStock              Total Stock
;

istar            = 0.06;
L_0(nL,j)        = SAM(nL,j);
K_0(j)           = SAM("CAP",j);
M_value(j)       = SAM(j,"IMPORT");
mtax_value(i)    = SAM(i,"IMP_TAX");
E_Value(i)       = SAM(i,"EXPORT");
etax_value(i)    = SAM(i,"EXP_TAX");
Lbar(nL,t)       = Table_Lbar(nL,t);
Fpbar(nH)        = SAM(nH,"EXPORT");
VA_0(j)          = sum(nL,L_0(nL,j))+SAM("CAP",j);
C_0(i,mH)        = SAM(i,mH);
G_0(i)           = SAM(i,"STATE");
X_0(j)           = SAM("TOTAL",j);
Inv_0(i)         = SAM(i,"SAV_INV");

Stock_0(j)       = SAM(j,"STOCK");
TotalStock       = sum(j,stock_0(j));

*Q_0(i)           = SAM(i,"TOTAL_C")+ sum(mH,C_0(i,mH))+G_0(i)+Inv_0(i);

Q_0(i)           = SAM(i,"TOTAL_C")+ sum(mH,C_0(i,mH))+G_0(i)+Inv_0(i)+ stock_0(i);

Interm_0(i,j)    = SAM(i,j);
dtaxL(mL)        = SAM("DIR",mL)/SAM("TOTAL",mL);
dtaxK            = SAM("DIR","CAP")/SAM("TOTAL","CAP");
itax(j)          = SAM("VAT",j)/X_0(j);
Y_0(mH)          = SAM("TOTAL",mH);
dL(nH,mL)        = SAM(nH,mL)/(SAM("TOTAL",mL)*(1-dtaxL(mL)));
dK(nH)           = SAM(nH,"CAP")/(SAM("TOTAL","CAP")*(1-dtaxK));
dT(nH)           = SAM(nH,"STATE")/sum(mH,SAM(mH,"STATE"));
Fgbar            = SAM("STATE","EXPORT");
FDIbar           = SAM("SAV_INV","EXPORT");
Tbar             = SAM("STATE","TOTAL");
tr               = sum(nH,SAM(nH,"STATE"))/Tbar;
T_inv_0          = SAM("TOTAL","SAV_INV");
T_itax_0         = SAM("STATE","VAT");
Kbar(j,t)        = Kstock(j,t);
PWmbar(j)        = M_value(j)/(M_value(j) + mtax_value(j));
PWebar(j)        = E_value(j)/(E_value(j) - etax_value(j));
H_DEB_bar(nH)    = SAM("EXPORT",nH)/istar;
M_0(j)           = M_value(j)/PWmbar(j);
E_0(j)           = E_value(j)/PWebar(j);
mtax(j,t)        = mtax_value(j)/(PWmbar(j)*M_0(j));
etax(j,t)        = etax_value(j)/(PWebar(j)*E_0(j));
D_0(i)           = Q_0(i)-M_0(i);

YX(j,t)          =  ACTUAL_YX(j,t);
YGDP(j,t)        =  ACTUAL_GDP(j,t);
YM(j,t)          =  ACTUAL_YM(j,t);
YE(j,t)          =  ACTUAL_YE(j,t) ;
YC(j,t)          =  ACTUAL_YC(j,t) ;
YG_budget(t)     =  Other("G_revenue",t);
YG(j,t)          =  ACTUAL_YG(j,t) ;
YI(j,t)          =  ACTUAL_YI(j,t) ;

*Calibration-------------------------------------------------------------------

parameter        qq_ces(i,zp)     Prior parameter distribution for CES
                 qq_cet(i,zp)     Prior parameter distribution for CET
                 zz_ces(zp)       Support space for CES parameter
                 zz_cet(zp)       Support space for CET parameter

                 uu(z)            Prior error

                 vvX(j,z)         support space for error
                 vvGDP(j,z)       Support space for error
                 vvM(j,z)         Support space for error
                 vvE(j,z)         Support space for error
                 vvC(j,z)         Support space for error
                 vvG(j,z)
                 vvI(j,z)
                 vvG_budget(z)

                 sigma_0(i)      CES parameter
                 phi_0(i)        CET parameter
                 sp(mH)          household saving rate
                 sg              government saving rate
                 betaL(nL,j)     labor elasticity of production
                 betaK(j)        capital elasticity of production
                 Abar(j)         Efficiency parameter for production function
                 v(j)            value added parameter
                 alpha(i,mH)     consumption share parameter
                 h(i)            Investment share
                 k(i)            Government consumption share
                 delta(i)        CES share parameter
                 Bbar(i)         Efficiency parameter for CES function
                 a(i,j)          intermediate input parameter
                 S_0(i)          Supply for domestic used
                 gama(i)         CET share parameter
                 Nbar(i)         Efficiency parameter for CET function

;
qq_ces(i,zp)              = PRIOR_CES(i,zp);
qq_cet(i,zp)              = PRIOR_CET(i,zp);

zz_ces("LOW")            =   0.1;
zz_ces("CENTRAL")        =   2.5;
zz_ces("HIGH")           =   14.5;

zz_cet("LOW")            =  0.1;
zz_cet("CENTRAL")        =  2.5;
zz_cet("HIGH")           =  14.5;

uu("LOW")                = 0.15  ;
uu("CENTRAL")            = 0.7  ;
uu("HIGH")               = 0.15  ;

vvX(j,z)                 = SUPPORT_YX(j,z);
vvGDP(j,z)               = SUPPORT_YGDP(j,z);
vvM(j,z)                 = SUPPORT_YM(j,z);
vvE(j,z)                 = SUPPORT_YE(j,z);
vvC(j,z)                 = SUPPORT_YC(j,z);
vvG(j,z)                 = SUPPORT_YG(j,z);
vvI(j,z)                 = SUPPORT_YI(j,z);


*vvG_budget("LOW")        = -450000 ;
*vvG_budget("CENTRAL")    =  0  ;
*vvG_budget("HIGH")       =  450000  ;


vvG_budget("LOW")        = -0941543;
vvG_budget("CENTRAL")    =  0  ;
vvG_budget("HIGH")       = -0941543;

sigma_0(i)       = PARA(i,"CES");
phi_0(i)         = PARA(i,"CET");
sp(nH)           = 1-(sum(i,C_0(i,nH))+H_DEB_bar(nH)*istar)/Y_0(nH);
sg               = 1-sum(i,G_0(i))/((1-tr)*Tbar);
betaL(nL,j)      = L_0(nL,j)/VA_0(j);
betaK(j)         = 1-sum(nL,betaL(nL,j));
Abar(j)          = VA_0(j)/(prod(nL,L_0(nL,j)**betaL(nL,j))*K_0(j)**betaK(j));
v(j)             = VA_0(j)/X_0(j);
alpha(i,nH)      = C_0(i,nH)/(((1-sp(nH))*Y_0(nH))-H_DEB_bar(nH)*istar);
h(i)             = Inv_0(i)/T_inv_0;
k(i)             = G_0(i)/((1-sg)*(1-tr)*Tbar);
delta(i)         = 1/(1+(M_0(i)/D_0(i))**(1/sigma_0(i)));
Bbar(i)          = (delta(i)**sigma_0(i)+(1-delta(i))**sigma_0(i))**(1/(1-sigma_0(i)));
a(i,j)           = interm_0(i,j)/X_0(j);
S_0(i)           = D_0(i);
gama(i)          = 1/(1+(S_0(i)/E_0(i))**(1/phi_0(i)));
Nbar(i)          = (gama(i)**(-phi_0(i))+(1-gama(i))**(-phi_0(i)))**(1/(1+phi_0(i)));


*defining model system---------------------------------------------------------
positive Variable
                 X(j,t)            Output of sector j
                 Interm(i,j,t)     Intermediate input
                 L(nL,j,t)         Labor demand
                 VA(j,t)           Value aded
                 Profit(j,t)       Profit
                 Y(nH,t)           Household income
                 C(j,nH,t)         Household consumption
                 Total_C(j,t)
                 G(j,t)            Government consumption
                 Inv(j,t)          Investment
                 Q(j,t)            Total domestic demand
                 D(j,t)            Demand for domestic goods
                 M(j,t)            Import
                 E(j,t)            Export
                 S(j,t)            Supply for domestic usage
                 W(nL,t)           Wage rate
                 PD(j,t)           Price of domestic good
                 PM(j,t)           Price of import good
                 PE(j,t)           Price of export good
                 P(j,t)            Price of composite good
                 Pstar(j,t)        Aggregate price of output
                 ER(t)             Exchange rate
                 PV(j,t)           Price of value added
                 PI(t)             Price index of investment basket
                 PG(t)             Price index of government consumption basket
                 G_budget(t)

                 sigma(j)
                 phi(j)

                 pp_ces(j,zp)
                 pp_cet(j,zp)

                 wwX(j,z,t)
                 wwGDP(j,z,t)
                 wwM(j,z,t)
                 wwE(j,z,t)
                 wwC(j,z,t)
                 wwG_budget(z,t)
                 wwG(j,z,t)
                 wwI(j,z,t)


;
Variable         HH               Objective variable
                 eeX(j,t)
                 eeGDP(j,t)
                 eeM(j,t)
                 eeE(j,t)
                 eeC(j,t)
                 eeG_budget(t)
                 eeG(j,t)
                 eeI(j,t)
;

Equation         eqL(nL,j,t)       Labor demand function
                 eqVA(j,t)         Cobb-Douglas production function
                 eqX(j,t)          Leontief production function
                 eqInterm(i,j,t)   Intermediate demand function
                 eqprofit(j,t)     Profit function
                 eqG_budget(t)
*                 eqT_itax
*                 eqitax(j)
                 eqY(nH,t)         Household income function
                 eqC(j,nH,t)       Household demand function
                 eqTotal_C(j,t)
                 eqInv(j,t)        Investment demand function
                 eqG(j,t)          Government demand function
                 eqQ(j,t)
                 eqD(j,t)
                 eqM(j,t)
                 eqE(j,t)
                 eqS(j,t)
                 eqL_clear(nL,t)   Labor market clearing condition
                 eqDS_clear(j,t)   Commodity market clearing condition
                 eqF_clear(t)      Foreign exchange market clearing condition
                 eqPM(j,t)
                 eqPE(j,t)
                 eqP(j,t)
                 eqPstar(j,t)
                 eqPrice_norm(t)
                 eqPV(j,t)
                 eqPI(t)
                 eqPG(t)

                 eqsigma(j)
                 eqphi(j)

                 eqpp_ces(j)
                 eqpp_cet(j)
                 eqeeX(j,t)
                 eqeeGDP(j,t)
                 eqeeM(j,t)
                 eqeeE(j,t)
                 eqeeC(j,t)
                 eqeeG_budget(t)
                 eqeeG(j,t)
                 eqeeI(j,t)

                 eqwwX(j,t)
                 eqwwGDP(j,t)
                 eqwwM(j,t)
                 eqwwE(j,t)
                 eqwwC(j,t)
                 eqwwG_budget(t)
                 eqwwG(j,t)
                 eqwwI(j,t)

                 eqYX(j,t)
                 eqYGDP(j,t)
                 eqYM(j,t)
                 eqYE(j,t)
                 eqYC(j,t)
                 eqYG_budget(t)
                 eqYG(j,t)
                 eqYI(j,t)

                 obj             Objective function
;
*****************************************************************************
eqsigma(j)..     sigma(j)        =e= sum(zp,pp_ces(j,zp)*zz_ces(zp));
eqphi(j)..       phi(j)          =e= sum(zp,pp_cet(j,zp)*zz_cet(zp));

eqpp_ces(j)..    sum(zp,pp_ces(j,zp))  =e= 1;
eqpp_cet(j)..    sum(zp,pp_cet(j,zp))  =e= 1;

eqeeX(j,t)..       eeX(j,t)          =e= sum(z,wwX(j,z,t)*vvX(j,z));
eqeeGDP(j,t)..     eeGDP(j,t)        =e= sum(z,wwGDP(j,z,t)*vvGDP(j,z));
eqeeM(j,t)..       eeM(j,t)          =e= sum(z,wwM(j,z,t)*vvM(j,z));
eqeeE(j,t)..       eeE(j,t)          =e= sum(z,wwE(j,z,t)*vvE(j,z));
eqeeC(j,t)..       eeC(j,t)          =e= sum(z,wwC(j,z,t)*vvC(j,z));
eqeeG(j,t)..       eeG(j,t)          =e= sum(z,wwG(j,z,t)*vvG(j,z));
eqeeI(j,t)..       eeI(j,t)          =e= sum(z,wwI(j,z,t)*vvI(j,z));
eqeeG_budget(t)..  eeG_budget(t)     =e= sum(z,wwG_budget(z,t)*vvG_budget(z));


eqwwX(j,t)..       sum(z,wwX(j,z,t))  =e= 1;
eqwwGDP(j,t)..     sum(z,wwGDP(j,z,t))=e= 1;
eqwwM(j,t)..       sum(z,wwM(j,z,t))  =e= 1;
eqwwE(j,t)..       sum(z,wwE(j,z,t))  =e= 1;
eqwwC(j,t)..       sum(z,wwC(j,z,t))  =e= 1;
eqwwG_budget(t)..  sum(z,wwG_budget(z,t))    =e= 1;
eqwwG(j,t)..       sum(z,wwG(j,z,t))  =e= 1;
eqwwI(j,t)..       sum(z,wwI(j,z,t))  =e= 1;


eqYX(j,t)..        YX(j,t)         =e= X(j,t)            + eeX(j,t);
eqYGDP(j,t)..      YGDP(j,t)       =e= VA(j,t)           + eeGDP(j,t) ;
eqYM(j,t)..        YM(j,t)         =e= M(j,t)            + eeM(j,t);
eqYE(j,t)..        YE(j,t)         =e= E(j,t)            + eeE(j,t);
eqYC(j,t)..        YC(j,t)         =e= Total_C(j,t)      + eeC(j,t);
eqYG_budget(t)..   YG_budget(t)    =e= G_budget(t)       + eeG_budget(t);
eqYG(j,t)..        YG(j,t)         =e= G(j,t)            + eeG(j,t);
eqYI(j,t)..        YI(j,t)         =e= Inv(j,t)          + eeI(j,t);
*****************************************************************************

* Production block

eqL(nL,j,t)..      L(nL,j,t)         =e= (PV(j,t)/W(nL,t))*betaL(nL,j)*VA(j,t);

eqVA(j,t)..        VA(j,t)           =e= Abar(j)*prod(nL,L(nL,j,t)**betaL(nL,j))*
                                     Kbar(j,t)**betaK(j);

eqX(j,t)..         X(j,t)            =e= VA(j,t)/v(j) ;

eqInterm(i,j,t)..  Interm(i,j,t)     =e= a(i,j)*X(j,t);

eqprofit(j,t)..    Profit(j,t)       =e= Pstar(j,t)*(1-itax(j))*X(j,t)-
                                     sum(i,Interm(i,j,t)*P(i,t))-
                                     sum(nL,L(nL,j,t)*W(nL,t));

* Government revenue and household income block

eqG_budget(t)..    G_budget(t)   =e= sum(j,itax(j)*X(j,t))+
                                     sum(nL,Lbar(nL,t)*W(nL,t)*dtaxL(nL))+
                                     sum(j,profit(j,t)*dtaxK)+
                                     sum(j,ER(t)*PWmbar(j)*M(j,t)*mtax(j,t)) +
                                     sum(j,ER(t)*PWebar(j)*E(j,t)*etax(j,t))+ ER(t)*Fgbar;
                                     ;

eqY(nH,t)..        Y(nH,t)           =e= sum(nL,Lbar(nL,t)*W(nL,t)*(1-dtaxL(nL))*
                                     dL(nH,nL))+ sum(j,profit(j,t))*(1-dtaxK)*
                                     dK(nH) + G_budget(t)*tr*dT(nH) + ER(t)*Fpbar(nH);
* Demand block

eqC(j,nH,t)..      C(j,nH,t)         =e= alpha(j,nH)*((1-sp(nH))*Y(nH,t)-H_DEB_bar(nH)*istar)/P(j,t);
eqTotal_C(j,t)..     Total_C(j,t)    =e= sum(nH,C(j,nH,t));

eqInv(j,t)..       Inv(j,t)          =e= (h(j)*(sum(nH,Y(nH,t)*sp(nH))+sg*G_budget(t)*(1-tr)+
                                     ER(t)*FDIbar - TotalStock ))/PI(t);

eqG(j,t)..         G(j,t)            =e= k(j)*((1-sg)*(1-tr)*G_budget(t))/PG(t);

*eqQ(i,t)..         Q(i,t)            =e= sum(j,Interm(i,j,t))+sum(nH,C(i,nH,t))+G(i,t)+
*                                     Inv(i,t);

eqQ(i,t)..         Q(i,t)            =e= sum(j,Interm(i,j,t))+sum(nH,C(i,nH,t))+G(i,t)+
                                     Inv(i,t)+ stock_0(i);


eqD(j,t)..         D(j,t)            =e= (Bbar(j)**(sigma(j)-1))*(delta(j)**sigma(j))
                                     *((PD(j,t)/P(j,t))**(-sigma(j)))*Q(j,t);
eqM(j,t)..         M(j,t)     =e= (Bbar(j)**(sigma(j)-1))*((1-delta(j))**
                                     sigma(j))*((PM(j,t)/P(j,t))**(-sigma(j)))*Q(j,t)
                                     ;
eqE(j,t)..         E(j,t)     =e= (Nbar(j)**(-1-phi(j)))*((1-gama(j))**
                                     (-phi(j)))*((PE(j,t)/Pstar(j,t))**phi(j))*X(j,t)
                                     ;
* Domestic supply block

eqS(j,t)..         S(j,t)            =e= (Nbar(j)**(-1-phi(j)))*(gama(j)**
                                     (-phi(j)))*((PD(j,t)/Pstar(j,t))**phi(j))*X(j,t);
* Market equilibrium block

eqL_clear(nL,t)..  sum(j,L(nL,j,t))  =e= Lbar(nL,t);
eqDS_clear(j+1,t)..  D(j+1,t)        =e= S(j+1,t);
eqF_clear(t)..      sum(j,PWmbar(j)*M(j,t))+istar/ER(t)*sum(nH,H_DEB_bar(nH)) =e=
                    sum(j,PWebar(j)*E(j,t))+ FDIbar + sum(nH,Fpbar(nH))+
                    Fgbar;

* price block

eqPM(j,t)..        PM(j,t)           =e= ER(t)*PWmbar(j)*(1+mtax(j,t));
eqPE(j,t)..        PE(j,t)           =e= ER(t)*PWebar(j)*(1-etax(j,t));

eqP(j,t)..         P(j,t)            =e= (1/Bbar(j))*((delta(j)**sigma(j))*(PD(j,t)**
                                     (1-sigma(j)))+((1-delta(j))**sigma(j))*
                                     (PM(j,t)**(1-sigma(j))))**(1/(1-sigma(j)));
eqPstar(j,t)..     Pstar(j,t)        =e= (1/Nbar(j))*((gama(j)**(-phi(j)))*(PD(j,t)**
                                     (phi(j)+1))+((1-gama(j))**(-phi(j)))*(PE(j,t)**
                                     (phi(j)+1)))**(1/(phi(j)+1));

eqPrice_norm(t)..   sum(j,P(j,t)*(Q(j,t)/sum(i,Q(i,t))))=e= 1;

eqPV(j,t)..        PV(j,t)           =e= (Pstar(j,t)*(1-itax(j))- sum(i,P(i,t)*a(i,j)))
                                     /v(j);
eqPI(t)..           PI(t)              =e= sum(j,h(j)*P(j,t));
eqPG(t)..           PG(t)              =e= sum(j,k(j)*P(j,t));

* Objective function

obj..     HH     =e=   sum(j,sum(zp,pp_ces(j,zp)*log(pp_ces(j,zp)/qq_ces(j,zp))))
                         + sum(j,sum(zp,pp_cet(j,zp)*log(pp_cet(j,zp)/qq_cet(j,zp))))
                         + sum(t,sum(j,sum(z,wwX(j,z,t)*log(wwX(j,z,t)/uu(z)))))
                         + sum(t,sum(j,sum(z,wwGDP(j,z,t)*log(wwGDP(j,z,t)/uu(z)))))
                         + sum(t,sum(j,sum(z,wwM(j,z,t)*log(wwM(j,z,t)/uu(z)))))
                         + sum(t,sum(j,sum(z,wwE(j,z,t)*log(wwE(j,z,t)/uu(z)))))
                         + sum(t,sum(j,sum(z,wwC(j,z,t)*log(wwC(j,z,t)/uu(z)))))
                         + sum(t,sum(z,wwG_budget(z,t)*log(wwG_budget(z,t)/uu(z))))
                         + sum(t,sum(j,sum(z,wwG(j,z,t)*log(wwG(j,z,t)/uu(z)))))
                         + sum(t,sum(j,sum(z,wwI(j,z,t)*log(wwI(j,z,t)/uu(z))))) ;

* Initializing variables------------------------------------------------------

                 X.l(j,t)          = X_0(j);
                 Interm.l(i,j,t)   = Interm_0(i,j);
                 L.l(nL,j,t)       = L_0(nL,j);
                 VA.l(j,t)         = VA_0(j);
                 Y.l(nH,t)         = Y_0(nH);
                 C.l(j,nH,t)       = C_0(j,nH);
                 Total_C.l(j,t)    = sum(nH,C_0(j,nH));
                 G.l(j,t)          = G_0(j);
                 Inv.l(j,t)        = Inv_0(j);
                 Q.l(j,t)          = Q_0(j);
                 D.l(j,t)          = D_0(j);
                 M.l(j,t)          = M_0(j);
                 E.l(j,t)          = E_0(j);
                 S.l(j,t)          = S_0(j);
                 W.l(nL,t)         = 1;
                 PD.l(j,t)         = 1;
                 PM.l(j,t)         = 1;
                 PE.l(j,t)         = 1;
                 P.l(j,t)          = 1;
                 Pstar.l(j,t)      = 1;
                 ER.l(t)           = 1;
                 PV.l(j,t)         = 1;
                 Profit.l(j,t)     = K_0(j);
                 PI.l(t)           = 1;
                 PG.l(t)           = 1;
                 G_budget.l(t)     = Tbar;
                 sigma.l(j)        = sigma_0(j);
                 phi.l(j)          = phi_0(j);
                 pp_ces.l(j,"LOW")     = 0.262697051;
                 pp_ces.l(j,"CENTRAL") = 0.5;
                 pp_ces.l(j,"HIGH")    = 0.049912434;
                 pp_cet.l(j,"LOW")     = 0.262697051;
                 pp_cet.l(j,"CENTRAL") = 0.5;
                 pp_cet.l(j,"HIGH")    = 0.049912434;


                 eeX.l(j,t)        =0;
                 eeGDP.l(j,t)      =0;
                 eeM.l(j,t)        =0;
                 eeE.l(j,t)        =0;
                 eeC.l(j,t)        =0;
                 eeG_budget.l(t)   =0;
                 eeG.l(j,t)        =0;
                 eeI.l(j,t)        =0;

                 wwX.l(j,z,t)      =uu(z);
                 wwGDP.l(j,z,t)    =uu(z);
                 wwM.l(j,z,t)      =uu(z);
                 wwE.l(j,z,t)      =uu(z);
                 wwC.l(j,z,t)      =uu(z);
                 wwG_budget.l(z,t) =uu(z);
                 wwG.l(j,z,t)      =uu(z);
                 wwI.l(j,z,t)      =uu(z);

*Setting lower bounds to avoid division by zero-------------------------------

                 X.lo(j,t)          = 0.0000000000000000000001;
                 Interm.lo(i,j,t)   = 0.0000000000000000000001;
                 L.lo(nL,j,t)       = 0.0000000000000000000001;
                 VA.lo(j,t)         = 0.0000000000000000000001;
                 Y.lo(nH,t)         = 0.0000000000000000000001;
                 C.lo(j,nH,t)       = 0.0000000000000000000001;
                 Total_C.lo(j,t)    = 0.0000000000000000000001;
                 G.lo(j,t)          = 0.0000000000000000000001;
                 Inv.lo(j,t)        = 0.0000000000000000000001;
                 Q.lo(j,t)          = 0.0000000000000000000001;
                 D.lo(j,t)          = 0.0000000000000000000001;
                 M.lo(j,t)          = 0.0000000000000000000001;
                 E.lo(j,t)          = 0.0000000000000000000001;
                 S.lo(j,t)          = 0.0000000000000000000001;
                 W.lo(nL,t)         = 0.0000000000000000000001;
                 PD.lo(j,t)         = 0.0000000000000000000001;
                 PM.lo(j,t)         = 0.0000000000000000000001;
                 PE.lo(j,t)         = 0.0000000000000000000001;
                 P.lo(j,t)          = 0.0000000000000000000001;
                 Pstar.lo(j,t)      = 0.0000000000000000000001;
                 ER.lo(t)           = 0.0000000000000000000001;
                 PV.lo(j,t)         = 0.0000000000000000000001;
                 PI.lo(t)           = 0.0000000000000000000001;
                 PG.lo(t)           = 0.0000000000000000000001;
                 Profit.lo(j,t)     = 0.0000000000000000000001;
                 sigma.lo(j)        = 0.0000000000000000000001;
                 phi.lo(j)          = 0.0000000000000000000001;
                 pp_ces.lo(j,zp)    = 0.0000000000000000000001;
                 pp_cet.lo(j,zp)    = 0.0000000000000000000001;
                 wwX.lo(j,z,t)      = 0.0000000000000000000001;
                 wwGDP.lo(j,z,t)    = 0.0000000000000000000001;
                 wwM.lo(j,z,t)      = 0.0000000000000000000001;
                 wwE.lo(j,z,t)      = 0.0000000000000000000001;
                 wwC.lo(j,z,t)      = 0.0000000000000000000001;
                 wwG_budget.lo(z,t) = 0.0000000000000000000001;
                 wwG.lo(j,z,t)      = 0.0000000000000000000001;
                 wwI.lo(j,z,t)      = 0.0000000000000000000001;

* Defining and solving the model-----------------------------------------------

model CGEVN_02 /all/;
solve CGEVN_02 minimizing HH using nlp;


option decimals = 4;
display sigma.l,pp_ces.l,phi.l,pp_cet.l,
eeX.l,eeGDP.l, eeG.l, eeG_Budget.l,eeC.l,eeM.l, eeE.l, eeI.l
;
Last edited by Nguyen Xuan 1 week ago, edited 1 time in total.

User avatar
Renger
Posts: 353
Joined: 2 years ago

Re: Help me in CES, CET estimate, please

Post by Renger » 1 week ago

Hi
Your code is not complete, so it doesn't produce your problem.
Cheers
Renger
____________________________________
Enjoy modeling even more: The lazy economist

Nguyen Xuan
User
User
Posts: 6
Joined: 1 week ago

Re: Help me in CES, CET estimate, please

Post by Nguyen Xuan » 1 week ago

What does it mean? What produces my ploblems?
The whole file is very large so I can't upload it, I have to remove the data and put it in the code. Can you explain to me why my results are corrupted? Thank you

User avatar
Renger
Posts: 353
Joined: 2 years ago

Re: Help me in CES, CET estimate, please

Post by Renger » 1 week ago

You can attach a file...and it is hard to check what is going wrong without a running model. Perhaps there are problems with your data, what you do with your data, mistakes in your equations, infeasible problems, ...
You can't expect from people that they go through your code of 1134 lines line-by-line.

Cheers
Renger
____________________________________
Enjoy modeling even more: The lazy economist

Nguyen Xuan
User
User
Posts: 6
Joined: 1 week ago

Re: Help me in CES, CET estimate, please

Post by Nguyen Xuan » 1 week ago

Hi
I attached file. Check file, please. Thanks you very much!
Cheers,
Nguyên Xuân.
Last edited by Nguyen Xuan 1 week ago, edited 1 time in total.

User avatar
dirkse
Moderator
Moderator
Posts: 70
Joined: 2 years ago
Location: Fairfax, VA

Re: Help me in CES, CET estimate, please

Post by dirkse » 1 week ago

Hello,

CONOPT has hit the iteration limit you set, so it stopped. Always look at the SOLVER STATUS and the MODEL STATUS before looking at the variable values. You could also use some GAMS code to print a message or abort if the solver didn't find a solution. This is sometimes better than continuing on.

**** SOLVER STATUS 2 ITERATION INTERRUPT
**** MODEL STATUS 6 INTERMEDIATE INFEASIBLE
**** OBJECTIVE VALUE 1191.9553

RESOURCE USAGE, LIMIT 1533.254 20000.000
ITERATION COUNT, LIMIT 20000 20000
EVALUATION ERRORS 0 0


Why do you set iterlim = 20000 ??

-Steve

Nguyen Xuan
User
User
Posts: 6
Joined: 1 week ago

Re: Help me in CES, CET estimate, please

Post by Nguyen Xuan » 1 week ago

Dear Steve,
I set interlim by 20000 based on the old results with 25 sector.
I set again interlim 2000000000 and run model again.
The report is as follow:


**** SOLVER STATUS 4 TERMINATED BY SOLVER
**** MODEL STATUS 6 INTERMEDIATE INFEASIBLE
**** OBJECTIVE VALUE 1089.1823

RESOURCE USAGE, LIMIT 1933.527 20000.000
ITERATION COUNT, LIMIT 11284 2000000000
EVALUATION ERRORS 0 0




Using default options.


The model has 55841 variables and 52221 constraints
with 270113 Jacobian elements, 103338 of which are nonlinear.
The Hessian of the Lagrangian has 16708 elements on the diagonal,
85908 elements below the diagonal, and 38884 nonlinear variables.

** Warning ** The variance of the derivatives in the initial
point is large (= 4.5 ). A better initial
point, a better scaling, or better bounds on the
variables will probably help the optimization.


** Infeasible solution. Convergence too slow. The change in objective
has been less than 7.0757E-10 for 20 consecutive iterations


CONOPT time Total 1932.608 seconds
of which: Function evaluations 169.090 = 8.7%
1st Derivative evaluations 43.490 = 2.3%
2nd Derivative evaluations 7.133 = 0.4%
Directional 2nd Derivative 9.547 = 0.5%

Work length = 202.43 Mbytes
Estimate = 202.43 Mbytes
Max used = 111.07 Mbytes


**** REPORT SUMMARY : 755 NONOPT ( NOPT)
871 INFEASIBLE (INFES)
SUM 4.9446E+7
MAX 3.1689E+6
MEAN 56769.576
0 UNBOUNDED
0 ERRORS



1) What can i do to make my result better?
2) In process running model there is warning (exit code 6) that i attached file. Could you check it and help me, please.
Thanks a lot!
Cheers,
Nguyen Xuan.
Attachments
Doc18.docx
(143.26 KiB) Downloaded 5 times
Last edited by Nguyen Xuan 1 week ago, edited 1 time in total.

User avatar
Renger
Posts: 353
Joined: 2 years ago

Re: Help me in CES, CET estimate, please

Post by Renger » 1 week ago

Hi

A few remarks on your model (using pathnlp as solver):
  • Your data seems to be not scaled very well. Your national account values go up to 1E8. You have many equality-equations where you force, for example, demand to be equal to supply. If the level of your values is around 1E8, equality is only reached if the difference is very small (e.g. 1E-7). Example, if you have all your values in dollars, this would mean that your precision to be met is 1E-7$. You might try to scale your values around 1.
  • Your starting values are often far away from your lower and upper bounds (often they are not within their bounds). As you use national account data, it should be possibility to initialize your data properly, e.g. such that the initial value is very close to the actual value.
Hope this helps

Cheers
Renger
____________________________________
Enjoy modeling even more: The lazy economist

Post Reply