Cover Image
close this bookMicrocomputers In Policy Research 4b - Key to Exercises in CGE Modeling Using GAMS (includes software) (IFPRI, 2000, 69 p.)
View the document(introduction...)
View the documentExercise 1: GAMS Code
View the documentExercise A1: GAMS Code
View the documentExercise 2: Mathematical Statement
View the documentExercise 2: GAMS Code
View the documentExercise 3: Mathematical Statement
View the documentExercise 3: GAMS Code
View the documentExercise 4: Mathematical Statement
View the documentExercise 4: GAMS Code
View the documentExercise 5: GAMS Code

Exercise 4: GAMS Code

GAMS 2.50.094 DOS Extended/C

12/10/99 14:41:33 PAGE 1

CGE4


3


4

*INTRODUCTION ====================================================




In this file, the starting point is CGE3.


Additions: A government (and a new SAM), and labor unemployment with an


infinitely elastic supply of labor at a wage which is fixed in real


(and nominal) terms.




The line before any new feature or modification starts with


"*++".



16


17

*SETS ============================================================

18


19

SETS

20


21

AC global set (SAM accounts and other items)

22

/

AGR-A

agricultural activity

23


NAGR-A

non-agricultural activity

24


AGR-C

agricultural commodity

25


NAGR-C

non-agricultural commodity

26


LAB

labor

27


CAP

capital

28


U-HHD

urban household

29


R-HHD

rural household

30

*++

31


GOV

government

32


S-I

savings-investment

33

*++

34


YTAX

income tax

35

*++

36


STAX

sales tax

37


TOTAL

total account in SAM

/

38


39

ACNT(AC) all elements in AC except total

40


41

A(AC)

activities

42


/AGR-A, NAGR-A/

43



44

C(AC)

commodities

45


/AGR-C, NAGR-C/

46



47

F(AC)

factors

48


/LAB, CAP/

49



50

*++


51

I(AC)

institutions

52


/U-HHD, R-HHD, GOV/

53



54

H(AC)

households

55


/U-HHD, R-HHD/

56

;

57


58

ALIAS(AC,ACP); ALIAS(C,CP); ALIAS(F,FP); ALIAS(I,IP);

59

ACNT(AC) = YES; ACNT('TOTAL') = NO; ALIAS(ACNT,ACNTP);

60


61


62

*PARAMETERS======================================================

63


64

PARAMETERS

65


66

ad(A)

efficiency parameter in the production fn for a

67

alpha(F,A)

share of value-added to factor f in activity a

68

beta(C,H)

share of household consumption spending on commodity c

69

cpi

consumer price index

70

cwts(C)

weight of commodity c in the CPI

71

ica(C,A)

qnty of c as intermediate input per unit of activity a

72

*++


73

qg(C)

government demand for commodity c

74

qinvbar(C)

base-year qnty of investment demand for commodity c

75

shry(H,F)

share for household h in the income of factor f

76

theta(A,C)

yield of output c per unit of activity a

77

*++


78

tq(C)

rate of sales tax for commodity c

79

*++


80

tr(I,IP)

transfer from institution ip to institution i

81

*++


82

ty(H)

rate of income tax for household h

83

;

84


85

*VARIABLES=======================================================

86


87

VARIABLES

88

*++


89

EG

government expenditures

90

IADJ

investment adjustment factor

91

MPS(H)

marginal (and average) propensity to save for household h

92

P(C)

price of commodity c

93

PA(A)

price of activity a

94

PVA(A)

value-added (or net) price for activity a

95

*++


96

PX(C)

producer price for commodity c

97

Q(C)

output level for commodity c

98

QA(A)

level of activity a

99

QF(F,A)

quantity demanded of factor f from activity a

100

*++


101

QFS(F)

supply of factor f

102

QH(C,H)

quantity consumed of commodity c by household h

103

QINT(C,A)

qnty of commodity c as intermediate input to activity a

104

QINV(C)

quantity of investment demand for commodity c

105

WALRAS

dummy variable (zero at equilibrium)

106

WF(F)

price of factor f

107

*++


108

