File: lola_common.inc

package info (click to toggle)
dynare 7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 79,248 kB
  • sloc: cpp: 82,011; ansic: 28,583; objc: 12,573; yacc: 5,105; pascal: 2,374; lex: 1,502; python: 1,118; sh: 1,116; makefile: 605; lisp: 162; xml: 18
file content (982 lines) | stat: -rw-r--r-- 17,684 bytes parent folder | download
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
//  Based on Luca Marchiori/Olivier Pierrard(2012) LOLA 2.0: Luxembourg
//  OverLapping generation model for policy Analysis

/* Snippet common to several test files.

   Macro-variables that can be defined to tune the computations:
   - block
   - mfs
*/

load lola_data.mat

% ====================================================
% declarations var -- varexo -- para
% ====================================================

@#define nbr_work_generations=9
@#define nbr_early_generations=2
@#define nbr_generations=16

parameters
length_period age_early;

length_period=5;
age_early=55;

@#define wt=[1]

@#define wg=0:nbr_work_generations-1
@#define ag=0:nbr_generations-1
@#define fwg=0:nbr_work_generations-nbr_early_generations-1
@#define nbwg=1:nbr_work_generations-1
@#define nbg=1:nbr_generations-1
@#define rg=nbr_work_generations:nbr_generations-1
@#define erg=nbr_work_generations-nbr_early_generations:nbr_work_generations-1
@#define endg=[nbr_generations-1]
@#define endw=[nbr_work_generations-1]

@#for i in wg
var
n@{i} u@{i} Omega@{i} w@{i} dWHN@{i} dWFN@{i}
n@{i}_f u@{i}_f Omega@{i}_f w@{i}_f dWFN@{i}_f
i@{i} lambda@{i} i@{i}_f lambda@{i}_f eta@{i};
parameters
Du@{i} Dn@{i} h@{i} h@{i}_f chi@{i} eta@{i}b;
varexo
eps_eta@{i};
@#endfor

@#for i in ag
var
c@{i} s@{i} P@{i} P@{i}_f;
varexo
beta@{i} beta@{i}_f PD@{i};
@#endfor

@#for i in erg
var
WE@{i} De_@{i};
parameters
De_@{i}b;
varexo
eps_De_@{i};
@#endfor

var
wb wb_f
Omega Omega_f Omega_hf
V M qq p
N N_f
Q RR H K Y gdp nx FH pi
ct st wshare rr
gamma mc phii D DH DF X bs bsY P00_f

rhou rhoe rhol tauw tauc tauf tauk g
TFP gh rrb
theta tau1 om1 om2 om2s Ds phijs

DepRatio DepRatio_n DepRatio_d ZARA Ptot Ptot_f sleep du de dl inA inB in
NBR NBRY NBR2 tauw2 tauf2 tauc2
PensCorr_L PensCorr_F;

parameters
rho phi delta alpha beta ann
fc nu aa

rhoub rhoeb rholb tauwb taucb taufb taukb gb
TFPb ghb rrbb
thetab tau1b om1b om2b om2sb Dsb phijsb

NBRYb bsY_iss;

varexo
P00 P00_foP00

eps_rhol eps_tauw eps_tauf eps_tauc eps_tauk
eps_rhoe eps_rhou eps_TFP eps_gh eps_theta eps_g
eps_Ds eps_phijs eps_PensCorr_L eps_PensCorr_F;


% ============================================================
% initialization
% ============================================================

@#for i in wg
set_param_value('Du@{i}',Du@{i});
set_param_value('Dn@{i}',Dn@{i});
set_param_value('h@{i}',h@{i});
set_param_value('h@{i}_f',h@{i}_f);
set_param_value('chi@{i}',chi@{i});
set_param_value('eta@{i}b',eta@{i}b);
@#endfor

@#for i in erg
set_param_value('De_@{i}b',De_@{i}b);
@#endfor

set_param_value('rho',rho);
set_param_value('phi',phi);
set_param_value('delta',delta);
set_param_value('alpha',alpha);
set_param_value('beta',beta);
set_param_value('ann',ann);
set_param_value('fc',fc);
set_param_value('nu',nu);
set_param_value('aa',aa);

set_param_value('rhoub',rhoub);
set_param_value('rhoeb',rhoeb);
set_param_value('rholb',rholb);
set_param_value('tauwb',tauwb);
set_param_value('taucb',taucb);
set_param_value('taufb',taufb);
set_param_value('taukb',taukb);
set_param_value('gb',gb);

