reverted r2010 because of problem with FILENAME token

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@2111 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
michel 2008-09-25 12:10:12 +00:00
parent 20bc1b1401
commit 464e29706f
20 changed files with 333 additions and 280 deletions

View File

@ -1,51 +1,44 @@
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf420
{\fonttbl\f0\fswiss\fcharset77 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
// example 1 from Collard's guide to Dynare
var y, c, k, a, h, b;
varexo e,u;
\f0\fs24 \cf0 // example 1 from Collard's guide to Dynare \
var y, c, k, a, h, b; \
varexo e,u; \
\
parameters beta, rho, beta, alpha, delta, theta, psi, tau; \
\
alpha = 0.36; \
rho = 0.95; \
tau = 0.025; \
beta = 0.99; \
delta = 0.025; \
psi = 0; \
theta = 2.95; \
\
phi = 0.1; \
\
model; \
c*theta*h^(1+psi)=(1-alpha)*y; \
k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1))) \
*(exp(b(+1))*alpha*y(+1)+(1-delta)*k)); \
y = exp(a)*(k(-1)^alpha)*(h^(1-alpha)); \
k = exp(b)*(y-c)+(1-delta)*k(-1); \
a = rho*a(-1)+tau*b(-1) + e; \
b = tau*a(-1)+rho*b(-1) + u; \
end; \
\
initval; \
y = 1.08068253095672; \
c = 0.80359242014163; \
h = 0.29175631001732; \
k = 5; \
a = 0; \
b = 0; \
e = 0; \
u = 0; \
end; \
\
shocks; \
var e; stderr 0.009; \
var u; stderr 0.009; \
var e, u = phi*0.009*0.009; \
end; \
\
stoch_simul(periods=2100); \
}
parameters beta, rho, beta, alpha, delta, theta, psi, tau;
alpha = 0.36;
rho = 0.95;
tau = 0.025;
beta = 0.99;
delta = 0.025;
psi = 0;
theta = 2.95;
phi = 0.1;
model;
c*theta*h^(1+psi)=(1-alpha)*y;
k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1)))
*(exp(b(+1))*alpha*y(+1)+(1-delta)*k));
y = exp(a)*(k(-1)^alpha)*(h^(1-alpha));
k = exp(b)*(y-c)+(1-delta)*k(-1);
a = rho*a(-1)+tau*b(-1) + e;
b = tau*a(-1)+rho*b(-1) + u;
end;
initval;
y = 1.08068253095672;
c = 0.80359242014163;
h = 0.29175631001732;
k = 5;
a = 0;
b = 0;
e = 0;
u = 0;
end;
shocks;
var e; stderr 0.009;
var u; stderr 0.009;
var e, u = phi*0.009*0.009;
end;
stoch_simul(periods=2100);

View File

@ -1,40 +1,40 @@
var y c k i l y_l w r z;
varexo e;
parameters beta psi delta alpha rho epsilon;
model;
(1/c) = beta*(1/c(+1))*(1+r(+1)-delta);
psi*c/(1-l) = w;
c+i = y;
y = (k(-1)^alpha)*(exp(z)*l)^(1-alpha);
w = y*((epsilon-1)/epsilon)*(1-alpha)/l;
r = y*((epsilon-1)/epsilon)*alpha/k(-1);
i = k-(1-delta)*k(-1);
y_l = y/l;
z = rho*z(-1)+e;
var y c k i l y_l w r z;
varexo e;
parameters beta psi delta alpha rho epsilon;
model;
(1/c) = beta*(1/c(+1))*(1+r(+1)-delta);
psi*c/(1-l) = w;
c+i = y;
y = (k(-1)^alpha)*(exp(z)*l)^(1-alpha);
w = y*((epsilon-1)/epsilon)*(1-alpha)/l;
r = y*((epsilon-1)/epsilon)*alpha/k(-1);
i = k-(1-delta)*k(-1);
y_l = y/l;
z = rho*z(-1)+e;
end;
varobs y;
initval;
k = 9;
c = 0.76;
l = 0.3;
w = 2.07;
r = 0.03;
z = 0;
e = 0;
end;
estimated_params;
alpha, beta_pdf, 0.35, 0.02;
beta, beta_pdf, 0.99, 0.002;
delta, beta_pdf, 0.025, 0.003;
psi, gamma_pdf, 1.75, 0.02;
rho, beta_pdf, 0.95, 0.05;
epsilon, gamma_pdf, 10, 0.003;
stderr e, inv_gamma_pdf, 0.01, inf;
end;
estimation(datafile=simuldataRBC,nobs=200,first_obs=500,mh_replic=2000,mh_nblocks=2,mh_drop=0.45,mh_jscale=0.8);
varobs y;
initval;
k = 9;
c = 0.76;
l = 0.3;
w = 2.07;
r = 0.03;
z = 0;
e = 0;
end;
estimated_params;
alpha, beta_pdf, 0.35, 0.02;
beta, beta_pdf, 0.99, 0.002;
delta, beta_pdf, 0.025, 0.003;
psi, gamma_pdf, 1.75, 0.02;
rho, beta_pdf, 0.95, 0.05;
epsilon, gamma_pdf, 10, 0.003;
stderr e, inv_gamma_pdf, 0.01, inf;
end;
estimation(datafile=simuldataRBC,nobs=200,first_obs=500,mh_replic=2000,mh_nblocks=2,mh_drop=0.45,mh_jscale=0.8);