WFDIST(F,A)

wage distortion factor for factor f in activity a

109



110

YF(H,F)

income of household h from factor f

111

*++


112

YG

government revenue

113

YH(H)

income of household h

114

;

115


116

*EQUATIONS=======================================================

117


118

EQUATIONS

119


120

*PRODUCTION AND COMMODITY BLOCK++++++++

121

PRODFN(A)

Cobb-Douglas production function for activity a

122

FACDEM(F,A)

demand for factor f from activity a

123

INTDEM(C,A)

intermediate demand for commodity c from activity a

124

OUTPUTFN(C)

output of commodity c

125

*++


126

PDEF(C)

demander price for commodity c

127

PADEF(A)

price for activity a

128

PVADEF(A)

value-added price for activity a

129


130

*INSTITUTION BLOCK+++++++++++++++++++++

131

FACTTRNS(H,F)

transfer of income from factor f to h-hold h

132

HHDINC(H)

income of household h

133

HHDEM(C,H)

consumption demand for household h & commodity c

134

INVDEM(C)

investment demand for commodity c

135

*++


136

GOVREV

government revenue

137

*++


138

GOVEXP

government expenditures

139


140

*SYSTEM CONSTRAINT BLOCK+++++++++++++++

141

FACTEQ(F)

market equilibrium condition for factor f

142

COMEQ(C)

market equilibrium condition for commodity c

143

SAVINV

savings-investment balance

144

PNORM

price normalization

145

;

146


147

148

*PRODUCTION AND COMMODITY BLOCK++++++++

149


150

PRODFN(A)..

QA(A) =E= ad(A)*PROD(F, QF(F,A)**alpha(F,A));

151



152

FACDEM(F,A)..

WF(F)*WFDIST(F,A) =E= alpha(F,A)*PVA(A)*QA(A) / QF(F,A);

153



154

INTDEM(C,A)..

QINT(C,A) =E= ica(C,A)*QA(A);

155



156

OUTPUTFN(C)..

Q(C) =E= SUM(A, theta(A,C)*QA(A));

157

*++


158

PDEF(C)..

P(C) =E= (1 + tq(C))*PX(C);

159

*++


160

PADEF(A)..

PA(A) =E= SUM(C, theta(A,C)*PX(C));

161



162

PVADEF(A)..

PVA(A) =E= PA(A) - SUM(C, P(C)*ica(C,A));

163


164


165

*INSTITUTION BLOCK+++++++++++++++++++++

166


167

FACTTRNS(H,F)..

YF(H,F)

168


=E= shry(H,F)*SUM(A, WF(F)*wfdist(F,A)*QF(F,A));

169

*++


170

HHDINC(H)..

YH(H) =E= SUM(F, YF(H,F)) +tr(H,'GOV');

171

*++


172

HHDEM(C,H)..

QH(C,H) =E=

173


beta(C,H)*(1-MPS(H))*(1-ty(H))*YH(H)/P(C);

174



175

INVDEM(C)..

QINV(C) =E= qinvbar(C)*IADJ;

176

*++


177

GOVREV..

YG =E= SUM(H, ty(H)*YH(H)) + SUM(C, tq(C)*PX(C)*Q(C));

178

*++


179

GOVEXP..

EG =E= SUM(C, P(C)*qg(C)) + SUM(H, tr(H,'GOV'));

180


181


182

*SYSTEM CONSTRAINT BLOCK+++++++++++++++

183

*++

184

FACTEQ(F)..

SUM(A, QF(F,A)) =E= QFS(F);

185

*++


186

COMEQ(C)..

Q(C) =E= SUM(H, QH(C,H)) + SUM(A, QINT(C,A))

187


+ QINV(C) + qg(C);

188

*++


189

SAVINV..

SUM(C, P(C)*QINV(C)) + WALRAS =E=

190


SUM(H, MPS(H)*(1 - ty(H))*YH(H)) + (YG - EG);

191



192

PNORM..

SUM(C, cwts(C)*P(C)) =E= cpi;

193


194


195

*MODEL===========================================================

196


197

MODEL

198


199


