Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 4.3
  • 4.4
  • 4.5
  • 4.6
  • 5.x
  • 6.x
  • asm
  • aux_func
  • benchmark-ec
  • clang+openmp
  • covariance-quadratic-approximation
  • dates-and-dseries-improvements
  • declare_vars_in_model_block
  • dmm
  • dprior
  • dragonfly
  • dynamic-striated
  • dynare_minreal
  • eigen
  • ep-sparse
  • error_msg_undeclared_model_vars
  • estim_params
  • exceptions
  • exo_steady_state
  • filter_initial_state
  • gpm-optimal-policy
  • julia
  • kalman_mex
  • master
  • mex-GetPowerDeriv
  • mr#2134
  • new-samplers
  • newton-quadratic-equation-solver
  • nlf-fixes
  • nlf-fixes-r
  • nls-fixes
  • nonlinear-filter-fixes
  • occbin
  • pac-mce-with-composite-target
  • parfor
  • penalty
  • rebase-1
  • remove-persistent-variables
  • remove-priordens
  • reset-seed-in-unit-tests
  • rmExtraExo
  • sep
  • sep-fixes
  • separateM_
  • silicon
  • silicon-new-samplers
  • slice
  • sphinx-doc-experimental
  • static_aux_vars
  • time-varying-information-set
  • use-dprior
  • various_fixes
  • 3.062
  • 3.063
  • 4.0.0
  • 4.0.1
  • 4.0.2
  • 4.0.3
  • 4.0.4
  • 4.1-alpha1
  • 4.1-alpha2
  • 4.1.0
  • 4.1.1
  • 4.1.2
  • 4.1.3
  • 4.2.0
  • 4.2.1
  • 4.2.2
  • 4.2.3
  • 4.2.4
  • 4.2.5
  • 4.3.0
  • 4.3.1
  • 4.3.2
  • 4.3.3
  • 4.4-beta1
  • 4.4.0
  • 4.4.1
  • 4.4.2
  • 4.4.3
  • 4.5.0
  • 4.5.1
  • 4.5.2
  • 4.5.3
  • 4.5.4
  • 4.5.5
  • 4.5.6
  • 4.5.7
  • 4.6-beta1
  • 4.6.0
  • 4.6.0-rc1
  • 4.6.0-rc2
  • 4.6.1
  • 4.6.2
  • 4.6.3
  • 4.6.4
  • 4.7-beta1
  • 4.7-beta2
  • 4.7-beta3
  • 5.0
  • 5.0-rc1
  • 5.1
  • 5.2
  • 5.3
  • 5.4
  • 5.5
111 results

Target

Select target project
  • giovanma/dynare
  • giorgiomas/dynare
  • Vermandel/dynare
  • Dynare/dynare
  • normann/dynare
  • MichelJuillard/dynare
  • wmutschl/dynare
  • FerhatMihoubi/dynare
  • sebastien/dynare
  • lnsongxf/dynare
  • rattoma/dynare
  • CIMERS/dynare
  • FredericKarame/dynare
  • SumuduK/dynare
  • MinjeJeon/dynare
  • camilomrch/dynare
  • DoraK/dynare
  • avtishin/dynare
  • selma/dynare
  • claudio_olguin/dynare
  • jeffjiang07/dynare
  • EthanSystem/dynare
  • stepan-a/dynare
  • wjgatt/dynare
  • JohannesPfeifer/dynare
  • gboehl/dynare
  • ebenetce/dynare
  • chskcau/dynare-doc-fixes
28 results
Select Git revision
  • 4.3
  • 4.4
  • 4.5
  • 4.6
  • 5.x
  • 6.x
  • asm
  • aux_func
  • clang+openmp
  • dates-and-dseries-improvements
  • declare_vars_in_model_block
  • dmm
  • dragonfly
  • dynare_minreal
  • eigen
  • error_msg_undeclared_model_vars
  • estim_params
  • exo_steady_state
  • gpm-optimal-policy
  • julia
  • madysson
  • master
  • mex-GetPowerDeriv
  • penalty
  • separateM_
  • slice
  • sphinx-doc-experimental
  • static_aux_vars
  • time-varying-information-set
  • various_fixes
  • 3.062
  • 3.063
  • 4.0.0
  • 4.0.1
  • 4.0.2
  • 4.0.3
  • 4.0.4
  • 4.1-alpha1
  • 4.1-alpha2
  • 4.1.0
  • 4.1.1
  • 4.1.2
  • 4.1.3
  • 4.2.0
  • 4.2.1
  • 4.2.2
  • 4.2.3
  • 4.2.4
  • 4.2.5
  • 4.3.0
  • 4.3.1
  • 4.3.2
  • 4.3.3
  • 4.4-beta1
  • 4.4.0
  • 4.4.1
  • 4.4.2
  • 4.4.3
  • 4.5.0
  • 4.5.1
  • 4.5.2
  • 4.5.3
  • 4.5.4
  • 4.5.5
  • 4.5.6
  • 4.5.7
  • 4.6-beta1
  • 4.6.0
  • 4.6.0-rc1
  • 4.6.0-rc2
  • 4.6.1
  • 4.6.2
  • 4.6.3
  • 4.6.4
  • 4.7-beta1
  • 4.7-beta2
  • 4.7-beta3
  • 5.0
  • 5.0-rc1
  • 5.1
  • 5.2
  • 5.3
  • 5.4
  • 5.5
  • 6-beta1
  • 6-beta2
  • 6.0
  • 6.1
  • 6.2
  • 6.3
  • 6.4
