Commit 464e2970 authored by michel's avatar michel
Browse files

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
parent 20bc1b14
{\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); \
}
\ No newline at end of file
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);
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;
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);
estimation(datafile=simuldataRBC,nobs=200,first_obs=500,mh_replic=2000,mh_nblocks=2,mh_drop=0.45,mh_jscale=0.8);
// 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);
......@@ -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');
......
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_);
No preview for this file type
......@@ -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;
......
......@@ -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
......
......@@ -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:')
......
......@@ -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);
\ No newline at end of file
estimation(datafile=data1,nobs=1000,mh_replic=2000,mh_jscale=1.2);
\ No newline at end of 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);
\ No newline at end of file
estimation(datafile=data1,nobs=1000,mh_replic=2000,diffuse_filter);
\ No newline at end of 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);
......@@ -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);
// 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;
\ No newline at end of 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);
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,39 +22,51 @@ max(max(abs(epsilonhat1-epsilonhat2)))
max(max(abs(etahat1-etahat2)))
max(max(abs(a11-a12)))
max(max(abs(aK1-aK2)))
return
H = zeros(size(H));
[alphahat1,etahat1,a11, aK1] = DiffuseKalmanSmoother1(T,R,Q, ...
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
[alphahat2,etahat2,a12, aK2] = DiffuseKalmanSmoother3(T,R,Q, ...
[alphahat2,epsilonhat2,etahat2,a12, aK2] = DiffuseKalmanSmootherH1(T,R,Q,H, ...
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, ...
[alphahat1,etahat1,a11, aK1] = DiffuseKalmanSmoother3(T,R,Q, ...
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
[alphahat2,epsilonhat2,etahat2,a12, aK2] = DiffuseKalmanSmootherH1(T,R,Q,H, ...
Pinf1,Pstar1,Y,trend, ...
pp,mm,smpl,mf);
[alphahat2,epsilonhat2,etahat2,a12, aK2] = DiffuseKalmanSmootherH3(T,R,Q, H, ...
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)))
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] = DiffuseKalmanSmoother3(T,R,Q, ...
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
[alphahat2,epsilonhat2,etahat2,a12, aK2] = DiffuseKalmanSmootherH3(T,R,Q, H, ...
[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
......@@ -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));