set_param_value('TFPb',TFPb);
set_param_value('ghb',ghb);
set_param_value('rrbb',rrbb);

set_param_value('thetab',thetab);
set_param_value('tau1b',tau1b);
set_param_value('om1b',om1b);
set_param_value('om2b',om2b);
set_param_value('om2sb',om2sb);
set_param_value('Dsb',Dsb);
set_param_value('phijsb',phijsb);

set_param_value('bsY_iss',bsY_iss);

NBRYb=NBR_iss/(phii_iss*gdp_iss);



@#if block
model(block, mfs=@{mfs}, static_mfs=@{mfs});
@#else
model;
@#endif

%  Labor Market Variables in the home country
%  ------------------------------------------

@#for i in fwg
0=lambda@{i};
@#endfor

@#for i in wg
1=n@{i}+u@{i}+i@{i};
@#endfor

i0=lambda0;
@#for i in nbwg
i@{i}=lambda@{i-1}(-1)+lambda@{i}*(1-lambda@{i-1}(-1));
@#endfor

P0=beta0*P00+PD0;
@#for i in nbg
P@{i}=beta@{i}*P@{i-1}(-1)+PD@{i};
@#endfor

Omega0=P0;
@#for i in nbwg
Omega@{i}=(1-lambda@{i})*( 1-lambda@{i-1}(-1)-(1-chi@{i})*n@{i-1}(-1))*P@{i};
@#endfor

n0=p;
@#for i in nbwg
n@{i}=(1-lambda@{i})*((1-p)*(1-chi@{i})*n@{i-1}(-1)+p*(1-lambda@{i-1}(-1)));
@#endfor

N=
@#for i in wg
+n@{i}*P@{i}
@#endfor
;

%  Labor Market Variables in the foreign country
%  ---------------------------------------------

@#for i in wg
1=n@{i}_f+u@{i}_f+i@{i}_f;
@#endfor

i0_f=lambda0_f;
@#for i in nbwg
i@{i}_f=lambda@{i-1}_f(-1)+lambda@{i}_f*(1-lambda@{i-1}_f(-1));
@#endfor

% -----------  reproduction cross-border   --------------------

P00_f=P00_foP00*P00;

P0_f=beta0_f*P00_f;
@#for i in nbg
P@{i}_f=beta@{i}_f*P@{i-1}_f(-1);
@#endfor

Omega0_f=P0_f;
@#for i in nbwg
Omega@{i}_f=(1-lambda@{i}_f)*(1-lambda@{i-1}_f(-1)-(1-chi@{i})*n@{i-1}_f(-1))*P@{i}_f;
@#endfor

n0_f=p;
@#for i in nbwg
n@{i}_f=(1-lambda@{i}_f)*((1-p)*(1-chi@{i})*n@{i-1}_f(-1)+p*(1-lambda@{i-1}_f(-1)));
@#endfor

N_f=
@#for i in wg
+n@{i}_f*P@{i}_f
@#endfor
;

%  Matching
% ----------

Omega=
@#for i in wg
+Omega@{i}
@#endfor
;

Omega_f=
@#for i in wg
+Omega@{i}_f
@#endfor
;

Omega_hf=Omega+Omega_f;

M=V*Omega_hf/(V^nu+Omega_hf^nu)^(1/nu);

qq=M/V;
p=M/Omega_hf;

%  Flow Budget Constraints (no bequests)
% --------------------------------------

rhou*w0*u0+ (1-tauw)*w0*n0 = (1+tauc)*c0+s0;
@#for i in nbwg
(1+rr*(1-tauk))/(beta@{i})^ann*s@{i-1}(-1)/(1+gh)+rhou*w@{i}*u@{i}+rhoe*w@{i}*i@{i}+(1-tauw)*w@{i}*n@{i}=(1+tauc)*c@{i}+s@{i};
@#endfor
@#for i in rg
(1+rr*(1-tauk))/(beta@{i})^ann*s@{i-1}(-1)/(1+gh)+rhol*wb=(1+tauc)*c@{i}+s@{i};
@#endfor
@#for i in endg
s@{i}=0;
@#endfor

wb=
@#for i in wg
+w@{i}/@{nbr_work_generations}
@#endfor
;