View File

@ -1,133 +1,47 @@
// Adapted from Jesus Fernandez-Villaverde, Basic RBC Model with Monopolistic Competion Philadelphia, March 3, 2005
var y c k i l y_l w r z;
varexo e;
parameters beta psi delta alpha rho gamma sigma epsilon;
alpha = 0.33;
beta = 0.99;
delta = 0.023;
psi = 1.75;
rho = 0.95;
sigma = (0.007/(1-alpha));
epsilon = 10;
model;
(1/c) = beta*(1/c(+1))*(1+r(+1)-delta);
psi*c/(1-l) = w;
c+i = y;
y = (k(-1)^alpha)*(exp(z)*l)^(1-alpha);
w = y*((epsilon-1)/epsilon)*(1-alpha)/l;
r = y*((epsilon-1)/epsilon)*alpha/k(-1);
i = k-(1-delta)*k(-1);
y_l = y/l;
z = rho*z(-1)+e;
end;
initval;
k = 9;
c = 0.76;
l = 0.3;
w = 2.07;
r = 0.03;
z = 0;
e = 0;
end;
// Adapted from Jesus Fernandez-Villaverde, Basic RBC Model with Monopolistic Competion Philadelphia, March 3, 2005
var y c k i l y_l w r z;
varexo e;
parameters beta psi delta alpha rho gamma sigma epsilon;
alpha = 0.33;
beta = 0.99;
delta = 0.023;
psi = 1.75;
rho = 0.95;
sigma = (0.007/(1-alpha));
epsilon = 10;
model;
(1/c) = beta*(1/c(+1))*(1+r(+1)-delta);
psi*c/(1-l) = w;
c+i = y;
y = (k(-1)^alpha)*(exp(z)*l)^(1-alpha);
w = y*((epsilon-1)/epsilon)*(1-alpha)/l;
r = y*((epsilon-1)/epsilon)*alpha/k(-1);
i = k-(1-delta)*k(-1);
y_l = y/l;
z = rho*z(-1)+e;
end;
initval;
k = 9;
c = 0.76;
l = 0.3;
w = 2.07;
r = 0.03;
z = 0;
e = 0;
end;
steady;
check;
shocks;
var e = sigma^2;
end;
steady;
stoch_simul(periods=2100);
check;
shocks;
var e = sigma^2;
end;
stoch_simul(periods=2100);

View File

@ -31,6 +31,8 @@ function CutSample(M_, options_, estim_params_)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global M_ options_ estim_params_
npar = estim_params_.np+estim_params_.nvn+estim_params_.ncx+estim_params_.ncn+estim_params_.nvx;
DirectoryName = CheckPath('metropolis');

View File

@ -1,7 +1,9 @@
function moments=compute_model_moments(dr,M_,options,_)
function moments=compute_model_moments(dr,SelectVariables,M_,options_)
%function moments=compute_model_moments(dr,M_,options_)
%
% INPUTS
% dr: structure describing model solution
% SelectVariables: indices of selected variables
% M_: structure of Dynare options
% options_
%
@ -28,4 +30,4 @@ function moments=compute_model_moments(dr,M_,options,_)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
moments = th_autocovariances(dr,options_.varlist,M_,options_);
moments = th_autocovariances(dr,SelectVariables,M_,options_);

