Debian Codegraph @

tests/heterogeneity/ks_news_shocks_stochastic_options_xfail.mod

raw
1 // EXPECTEDFAIL Test: News shocks + heterogeneity_simulate stochastic options
2 //
3 // This test verifies that the preprocessor correctly rejects .mod files that
4 // combine news shocks (anticipated shocks known at t=0) with stochastic
5 // simulation options in heterogeneity_simulate.
6 //
7 // NEWS SHOCKS are triggered by shocks block with 'periods' and 'values' keywords
8 // STOCHASTIC OPTIONS include: irf, periods, drop, irf_shocks, relative_irf
9 //
10 // These modes are mutually exclusive (Auclert et al. 2021 terminology).
11 //
12 // USAGE: Set TEST_OPTION macro to select which option to test:
13 // -DTEST_OPTION=periods : Test periods option
14 // -DTEST_OPTION=irf : Test irf option
15 // -DTEST_OPTION=irf_shocks : Test irf_shocks option
16 // -DTEST_OPTION=relative_irf : Test relative_irf option
17 // -DTEST_OPTION=combined : Test combined irf+periods
18 //
19 // Expected result: Preprocessor error during dynare command execution
20
21 @#echomacrovars
22
23 // Minimal Krusell-Smith model definition
24 heterogeneity_dimension households;
25
26 var(heterogeneity=households)
27 c // Consumption
28 a // Assets
29 Va // Derivative of the value function w.r.t assets
30 ;
31
32 varexo(heterogeneity=households)
33 e // Idiosyncratic productivity shock
34 ;
35
36 var
37 Y // Aggregate output
38 r // Rate of return on capital net of depreciation
39 w // Wage rate
40 K // Aggregate capital
41 ;
42
43 varexo Z; // Aggregate productivity shock
44
45 parameters
46 L // Labor
47 alpha // Share of capital in production function
48 beta // Subjective discount rate of households
49 delta // Capital depreciation rate
50 eis // Elasticity of intertemporal substitution
51 Z_ss // Aggregate TFP shock average value
52 ;
53
54 // Household optimization problem
55 model(heterogeneity=households);
56 c^(-1/eis)-beta*Va(+1)=0 ⟂ a>=0;
57 (1+r)*a(-1)+w*e-c-a;
58 Va = (1+r)*c^(-1/eis);
59 end;
60
61 // Aggregate equilibrium conditions
62 model;
63 (Z_ss+Z) * K(-1)^alpha * L^(1 - alpha) - Y;
64 alpha * (Z_ss+Z) * (K(-1) / L)^(alpha - 1) - delta - r;
65 (1 - alpha) * (Z_ss+Z) * (K(-1) / L)^alpha - w;
66 K - SUM(a);
67 end;
68
69 //==========================================================================
70 // NEWS SHOCKS DEFINITION
71 // Using 'periods' and 'values' keywords triggers news shock sequence mode
72 //==========================================================================
73 shocks;
74 var Z;
75 periods 1:10;
76 values 0.01;
77 end;
78
79 heterogeneity_load_steady_state(filename=ks);
80
81 heterogeneity_solve;
82
83 //==========================================================================
84 // CONFLICTING HETEROGENEITY_SIMULATE COMMAND
85 // This should trigger preprocessor validation error
86 //==========================================================================
87 @#if TEST_OPTION == "periods"
88 // ERROR: 'periods' option conflicts with news shock mode
89 heterogeneity_simulate(periods = 100);
90
91 @#elseif TEST_OPTION == "irf"
92 // ERROR: 'irf' option conflicts with news shock mode
93 heterogeneity_simulate(irf = 50);
94
95 @#elseif TEST_OPTION == "irf_shocks"
96 // ERROR: 'irf_shocks' option conflicts with news shock mode
97 heterogeneity_simulate(irf_shocks = (Z));
98
99 @#elseif TEST_OPTION == "relative_irf"
100 // ERROR: 'relative_irf' option conflicts with news shock mode
101 heterogeneity_simulate(relative_irf);
102
103 @#elseif TEST_OPTION == "combined"
104 // ERROR: Combined options conflict with news shock mode
105 heterogeneity_simulate(irf = 50, periods = 100);
106
107 @#else
108 @#error "Invalid TEST_OPTION: must be periods, irf, irf_shocks, relative_irf, or combined"
109 @#endif