%  Euler Conditions
% ------------------

@#for i in nbg
1/(1+tauc)/c@{i-1}=beta*(1+rr(+1)*(1-tauk(+1)))/(1+tauc(+1))/c@{i}(+1)*(beta@{i})^(1-ann)/(1+gh);
@#endfor


%  Optimal Participation Rates (Early Retirement)
%  ----------------------------------------------

@#for i in erg
WE@{i} = 0;
@#endfor

@#for i in erg
@#if i in endw
WE@{i} = ((De_@{i}b*i@{i}^(phi-1))+Du@{i}+(rhoe-rhou)*w@{i}/(1+tauc)/c@{i})*(1-i@{i})-((1-tauw-rhou)*w@{i}/(1+tauc)/c@{i}-(Dn@{i}-Du@{i}))*n@{i};
@#else
WE@{i} = ((De_@{i}b*i@{i}^(phi-1))+Du@{i}+(rhoe-rhou)*w@{i}/(1+tauc)/c@{i})*(1-i@{i})-((1-tauw-rhou)*w@{i}/(1+tauc)/c@{i}-(Dn@{i}-Du@{i}))*n@{i}+ beta*beta@{i+1}*WE@{i+1};
@#endif
@#endfor

%  Household Surplus
% -------------------

@#for i in wg
@#if i in endw
dWHN@{i} = w@{i}*(1-tauw-rhou)/(1+tauc)-(Dn@{i}-Du@{i})*c@{i};
@#else
dWHN@{i} = w@{i}*(1-tauw-rhou)/(1+tauc)-(Dn@{i}-Du@{i})*c@{i} + beta*beta@{i+1}*c@{i}/c@{i+1}(+1)*dWHN@{i+1}(+1)*(1-p(+1))*(1-chi@{i+1})*(1-lambda@{i+1}(+1));
@#endif
@#endfor

%  Foreign household
%  ------------------------
%  participation and wages
% ........................

@#for i in wg
lambda@{i}=lambda@{i}_f;
w@{i}_f=w@{i};
@#endfor

wb_f=
@#for i in wg
+w@{i}_f/@{nbr_work_generations}
@#endfor
;

%  Firm's Behavior
% -------------------

H=
@#for i in wg
+h@{i}*n@{i}*P@{i}+h@{i}_f*n@{i}_f*P@{i}_f
@#endfor
;

wshare=(1+tauf)*(
@#for i in wg
+w@{i}*n@{i}*P@{i}+w@{i}_f*n@{i}_f*P@{i}_f
@#endfor
)/(phii*gdp);

Y=TFP*H^(1-alpha)*(K)^alpha;
gdp= TFP*H^(1-alpha)*(K)^alpha-aa*V/phii-fc/phii;
pi = phii*gdp - wshare*phii*gdp - (rr+delta)*K(-1)/(1+gh);
(rr(+1)+delta)/(1+rr(+1)*(1-tauk(+1))) = mc*TFP*alpha*(H/(K))^(1-alpha);
FH=TFP*(1-alpha)*((K)/H)^alpha;

RR=1+rr*(1-tauk);
rr=rrb+tau1*(exp(bsY_iss-bsY)-1);

%  Firm's Surplus
%  ---------------------

@#for i in wg
@#if i in endw
dWFN@{i} = h@{i}*mc*FH-(1+tauf)*w@{i};
dWFN@{i}_f = h@{i}_f*mc*FH-(1+tauf)*w@{i}_f;
@#else
dWFN@{i} = h@{i}*mc*FH-(1+tauf)*w@{i} + beta@{i+1}/RR(+1)*dWFN@{i+1}(+1)*(1-chi@{i+1})*(1-lambda@{i+1}(+1))*(1+gh);
dWFN@{i}_f = h@{i}_f*mc*FH-(1+tauf)*w@{i}_f + beta@{i+1}_f/RR(+1)*dWFN@{i+1}_f(+1)*(1-chi@{i+1})*(1-lambda@{i+1}_f(+1))*(1+gh);
@#endif
@#endfor

%  Free Entry Condition
%  ---------------------

aa=qq/Omega_hf*(
@#for i in wg
+Omega@{i}*dWFN@{i}+Omega@{i}_f*dWFN@{i}_f
@#endfor
);

%  Wage Determination (Rent Sharing)
%  -----------------------------------

