rbcii.mod 3.07 KB
Newer Older
1
@#define extended_path_version = 1
2

3
var Capital, Output, Labour, Consumption,  Investment, Output1, Labour1, Consumption1, Output2, Labour2, Consumption2, Efficiency, efficiency, ExpectedTerm;
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

varexo EfficiencyInnovation;

parameters beta, theta, tau, alpha, psi, delta, rho, effstar, sigma2;

/*
** Calibration
*/


beta    =  0.990;
theta   =  0.357;
tau     =  2.000;
alpha   =  0.450;
psi     =  -0.500;
delta   =  0.020;
rho     =  0.995;
effstar =  1.000;
sigma2  =  0.001;


@#if extended_path_version
    rho = 0.800;
@#endif
28

29
external_function(name=mean_preserving_spread,nargs=2);
30

31
model;
32
33
34

  efficiency = rho*efficiency(-1) + EfficiencyInnovation;

35
  Efficiency = effstar*exp(efficiency-mean_preserving_spread(rho,sigma2));
36

37
  (((Consumption1^theta)*((1-Labour1)^(1-theta)))^(1-tau))/Consumption1 - ExpectedTerm(1);
38

39
  ExpectedTerm = beta*((((Consumption^theta)*((1-Labour)^(1-theta)))^(1-tau))/Consumption)*(alpha*((Output/Capital(-1))^(1-psi))+1-delta);
40

41
  ((1-theta)/theta)*(Consumption1/(1-Labour1)) - (1-alpha)*(Output1/Labour1)^(1-psi);
42

43
  Output1 = Efficiency*(alpha*(Capital(-1)^psi)+(1-alpha)*(Labour1^psi))^(1/psi);
44

45
46
47
48
49
50
51
52
53
  Consumption2  = Output2;

  ((1-theta)/theta)*(Consumption2/(1-Labour2)) - (1-alpha)*(Output2/Labour2)^(1-psi);

  Output2 = Efficiency*(alpha*(Capital(-1)^psi)+(1-alpha)*(Labour2^psi))^(1/psi);

  Consumption = (Output1 > Consumption1)*Consumption1 + (1-(Output1 > Consumption1))*Consumption2;

  Labour = (Output1 > Consumption1)*Labour1 + (1-(Output1 > Consumption1))*Labour2;
54

55
56
57
58
59
  Output = (Output1 > Consumption1)*Output1 + (1-(Output1 > Consumption1))*Output2;

  Capital = Output-Consumption + (1-delta)*Capital(-1);

  Investment = Capital - (1-delta)*Capital(-1);
60
61
62

end;

63
64
65
// Write analytical steady state file (without globals)
options_.steadystate_flag = 2;
copyfile('rbcii_steady_state.m','rbcii_steadystate2.m');
66
67
68
69

@#if extended_path_version

    shocks;
70
    var EfficiencyInnovation = 1;
71
72
    end;

73
    steady(nocheck);
74

75
76
    options_.maxit_ = 100;
    options_.ep.verbosity = 0;
77
    options_.ep.stochastic.order = 0;
78
    options_.ep.stochastic.nodes = 2;
79
    options_.console_mode = 0;
80
    ts = extended_path([],100);
81

82
    options_.ep.stochastic.order = 1;
83
    sts = extended_path([],100);
84

85
86
//    options_.ep.stochastic.order = 2;
//    sts2 = extended_path([],100);
87

88
89
90
//    options_.ep.stochastic.order = 3;
//    sts3 = extended_path([],100);

91
92
//    figure(1)
//    plot(ts(2,:)-ts(4,:));
93

94
95
//    figure(2)
//    plot(sts(2,:)-sts(4,:));
96

97
98
//    figure(3)
//    plot(sts(2,:)-ts(2,:))
99

100
//    figure(4)
101
//    plot([(ts(2,:)-ts(4,:))' (sts(2,:)-sts(4,:))' (sts2(2,:)-sts2(4,:))' (sts3(2,:)-sts3(4,:))']) 
102
//    plot([(ts(2,:)-ts(4,:))' (sts(2,:)-sts(4,:))']) 
103

104
105
106
107
108
109
110
111
112
@#else

    shocks;
    var EfficiencyInnovation;
    periods 1;
    values -.4;
    end;

    steady;
113

114
    options_.maxit_ = 100;
115

116
117
118
    simul(periods=4000);

    n = 100;
119
120

    figure('Name','(rbcii) Investment.');
121
    plot(Output(1:n)-Consumption(1:n),'-b','linewidth',2)
122
123
124

    figure('Name','(rbcii) Lagrange multiplier associated to the positivity constraint on investment.');
    plot(LagrangeMultiplier(1:n),'-b','linewidth',2)
125

126
@#endif