Debian Codegraph @

tests/var-expectations/1-with-time-shift-b/example1.mod

raw
1 // --+ options: stochastic,json=compute +--
2
3 var foo z x y;
4 varexo e_x e_y e_z;
5 parameters a b c d e f beta ;
6
7 a = .9;
8 b = -.2;
9 c = .3;
10 f = .8;
11 d = .5;
12 e = .4;
13
14 beta = 1/(1+.02);
15
16 // Define a VAR model from a subset of equations in the model block.
17 var_model(model_name = toto, eqtags = [ 'X' 'Y' 'Z' ]);
18
19 /* Define a VAR_EXPECTATION_MODEL
20 ** ------------------------------
21 **
22 ** model_name: the name of the VAR_EXPECTATION_MODEL (mandatory).
23 ** var_model_name: the name of the VAR model used for the expectations (mandatory).
24 ** variable: the name of the variable to be forecasted (mandatory).
25 ** horizon: the horizon forecast (mandatory).
26 ** discount: the discount factor, which can be a value or a declared parameter (default is 1.0, no discounting).
27 ** time_shift: shifts the information set to the past, must be a non positive scalar. By default, expectations
28 ** about `variable` in period `t+horizon` are formed in period t (time_shift=0)
29 **
30 **
31 ** The `horizon` parameter can be an integer in which case the (discounted) `horizon` step ahead forecast
32 ** is computed using the VAR model `var_model_name`. Alternatively, `horizon` can be a range. In this case
33 ** VAR_EXPECTATION_MODEL returns a discounted sum of expected values. If `horizon` is set equal to the range
34 ** 0:Inf, then VAR_EXPECTATION_MODEL computes:
35 **
36 ** ∑ βʰ Eₜ[yₜ₊ₕ]
37 **
38 ** where the sum is over h=0,…,∞ and the conditional expectations are computed with VAR model `var_model_name`.
39 */
40
41 var_expectation_model(model_name = varexp, expression = x, auxiliary_model_name = toto, horizon = 1, time_shift=1, discount = beta) ;
42
43
44 model;
45 [ name = 'X' ]
46 x = a*x(-1) + b*x(-2) + c*z(-2) + e_x;
47 [ name = 'Z' ]
48 z = f*z(-1) + e_z;
49 [ name = 'Y' ]
50 y = d*y(-2) + e*z(-1) + e_y;
51
52 foo = .5*foo(-1) + var_expectation(varexp);
53 end;
54
55
56 // Initialize the VAR expectation model, will build the companion matrix of the VAR.
57 var_expectation.initialize('varexp')
58
59 // Update VAR_EXPECTATION reduced form parameters
60 try
61 var_expectation.update('varexp');
62 if isfield(M_.var_expectation.varexp, 'time_shift')
63 error('Preprocessor should not allow positive values for time_shift option.')
64 end
65 catch
66 end