CGE4 Model with gov't and flexible factor market treatment

200

/ALL/

201

;

202


203

*SOCIAL ACCOUNTING MATRIX========================================

204


205

TABLE SAM(AC,ACP) social accounting matrix

206


207


AGR-A

NAGR-A

AGR-C

NAGR-C

LAB

CAP


208

AGR-A



255





209

NAGR-A




350




210

AGR-C

66

44






211

NAGR-C

44

66






212

LAB

72

105






213

CAP

73

135






214

U-HHD





95

125


215

R-HHD





82

83


216

GOV








217

S-I








218

YTAX








219

STAX



25

33




220









221









222

+

U-HHD

R-HHD

GOV

S-I

YTAX

STAX


223

AGR-A








224

NAGR-A








225

AGR-C

55

77

11

27




226

NAGR-C

110

55

47

61




227

LAB








228

CAP








229

U-HHD



25





230

R-HHD



5





231

GOV





25

58


232

S-I

60

33

-5





233

YTAX

20

5






234

STAX








235

;








236









237

PARAMETER

238

tdiff(AC) column minus row total for account ac;

239


SAM('TOTAL',ACNTP)

= SUM(ACNT, SAM(ACNT,ACNTP));

240


SAM(ACNT,'TOTAL')

= SUM(ACNTP, SAM(ACNT,ACNTP));

241


tdiff(ACNT)

= SAM('TOTAL',ACNT) - SAM(ACNT,'TOTAL');

242


243

DISPLAY SAM, tdiff;

244


245


246

*ASSIGNMENTS FOR PARAMETERS AND VARIABLES========================

247


248

PARAMETERS

249

*The following parameters are used to define initial values of

250

*model variables.

251

EG0, IADJ0, MPS0(H), P0(C), PA0(A), PVA0(A), PX0(C), Q0(C), QA0(A),

252

QF0(F,A), QFS0(F), QH0(C,H), QINT0(C,A), QINV0(C), WF0(F),

253

WFDIST0(F,A), YF0(H,F), YG0, YH0(H)

254

;

255


256


257

*FACTOR EMPLOYMENT AND PRICES++++++++++

258


259


260

PARAMETERS

261

labor(A)

quantity of labor employed by activity (no. of workers)

262


/AGR-A 100, NAGR-A 50/

263


264

wfa(F,A)

wage for factor f in activity a (only for calibration)

265

costgap(F,A)

gap calibrated factor cost - SAM value (should be zero)

266

;

267


268

*Defining factor employment and supply

269

QF0('LAB',A)

= labor(A);

270

QF0('CAP',A)

= SAM('CAP',A);

271

*++


272

QFS0(F)

= SUM(A, QF0(F,A));

273


274

*Computing activity-specific wage

275

wfa(F,A)

= SAM(F,A)/QF0(F,A);

276


277

*Computing average wage

278

WF0(F)

= SUM(A, SAM(F,A))/SUM(A, QF0(F,A));

279


280

*Computing wage distortion factors

281

wfdist(F,A)

= wfa(F,A) / WF0(F);

282


283

*Checking calibration

284

costgap(F,A)

= WF0(F)*wfdist(F,A)*QF0(F,A) - SAM(F,A);

285


286

DISPLAY wfa, costgap;

287


288


289

*PRICE, PRODUCTION AND COMMODITY BLOCK++++++++

290


291

PA0(A)

= 1;

292

*++


293

PX0(C)

= 1;

294

PVA0(A)

= SUM(F, SAM(F,A)) / (SAM(A,'TOTAL')/PA0(A));

295



296

*++


297

tq(C)

= SAM('STAX',C)/SUM(A, SAM(A,C) );

298

*++


299

P0(C)

= PX0(C)*(1 + tq(C));

300



301

Q0(C)

= SAM('TOTAL',C)/P0(C);

302

QA0(A)

= SAM('TOTAL',A)/PA0(A);

303

QINT0(C,A)

= SAM(C,A)/P0(C);

304



305

alpha(F,A)

= SAM(F,A) / SUM(FP, SAM(FP,A));

306

ad(A)