Binary file not shown.

View File

@ -99,6 +99,19 @@ if ~(exist('stab_map_','file')==6 | exist('stab_map_','file')==2),
end
end
if ~(exist('gsa_sdp','file')==6 | exist('gsa_sdp','file')==2),
dynare_root = strrep(which('dynare.m'),'dynare.m','');
ss_anova_path = [dynare_root 'gsa/ss_anova_recurs'];
if exist(ss_anova_path)
addpath(ss_anova_path,path)
else
disp('Download Dynare sensitivity routines at:')
disp('http://eemc.jrc.ec.europa.eu/softwareDYNARE-Dowload.htm')
disp(' ' )
error('Mapping routines missing!')
end
end
if options_gsa.morris,
options_gsa.redform=1;

View File

@ -46,10 +46,10 @@ for k=1:size(s1,1)
y = [y; oo_.endo_simul(strmatch(s1(k,:),M_.endo_names,'exact'),:)] ;
end
if options_.smpl == 0
if options_.dsample == 0
i = [M_.maximum_lag:size(oo_.endo_simul,2)]' ;
else
i = [options_.smpl(1)+M_.maximum_lag:options_.smpl(2)+M_.maximum_lag]' ;
i = [options_.dsample(1)+M_.maximum_lag:options_.dsample(2)+M_.maximum_lag]' ;
end
t = ['Plot of '] ;
@ -86,9 +86,6 @@ elseif rplottype == 2
end
end
% 02/28/01 MJ replaced bseastr by MATLAB's strmatch
% 06/19/01 MJ added 'exact' to strmatch calls
% 06/25/03 MJ correction when options_.smpl ~= 0

View File

@ -49,7 +49,19 @@ function steady()
homotopy3(options_.homotopy_values, options_.homotopy_steps);
end
steady_;
if options_.homotopy_mode == 1
homotopy1(options_.homotopy_param,options_.homotopy_exo, ...
options_.homotopy_exodet,options_.homotopy_steps);
elseif options_.homotopy_mode == 2
homotopy2(options_.homotopy_param,options_.homotopy_exo, ...
options_.homotopy_exodet,options_.homotopy_steps);
elseif options_.homotopy_mode == 3
homotopy3(options_.homotopy_param,options_.homotopy_exo, ...
options_.homotopy_exodet,options_.homotopy_steps);
else
steady_;
end
disp(' ')
disp('STEADY-STATE RESULTS:')

View File

@ -3,11 +3,11 @@ varexo e_x e_y;
parameters rho_x rho_y;
rho_x = 0.5;
rho_x = 0.5; // comment 1
rho_y = -0.3;
model;
dx = rho_x*dx(-1)+e_x;
dx = rho_x*dx(-1)+e_x; // comment 2
dy = rho_y*dy(-1)+e_y;
end;
@ -20,4 +20,4 @@ end;
varobs dx dy;
check;
estimation(datafile=data1,nobs=1000,mh_replic=2000);
estimation(datafile=data1,nobs=1000,mh_replic=2000,mh_jscale=1.2);

View File

@ -24,4 +24,4 @@ end;
varobs x y;
unit_root_vars x y;
estimation(datafile=data1,nobs=1000,mh_replic=2000,lik_init=2);
estimation(datafile=data1,nobs=1000,mh_replic=2000,diffuse_filter);

View File

@ -30,4 +30,4 @@ end;
varobs dx dy;
unit_root_vars x y;
estimation(datafile=data2,nobs=100,mh_replic=0,lik_init=2);
estimation(datafile=data2,nobs=100,mh_replic=0,diffuse_filter);

View File

@ -29,5 +29,4 @@ end;
varobs x y;
unit_root_vars x y;
estimation(datafile=data2,nobs=100,mh_replic=0,lik_init=2);
estimation(datafile=data2,nobs=100,mh_replic=0,mh_nblocks=1);

View File

@ -1,6 +1,6 @@
// example 1 from Collard's guide to Dynare
var y, c, k, a, h, b;
varexo e,u;
varexo u, e;
parameters beta, rho, alpha, delta, theta, psi, tau, phi;
@ -36,9 +36,13 @@ u = 0;
end;
shocks;
var e; stderr 0.009;
var e; stderr 0.018;
var u; stderr 0.009;
var e, u = phi*0.009*0.009;
var e, u = phi*0.018*0.009;
end;
stoch_simul;
rhos = 0.8:0.05:0.8;
for i=1:length(rhos);
rho = rhos(i);
stoch_simul(order=2);
end;

