Debian Codegraph @

tests/smoother2histval/fs2000_simul.mod

raw
1 // Test that histval_file works with a file created by smoother2histval (after a Metropolis)
2
3 var m P c e W R k d n l gy_obs gp_obs y dA;
4 varexo e_a e_m;
5
6 parameters alp bet gam mst rho psi del;
7
8 model;
9 dA = exp(gam+e_a);
10 log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
11 -P/(c(+1)*P(+1)*m)+bet*P(+1)*(alp*exp(-alp*(gam+log(e(+1))))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0;
12 W = l/n;
13 -(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
14 R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
15 1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l*c(+1)*P(+1)) = 0;
16 c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
17 P*c = m;
18 m-1+d = l;
19 e = exp(e_a);
20 y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a(-1)));
21 gy_obs = dA*y/y(-2);
22 gp_obs = (P/P(-1))*m(-1)/dA;
23 end;
24
25 steady_state_model;
26 dA = exp(gam);
27 gst = 1/dA;
28 m = mst;
29 khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
30 xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
31 nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
32 n = xist/(nust+xist);
33 P = xist + nust;
34 k = khst*n;
35
36 l = psi*mst*n/( (1-psi)*(1-n) );
37 c = mst/P;
38 d = l - mst + 1;
39 y = k^alp*n^(1-alp)*gst^alp;
40 R = mst/bet;
41 W = l/n;
42 ist = y-c;
43 q = 1 - d;
44
45 e = 1;
46
47 gp_obs = m/dA;
48 gy_obs = dA;
49 end;
50
51 % Use estimated parameters (posterior mean) as calibration
52 results_estimation=load(['fs2000_smooth' filesep 'Output' filesep 'fs2000_smooth_results']);
53 M_.params=results_estimation.M_.params;
54
55 steady;
56
57 histval_file(datafile = 'fs2000_histval.mat');
58
59 perfect_foresight_setup(periods = 100);
60 perfect_foresight_solver;
61
62
63 hf = dseries('fs2000_histval.mat');
64
65 % Check that y(0) is correct
66 assert(oo_.endo_simul(13,1) == hf.y('2Y').data)
67
68 % Check that y(-1) is correct
69 % First find the corresponding auxiliary variable
70 % NB: we must use cellfun and brackets become some orig_index and orig_lead_lag fields are empty
71 auxid = find([M_.aux_vars.type] == 1 & cellfun(@(x) isequal(x, 13), {M_.aux_vars.orig_index}) & cellfun(@(x) isequal(x, -1), {M_.aux_vars.orig_lead_lag}));
72 endoid = M_.aux_vars(auxid).endo_index;
73 assert(oo_.endo_simul(endoid,1) == hf.y('1Y').data);