= QA0(A) / PROD(F, QF0(F,A)**alpha(F,A));

307

ica(C,A)

= (SAM(C,A)/P0(C)) / QA0(A);

308

*++


309

theta(A,C)

= (SAM(A,C)/PX0(C)) / QA0(A);

310


311


312

*INSTITUTION BLOCK+++++++++++++++++++++

313

*++


314

EG0

= SAM('TOTAL','GOV') - SAM('S-I','GOV');

315

IADJ0

= 1;

316

*++


317

MPS0(H)

= SAM('S-I',H) / (SAM('TOTAL',H) - SAM('YTAX',H));

318

QH0(C,H)

= SAM(C,H)/P0(C);

319

QINV0(C)

= SAM(C,'S-I')/P0(C);

320

YF0(H,F)

= SAM(H,F);

321

*++


322

YG0

= SAM('GOV','TOTAL');

323

YH0(H)

= SAM('TOTAL',H);

324



325

beta(C,H)

= SAM(C,H)/SUM(CP, SAM(CP,H));

326

*++


327

qg(C)

= SAM(C,'GOV')/P0(C);

328

qinvbar(C)

= SAM(C,'S-I')/P0(C);

329

shry(H,F)

= SAM(H,F)/SAM('TOTAL',F);

330

*++


331

tr(H,'GOV')

= SAM(H,'GOV');

332

*++


333

ty(H)

= SAM('YTAX',H) / SAM('TOTAL',H);

334



335



336

*SYSTEM CONSTRAINT BLOCK+++++++++++++++

337



338

cwts(C)

= SUM(H, SAM(C,H)) / SUM((CP,H), SAM(CP,H));

339

cpi

= SUM(C, cwts(C)*P0(C));

340



341



342

*INITIALISATION OF VARIABLES+++++++++++

343



344

EG.L

= EG0;

345

IADJ.L

= IADJ0;

346

MPS.L(H)

= MPS0(H);

347

P.L(C)

= P0(C);

348

PA.L(A)

= PA0(A);

349

PVA.L(A)

= PVA0(A);

350

PX.L(C)

= PX0(C);

351

Q.L(C)

= Q0(C);

352

QA.L(A)

= QA0(A);

353

QF.L(F,A)

= QF0(F,A);

354

QFS.L(F)

= QFS0(F);

355

QH.L(C,H)

= QH0(C,H);

356

QINT.L(C,A)

= QINT0(C,A);

357

QINV.L(C)

= QINV0(C);

358

WF.L(F)

= WF0(F);

359

WFDIST.L(F,A)

= WFDIST0(F,A);

360

YF.L(H,F)

= YF0(H,F);

361

YG.L

= YG0;

362

YH.L(H)

= YH0(H);

363



364



365

*DISPLAY+++++++++++++++++++++++++++++++

366


367

DISPLAY

368

ad, alpha, beta, cpi, cwts, ica, shry, qg, qinvbar, theta, tr, ty

369


370

EG.L, IADJ.L, MPS.L, P.L, PA.L, PVA.L, PX.L, Q.L, QA.L, QF.L, QFS.L,

371

QH.L, QINT.L, QINV.L, WF.L, WFDIST.L, YF.L, YG.L, YH.L

372

;

373


374


375

*SELECTING CLOSURES++++++++++++++++++++

376


377

*SAVINGS-INVESTMENT BALANCE

378


379

SCALAR

380

SICLOS savings-investment closure /1/

381

*Select 1 or 2

382

*if SICLOS = 1, savings is investment-driven

383

*if SICLOS = 2, investment is savings-driven

384


385

IF(SICLOS EQ 1,

386

*Investment-driven savings -- MPS('U-HHD') is flexible, permitting

387

*the savings value to adjust.

388

IADJ.FX

= IADJ0;

389

MPS.FX('R-HHD')

= MPS0('R-HHD');

390

MPS.LO('U-HHD')

= -INF;

391

MPS.UP('U-HHD')

= +INF;

392

MPS.L('U-HHD')

= MPS0('U-HHD');

393

);


394



395