@#for i in wg
(1-eta@{i})*dWHN@{i}  =  eta@{i}*((1-tauw)/(1+tauf)/(1+tauc))*dWFN@{i};
@#endfor

%  Equilibrium Conditions
%  ----------------------

ct=
@#for i in ag
+c@{i}*P@{i}
@#endfor
;

st=
@#for i in ag
+s@{i}*P@{i}
@#endfor
;

%  Non-Arbitrage condition (physical capital-shares)
% .........................

Q(+1)+pi(+1)=(1+rr(+1))*Q/(1+gh);

%  New Open Economy Macroeconomics (NOEM)
%  ---------------------------------------

phii=mc/theta;
D= ct + K-(1-delta)*K(-1)/(1+gh)  + g*gdp*phii + fc+aa*V;
DH=(1/om1*phii)^(1/(rho-1))*D;
X=(1/om2s*phii/gamma)^(1/(rho-1))*Ds;
DF=(1/om2*gamma*phijs)^(1/(rho-1))*D;
nx=phii*X-phijs*gamma*DF;
bsY=bs/(phii*gdp);
Y=DH+X;
phii*gdp=ct + K-(1-delta)*K(-1)/(1+gh) + g*gdp*phii+nx;

st=K+Q +bs ;

%  Policies
%  ----------

rhou=rhoub*eps_rhou;
rhoe=rhoeb*eps_rhoe;
rhol=rholb*eps_rhol;
g=gb*eps_g;

@#for i in erg
De_@{i}=De_@{i}b*eps_De_@{i};
@#endfor

TFP=TFPb*eps_TFP;
gh=ghb*eps_gh;

@#for i in wg
eta@{i}=eta@{i}b*eps_eta@{i};
@#endfor

rrb=rrbb;

theta=thetab*eps_theta;
tau1=tau1b;
om1=om1b;
om2=om2b;
om2s=om2sb;
Ds=Dsb*eps_Ds;
phijs=phijsb*eps_phijs;


% ----------- RefDR scenario

DepRatio_n=
@#for i in rg
+P@{i}
@#endfor
;
DepRatio_d=
@#for i in wg
+P@{i}
@#endfor
;

DepRatio=DepRatio_n/DepRatio_d;

ZARA=age_early+length_period*(
@#for i in erg
+1-i@{i}
@#endfor
);

% ----------- WGEM

Ptot=
@#for i in ag
+P@{i}
@#endfor
;
Ptot_f=
@#for i in ag
+P@{i}_f
@#endfor
;

sleep=(1+rr)*(
@#for i in nbg
+1/beta@{i}*(1-1/beta@{i}^(ann-1))*s@{i-1}(-1)*P@{i}
@#endfor
)/(1+gh);

du=rhou*(
@#for i in wg
+w@{i}*u@{i}*P@{i}
@#endfor
);

de=rhoe*(
@#for i in erg
+w@{i}*i@{i}*P@{i}+w@{i}_f*i@{i}_f*P@{i}_f
@#endfor
);

dl=
@#for i in rg
+rhol*wb*PensCorr_L*P@{i}+rhol*wb_f*(N_f/(N+N_f))*PensCorr_F*P@{i}_f
@#endfor
;

PensCorr_L=eps_PensCorr_L;
PensCorr_F=eps_PensCorr_F;

inA=(tauw+tauf)*(
@#for i in wg
+n@{i}*w@{i}*P@{i}+n@{i}_f*w@{i}_f*P@{i}_f
@#endfor
);

inB=tauk*rr*(
@#for i in nbg
+1/beta@{i}^ann*s@{i-1}(-1)*P@{i}
@#endfor
)/(1+gh);

in=tauc*ct+inA+inB+sleep;
NBR=g*phii*gdp+(du+de+dl)-(in);
NBRY=NBR/(phii*gdp);

% ----------- WGEM Adjustment variable ---------------

tauf2=tauf;
tauw2=tauw;
NBR2=NBR;
tauc2=tauc;
tauf=taufb*eps_tauf;
%----- WGEM: adjustment through tauc
tauc=taucb*eps_tauc;
%----- WGEM: adjustment through tauk
tauk=taukb*eps_tauk;
%----- WGEM: adjustment through tauw
tauw=tauwb*eps_tauw;

end;

%==================================
initval;
%==================================