91 results
Show changes
Showing
with 878 additions and 156 deletions
/* Checks that, for order = 2, k_order_solver = 0 (fs2000k2a)
and k_order_solver = 1 (this file) give the same results */
// Test that the presence of a non estimated parameter in the estimated_params_init block does not lead to a crash.
/*
* Copyright (C) 2004-2017 Dynare Team
*
* This file is part of Dynare.
*
* Dynare is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dynare is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
var m P c e W R k d n l gy_obs gp_obs y dA;
varexo e_a e_m;
......@@ -14,7 +32,7 @@ rho = 0.7;
psi = 0.787;
del = 0.02;
model (use_dll);
model;
dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
-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;
......@@ -31,47 +49,57 @@ gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA;
end;
initval;
m = mst;
P = 2.25;
c = 0.45;
e = 1;
W = 4;
R = 1.02;
k = 6;
d = 0.85;
n = 0.19;
l = 0.86;
y = 0.6;
gy_obs = exp(gam);
gp_obs = exp(-gam);
dA = exp(gam);
end;
shocks;
var e_a; stderr 0.014;
var e_m; stderr 0.005;
end;
steady_state_model;
dA = exp(gam);
gst = 1/dA;
m = mst;
khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
n = xist/(nust+xist);
P = xist + nust;
k = khst*n;
l = psi*mst*n/( (1-psi)*(1-n) );
c = mst/P;
d = l - mst + 1;
y = k^alp*n^(1-alp)*gst^alp;
R = mst/bet;
W = l/n;
ist = y-c;
q = 1 - d;
e = 1;
gp_obs = m/dA;
gy_obs = dA;
end;
steady;
check;
estimated_params;
alp, beta_pdf, 0.356, 0.02;
bet, beta_pdf, 0.993, 0.002;
gam, normal_pdf, 0.0085, 0.003;
mst, normal_pdf, 1.0002, 0.007;
rho, beta_pdf, 0.129, 0.223;
rho, beta_pdf, 0.129, 0.100;
psi, beta_pdf, 0.65, 0.05;
del, beta_pdf, 0.01, 0.005;
stderr e_a, inv_gamma_pdf, 0.035449, inf;
% del, beta_pdf, 0.01, 0.005;
% stderr e_a, inv_gamma_pdf, 0.035449, inf;
stderr e_m, inv_gamma_pdf, 0.008862, inf;
end;
varobs gp_obs gy_obs;
//estimation(datafile=fsdat,nobs=192,loglinear,mh_replic=2000,
// mode_compute=4,mh_nblocks=2,mh_drop=0.45,mh_jscale=0.65);
estimation(datafile=fsdat,nobs=192,mh_replic=2000,
mode_compute=4,mh_nblocks=2,mh_drop=0.45,mh_jscale=0.65);
estimated_params_init;
del,0.02;
stderr e_a, 0.01;
corr e_a,e_m, 0.5;
end;
varobs gp_obs gy_obs;
\ No newline at end of file
......@@ -41,3 +41,11 @@ var u = 0.009^2;
end;
stoch_simul(periods=2000, drop=200);
%% test that simul_replic does not affect simulated moments
moments_temp=oo_.var;
set_dynare_seed('default');
stoch_simul(periods=2000, drop=200,simul_replic=2);
if ~isequal(moments_temp,oo_.var)
error('Simul_replic affects simulated moments')
end
\ No newline at end of file
var y yp z mu;
varexo ez eyp emu;
parameters alpha;
alpha = .889;
model(linear);
y = yp + z;
yp = mu + yp(-1) + eyp;
mu = mu(-1) + emu;
z = alpha*z(-1) + ez;
end;
initval;
y=8.655680;
z=0;
yp=8.655680;
mu=0;
end;
steady(nocheck);
estimated_params;
stderr emu , inv_gamma_pdf, 0.002 , inf;
stderr eyp , inv_gamma_pdf, 0.002 , inf;
stderr ez , inv_gamma_pdf, 0.06 , inf;
alpha, normal_pdf, 0.9, 0.1;
end;
varobs y;
estimation(datafile=trend_cycle_decomposition_data,nobs=82, mh_replic=2000, mode_compute=4, mh_nblocks=1, mh_jscale=0.3, filtered_vars, smoother, diffuse_filter) yp z;
y=[8.655680
8.656123
8.654401
8.641229
8.630567
8.620637
8.605288
8.608660
8.620357
8.619683
8.630202
8.636380
8.614226
8.605106
8.537263
8.555079
8.591242
8.626651
8.645062
8.671851
8.704031
8.723127
8.737705
8.750433
8.758621
8.772876
8.790050
8.794088
8.798091
8.816624
8.836301
8.852974
8.872307
8.887314
8.902466
8.924601
8.944691
8.960662
8.973784
8.984161
9.000123
9.019129
9.035000
9.054575
9.075913
9.094302
9.114171
9.135554
9.157538
9.176307
9.193220
9.220434
9.246620
9.257001
9.243476
9.202275
9.160007
9.147657
9.157229
9.171294
9.189745
9.198273
9.201042
9.214450
9.225220
9.233702
9.247974
9.262110
9.272097
9.275883
9.277719
9.278357
9.282812
9.289376
9.290788
9.292530
9.295274
9.297219
9.297555
9.290289
9.271941
9.255655];
ipc=[23.5993149
24.9374227
15.5668177
12.822998
8.720567
5.2893706
3.4198277
3.274742
3.664711
3.0744047
2.0693272
1.704983
1.3786582
1.3437517
2.6167173
4.7126735
6.3341827
7.3020707
6.5659735
4.3717219
3.4512364
4.7505574
5.6671666
5.6241466
5.5933745
4.7565382
3.7032831
3.6624086
3.8250059
3.2723449
3.3568247
3.7965188
3.5401286
2.7513284
2.5482882
2.2870368
2.0836978
2.6555146
3.3263235
3.3905589
3.2762151
2.8684465
2.1706005
2.3531933
2.5136208
2.3339758
2.0782414
1.8397957
1.7220838
2.3651145
3.4129652
3.8212567
3.9356373
3.6723844
3.11287
2.9099557
3.1280929
2.5837809
1.5138311
1.191679
1.286452
1.8904928
2.4851907
2.7408867
2.2572768
1.3839678
0.813925
0.88364
1.2723562
2.0426676
2.4161978
1.5967846
0.9763814
1.6120089
2.0962214
1.6427865
1.5391928
2.0537506
3.1496297
4.34142
4.3532191
2.2026746];
// Regression test for issue #1608 (combining forecast, varexo_det and linear)
var y, pi, i, g, u, k;
varexo e_g e_u e_k;
varexo_det gov;
parameters lambda, pi_target, y_target, phi_pi, phi, rho, rhoout, rhopi, rhoint, sigma1, sigma2, sigma3;
lambda = 0.3;
pi_target = 0;
y_target = 0;
phi_pi = 1.5;
phi = 1;
rho = 0.99;
T = 50;
rhoout = 0.8;
rhopi = 0.5;
rhoint = 0;
sigma1 = 1;
sigma2 = 1;
sigma3 = 1;
model(linear);
y=y(+1)-phi*(i-pi(+1))+gov+g;
pi=lambda*y+rho*pi(+1)+u;
i=phi_pi*(pi-pi_target)+k;
g=rhoout*g(-1)+e_g;
u=rhopi*u(-1)+e_u;
k=rhoint*k(-1)+e_k;
end;
steady;
check;
shocks;
var e_g;
stderr sigma1;
var e_u;
stderr sigma2;
var e_k;
stderr sigma3;
var gov;
periods 1:9;
values 0.2;
end;
stoch_simul(irf=0);
forecast;
......@@ -88,7 +88,7 @@ end;
moment_calibration;
//y_obs,y_obs, [0.8 1.1]; //[unconditional variance]
y_obs,y_obs(-(1:4)), +; //[first year acf]
y_obs,y_obs(1:4), +; //[first year acf]
//y_obs,pie_obs(-4:4), -; //[ccf]
@#for ilag in -2:2
y_obs,R_obs(@{ilag}), -; //[ccf]
......
......@@ -52,15 +52,15 @@ SmoothedShocks(:,:,6)=cell2mat(struct2cell(oo_.SmoothedShocks));
SmoothedVariables(:,:,6)=cell2mat(struct2cell(oo_.SmoothedVariables));
if max(max(abs(SmoothedMeasurementErrors-repmat(SmoothedMeasurementErrors(:,:,1),[1,1,6]))))>1e-8
if max(max(abs(SmoothedMeasurementErrors-repmat(SmoothedMeasurementErrors(:,:,1),[1,1,6]))))>1e-6
error('SmoothedMeasurementErrors do not match')
end
if max(max(abs(SmoothedShocks-repmat(SmoothedShocks(:,:,1),[1,1,6]))))>1e-8
if max(max(abs(SmoothedShocks-repmat(SmoothedShocks(:,:,1),[1,1,6]))))>1e-6
error('SmoothedShocks do not match')
end
if max(max(abs(SmoothedVariables-repmat(SmoothedVariables(:,:,1),[1,1,6]))))>1e-8
if max(max(abs(SmoothedVariables-repmat(SmoothedVariables(:,:,1),[1,1,6]))))>1e-6
error('SmoothedVariables do not match')
end
......
var Capital, Output, Labour, Consumption, Investment, Efficiency, efficiency, residual, marginal_utility;
varexo EfficiencyInnovation;
parameters beta, theta, tau, alpha, psi, delta, rho, effstar, sigma;
/*
** Calibration
*/
var k, y, L, c, i, A, a, mu;
varexo epsilon;
parameters beta, theta, tau, alpha, psi, delta, rho, Astar, sigma;
beta = 0.990;
theta = 0.357;
tau = 2.000;
alpha = 0.450;
psi = -0.200;
psi = -2.500;
delta = 0.020;
rho = 0.800;
effstar = 1.000;
rho = 0.998;
Astar = 1.000;
sigma = 0.100;
model;
efficiency = rho*efficiency(-1) + sigma*EfficiencyInnovation;
Efficiency = effstar*exp(efficiency);
[mcp = 'Investment > 0',name='Investment Euler Equation']
-(((Consumption^theta)*((1-Labour)^(1-theta)))^(1-tau))/Consumption + beta*((((Consumption(+1)^theta)*((1-Labour(+1))^(1-theta)))^(1-tau))/Consumption(+1))*(alpha*((Output(+1)/Capital)^(1-psi))+1-delta);
residual = (((Consumption^theta)*((1-Labour)^(1-theta)))^(1-tau))/Consumption - beta*((((Consumption(+1)^theta)*((1-Labour(+1))^(1-theta)))^(1-tau))/Consumption(+1))*(alpha*((Output(+1)/Capital)^(1-psi))+1-delta);
((1-theta)/theta)*(Consumption/(1-Labour)) - (1-alpha)*(Output/Labour)^(1-psi);
Output = Efficiency*(alpha*(Capital(-1)^psi)+(1-alpha)*(Labour^psi))^(1/psi);
Output = Consumption + Investment;
Investment = Capital - (1-delta)*Capital(-1);
marginal_utility = (((Consumption^theta)*((1-Labour)^(1-theta)))^(1-tau))/Consumption;
a = rho*a(-1) + sigma*epsilon;
A = Astar*exp(a);
(c^theta*(1-L)^(1-theta))^(1-tau)/c - mu = beta*((c(+1)^theta*(1-L(+1))^(1-theta))^(1-tau)/c(+1)*(alpha*(y(+1)/k)^(1-psi)+1-delta)-mu(+1)*(1-delta));
((1-theta)/theta)*(c/(1-L)) - (1-alpha)*(y/L)^(1-psi);
y = A*(alpha*(k(-1)^psi)+(1-alpha)*(L^psi))^(1/psi);
k = y-c+(1-delta)*k(-1);
i = k-(1-delta)*k(-1);
[ mcp = 'i > 0' ]
mu = 0;
end;
steady_state_model;
Efficiency = effstar;
y_k = (Efficiency^(-psi)*(1/beta-1+delta)/alpha)^(1/(1-psi));
c_k = y_k - delta;
n_k = (((y_k/Efficiency)^psi-alpha)/(1-alpha))^(1/psi);
y_n = y_k/n_k;
c_n = c_k/n_k;
Labour = y_k*(1-alpha)/(((1-theta)/theta)*c_k*(alpha*n_k^(-psi)+1-alpha)+y_k*(1-alpha));
Capital = Labour/n_k;
Consumption = c_n*Labour;
Output = Efficiency*(alpha*Capital^psi+(1-alpha)*Labour^psi)^(1/psi);
Investment = delta*Capital;
residual = 0;
marginal_utility = (((Consumption^theta)*((1-Labour)^(1-theta)))^(1-tau))/Consumption;
a=0;
mu=0;
A=Astar;
// Steady state ratios
Output_per_unit_of_Capital=((1/beta-1+delta)/alpha)^(1/(1-psi));
Consumption_per_unit_of_Capital=Output_per_unit_of_Capital-delta;
Labour_per_unit_of_Capital=(((Output_per_unit_of_Capital/A)^psi-alpha)/(1-alpha))^(1/psi);
Output_per_unit_of_Labour=Output_per_unit_of_Capital/Labour_per_unit_of_Capital;
Consumption_per_unit_of_Labour=Consumption_per_unit_of_Capital/Labour_per_unit_of_Capital;
L=1/(1+Consumption_per_unit_of_Labour/((1-alpha)*theta/(1-theta)*Output_per_unit_of_Labour^(1-psi)));
c=Consumption_per_unit_of_Labour*L;
k=L/Labour_per_unit_of_Capital;
y=Output_per_unit_of_Capital*k;
i=delta*k;
end;
resid;
steady;
shocks;
var EfficiencyInnovation;
periods 1;
values -4;
var epsilon;
periods 10;
values -1;
end;
perfect_foresight_setup(periods=100);
steady;
perfect_foresight_setup(periods=400);
perfect_foresight_solver(lmmcp, maxit=200);
perfect_foresight_solver(lmmcp);
n = 40;
rplot Investment;
figure(2);
subplot(3,2,1); plot(1:n,A(1:n)); title('A');
subplot(3,2,2); plot(2:n,y(2:n)); title('y');
subplot(3,2,3); plot(2:n,L(2:n)); title('L');
subplot(3,2,4); plot(1:n,k(1:n)); title('k');
subplot(3,2,5); plot(2:n,c(2:n)); title('c');
subplot(3,2,6); plot(2:n, y(2:n)-c(2:n)); title('i');
rplot residual;
//test whether Dynare correctly reverts to linear approximation if 0 Hessian is detected
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
varexo e_R e_q e_ys e_pies e_A;
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
psi1 = 1.54;
psi2 = 0.25;
psi3 = 0.25;
rho_R = 0.5;
alpha = 0.3;
rr = 2.51;
k = 0.5;
tau = 0.5;
rho_q = 0.4;
rho_A = 0.2;
rho_ys = 0.9;
rho_pies = 0.7;
model;
y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
pie = de+(1-alpha)*dq+pie_s;
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
dq = rho_q*dq(-1)+e_q;
y_s = rho_ys*y_s(-1)+e_ys;
pie_s = rho_pies*pie_s(-1)+e_pies;
A = rho_A*A(-1)+e_A;
y_obs = y-y(-1)+A;
pie_obs = 4*pie;
R_obs = 4*R;
end;
shocks;
var e_R = 1.25^2;
var e_q = 2.5^2;
var e_A = 1.89;
var e_ys = 1.89;
var e_pies = 1.89;
end;
stoch_simul(order=2);
\ No newline at end of file
/*
* This file replicates the estimation of the cash in advance model (termed M1
* in the paper) described in Frank Schorfheide (2000): "Loss function-based
* evaluation of DSGE models", Journal of Applied Econometrics, 15(6), 645-670.
*
* The data are in file "fsdat_simul.m", and have been artificially generated.
* They are therefore different from the original dataset used by Schorfheide.
*
* The prior distribution follows the one originally specified in Schorfheide's
* paper, except for parameter rho. In the paper, the elicited beta prior for rho
* implies an asymptote and corresponding prior mode at 0. It is generally
* recommended to avoid this extreme type of prior. Some optimizers, for instance
* mode_compute=12 (Mathworks' particleswarm algorithm) may find a posterior mode
* with rho equal to zero. We lowered the value of the prior standard deviation
* (changing .223 to .100) to remove the asymptote.
*
* The equations are taken from J. Nason and T. Cogley (1994): "Testing the
* implications of long-run neutrality for monetary business cycle models",
* Journal of Applied Econometrics, 9, S37-S70.
* Note that there is an initial minus sign missing in equation (A1), p. S63.
*
* This implementation was originally written by Michel Juillard. Please note that the
* following copyright notice only applies to this Dynare implementation of the
* model.
*/
/*
* Copyright (C) 2004-2017 Dynare Team
*
* This file is part of Dynare.
*
* Dynare is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dynare is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
var m P c e W R k d n l gy_obs gp_obs y dA;
varexo e_a e_m;
parameters alp bet gam mst rho psi del;
alp = 0.33;
bet = 0.99;
gam = 0.003;
mst = 1.011;
rho = 0.7;
psi = 0.787;
del = 0.02;
model;
dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
-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;
W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
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;
c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m;
m-1+d = l;
e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA;
end;
shocks;
var e_a; stderr 0.014;
var e_m; stderr 0.005;
end;
steady_state_model;
dA = exp(gam);
gst = 1/dA;
m = mst;
khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
n = xist/(nust+xist);
P = xist + nust;
k = khst*n;
l = psi*mst*n/( (1-psi)*(1-n) );
c = mst/P;
d = l - mst + 1;
y = k^alp*n^(1-alp)*gst^alp;
R = mst/bet;
W = l/n;
ist = y-c;
q = 1 - d;
e = 1;
gp_obs = m/dA;
gy_obs = dA;
end;
steady;
check;
estimated_params;
alp, beta_pdf, 0.356, 0.02;
bet, beta_pdf, 0.993, 0.002;
gam, normal_pdf, 0.0085, 0.003;
mst, normal_pdf, 1.0002, 0.007;
rho, beta_pdf, 0.129, 0.100;
psi, beta_pdf, 0.65, 0.05;
del, beta_pdf, 0.01, 0.005;
stderr e_a, inv_gamma_pdf, 0.035449, inf;
stderr e_m, inv_gamma_pdf, 0.008862, inf;
end;
varobs gp_obs gy_obs;
estimation(order=1,mode_compute=5, datafile='../fs2000/fsdat_simul.m', nobs=192, loglinear, mh_replic=20, mh_nblocks=1, mh_jscale=0.8,moments_varendo,
conditional_variance_decomposition=[2,2000],consider_all_endogenous,sub_draws=2);
stoch_simul(order=1,conditional_variance_decomposition=[2,2000],noprint,nograph);
par=load([M_.fname filesep 'metropolis' filesep M_.fname '_posterior_draws1']);
for par_iter=1:size(par.pdraws,1)
M_=set_parameters_locally(M_,par.pdraws{par_iter,1});
info=stoch_simul(var_list_);
correlation(:,:,par_iter)=cell2mat(oo_.autocorr);
covariance(:,:,par_iter)=oo_.var;
conditional_variance_decomposition(:,:,:,par_iter)=oo_.conditional_variance_decomposition;
variance_decomposition(:,:,par_iter)=oo_.variance_decomposition;
end
correlation=mean(correlation,3);
nvars=M_.orig_endo_nbr;
for var_iter_1=1:nvars
for var_iter_2=1:nvars
if max(abs(correlation(var_iter_1,var_iter_2:nvars:end)'-oo_.PosteriorTheoreticalMoments.dsge.correlation.Mean.(deblank(M_.endo_names(var_iter_1,:))).(deblank(M_.endo_names(var_iter_2,:)))))>1e-8
error('Correlations do not match')
end
end
end
covariance=mean(covariance,3);
nvars=size(M_.endo_names(1:M_.orig_endo_nbr,:),1);
for var_iter_1=1:nvars
for var_iter_2=var_iter_1:nvars
if max(abs(covariance(var_iter_1,var_iter_2)-oo_.PosteriorTheoreticalMoments.dsge.covariance.Mean.(deblank(M_.endo_names(var_iter_1,:))).(deblank(M_.endo_names(var_iter_2,:)))))>1e-8
error('Covariances do not match')
end
end
end
variance_decomposition=mean(variance_decomposition,3);
nvars=size(M_.endo_names(1:M_.orig_endo_nbr,:),1);
for var_iter_1=1:nvars
for shock_iter=1:M_.exo_nbr
if max(abs(variance_decomposition(var_iter_1,shock_iter)/100-oo_.PosteriorTheoreticalMoments.dsge.VarianceDecomposition.Mean.(deblank(M_.endo_names(var_iter_1,:))).(deblank(M_.exo_names(shock_iter,:)))))>1e-8
error('Variance decomposition does not match')
end
end
end
conditional_variance_decomposition=mean(conditional_variance_decomposition,4);
nvars=size(M_.endo_names(1:M_.orig_endo_nbr,:),1);
horizon_size=size(conditional_variance_decomposition,3);
for var_iter_1=1:nvars
for shock_iter=1:M_.exo_nbr
for horizon_iter=1:horizon_size
if max(abs(conditional_variance_decomposition(var_iter_1,horizon_iter,shock_iter)-oo_.PosteriorTheoreticalMoments.dsge.ConditionalVarianceDecomposition.Mean.(deblank(M_.endo_names(var_iter_1,:))).(deblank(M_.exo_names(shock_iter,:)))(horizon_iter)))>1e-8
error('Conditional Variance decomposition does not match')
end
end
end
end
/*
* The following lines were used to generate the data file. If you want to
* generate another random data file, comment the "estimation" line and uncomment
* the following lines.
*/
//stoch_simul(periods=200, order=1);
//datatomfile('fsdat_simul', char('gy_obs', 'gp_obs'));
% Test whether preprocessor recognizes state variables introduced by optimal policy Github #1193
var pai, c, n, r, a;
varexo u;
parameters beta, rho, epsilon, omega, phi, gamma;
beta=0.99;
gamma=3;
omega=17;
epsilon=8;
phi=1;
rho=0.95;
model;
a = rho*a(-1)+u;
1/c = beta*r/(c(+1)*pai(+1));
pai*(pai-1)/c = beta*pai(+1)*(pai(+1)-1)/c(+1)+epsilon*phi*n^(gamma+1)/omega -exp(a)*n*(epsilon-1)/(omega*c);
exp(a)*n = c+(omega/2)*(pai-1)^2;
end;
initval;
r=1;
end;
histval;
r(0)=1;
end;
steady_state_model;
a = 0;
pai = beta*r;
c = find_c(0.96,pai,beta,epsilon,phi,gamma,omega);
n = c+(omega/2)*(pai-1)^2;
end;
shocks;
var u; stderr 0.008;
var u;
periods 1;
values 1;
end;
options_.dr_display_tol=0;
planner_objective(ln(c)-phi*((n^(1+gamma))/(1+gamma)));
ramsey_policy(planner_discount=0.99,order=1,instruments=(r),periods=500);
\ No newline at end of file
% Test whether preprocessor fails if histval set future lags
var pai, c, n, r, a;
varexo u;
parameters beta, rho, epsilon, omega, phi, gamma;
beta=0.99;
gamma=3;
omega=17;
epsilon=8;
phi=1;
rho=0.95;
model;
a = rho*a(-1)+u;
1/c = beta*r/(c(+1)*pai(+1));
pai*(pai-1)/c = beta*pai(+1)*(pai(+1)-1)/c(+1)+epsilon*phi*n^(gamma+1)/omega -exp(a)*n*(epsilon-1)/(omega*c);
exp(a)*n = c+(omega/2)*(pai-1)^2;
end;
initval;
r=1;
end;
histval;
a(5)=1;
end;
steady_state_model;
a = 0;
pai = beta*r;
c = find_c(0.96,pai,beta,epsilon,phi,gamma,omega);
n = c+(omega/2)*(pai-1)^2;
end;
shocks;
var u; stderr 0.008;
var u;
periods 1;
values 1;
end;
options_.dr_display_tol=0;
planner_objective(ln(c)-phi*((n^(1+gamma))/(1+gamma)));
ramsey_policy(planner_discount=0.99,order=1,instruments=(r),periods=500);
\ No newline at end of file
// DGP
@#ifndef RISKY_CALIBRATION
@#define RISKY_CALIBRATION = 0
@#define RISKY_CALIBRATION = 1
@#endif
@#ifndef EXTREME_CALIBRATION
@#define EXTREME_CALIBRATION = 1
@#define EXTREME_CALIBRATION = 0
@#endif
@#ifndef BENCHMARK_CALIBRATION
@#define BENCHMARK_CALIBRATION = 0
......@@ -13,8 +13,11 @@
@#ifndef LINEAR_KALMAN
@#define LINEAR_KALMAN = 0
@#endif
@#ifndef NON_LINEAR_KALMAN
@#define NON_LINEAR_KALMAN = 0
@#endif
@#ifndef ALGO_SIR
@#define ALGO_SIR = 0
@#define ALGO_SIR = 1
@#endif
@#ifndef ALGO_SISmoothR
@#define ALGO_SISmoothR = 0
......@@ -29,7 +32,7 @@
@#define ALGO_GCF = 0
@#endif
@#ifndef ALGO_GUF
@#define ALGO_GUF = 1
@#define ALGO_GUF = 0
@#endif
@#ifndef ALGO_GMPF
@#define ALGO_GMPF = 0
......@@ -86,7 +89,7 @@ stderr l, uniform_pdf,,, 0.00001, 0.1;
stderr i, uniform_pdf,,, 0.00001, 0.1;
end;
@#if RISKY_CALIBRATION
@#if EXTREME_CALIBRATION
estimated_params_init;
alp, 0.4;
bet, 0.99;
......@@ -101,7 +104,7 @@ end;
end;
@#endif
@#if EXTREME_CALIBRATION
@#if RISKY_CALIBRATION
estimated_params_init;
alp, 0.4;
bet, 0.99;
......@@ -118,8 +121,9 @@ end;
varobs y l i ;
options_.mode_check.neighbourhood_size = .01 ;
options_.mode_check.neighbourhood_size = .1 ;
options_.mode_check.number_of_points = 250;
options_.threads.local_state_space_iteration_2 = 4;
@#if EXTREME_CALIBRATION
data(file='./extreme.m');
......@@ -135,11 +139,15 @@ options_.mode_check.number_of_points = 250;
@#if LINEAR_KALMAN
% estimation(nograph,order=1,mode_compute=8,mh_replic=0,mode_check);
estimation(nograph,order=1,mode_compute=8,mh_replic=0,mode_check);
@#endif
@#if NON_LINEAR_KALMAN
estimation(nograph,order=2,filter_algorithm=nlkf,mode_compute=8,mh_replic=0);
@#endif
@#if ALGO_SIR
estimation(order=2,nograph,number_of_particles=1000,mh_replic=0,mode_compute=8,mode_check);
estimation(order=2,nograph,number_of_particles=1000,mh_replic=0,mode_compute=8);
@#endif
@#if ALGO_SISmoothR
......@@ -149,7 +157,7 @@ options_.mode_check.number_of_points = 250;
@#endif
@#if ALGO_APF
estimation(order=2,nograph,filter_algorithm=apf,number_of_particles=1000,mh_replic=0,mode_compute=8,mode_check);
estimation(order=2,nograph,filter_algorithm=apf,number_of_particles=10000,resampling=none,mh_replic=0,mode_compute=8,mode_check);
@#endif
@#if ALGO_GPF
......@@ -163,7 +171,7 @@ options_.mode_check.number_of_points = 250;
@#endif
@#if ALGO_GUF
estimation(order=2,nograph,filter_algorithm=gf,proposal_approximation=unscented,distribution_approximation=unscented,mh_replic=0,mode_compute=4);
estimation(order=2,nograph,filter_algorithm=gf,proposal_approximation=unscented,distribution_approximation=unscented,mh_replic=0,mode_compute=8);
estimation(order=2,nograph,filter_algorithm=gf,proposal_approximation=unscented,distribution_approximation=unscented,mh_replic=0,mode_compute=8,mode_check);
@#endif
......
#!/bin/bash
declare -i total=0;
declare -i total_xfail=0;
declare -i failed=0;
declare -i xpassed=0;
declare -a failed_tests=("");
declare -a xpassed_tests=("");
declare -i total=0
declare -i total_xfail=0
declare -i failed=0
declare -i xpassed=0
declare -a failed_tests=()
declare -a xpassed_tests=()
# Parse TRS Files
tosort=""
for file in $1 ; do
# Find number of tests run in trs file
((total += `grep number-tests $file | cut -d: -f3`))
((total += $(grep ^:number-tests: "$file" | cut -d: -f3)))
# Find number of tests failed in trs file
numfailed=`grep number-failed-tests $file | cut -d: -f3`
if [ $numfailed -ne 0 ] ; then
((failed += $numfailed))
for failedfile in `grep list-of-failed-tests $file | cut -d: -f3` ; do
failed_tests=("${failed_tests[@]}" "$failedfile");
done
numfailed=$(grep ^:number-failed-tests: "$file" | cut -d: -f3)
if ((numfailed != 0)) ; then
((failed += numfailed))
failed_tests+=($(grep ^:list-of-failed-tests: "$file" | cut -d: -f3))
fi
time=`grep elapsed-time $file | cut -d: -f3`
tosort=`echo $tosort\| $file ' - ' $time:`
time=$(grep ^:elapsed-time: "$file" | cut -d: -f3)
tosort="$tosort| $file - $time:"
done
((passed=$total-$failed));
((passed = total - failed))
# Parse XFAIL TRS Files
for file in $2 ; do
# Find number of tests run in xfail trs file
((xfail = `grep number-tests $file | cut -d: -f3`))
((total_xfail += $xfail))
xfail=$(grep ^:number-tests: "$file" | cut -d: -f3)
((total_xfail += xfail))
# Find number of tests failed in trs file
numpassed=`grep number-failed-tests $file | cut -d: -f3`
if [ $numpassed -eq 0 ] ; then
((xpassed += (($xfail - $numpassed))))
for xpassedfile in `grep list-of-passed-tests $file | cut -d: -f3` ; do
xpassed_tests=("${xpassed_tests[@]}" "$xpassedfile");
done
numfailed=$(grep ^:number-failed-tests: "$file" | cut -d: -f3)
if ((numfailed != xfail)) ; then
((xpassed += xfail - numfailed))
xpassed_tests+=($(grep ^:list-of-passed-tests: "$file" | cut -d: -f3))
fi
time=`grep elapsed-time $file | cut -d: -f3`
tosort=`echo $tosort\| $file ' - ' $time:`
time=$(grep ^:elapsed-time: "$file" | cut -d: -f3)
tosort="$tosort| $file - $time:"
done
((xfailed=$total_xfail-$xpassed));
((total+=$total_xfail));
((xfailed = total_xfail - xpassed))
((total += total_xfail))
timing=`echo $tosort | tr ":" "\n" | sort -rn -k4 | sed -e 's/$/:/' | head -n10`
timing=$(echo "$tosort" | tr ":" "\n" | sort -rn -k4 | sed -e 's/$/:/' | head -n10)
# Determine if we are parsing Matlab or Octave trs files
if [ `grep -c '.m.trs' <<< $1` -eq 0 ]; then
prg='OCTAVE';
outfile='run_test_octave_output.txt'
if (($(grep -c '.m.trs' <<< "$1") == 0)); then
prg=OCTAVE
outfile=run_test_octave_output.txt
else
prg='MATLAB';
outfile='run_test_matlab_output.txt'
prg=MATLAB
outfile=run_test_matlab_output.txt
fi
# Print Output
echo '================================' > $outfile
echo 'DYNARE MAKE CHECK '$prg' RESULTS' >> $outfile
echo '================================' >> $outfile
echo '| TOTAL: '$total >> $outfile
echo '| PASS: '$passed >> $outfile
echo '| FAIL: '$failed >> $outfile
echo '| XFAIL: '$xfailed >> $outfile
echo '| XPASS: '$xpassed >> $outfile
if [ $failed -gt 0 ] ; then
echo '| LIST OF FAILED TESTS:' >> $outfile
for file in ${failed_tests[@]} ; do
if [ "$prg" == "MATLAB" ]; then
modfile=`sed 's/\.m\.trs/\.mod/g' <<< $file` >> $outfile
else
modfile=`sed 's/\.o\.trs/\.mod/g' <<< $file` >> $outfile
fi
echo '| * '$modfile >> $outfile
# Print Output (to stdout and to a file)
{
echo '================================'
echo "DYNARE MAKE CHECK $prg RESULTS"
echo '================================'
echo "| TOTAL: $total"
echo "| PASS: $passed"
echo "| FAIL: $failed"
echo "| XFAIL: $xfailed"
echo "| XPASS: $xpassed"
if ((failed > 0)) ; then
echo '|'
echo '| LIST OF FAILED TESTS:'
for file in "${failed_tests[@]}" ; do
echo "| * $file"
done
fi
if [ $xpassed -gt 0 ] ; then
echo '| LIST OF XPASSED TESTS:' >> $outfile
for file in ${xpassed_tests[@]} ; do
if [ "$prg" == "MATLAB" ]; then
modfile=`sed 's/\.m\.trs/\.mod/g' <<< $file` >> $outfile
else
modfile=`sed 's/\.o\.trs/\.mod/g' <<< $file` >> $outfile
fi
echo '| * '$modfile >> $outfile
if ((xpassed > 0)) ; then
echo '|'
echo '| LIST OF XPASSED TESTS:'
for file in "${xpassed_tests[@]}" ; do
echo "| * $file"
done
fi
echo '|' >> $outfile
echo '| LIST OF 10 SLOWEST TESTS:' >> $outfile
if [ "$prg" == "MATLAB" ]; then
timing=`sed 's/\.m\.trs/\.mod/g' <<< $timing`
echo '|'
echo '| LIST OF 10 SLOWEST TESTS:'
if [[ $prg == MATLAB ]]; then
timing=$(sed 's/\.m\.trs/\.mod/g' <<< "$timing")
else
timing=`sed 's/\.o\.trs/\.mod/g' <<< $timing`
timing=$(sed 's/\.o\.trs/\.mod/g' <<< "$timing")
fi
echo $timing | tr ':' '\n' | sed -e 's/^[ \t]*//' | \
sed '/^$/d' | sed -e 's/^|[ ]/| * /' >> $outfile
echo >> $outfile
echo "$timing" | tr ':' '\n' | sed -e 's/^[ \t]*//;/^$/d;s/^|[ ]/| * /'
echo
} | tee $outfile
# Exit with error code if some tests failed
((failed + xpassed == 0))
......@@ -25,7 +25,6 @@ load_octave_packages
top_test_dir = getenv('TOP_TEST_DIR');
addpath(top_test_dir);
addpath('.'); % workaround for bug in Octave 4.2.0-rc2: https://savannah.gnu.org/bugs/?49334
addpath([top_test_dir filesep '..' filesep 'matlab']);
## Test Dynare Version
......
%mod-file triggering the sim1_linear.m solver;
%The exogenous arma processes test whether the Jacobian at the
%deterministic steady state is correctly computed
var x
y
z;
varexo u
v;
parameters a1 a2 a3 a4
b1 b2 b3
c1;
a1 = .50;
a2 = .00;
a3 = .70;
a4 = .40;
b1 = .90;
b2 = .00;
b3 = .80;
c1 = .95;
model(linear);
y = a1*x(-1) + a2*x(+1) + a3*z + a4*y(-1);
z = b1*z(-1) + b2*z(+1) + b3*x + u;
x = c1*x(-1) + v +v(-1)+v(+1);
end;
initval;
y=-1;
x=-1;
z=-1;
end;
endval;
y=0;
x=0;
z=0;
end;
steady;
simul(periods=1000,stack_solve_algo=0);
......@@ -62,6 +62,6 @@ end
IntensiveCapitalStock = oo_.endo_simul(6,1:end)./(oo_.endo_simul(1,1:end).*oo_.endo_simul(3,1:end));
if abs(IntensiveCapitalStock-LongRunIntensiveCapitalStock)>1e-6
if abs(IntensiveCapitalStock(end)-LongRunIntensiveCapitalStock>1e-10)
error('Wrong long run level!')
end
......@@ -57,11 +57,11 @@ Using Dynare with Octave
Dynare also works on top of GNU Octave, a free clone of MATLAB (R) (see
<http://www.octave.org>).
This version of Dynare is compiled for Octave 4.2.1 (MinGW, 32bit and 64bit), and may not work
This version of Dynare is compiled for Octave 4.4.1 (MinGW, 32bit and 64bit), and may not work
with other versions of Octave. The recommended version of Octave can be
downloaded at:
http://www.dynare.org/download/octave/windows
https://www.gnu.org/software/octave/download.html
Every time you run Octave, you should type the two following commands (assuming
that you have installed Dynare at the standard location, and replacing '4.x.y'
......
......@@ -54,7 +54,7 @@ Section "Dynare core (preprocessor and M-files)"
SectionIn RO
!insertmacro DETERMINE_CONTEXT
SetOutPath $INSTDIR
File README.txt ..\NEWS mexopts-win32.bat mexopts-win64.bat ..\license.txt
File README.txt ..\NEWS mexopts-win32.bat mexopts-win64.bat ..\license.txt ..\VERSION
SetOutPath $INSTDIR\matlab
File /r ..\matlab\*.m
......@@ -98,21 +98,26 @@ Section "MEX files for MATLAB 64-bit, version 7.5 to 7.7 (R2007b to R2008b)"
File ..\mex\matlab\win64-7.5-7.7\*.mexw64
SectionEnd
Section "MEX files for MATLAB 64-bit, version 7.8 to 9.2 (R2009a to R2017a)"
SetOutPath $INSTDIR\mex\matlab\win64-7.8-9.2
File ..\mex\matlab\win64-7.8-9.2\*.mexw64
Section "MEX files for MATLAB 64-bit, version 7.8 to 9.3 (R2009a to R2017b)"
SetOutPath $INSTDIR\mex\matlab\win64-7.8-9.3
File ..\mex\matlab\win64-7.8-9.3\*.mexw64
SectionEnd
Section "MEX files for MATLAB 64-bit, version 9.4 to 9.7 (R2018a to R2019b)"
SetOutPath $INSTDIR\mex\matlab\win64-9.4-9.7
File ..\mex\matlab\win64-9.4-9.7\*.mexw64
SectionEnd
SectionGroupEnd
SectionGroup "MEX files for OCTAVE"
SectionGroup "MEX files for Octave"
Section "MEX files for Octave 4.2.1 (MinGW, 64bit)"
Section "MEX files for Octave 4.4.1 (MinGW, 64bit)"
SetOutPath $INSTDIR\mex\octave
File ..\mex\octave\*.mex ..\mex\octave\*.oct
SectionEnd
Section "MEX files for Octave 4.2.1 (MinGW, 32bit)"
Section "MEX files for Octave 4.4.1 (MinGW, 32bit)"
SetOutPath $INSTDIR\mex\octave32
File ..\mex\octave32\*.mex ..\mex\octave32\*.oct
SectionEnd
......@@ -156,6 +161,7 @@ Section "Uninstall"
Delete $INSTDIR\license.txt
Delete $INSTDIR\mexopts-win32.bat
Delete $INSTDIR\mexopts-win64.bat
Delete $INSTDIR\VERSION
Rmdir /r $INSTDIR\matlab
Rmdir /r $INSTDIR\contrib
Rmdir /r $INSTDIR\mex
......