IF(SICLOS EQ 2,

396

*Savings-driven investment -- IADJ is flexible, permitting

397

*investment quantities and the investment value to adjust.

398

MPS.FX(H)

= MPS0(H);

399

IADJ.LO

= -INF;

400

IADJ.UP

= +INF;

401

IADJ.L

= IADJ0;

402

);


403



404



405

*FACTOR MARKETS

406

*For each factor, fix (A + 1) quantity and-or price variables

407


408

SCALARS

409

CAPCLOS closure for capital market /2/

410

*Select 1 or 2

411

*if CAPCLOS = 1, capital is mobile and fully employed

412

*if CAPCLOS = 2, capital is activity-specific and fully employed

413


414

LABCLOS closure for labor market /2/

415

*Select 1 or 2

416

*if LABCLOS = 1, labor is mobile and fully employed

417

*if LABCLOS = 2, labor is mobile and unemployed (fixed wages)

418


419


420

IF(CAPCLOS EQ 1,

421

*Capital is fully employed and mobile. WF('CAP') is the market-clearing

422

*variable for the unified capital market.

423


424

WFDIST.FX('CAP',A)

= WFDIST0('CAP',A);

425



426

WF.LO('CAP')

= -INF;

427

WF.UP('CAP')

= +INF;

428

WF.L('CAP')

= WF0('CAP');

429



430

QF.LO('CAP',A)

= -INF;

431

QF.UP('CAP',A)

= +INF;

432

QF.L('CAP',A)

= QF0('CAP',A);

433



434

QFS.FX('CAP')

= QFS0('CAP');

435

);


436



437

IF(CAPCLOS EQ 2,

438

*Capital is fully employed and activity-specific.

439

*WFDIST('CAP',A) is the market-clearing variable, one for

440

*each segment of the capital market.

441



442

WFDIST.LO('CAP',A)

= -INF;

443

WFDIST.UP('CAP',A)

= +INF;

444

WFDIST.L('CAP',A)

= WFDIST0('CAP',A);

445



446

WF.FX('CAP')

= WF0('CAP');

447



448

QF.FX('CAP',A)

= QF0('CAP',A);

449



450

QFS.LO('CAP')

= -INF;

451

QFS.UP('CAP')

= +INF;

452

QFS.L('CAP')

= QFS0('CAP');

453

);


454



455

IF(LABCLOS EQ 1,

456

*Labor is fully employed and mobile. WF('LAB') is the market-clearing

457

*variable for the unified capital market.

458



459

WFDIST.FX('LAB',A)

= WFDIST0('LAB',A);

460



461

WF.LO('LAB')

= -INF;

462

WF.UP('LAB')

= +INF;

463

WF.L('LAB')

= WF0('LAB');

464



465

QF.LO('LAB',A)

= -INF;

466

QF.UP('LAB',A)

= +INF;

467

QF.L('LAB',A)

= QF0('LAB',A);

468



469

QFS.FX('LAB')

= QFS0('LAB');

470

);


471



472

IF(LABCLOS EQ 2,

473

*Labor is unemployed and mobile. For each activity, the wage,

474

*WFDIST('LAB',A)*WF('LAB'), is fixed. QFS('LAB') is the market-clearing

475

*variable for the unified labor market.

476



477

WFDIST.FX('LAB',A)

= WFDIST0('LAB',A);

478



479

WF.FX('LAB')

= WF0('LAB');

480



481

QF.LO('LAB',A)

= -INF;

482

QF.UP('LAB',A)

= +INF;

483

QF.L('LAB',A)

= QF0('LAB',A);

484



485

QFS.LO('LAB')

= -INF;

486

QFS.UP('LAB')

= +INF;

487

QFS.L('LAB')

= QFS0('LAB');

488

);


489



490

DISPLAY SICLOS, CAPCLOS, LABCLOS;

491


492


493

*SOLVE STATEMENT FOR BASE========================================

494


495

CGE4.HOLDFIXED = 1;

496


497

*SOLVE CGE4 USING MCP;

498


499


500

*REPORT SETUP AND BASE REPORT====================================

501


502