@#for i in wg
n@{i}=n@{i}_iss;
n@{i}_f=n@{i}_f_iss;
u@{i}=u@{i}_iss;
u@{i}_f=u@{i}_f_iss;
Omega@{i}=Omega@{i}_iss;
Omega@{i}_f=Omega@{i}_f_iss;
w@{i}=w@{i}_iss;
w@{i}_f=w@{i}_f_iss;
dWHN@{i}=dWHN@{i}_iss;
dWFN@{i}=dWFN@{i}_iss;
dWFN@{i}_f=dWFN@{i}_f_iss;
eps_eta@{i}=eps_eta@{i}_iss;
eta@{i}=eta@{i}b*eps_eta@{i};
@#endfor

@#for i in erg
i@{i}=i@{i}_iss;
lambda@{i}=lambda@{i}_iss;
i@{i}_f=i@{i}_f_iss;
lambda@{i}_f=lambda@{i}_f_iss;
WE@{i}=0;
eps_De_@{i}=eps_De_@{i}_iss;
De_@{i}=De_@{i}b*eps_De_@{i}_iss;
@#endfor

@#for i in fwg
i@{i}=0;
lambda@{i}=0;
i@{i}_f=0;
lambda@{i}_f=0;
@#endfor

@#for i in ag
@#if i in endg
s@{i}=0;
@#else
s@{i}=s@{i}_iss;
@#endif
@#endfor

@#for i in ag
beta@{i}=beta@{i}_iss;
beta@{i}_f=beta@{i}_f_iss;
PD@{i}=PD@{i}_iss;
c@{i}=c@{i}_iss;
P@{i}=P@{i}_iss;
P@{i}_f=P@{i}_f_iss;
@#endfor

wb          =   wb_iss;
wb_f        =   wb_f_iss;
Omega       =   Omega_iss;
Omega_f     =   Omega_f_iss;
Omega_hf    =   Omega_hf_iss;
V        	=	V_iss	;
M        	=	M_iss	;
qq       	=	qq_iss	;
p        	=	p_iss	;
N        	=	N_iss	;
N_f      	=	N_f_iss	;
Q        	=	Q_iss	;
RR       	=	RR_iss	;
H        	=	H_iss	;
K        	=	K_iss	;
Y        	=	Y_iss	;
gdp      	=	gdp_iss	;
nx       	=	nx_iss	;
FH       	=	FH_iss	;
pi       	=	pi_iss	;
ct       	=	ct_iss	;
st       	=	st_iss	;
wshare   	=	wshare_iss	;
rr       	=	rr_iss	;

gamma    	=	gamma_iss	;
mc       	=	mc_iss	;
phii     	=	phii_iss	;
D        	=	D_iss	;
DH       	=	DH_iss	;
DF       	=	DF_iss	;
X        	=	X_iss	;
bs       	=	bs_iss	;
bsY      	=	bsY_iss	;
P00_f       =   P00_f_iss;

eps_rhol=eps_rhol_iss;
eps_rhoe=eps_rhoe_iss;
eps_rhou=eps_rhou_iss;
rhou=rhoub*eps_rhou_iss;
rhoe=rhoeb*eps_rhoe_iss;
rhol=rholb*eps_rhol_iss;
eps_tauc=eps_tauc_iss;
eps_tauk=eps_tauk_iss;
eps_tauw=eps_tauw_iss;
eps_tauf=eps_tauf_iss;
tauw=tauwb*eps_tauw;
tauc=taucb*eps_tauc;
tauf=taufb*eps_tauf;
tauk=taukb*eps_tauk;
eps_theta=eps_theta_iss;
eps_gh=eps_gh_iss;
eps_TFP=eps_TFP_iss;
eps_g=eps_g_iss;
g=gb*eps_g_iss;
TFP=TFPb*eps_TFP_iss;
gh=ghb*eps_gh_iss;
theta=thetab*eps_theta_iss;

rrb=rrbb;
tau1=tau1b;
om1=om1b;
om2=om2b;
om2s=om2sb;

eps_Ds=1;
eps_phijs=1;
Ds=Dsb*eps_Ds;
phijs=phijsb*eps_phijs;

eps_PensCorr_F=eps_PensCorr_F_iss;
eps_PensCorr_L=eps_PensCorr_L_iss;
PensCorr_F=eps_PensCorr_F_iss;
PensCorr_L=eps_PensCorr_L_iss;