View File

@ -72,6 +72,8 @@ var e_a; stderr 0.014;
var e_m; stderr 0.005;
end;
unit_root_vars P_obs Y_obs;
steady;
check;
@ -95,8 +97,7 @@ P_obs (log(mst)-gam);
Y_obs (gam);
end;
unit_root_vars P_obs Y_obs;
//stoch_simul(order=1,nomoments,irf=0);
estimation(datafile=fsdat,nobs=192,loglinear,mh_replic=0,mh_nblocks=2,mh_drop=0.45,mode_compute=0,mode_file=fs2000b_mode,load_mh_file);
stab_map_;
estimation(datafile=fsdat,nobs=192,loglinear,mh_replic=2000,mh_nblocks=2,mh_jscale=0.8,mode_compute=0,mode_file=fs2000b_mode,kalman_algo=4);

View File

@ -1,13 +1,17 @@
global options_ M_
load test
% $$$ Y = Y(1:2,:);
% $$$ mf = mf(1:2);
% $$$ H=H(1:2,1:2);
% $$$ pp = pp-1;
% $$$ trend =trend(1:2,:);
M_.fname = ' ';
global_initialization;
options_.nk = 1;
Pinf1(1,1) = 1;
Pstar1(1,1) = 0;
Pstar1(4,1) = 0;
Pstar1(1,4) = 0;
Pstar1(5,1) = 0;
Pstar1(1,5) = 0;
[alphahat1,epsilonhat1,etahat1,a11, aK1] = DiffuseKalmanSmootherH1(T,R,Q,H, ...
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
[alphahat2,epsilonhat2,etahat2,a12, aK2] = DiffuseKalmanSmootherH3(T,R,Q,H, ...
@ -18,21 +22,7 @@ max(max(abs(epsilonhat1-epsilonhat2)))
max(max(abs(etahat1-etahat2)))
max(max(abs(a11-a12)))
max(max(abs(aK1-aK2)))
return
[alphahat1,etahat1,a11, aK1] = DiffuseKalmanSmoother1(T,R,Q, ...
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
[alphahat2,etahat2,a12, aK2] = DiffuseKalmanSmoother3(T,R,Q, ...
Pinf1,Pstar1,Y,trend, ...
pp,mm,smpl,mf);
max(max(abs(alphahat1-alphahat2)))
max(max(abs(etahat1-etahat2)))
max(max(abs(a11-a12)))
%max(max(abs(aK1-aK2)))
H = zeros(size(H));
[alphahat1,etahat1,a11, aK1] = DiffuseKalmanSmoother1(T,R,Q, ...
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
@ -54,3 +44,29 @@ max(max(abs(alphahat1-alphahat2)))
max(max(abs(etahat1-etahat2)))
max(max(abs(a11-a12)))
%max(max(abs(aK1-aK2)))
Pinf1 = zeros(5,5);
Pinf1(1,1) = 1;
a=0.3*randn(4,4);
Pstar1 = [zeros(1,5); [zeros(4,1) a'*a]];
T = 0.8*eye(5);
T(1,1) = 1;
Y = Y(1,:);
mf = 1;
pp = 1;
trend = trend(1,:);
options_.diffuse_d = 1;
[alphahat1,etahat1,a11, aK1] = DiffuseKalmanSmoother1(T,R,Q, ...
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
[alphahat2,etahat2,a12, aK2] = DiffuseKalmanSmoother3(T,R,Q, ...
Pinf1,Pstar1,Y,trend, ...
pp,mm,smpl,mf);
max(max(abs(alphahat1-alphahat2)))
max(max(abs(etahat1-etahat2)))
max(max(abs(a11-a12)))
%max(max(abs(aK1-aK2)))
return

View File

@ -53,8 +53,8 @@ oc = c;
oh = h;
end;
steady;
check;
//steady;
//check;
estimated_params;
theta , 0.22, 0.1, 0.5;
@ -87,4 +87,5 @@ oy (log(eta));
oc (log(eta));
end;
estimation(datafile=idata,mode_compute=1,nograph);
//options_.debug=1;
estimation(datafile=idata,mode_compute=4,nograph);

View File

@ -87,4 +87,5 @@ oy (log(eta));
oc (log(eta));
end;
estimation(datafile=idata,nograph);
warning off;
estimation(datafile=idata,mode_compute=4,nograph);

View File

@ -26,7 +26,7 @@ check;
shocks;
var x;
periods 1;
periods 10;
values 1.2;
end;

View File

@ -1,39 +1,137 @@
function run_test()
test_files = {
'.' 'ramst';
'.' 'ramst_a';
'.' 'ramst';
'.' 'ramst_a';
'.' 'example1';
'.' 'example2';
'.' 't_sgu_ex1';
'arima' 'mod1';
'arima' 'mod1a';
'arima' 'mod1b';
'arima' 'mod1c';
'arima' 'mod2';
'arima' 'mod2a';
'arima' 'mod2b';
'arima' 'mod2c';
'fs2000' 'fs2000';
'fs2000' 'fs2000a';
}
%'.' 'example2';
'.' 't_sgu_ex1';
'arima' 'mod1';
'arima' 'mod1a';
'arima' 'mod1b';
'arima' 'mod1c';
'arima' 'mod2';
'arima' 'mod2a';
'arima' 'mod2b';
'arima' 'mod2c';
'fs2000' 'fs2000';
'fs2000' 'fs2000a';
'estimation_options','fs2000A';
'estimation_options','fs2000B';
}
results = cell(length(test_files),1);
for i=1:length(test_files)
tic;
rand('state',1);
randn('state',1);
results{i}= run_test1(test_files{i,1},test_files{i,2});
toc;
end
for i=1:length(test_files)
disp(test_files{i,2})
disp(results{i})
disp(toc)
end
end
function msg=run_test1(path1,mod_file)
global options_
clear options_
global options_ oo_
options_=struct('trick',1);
oo_=struct('trick',1);
old_path = pwd;
cd(path1);
msg = 'OK';
expr = ['disp(''error in ' mod_file ''');msg=lasterr;disp(msg)'];
eval(['dynare ' mod_file ' noclearall'],'eval(expr)');
cd(old_path)
try
old_results=load([mod_file '_results']);
catch
eval(['dynare ' mod_file ' noclearall'],'eval(expr)');
msg = 'no previous results'
cd(old_path)
return
end
eval(['dynare ' mod_file ' noclearall'],'eval(expr)');
msg = strvcat(msg, comparison(oo_,old_results.oo_,0, 'oo_'));
cd(old_path)
end
function msg=comparison(A,B,tol,parent)
msg = '';
mca = my_class(A);
mcb = my_class(B);
if size(mca,2) ~= size(mcb,2) || any(mca ~= mcb)
msg = ['Types differ in ' parent];
return
end
switch my_class(A)
case 'numeric'
if size(A)==size(B)
if ~all(all(abs(A-B)<tol))
msg = ['Difference greater than tolerance in ' parent];
end
else
msg = ['Sizes differ in ' parent];
end
case 'char'
if A~=B
msg = ['Strings differ in ' parent];
end
case 'cell'
if size(A) == size(B)
[M,N] = size(A);
for i = 1:M
for j = 1:N
msg = strvcat(msg, comparison(A{i,j}, B{i,j}, tol, sprintf('%s{%d,%d}', parent, i, j)))
end
end
else
msg = [ 'Cell sizes differ in ' parent ];
end
case 'struct'
namesA=fieldnames(A);
namesB=fieldnames(B);
if length(namesA)~=length(namesB)
msg = [ 'Number of fields differ in ' parent ]
return
end
namesA = sort(namesA);
namesB = sort(namesB);
for i=1:length(namesA)
if namesA{i}==namesB{i}
msg = strvcat(msg, comparison(A.(namesA{i}),B.(namesB{i}),tol, sprintf('%s.%s', parent, namesA{i})));
else
msg = strvcat(msg, sprintf('Field %s.%s in 1st arg does not exist in 2nd arg', parent, namesA{i}));
end
end
otherwise
msg = ['Unsupported type in ' parent ];
end
end
function t = my_class(a)
c = class(a);
if isequal(c, 'double') | isequal(c, 'single') | isequal(c, 'int8')| isequal(c, 'uint8') | ...
isequal(c, 'int16') | isequal(c, 'uint16') | isequal(c, 'int32') | isequal(c, 'uint32') | ...
isequal(c, 'int64') | isequal(c, 'uint64')
t = 'numeric';
else
t = c;
end
end