*SET AND PARAMETERS FOR REPORTS++++++++

503


504

*++

505

SET

506


SIM

simulations

507


/

BASE

base simulation

508



QGINCR

increase in government consumption /

509



;


510


511

PARAMETERS

512

*++

513

QGSIM(C,SIM)

government consumption of c for sim

514

*++


515

QGREP(C,SIM)

government consumption of c for sim (check)

516



517

EGREP(SIM)

government expenditures

518

IADJREP(SIM)

investment adjustment factor

519

MPSREP(H,SIM)

marginal (and avg) propensity to save for household h

520

PREP(C,SIM)

demander price for commodity c

521

PAREP(A,SIM)

price of activity a

522

PVAREP(A,SIM)

value-added price for activity a

523

PXREP(C,SIM)

producer price (excl. sales tax) for commodity c

524

QREP(C,SIM)

output level for commodity c

525

QAREP(A,SIM)

level of activity a

526

QFREP(F,A,SIM)

demand for factor f from activity a

527

QFSREP(F,SIM)

supply of factor f for sim

528

QHREP(C,H,SIM)

consumption of commodity c by household h

529

QINTREP(C,A,SIM)

qnty of commodity c as intermed. input for activity a

530

QINVREP(C,SIM)

quantity of investment by commodity of origin c

531

WFREP(F,SIM)

average price of factor f

532

WFAREP(F,A,SIM)

price of factor f for activity a

533

WFDISTREP(F,A,SIM)

wage distortion factof for factor f in activity a

534

YFREP(H,F,SIM)

income of household h from factor f

535

YGREP(SIM)

government revenue

536

YHREP(H,SIM)

income of household h

537

WALRASREP(SIM)

dummy variable (zero at equilibrium)

538

;


539



540

*++


541

QGSIM(C,'BASE')

= qg(C);

542

QGSIM(C,'QGINCR')

= 1.2*qg(C);

543



544

DISPLAY QGSIM;


545


546


547

LOOP(SIM,

548

*++

549

qg(C) = QGSIM(C,SIM);

550


551

SOLVE CGE4 USING MCP;

552


553

*++


554

QGREP(C,SIM)

= qg(c);

555



556

EGREP(SIM)

= EG.L;

557

IADJREP(SIM)

= IADJ.L;

558

MPSREP(H,SIM)

= MPS.L(H);

559

PREP(C,SIM)

= P.L(C);

560

PAREP(A,SIM)

= PA.L(A);

561

PVAREP(A,SIM)

= PVA.L(A);

562

PXREP(C,SIM)

= PX.L(C);

563

QREP(C,SIM)

= Q.L(C);

564

QAREP(A,SIM)

= QA.L(A);

565

QFREP(F,A,SIM)

= QF.L(F,A);

566

QFSREP(F,SIM)

= QFS.L(F);

567

QHREP(C,H,SIM)

= QH.L(C,H);

568

QINTREP(C,A,SIM)

= QINT.L(C,A);

569

QINVREP(C,SIM)

= QINV.L(C);

570

WFREP(F,SIM)

= WF.L(F);

571

WFAREP(F,A,SIM)

= WF.L(F)*WFDIST.L(F,A);

572

WFDISTREP(F,A,SIM)

= WFDIST.L(F,A);

573

YFREP(H,F,SIM)

= YF.L(H,F);

574

YGREP(SIM)

= YG.L;

575

YHREP(H,SIM)

= YH.L(H);

576

WALRASREP(SIM)

= WALRAS.L;

577

);


578



579

OPTION

QFREP:3:1:1, QHREP:3:1:1, QINTREP:3:1:1, WFAREP:3:1:1,

580


WFAREP:3:1:1, WFDISTREP:3:1:1, YFREP:3:1:1

581

;

582


583

DISPLAY

584

QGREP, EGREP, IADJREP, MPSREP, PREP, PAREP, PVAREP, PXREP, QREP,

585

QAREP, QFREP, QFSREP, QHREP, QINTREP, QINVREP, WFREP, WFAREP,

586

WFDISTREP, YFREP, YGREP, YHREP, WALRASREP

587

;