P00	        =	P00_iss	;
P00_foP00	=	P00_foP00_iss	;

DepRatio_n=
@#for i in rg
+P@{i}
@#endfor
;
DepRatio_d=
@#for i in wg
+P@{i}
@#endfor
;

DepRatio=DepRatio_n/DepRatio_d;

ZARA=age_early+length_period*(
@#for i in erg
+1-i@{i}
@#endfor
);

Ptot=Ptot_iss;
Ptot_f=Ptot_f_iss;
sleep=sleep_iss;
du=du_iss;
de=de_iss;
dl=dl_iss;

inA=inA_iss;%(tauw+tauf)*(
%@#for i in wg
%+n@{i}*w@{i}*P@{i}+n@{i}_f*w@{i}_f*P@{i}_f
%@#endfor
%);

inB=inB_iss;%tauk*rr*(
%@#for i in nbg
%+1/beta@{i}^ann*s@{i-1}*P@{i}
%@#endfor
%)/(1+gh);

in=in_iss;%tauc*ct+inA+inB+sleep;
NBR=NBR_iss;%g*phii*gdp+(du+de+dl)-(in);
NBRY=NBR/(phii*gdp);
NBR2=NBR;
tauf2=tauf;
tauw2=tauw;
tauc2=tauc;

end;

%==============================
% compute initial steady state
%==============================

resid;
steady(solve_algo=3);

endval;
@#for i in wg
n@{i}=n@{i}_fss;
n@{i}_f=n@{i}_f_fss;
u@{i}=u@{i}_fss;
u@{i}_f=u@{i}_f_fss;
Omega@{i}=Omega@{i}_fss;
Omega@{i}_f=Omega@{i}_f_fss;
w@{i}=w@{i}_fss;
w@{i}_f=w@{i}_f_fss;
dWHN@{i}=dWHN@{i}_fss;
dWFN@{i}=dWFN@{i}_fss;
dWFN@{i}_f=dWFN@{i}_f_fss;
eps_eta@{i}=eps_eta@{i}_fss;
eta@{i}=eta@{i}b*eps_eta@{i};
@#endfor

@#for i in erg
i@{i}=i@{i}_fss;
lambda@{i}=lambda@{i}_fss;
i@{i}_f=i@{i}_f_fss;
lambda@{i}_f=lambda@{i}_f_fss;
WE@{i}=0;
eps_De_@{i}=eps_De_@{i}_fss;
De_@{i}=De_@{i}b*eps_De_@{i}_fss;
@#endfor

@#for i in fwg
i@{i}=0;
lambda@{i}=0;
i@{i}_f=0;
lambda@{i}_f=0;
@#endfor

@#for i in ag
@#if i in endg
s@{i}=0;
@#else
s@{i}=s@{i}_fss;
@#endif
@#endfor

@#for i in ag
beta@{i}=beta@{i}_fss;
beta@{i}_f=beta@{i}_f_fss;
PD@{i}=PD@{i}_fss;
c@{i}=c@{i}_fss;
P@{i}=P@{i}_fss;
P@{i}_f=P@{i}_f_fss;
@#endfor

wb          =   wb_fss;
wb_f        =   wb_f_fss;
Omega       =   Omega_fss;
Omega_f     =   Omega_f_fss;
Omega_hf    =   Omega_hf_fss;
V        	=	V_fss	;
M        	=	M_fss	;
qq       	=	qq_fss	;
p        	=	p_fss	;
N        	=	N_fss	;
N_f      	=	N_f_fss	;
Q        	=	Q_fss	;
RR       	=	RR_fss	;
H        	=	H_fss	;
K        	=	K_fss	;
Y        	=	Y_fss	;
gdp      	=	gdp_fss	;
nx       	=	nx_fss	;
FH       	=	FH_fss	;
pi       	=	pi_fss	;
ct       	=	ct_fss	;
st       	=	st_fss	;
wshare   	=	wshare_fss	;
rr       	=	rr_fss	;

gamma    	=	gamma_fss	;
mc       	=	mc_fss	;
phii     	=	phii_fss	;
D        	=	D_fss	;
DH       	=	DH_fss	;
DF       	=	DF_fss	;
X        	=	X_fss	;
bs       	=	bs_fss	;
bsY      	=	bsY_fss	;
P00_f       =   P00_f_fss;

