-
Notifications
You must be signed in to change notification settings - Fork 1
/
Italy_SFC_model.r
1838 lines (1589 loc) · 71.7 KB
/
Italy_SFC_model.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
##############################################################################
# Empirical SFC macroeconomic model for Italy (1998-2026) using 'Bimets' package
# Authors: Rosa Canelli and Marco Veronese Passarella
# Last change: 9 May 2022
# Note: this R code reproduces the experiments discussed in: Canelli, R.,
# Fontana, G., Realfonzo, R. and Veronese Passarella, M. (2022) "Is the Italian
# government debt sustainable? Scenarios after the Covid-19 shock", Cambridge
# Journal of Economics. An early version of it was used to produce the
# simulations discussed in: Canelli, R., Fontana, G., Realfonzo, R. and Veronese
# Passarella, M. (2021) "Are EU Policies Effective to Tackle the Covid-19
# Crisis? The Case of Italy", Review of Political Economy.
# Instructions: just download the file and run/source it!
##############################################################################
#A) PREPARE THE ENVIRONMENT
#Clear environment
rm(list=ls(all=TRUE))
#Clear plots
if(!is.null(dev.list())) dev.off()
#Clear console
cat("\014")
#Upload libraries
library(mFilter)
library(bimets)
library(knitr)
#Upload data: time series for transactions-flow matrix and balance sheet
DataCJE <- read.csv("https://www.dropbox.com/s/xl6m4jmrirsdubp/cje_data.csv?dl=1")
#Source: (our elaboration on) Eurostat data, December 2021
##############################################################################
#B) DEFINE MODEL EQUATIONS
S_model.txt="MODEL
COMMENT> FIRMS SECTOR
COMMENT> GDP
IDENTITY> y
EQ> y = cons + id + gov + nx
COMMENT> Target capital to output ratio
BEHAVIORAL> kappa
TSRANGE 1998 1 2019 1
EQ> kappa = kappa0 + kappa1*LAG(kappa,1)
COEFF> kappa0 kappa1
STORE> coe(32)
COMMENT> Target capital stock (in real terms)
IDENTITY> kt
EQ> kt = kappa*y*100/p
COMMENT> Real investment
BEHAVIORAL> idR
TSRANGE 1998 1 2019 1
EQ> idR = gamma1*TSLAG(y*100/p,1) + gamma2*(kt - k*100/p) + gamma3*(rl-rstar)*100
COEFF> gamma1 gamma2 gamma3
STORE> coe(1)
COMMENT> Nominal investment
IDENTITY> id
EQ> id = idR*p/100
COMMENT> Capital stock (Note: delta=0, hence no depreciation)
IDENTITY> k
EQ> k = TSLAG(k,1) + id
COMMENT> Firms' profit
IDENTITY> ff
EQ> ff = y - intf - wb
COMMENT> Interest payments on loans by firms
IDENTITY> intf
EQ> intf = rl*lf
COMMENT> Interest rate on loans to firms
BEHAVIORAL> rl
TSRANGE 1998 1 2019 1
EQ> rl = rl0 + rl1*rstar + rl2*mub
COEFF> rl0 rl1 rl2
STORE> coe(2)
COMMENT> Firms' undistributed profit
BEHAVIORAL> fuf
TSRANGE 1998 1 2019 1
EQ> fuf = theta*ff
COEFF> theta
ERROR> AUTO(1)
STORE> coe(3)
COMMENT> Firms' distributed profit
IDENTITY> fdf
EQ> fdf = ff - fuf
COMMENT> Firms' demand for bank loans
IDENTITY> lf
EQ> lf = TSLAG(lf,1) + id - fuf - (es-TSLAG(es,1))
COMMENT> Supply of shares
IDENTITY> es
EQ> es = eh
COMMENT> Other payments or receipts received by firms (exogenous variable)
BEHAVIORAL> opf
TSRANGE 1998 1 2019 1
EQ> opf = opf1*oaf
ERROR> AUTO(1)
COEFF> opf1
STORE> coe(38)
COMMENT> Total wealth accumulated by firms
IDENTITY> vf
EQ> vf = TSLAG(vf,1) + y - wb - intf - fdf + opf - id
COMMENT> Other financial assets held by firms
IDENTITY> oaf
EQ> oaf = vf + lf + es
COMMENT> HOUSEHOLD SECTOR
COMMENT> Disposable income
IDENTITY> yd
EQ> yd = wb - tax + tr + inth + fdf + fb + oph
COMMENT> Other payments or receipts (exogenous variable)
BEHAVIORAL> oph
TSRANGE 1998 1 2019 1
EQ> oph = oph1*oah
ERROR> AUTO(1)
COEFF> oph1
STORE> coe(4)
COMMENT> Log of Real consumption
BEHAVIORAL> LconsR
TSRANGE 1998 1 2019 1
EQ> LconsR = alpha1*(log(wb*100/p)) + alpha2*(log((yd-wb)*100/p)) + alpha3*log(TSLAG(nvh*100/p,1))
COEFF> alpha1 alpha2 alpha3
STORE> coe(5)
COMMENT> Real consumption
IDENTITY> consR
EQ> consR = exp(LconsR)
COMMENT> Nominal consumption
IDENTITY> cons
EQ> cons = consR*p/100
COMMENT> Net wealth of households - Note: yd = wb - tax + tr + inth + fdf + fb + oph
IDENTITY> nvh
EQ> nvh = TSLAG(nvh,1) + yd - cons
COMMENT> Gross wealth of households
IDENTITY> vh
EQ> vh = nvh + lh
COMMENT> Loans to households
BEHAVIORAL> lh
TSRANGE 1998 1 2019 1
EQ> TSDELTA(lh,1) = phi2*TSLAG(yd,1)
COEFF> phi2
STORE> coe(6)
COMMENT> Interests paid by households on personal loans
IDENTITY> intlh
EQ> intlh = rlh*lh
COMMENT> Interests received by households on their government debt holdings
IDENTITY> intgh
EQ> intgh = rb*bh
COMMENT> Net interest payments received by households
IDENTITY> inth
EQ> inth = intgh - intlh
COMMENT> Interest rate on loans to households
BEHAVIORAL> rlh
TSRANGE 1998 1 2019 1
EQ> rlh = rlh0 + rlh1*rstar + rlh2*mub
COEFF> rlh0 rlh1 rlh2
ERROR> AUTO(1)
STORE> coe(7)
COMMENT> Wage share (endogenous)
IDENTITY> Omega
EQ> Omega = wb/y
COMMENT> BANKING SECTOR
COMMENT> Total loans
IDENTITY> ls
EQ> ls = lf + lh
COMMENT> Supply of deposits
IDENTITY> ms
EQ> ms = mh
COMMENT> Net interest payments received by banks on government bills
IDENTITY> intgb
EQ> intgb = rb*bb
COMMENT> Banks profit (note: interest payments on advances and reserves are assumed = 0)
IDENTITY> fb
EQ> fb = intf + intlh + intgb
COMMENT> Stock of bills held by banks
IDENTITY> bb
EQ> bb = bs - bcb - bcb_star - bh
COMMENT> Other payments or receipts received by banks (exogenous variable)
BEHAVIORAL> opb
TSRANGE 1998 1 2019 1
EQ> opb = opb1*oab
ERROR> AUTO(1)
COEFF> opb1
STORE> coe(36)
COMMENT> Total wealth accumulated by banks
IDENTITY> vb
EQ> vb = TSLAG(vb,1) + opb
COMMENT> Other financial assets held by banks
IDENTITY> oab
EQ> oab = vb - hbs + ms - bb - ls
COMMENT> GOVERNMENT SECTOR
COMMENT> Government consumption net of loans and grants
BEHAVIORAL> gov_net
TSRANGE 1998 1 2019 1
EQ> gov_net = sigma1*TSLAG(gov_net/p,1)*p
COEFF> sigma1
STORE> coe(12)
COMMENT> Tax revenue
BEHAVIORAL> tax
TSRANGE 1998 1 2019 1
EQ> tax = tau1*wb + tau2*(yd - wb) + tau3*TSLAG(vh,1)
COEFF> tau1 tau2 tau3
STORE> coe(10)
COMMENT> Transfers and benefits
BEHAVIORAL> tr
TSRANGE 1998 1 2019 1
EQ> tr = tau4*TSLAG(tr,1) + tau5*(ns-nd)
COEFF> tau4 tau5
STORE> coe(11)
COMMENT> Total government consumption, including loans and grants
IDENTITY> gov
EQ> gov = gov_net + loans + grants
COMMENT> Government deficit (based on consumption, taxes, transfers, interests, seigniorage and payments net of grants)
IDENTITY> def1
EQ> def1 = gov + tr + intg - tax - fcb - (grants - paym)
COMMENT> Goverment spending covered by loans from supranational institutions
BEHAVIORAL> loans
TSRANGE 1998 1 2019 1
EQ> loans = loans0
COEFF> loans0
STORE> coe(40)
COMMENT> Goverment spending covered by grants from supranational institutions
BEHAVIORAL> grants
TSRANGE 1998 1 2019 1
EQ> grants = grants0
COEFF> grants0
STORE> coe(41)
COMMENT> Payments to supranational institutions
BEHAVIORAL> paym
TSRANGE 1998 1 2019 1
EQ> paym = paym0
COEFF> paym0
STORE> coe(42)
COMMENT> Stock of loans from supranational institutions received by the government
IDENTITY> deb_l
EQ> deb_l = TSLAG(deb_l,1) + loans
COMMENT> Government debt stock
IDENTITY> deb
EQ> deb = bs + ogds
COMMENT> Interest payments on government debt
IDENTITY> intg
EQ> intg = deb*rb
COMMENT> Additional entries of government balance
BEHAVIORAL> defa
TSRANGE 1998 1 2019 1
EQ> defa = defa0
ERROR> AUTO(1)
COEFF> defa0
STORE> coe(14)
COMMENT> Government deficit including additional entries
IDENTITY> def2
EQ> def2 = def1 + defa
COMMENT> Supply of government bills and bonds
IDENTITY> bs
EQ> bs = TSLAG(bs,1) + def2
COMMENT> Supply of additional goverment debt
IDENTITY> ogds
EQ> ogds = ogdd
COMMENT> Other payments or receipts by government (exogenous variable)
BEHAVIORAL> opg
TSRANGE 1998 1 2019 1
EQ> opg = opg0
COEFF> opg0
ERROR> AUTO(1)
STORE> coe(34)
COMMENT> Net wealth of goverment sector (Note: negative value)
IDENTITY> vg
EQ> vg = TSLAG(vg,1) - gov + tax - tr - intg + opg + fcb
COMMENT> Other financial assets held by government
IDENTITY> oag
EQ> oag = vg + bs + ogds
COMMENT> PORTFOLIO EQUATIONS
COMMENT> Holdings of shares (Note: rm = 0)
BEHAVIORAL> eh
TSRANGE 1998 1 2019 1
EQ> eh = lambda10*vh + lambda11*rb*vh + lambda13*yd + lambda14*re*vh
COEFF> lambda10 lambda11 lambda13 lambda14
STORE> coe(15)
COMMENT> Target holdings of government bills (Note: rm = 0)
BEHAVIORAL> bh_star
TSRANGE 1998 1 2019 1
EQ> bh_star = lambda20*vh + lambda21*rb*vh + lambda23*yd + lambda24*re*vh
COEFF> lambda20 lambda21 lambda23 lambda24
STORE> coe(16)
COMMENT> Government bills held by households and other private agents
IDENTITY> bh
EQ> bh = bh_star
COMMENT> Holdings of cash
BEHAVIORAL> hh
TSRANGE 1998 1 2019 1
EQ> hh = lambdac*cons
ERROR> AUTO(1)
COEFF> lambdac
STORE> coe(17)
COMMENT> Holdings of deposits
IDENTITY> mh
EQ> mh = vh - hh - bh - eh - oah
COMMENT> Other assets
BEHAVIORAL> oah
TSRANGE 1998 1 2019 1
EQ> oah = lambdao*vh
ERROR>AUTO(1)
COEFF> lambdao
STORE> coe(18)
COMMENT> CENTRAL BANK
COMMENT> CB holdings of gov. securities
IDENTITY> bcb
EQ> bcb = lambdab*bs
COMMENT> Share of gov. securities purchased by CB
BEHAVIORAL> lambdab
TSRANGE 1998 1 2019 1
EQ> lambdab = lambdab1*bcb + lambdab2*LAG(lambdab,1)
COEFF> lambdab1 lambdab2
STORE> coe(31)
COMMENT> Extra purchases of gov. securities
BEHAVIORAL> bcb_star
TSRANGE 1998 1 2019 1
EQ> bcb_star = bcb_star0
COEFF> bcb_star0
COMMENT> Supply of cash
IDENTITY> hs
EQ> hs = -vcb + (bcb + bcb_star + oacb)
COMMENT> Other net assets held by central bank
IDENTITY> oacb
EQ> oacb = hh + hbs + vcb - bcb - bcb_star
COMMENT> Profit realised and distributed by CB (note: interest payments on advances and reserves are assumed away)
IDENTITY> fcb
EQ> fcb = intg - intgb - intgh
COMMENT> Reserve requirement: demand
IDENTITY> hbd
EQ> hbd = rho*ms
COMMENT> Total demand for cash and reserves
IDENTITY> hd
EQ> hd = hbd + hh
COMMENT> Reserve requirement: supply
IDENTITY> hbs
EQ> hbs = hbd
COMMENT> Debt held by BoI, ECB, ESM and IMF
IDENTITY> debcb
EQ> debcb = deb*percb + bcb_star
COMMENT> Percentage of debt held by institutions above
BEHAVIORAL> percb
TSRANGE 1998 1 2019 1
EQ> percb = percb1
COEFF> percb1
STORE> coe(35)
COMMENT> Other payments or receipts received by CB (exogenous variable)
BEHAVIORAL> opcb
TSRANGE 1998 1 2019 1
EQ> opcb = opcb1*oacb
ERROR> AUTO(1)
COEFF> opcb1
STORE> coe(37)
COMMENT> Total wealth accumulated by central bank
IDENTITY> vcb
EQ> vcb = TSLAG(vcb,1) + opcb
COMMENT> FOREIGN SECTOR
COMMENT> Gross import
BEHAVIORAL> im
TSRANGE 1998 1 2019 1
EQ> im = m0 + m1*y
COEFF> m0 m1
STORE> coe(20)
COMMENT> Log of export
BEHAVIORAL> Lx
TSRANGE 1998 1 2019 1
EQ> Lx = x0 + x1*log(yf) +x2*log(prod)
COEFF> x0 x1 x2
STORE> coe(21)
COMMENT> Nominal export
IDENTITY> x
EQ> x = exp(Lx)
COMMENT> Foreign income
BEHAVIORAL> yf
TSRANGE 1998 1 2019 1
EQ> yf = yf1*TSLAG(yf,1)
COEFF> yf1
STORE> coe(22)
COMMENT> Net export (trade balance)
IDENTITY> nx
EQ> nx = x - im
COMMENT> Additional stock of Italian goverment debt held by foreign agents
BEHAVIORAL> ogdd
TSRANGE 1998 1 2019 1
EQ> ogdd = lambdarow*vrow
COEFF> lambdarow
ERROR> AUTO(1)
STORE> coe(33)
COMMENT> Other payments or receipts received by RoW (including net received interest payments)
IDENTITY> oprow
EQ> oprow = -(opf + opb + opcb + oph + opg)
COMMENT> Total wealth accumulated by RoW
IDENTITY> vrow
EQ> vrow = -(nvh+vf+vcb+vg+vb)
COMMENT> Other financial assets held by RoW
IDENTITY> oarow
EQ> oarow = vrow - ogdd
COMMENT> INTEREST RATES
COMMENT> Return rate on shares
IDENTITY> re
EQ> re = fdf/eh
COMMENT> other interest rates either = 0 (ra, rh, rm) or already estimated (rl, rlh)
COMMENT> Policy rate
BEHAVIORAL> rstar
TSRANGE 1998 1 2019 1
EQ> rstar = r0 + r2*TSLAG(y,1)
COEFF> r0 r2
STORE> coe(25)
COMMENT> Return rate on government bills and other securities
BEHAVIORAL> rb
TSRANGE 1998 1 2019 1
EQ> rb = rb0 + rb1*rstar + rb2*(deb/y) + rb3*(bcb/bs)
COEFF> rb0 rb1 rb2 rb3
STORE> coe(39)
COMMENT> Aaverage risk premium on government bond
IDENTITY> mub
EQ> mub = rb - rstar
COMMENT> LABOUR MARKET
COMMENT> Wage bill
IDENTITY> wb
EQ> wb = w*nd
IF> ns>nd
IDENTITY> wb
EQ> wb = w*ns
IF> ns<nd
COMMENT> Labur productivity
BEHAVIORAL> prod
TSRANGE 1998 1 2019 1
EQ> prod = pr0 + pr1*TSLAG(y,1)
COEFF> pr0 pr1
STORE> coe(26)
COMMENT> Actual employment
BEHAVIORAL> nd
TSRANGE 1998 1 2019 1
EQ> nd = nu3 + nu4*y + nu5*w
ERROR> AUTO(1)
COEFF> nu3 nu4 nu5
STORE> coe(26)
COMMENT> Labour force
BEHAVIORAL> ns
TSRANGE 1998 1 2019 1
EQ> ns = nu1*TSLAG(ns,1) + nu2*(nd-TSLAG(ns,1))
COEFF> nu1 nu2
STORE> coe(27)
COMMENT> Wage rate growth (note: nun = 0; from 1998)
BEHAVIORAL> gw
TSRANGE 1998 1 2019 1
EQ> gw = omega2*TSDELTA(un,1) + omega3*TSDELTAP(pc,1)
COEFF> omega2 omega3
STORE> coe(28)
COMMENT> Wage rate
IDENTITY> w
EQ> w = TSLAG(w,1)*(1+gw)
COMMENT> Unemployment rate
IDENTITY> un
EQ> un = 1-(nd/ns)
COMMENT> CALCULATIONS
COMMENT> Government deficit net of seigniorage
IDENTITY> def0
EQ> def0 = def1 + fcb
COMMENT> GDP growth rate
IDENTITY> gy
EQ> gy = (y-TSLAG(y,1))/TSLAG(y,1)
COMMENT> consumption growth rate
IDENTITY> gc
EQ> gc = (cons/TSLAG(cons,1)) - 1
COMMENT> Investment growth rate
IDENTITY> gid
EQ> gid = (id/TSLAG(id,1)) - 1
COMMENT> Export growth rate
IDENTITY> gx
EQ> gx = (x/TSLAG(x,1)) - 1
COMMENT> Import growth rate
IDENTITY> gim
EQ> gim = (im/TSLAG(im,1)) - 1
COMMENT> Potential employment (if working hours were fixed; note: better calculated as: (y/p)/prod)
IDENTITY> nd_star
EQ> nd_star = y/prod
COMMENT> Max. interest rate implied by stability condition
IDENTITY> RR
EQ> RR = gy + (tax-tr-gov)/bs
COMMENT> Max. government spending implied by stability condition
IDENTITY> GG
EQ> GG = tax-tr-bs*(rb-gy)
COMMENT> PRODUCTION AND PRICES
COMMENT> Price level: GDP deflator
BEHAVIORAL> p
TSRANGE 1998 1 2019 1
EQ> p = vi0 + vi1*TSLAG(p,1)
COEFF> vi0 vi1
STORE> coe(30)
COMMENT> Price level: CPI
BEHAVIORAL> pc
TSRANGE 1998 1 2019 1
EQ> pc = fi1*w + fi2*prod + fi3*TSLAG(p,1)
COEFF> fi1 fi2 fi3
STORE> coe(43)
END"
##############################################################################
#C) CALCULATE TARGET CAPITAL
#Deflate K
kr = 100*DataCJE$K/DataCJE$P
#Take log of real capital
lk<-log(kr)
#Filter K log
lk.hp <- hpfilter(lk, freq=100, drift=FALSE)
##############################################################################
#D) LOAD THE MODEL AND ESTIMATE COEFFICIENTS
#Load the model
S_model=LOAD_MODEL(modelText = S_model.txt)
#Attribute values to model variables and coefficients
S_modelData=list(
y = TIMESERIES(c(DataCJE$Y),
START=c(1995,1),FREQ=1),
cons = TIMESERIES(c(DataCJE$CONS),
START=c(1995,1),FREQ=1),
id = TIMESERIES(c(DataCJE$INV),
START=c(1995,1),FREQ=1),
gov = TIMESERIES(c(DataCJE$GOV),
START=c(1995,1),FREQ=1),
gov_net = TIMESERIES(c(DataCJE$GOV),
START=c(1995,1),FREQ=1),
x = TIMESERIES(c(DataCJE$X),
START=c(1995,1),FREQ=1),
Lx = TIMESERIES(c(log(DataCJE$X)),
START=c(1995,1),FREQ=1),
im = TIMESERIES(c(DataCJE$IM),
START=c(1995,1),FREQ=1),
consR = TIMESERIES(c(DataCJE$CONS*100/DataCJE$P),
START=c(1995,1),FREQ=1),
LconsR = TIMESERIES(c(log(DataCJE$CONS*100/DataCJE$P)),
START=c(1995,1),FREQ=1),
idR = TIMESERIES(c(DataCJE$INV*100/DataCJE$P),
START=c(1995,1),FREQ=1),
nx = TIMESERIES(c(DataCJE$X-DataCJE$IM),
START=c(1995,1),FREQ=1),
wb = TIMESERIES(c(DataCJE$WB),
START=c(1995,1),FREQ=1),
yd = TIMESERIES(c(DataCJE$YD),
START=c(1995,1),FREQ=1),
nvh = TIMESERIES(c(DataCJE$NVh),
START=c(1995,1),FREQ=1),
vh = TIMESERIES(c(DataCJE$NVh+(-DataCJE$Lh)),
START=c(1995,1),FREQ=1),
k = TIMESERIES(c(DataCJE$K),
START=c(1995,1),FREQ=1),
intf = TIMESERIES(c(DataCJE$INTf),
START=c(1995,1),FREQ=1),
lf = TIMESERIES(c(-DataCJE$Lf),
START=c(1995,1),FREQ=1),
fdf = TIMESERIES(c(DataCJE$Fdf),
START=c(1995,1),FREQ=1),
ff = TIMESERIES(c(DataCJE$Ff),
START=c(1995,1),FREQ=1),
fuf = TIMESERIES(c(DataCJE$Fuf),
START=c(1995,1),FREQ=1),
es = TIMESERIES(c(-DataCJE$Es),
START=c(1995,1),FREQ=1),
eh = TIMESERIES(c(DataCJE$Eh),
START=c(1995,1),FREQ=1),
tax = TIMESERIES(c(DataCJE$TAX),
START=c(1995,1),FREQ=1),
tr = TIMESERIES(c(DataCJE$TR),
START=c(1995,1),FREQ=1),
lh = TIMESERIES(c(-DataCJE$Lh),
START=c(1995,1),FREQ=1),
ls = TIMESERIES(c(DataCJE$Ls),
START=c(1995,1),FREQ=1),
mh = TIMESERIES(c(DataCJE$Mh),
START=c(1995,1),FREQ=1),
ms = TIMESERIES(c(-DataCJE$Ms),
START=c(1995,1),FREQ=1),
inth = TIMESERIES(c(DataCJE$INTh),
START=c(1995,1),FREQ=1),
un = TIMESERIES(c(DataCJE$Un),
START=c(1995,1),FREQ=1),
Omega = TIMESERIES(c(DataCJE$WB/DataCJE$Y),
START=c(1995,1),FREQ=1),
ns = TIMESERIES(c(DataCJE$Ns),
START=c(1995,1),FREQ=1),
bs = TIMESERIES(c(-DataCJE$Bs),
START=c(1995,1),FREQ=1),
intg = TIMESERIES(c(DataCJE$R_b*DataCJE$Deb),
START=c(1995,1),FREQ=1),
bh_star = TIMESERIES(c(DataCJE$Bh),
START=c(1995,1),FREQ=1),
bh = TIMESERIES(c(DataCJE$Bh),
START=c(1995,1),FREQ=1),
rb = TIMESERIES(c(DataCJE$R_b),
START=c(1995,1),FREQ=1),
fcb = TIMESERIES(c(DataCJE$Fcb),
START=c(1995,1),FREQ=1),
re = TIMESERIES(c(DataCJE$Fdf/DataCJE$Eh),
START=c(1995,1),FREQ=1),
hh = TIMESERIES(c(DataCJE$Hh),
START=c(1995,1),FREQ=1),
rho = TIMESERIES(c(DataCJE$RHO),
START=c(1995,1),FREQ=1),
yf = TIMESERIES(c(DataCJE$YRoW/1000),
START=c(1995,1),FREQ=1),
fr = TIMESERIES(c(DataCJE$FR),
START=c(1995,1),FREQ=1),
rstar = TIMESERIES(c(DataCJE$R_star),
START=c(1995,1),FREQ=1),
mub = TIMESERIES(c(DataCJE$R_b-DataCJE$R_star),
START=c(1995,1),FREQ=1),
deb = TIMESERIES(c(DataCJE$Deb),
START=c(1995,1),FREQ=1),
ogdd = TIMESERIES(c(DataCJE$OGD),
START=c(1995,1),FREQ=1),
ogds = TIMESERIES(c(DataCJE$OGD),
START=c(1995,1),FREQ=1),
vg = TIMESERIES(c(DataCJE$Vg),
START=c(1995,1),FREQ=1),
def0 = TIMESERIES(c(DataCJE$DEF1+DataCJE$Fcb),
START=c(1995,1),FREQ=1),
def1 = TIMESERIES(c(DataCJE$DEF1),
START=c(1995,1),FREQ=1),
defa = TIMESERIES(c(DataCJE$DEF2-DataCJE$DEF1),
START=c(1995,1),FREQ=1),
def2 = TIMESERIES(c(DataCJE$DEF2),
START=c(1995,1),FREQ=1),
nd = TIMESERIES(c(DataCJE$Nd),
START=c(1995,1),FREQ=1),
w = TIMESERIES(c(DataCJE$w),
START=c(1995,1),FREQ=1),
gw = TIMESERIES(c(DataCJE$gw),
START=c(1995,1),FREQ=1),
bb = TIMESERIES(c(DataCJE$Bb),
START=c(1995,1),FREQ=1),
bcb = TIMESERIES(c(DataCJE$Bcb),
START=c(1995,1),FREQ=1),
bb_not = TIMESERIES(c(-DataCJE$Ms - DataCJE$Ls - DataCJE$HBd),
START=c(1995,1),FREQ=1),
hbd = TIMESERIES(c(DataCJE$HBd),
START=c(1995,1),FREQ=1),
hbs = TIMESERIES(c(-DataCJE$HBs),
START=c(1995,1),FREQ=1),
hs = TIMESERIES(c(-DataCJE$Hs ),
START=c(1995,1),FREQ=1),
hd = TIMESERIES(c(-DataCJE$Hs),
START=c(1995,1),FREQ=1),
fb = TIMESERIES(c(DataCJE$Fb ),
START=c(1995,1),FREQ=1),
lambdab = TIMESERIES(c(-DataCJE$Bcb/DataCJE$Bs),
START=c(1995,1),FREQ=1),
pr = TIMESERIES(c(DataCJE$Y/DataCJE$Nd),
START=c(1995,1),FREQ=1),
oph = TIMESERIES(c(DataCJE$OPH),
START=c(1995,1),FREQ=1),
opb = TIMESERIES(c(DataCJE$OPB),
START=c(1995,1),FREQ=1),
opcb = TIMESERIES(c(DataCJE$OPBC),
START=c(1995,1),FREQ=1),
opf = TIMESERIES(c(DataCJE$OPF),
START=c(1995,1),FREQ=1),
opg = TIMESERIES(c(DataCJE$OPG),
START=c(1995,1),FREQ=1),
oprow = TIMESERIES(c(DataCJE$OPROW),
START=c(1995,1),FREQ=1),
beta = TIMESERIES(c(DataCJE$Bb/(-DataCJE$Ms-DataCJE$Ls-DataCJE$HBd)),
START=c(1995,1),FREQ=1),
vb = TIMESERIES(c(DataCJE$Vb),
START=c(1995,1),FREQ=1),
vf = TIMESERIES(c(DataCJE$Vf),
START=c(1995,1),FREQ=1),
vrow = TIMESERIES(c(DataCJE$Vrow),
START=c(1995,1),FREQ=1),
oah = TIMESERIES(c(DataCJE$OAh),
START=c(1995,1),FREQ=1),
oaf = TIMESERIES(c(DataCJE$OAf),
START=c(1995,1),FREQ=1),
oab = TIMESERIES(c(DataCJE$OAb),
START=c(1995,1),FREQ=1),
oag = TIMESERIES(c(DataCJE$OAg),
START=c(1995,1),FREQ=1),
oacb = TIMESERIES(c(DataCJE$OAcb),
START=c(1995,1),FREQ=1),
oarow = TIMESERIES(c(DataCJE$OAROW),
START=c(1995,1),FREQ=1),
vcb = TIMESERIES(c(DataCJE$Vcb),
START=c(1995,1),FREQ=1),
kt = TIMESERIES(c(exp(lk.hp$trend)),
START=c(1995,1),FREQ=1),
kappa = TIMESERIES(c(exp(lk.hp$trend)*DataCJE$P/(DataCJE$Y*100)),
START=c(1995,1),FREQ=1),
p = TIMESERIES(c(DataCJE$P),
START=c(1995,1),FREQ=1),
prod = TIMESERIES(c(DataCJE$Prod),
START=c(1995,1),FREQ=1),
gy = TIMESERIES(c(DataCJE$gy),
START=c(1995,1),FREQ=1),
gc = TIMESERIES(c(DataCJE$gc),
START=c(1995,1),FREQ=1),
gid = TIMESERIES(c(DataCJE$gid),
START=c(1995,1),FREQ=1),
gx = TIMESERIES(c(DataCJE$gx),
START=c(1995,1),FREQ=1),
gim = TIMESERIES(c(DataCJE$gim),
START=c(1995,1),FREQ=1),
nd_star = TIMESERIES(c(DataCJE$Nd),
START=c(1995,1),FREQ=1),
rl = TIMESERIES(c(-DataCJE$INTf/DataCJE$Lf),
START=c(1995,1),FREQ=1),
intgb = TIMESERIES(c(DataCJE$INTgb),
START=c(1995,1),FREQ=1),
intgh = TIMESERIES(c(DataCJE$R_b*DataCJE$Bh),
START=c(1995,1),FREQ=1),
intlh = TIMESERIES(-c(((DataCJE$R_b*DataCJE$Bh)-DataCJE$INTh)),
START=c(1995,1),FREQ=1),
rlh = TIMESERIES(c(((DataCJE$R_b*DataCJE$Bh)-DataCJE$INTh)/DataCJE$Lh),
START=c(1995,1),FREQ=1),
pi = TIMESERIES(c(DataCJE$Pi),
START=c(1995,1),FREQ=1),
pf = TIMESERIES(c(DataCJE$PF),
START=c(1995,1),FREQ=1),
RR = TIMESERIES(c( DataCJE$gy+(DataCJE$TAX-DataCJE$GOV-DataCJE$TR)/(-DataCJE$Bs) ),
START=c(1995,1),FREQ=1),
GG = TIMESERIES(c( DataCJE$TAX-DataCJE$TR-(-DataCJE$Bs)*(DataCJE$R_b -DataCJE$gy) ),
START=c(1995,1),FREQ=1),
percb = TIMESERIES(c(DataCJE$PercB),
START=c(1995,1),FREQ=1),
debcb = TIMESERIES(c(DataCJE$PercB*DataCJE$Deb),
START=c(1995,1),FREQ=1),
bcb_star = TIMESERIES(c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
START=c(1995,1),FREQ=1),
loans = TIMESERIES(c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
START=c(1995,1),FREQ=1),
deb_l = TIMESERIES(c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
START=c(1995,1),FREQ=1),
grants = TIMESERIES(c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
START=c(1995,1),FREQ=1),
paym = TIMESERIES(c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
START=c(1995,1),FREQ=1),
pc = TIMESERIES(c(DataCJE$P2),
START=c(1995,1),FREQ=1)
)
#Load the data into the model
S_model=LOAD_MODEL_DATA(S_model,S_modelData)
#Estimate model coefficients
S_model=ESTIMATE(S_model
,TSRANGE=c(1998,1,2019,1)
,forceTSRANGE = TRUE
)
##############################################################################
#E) RUN AND SAVE IN-SAMPLE PREDICTIONS
# Define exogenization list
exogenizeList <- list(
rstar = TRUE,
defa = TRUE,
percb = TRUE,
oph = TRUE,
vb = TRUE,
opf = TRUE,
opcb = TRUE,
opg = TRUE,
oprow = TRUE,
loans = TRUE
)
# In-sample prediction (no add factors)
S_model <- SIMULATE(S_model
,simType='STATIC'
,TSRANGE=c(1997,1,2020,1)
,simConvergence=0.00001
,simIterLimit=100
,Exogenize=exogenizeList)
#Save selected pre-baseline values with no add factors
y_00 = S_model$simulation$y
yd_00 = S_model$simulation$yd
cons_00 = S_model$simulation$cons
id_00 = S_model$simulation$id
gov_00 = S_model$simulation$gov
x_00 = S_model$simulation$x
im_00 = S_model$simulation$im
def2_00 = S_model$simulation$def2
def1_00 = S_model$simulation$def1
def0_00 = S_model$simulation$def0
deb_00 = S_model$simulation$deb
debcb_00 = S_model$simulation$debcb
tax_00 = S_model$simulation$tax
tr_00 = S_model$simulation$tr
intg_00 = S_model$simulation$intg
fcb_00 = S_model$simulation$fcb
gy_00 = S_model$simulation$gy
gc_00 = S_model$simulation$gc
gid_00 = S_model$simulation$gid
gx_00 = S_model$simulation$gx
gim_00 = S_model$simulation$gim
bcb_00 = S_model$simulation$bcb + S_model$simulation$bcb_star
bs_00 = S_model$simulation$bs
un_00 = S_model$simulation$un
rb_00 = S_model$simulation$rb
p_00 = S_model$simulation$p
pi_00 = (S_model$simulation$p - TSLAG(S_model$simulation$p,1))/TSLAG(S_model$simulation$p,1)
pc_00 = S_model$simulation$pc
pic_00 = (S_model$simulation$pc - TSLAG(S_model$simulation$pc,1))/TSLAG(S_model$simulation$pc,1)
lambdab_00 = S_model$simulation$lambdab
yf_00 = S_model$simulation$yf
ns_00 = S_model$simulation$ns
nd_00 = S_model$simulation$nd
fr_00 = S_model$simulation$fr
hh_00 = S_model$simulation$hh
hs_00 = S_model$simulation$hs
hbs_00 = S_model$simulation$hbs
loans_00 = S_model$simulation$loans
grants_00 = S_model$simulation$grants
paym_00 = S_model$simulation$paym
rl_00 = S_model$simulation$rl
RR_00 = S_model$simulation$RR
GG_00 = S_model$simulation$GG
nd_00 = S_model$simulation$nd
##############################################################################
#F) FORECAST SERIES USING IN-SAMPLE ADJUSTMENT (ADD FACTORS)
# Extend exogenous and conditionally evaluated variables up to 2026
S_model$modelData <- within(S_model$modelData,{
rho = TSEXTEND(rho, UPTO=c(2026,1))
wb = TSEXTEND(wb, UPTO=c(2026,1))
beta = TSEXTEND(beta, UPTO=c(2026,1))
pf = TSEXTEND(pf, UPTO=c(2026,1))
hd = TSEXTEND(hd, UPTO=c(2026,1))
})
# Define exogenization list to 2019
exogenizeList <- list(
#Adjusted variables in 1996-2019
LconsR = c(1996,1,2019,1),
idR = c(1996,1,2019,1),
x = c(1996,1,2019,1),
im = c(1996,1,2019,1),
k = c(1996,1,2019,1),
intf = c(1996,1,2019,1),
fuf = c(1996,1,2019,1),
ff = c(1996,1,2019,1),
lh = c(1996,1,2019,1),
inth = c(1996,1,2019,1),
tax = c(1996,1,2019,1),
tr = c(1996,1,2019,1),
intg = c(1996,1,2019,1),
eh = c(1996,1,2019,1),
bh_star = c(1996,1,2019,1),
hh = c(1996,1,2019,1),
oah = c(1996,1,2019,1),
yf = c(1996,1,2019,1),
rb = c(1996,1,2019,1),
nd = c(1996,1,2019,1),