eps_rhol=eps_rhol_fss;
eps_rhoe=eps_rhoe_fss;
eps_rhou=eps_rhou_fss;
rhou=rhoub*eps_rhou_fss;
rhoe=rhoeb*eps_rhoe_fss;
rhol=rholb*eps_rhol_fss;
eps_tauc=eps_tauc_fss;
eps_tauk=eps_tauk_fss;
eps_tauw=eps_tauw_fss;
eps_tauf=eps_tauf_fss;
tauw=tauwb*eps_tauw;
tauc=taucb*eps_tauc;
tauf=taufb*eps_tauf;
tauk=taukb*eps_tauk;
eps_theta=eps_theta_fss;
eps_gh=eps_gh_fss;
eps_TFP=eps_TFP_fss;
eps_g=eps_g_fss;
g=gb*eps_g_fss;
TFP=TFPb*eps_TFP_fss;
gh=ghb*eps_gh_fss;
theta=thetab*eps_theta_fss;

rrb=rrbb;
tau1=tau1b;
om1=om1b;
om2=om2b;
om2s=om2sb;

eps_Ds=1;
eps_phijs=1;
Ds=Dsb*eps_Ds;
phijs=phijsb*eps_phijs;

eps_PensCorr_F=eps_PensCorr_F_fss;
eps_PensCorr_L=eps_PensCorr_L_fss;
PensCorr_F=eps_PensCorr_F_fss;
PensCorr_L=eps_PensCorr_L_fss;

P00	        =	P00_fss	;
P00_foP00	=	P00_foP00_fss	;

DepRatio_n=
@#for i in rg
+P@{i}
@#endfor
;
DepRatio_d=
@#for i in wg
+P@{i}
@#endfor
;

DepRatio=DepRatio_n/DepRatio_d;

ZARA=age_early+length_period*(
@#for i in erg
+1-i@{i}
@#endfor
);

Ptot=
@#for i in ag
+P@{i}
@#endfor
;
Ptot_f=
@#for i in ag
+P@{i}_f
@#endfor
;

sleep=(1+rr)*(
@#for i in nbg
+1/beta@{i}*(1-1/beta@{i}^(ann-1))*s@{i-1}*P@{i}
@#endfor
)/(1+gh);

du=rhou*(
@#for i in wg
+w@{i}*u@{i}*P@{i}
@#endfor
);

de=rhoe*(
@#for i in erg
+w@{i}*i@{i}*P@{i}+w@{i}_f*i@{i}_f*P@{i}_f
@#endfor
);

dl=
@#for i in rg
+rhol*wb*PensCorr_L*P@{i}+rhol*wb_f*(N_f/(N+N_f))*PensCorr_F*P@{i}_f
@#endfor
;

inA=(tauw+tauf)*(
@#for i in wg
+n@{i}*w@{i}*P@{i}+n@{i}_f*w@{i}_f*P@{i}_f
@#endfor
);

inB=tauk*rr*(
@#for i in nbg
+1/beta@{i}^ann*s@{i-1}*P@{i}
@#endfor
)/(1+gh);

in=tauc*ct+inA+inB+sleep;
NBR=g*phii*gdp+(du+de+dl)-(in);
NBRY=NBR/(phii*gdp);
NBR2=NBR;
tauf2=tauf;
tauw2=tauw;
tauc2=tauc;
end;

%============================
% compute final steady state
%============================

resid;
steady(solve_algo=3);


shocks;
  var P00;
  periods 1:99;
  values (se_P00);

@#for i in nbg
  var beta@{i};
  periods  1:99;
  values (se_beta@{i});

  var beta@{i}_f;
  periods  1:99;
  values (se_beta@{i}_f);

  var PD@{i};
  periods  1:99;
  values (se_PD@{i});
@#endfor

  var P00_foP00;
  periods 1:99;
  values (se_P00_foP00);

  var eps_g;
  periods 1:99;
  values (se_eps_g);

  var eps_PensCorr_F;
  periods 1:99;
  values (se_eps_PensCorr_F);

  var eps_PensCorr_L;
  periods 1:99;
  values (se_eps_PensCorr_L);
end;

% *******************************************
% Numerical Simulation, Control Parameters
% *******************************************

perfect_foresight_setup(periods=125);
perfect_foresight_solver;

if ~oo_.deterministic_simulation.status
   error('Perfect foresight simulation failed')
end