Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
d0640ddf
Commit
d0640ddf
authored
Feb 10, 2011
by
Sébastien Villemot
Browse files
Merge remote branch 'houtanb/master'
parents
24d109c2
43479f6e
Changes
36
Hide whitespace changes
Inline
Side-by-side
matlab/AIM/SPExact_shift.m
View file @
d0640ddf
...
...
@@ -34,7 +34,7 @@ left = 1:qcols;
right
=
qcols
+
1
:
qcols
+
neq
;
zerorows
=
find
(
sum
(
abs
(
hs
(:,
right
)
'
))
==
0
);
while
(
any
(
zerorows
)
&
iq
<=
qrows
)
while
(
any
(
zerorows
)
&
&
iq
<=
qrows
)
nz
=
length
(
zerorows
);
q
(
iq
+
1
:
iq
+
nz
,:)
=
hs
(
zerorows
,
left
);
hs
(
zerorows
,:)
=
SPShiftright
(
hs
(
zerorows
,:),
neq
);
...
...
matlab/AIM/SPNumeric_shift.m
View file @
d0640ddf
...
...
@@ -35,7 +35,7 @@ right = qcols+1:qcols+neq;
[
Q
,
R
,
E
]
=
qr
(
h
(:,
right
)
);
zerorows
=
find
(
abs
(
diag
(
R
))
<=
condn
);
while
(
any
(
zerorows
)
&
iq
<=
qrows
)
while
(
any
(
zerorows
)
&
&
iq
<=
qrows
)
h
=
sparse
(
h
);
Q
=
sparse
(
Q
);
h
=
Q
'*
h
;
...
...
matlab/CutSample.m
View file @
d0640ddf
...
...
@@ -14,7 +14,7 @@ function CutSample(M_, options_, estim_params_)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2005-20
09
Dynare Team
% Copyright (C) 2005-20
11
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -60,7 +60,7 @@ if (TotalNumberOfMhFiles-1)-(FirstMhFile+1)+1 > 0
record
.
MhDraws
(
end
,
3
)
];
elseif
TotalNumberOfMhFiles
==
1
record
.
KeepedDraws
.
Distribution
=
[];
elseif
TotalNumberOfMhFiles
==
2
&
FirstMhFile
>
1
elseif
TotalNumberOfMhFiles
==
2
&
&
FirstMhFile
>
1
record
.
KeepedDraws
.
Distribution
=
[
MAX_nruns
-
FirstLine
+
1
;
record
.
MhDraws
(
end
,
3
)];
end
save
([
DirectoryName
'/'
M_
.
fname
'_mh_history.mat'
],
'record'
);
...
...
matlab/DsgeLikelihood.m
View file @
d0640ddf
...
...
@@ -47,14 +47,14 @@ nobs = size(options_.varobs,1);
%------------------------------------------------------------------------------
% 1. Get the structural parameters & define penalties
%------------------------------------------------------------------------------
if
options_
.
mode_compute
~=
1
&
any
(
xparam1
<
bayestopt_
.
lb
)
if
options_
.
mode_compute
~=
1
&
&
any
(
xparam1
<
bayestopt_
.
lb
)
k
=
find
(
xparam1
<
bayestopt_
.
lb
);
fval
=
bayestopt_
.
penalty
+
sum
((
bayestopt_
.
lb
(
k
)
-
xparam1
(
k
))
.^
2
);
cost_flag
=
0
;
info
=
41
;
return
;
end
if
options_
.
mode_compute
~=
1
&
any
(
xparam1
>
bayestopt_
.
ub
)
if
options_
.
mode_compute
~=
1
&
&
any
(
xparam1
>
bayestopt_
.
ub
)
k
=
find
(
xparam1
>
bayestopt_
.
ub
);
fval
=
bayestopt_
.
penalty
+
sum
((
xparam1
(
k
)
-
bayestopt_
.
ub
(
k
))
.^
2
);
cost_flag
=
0
;
...
...
matlab/DsgeVarLikelihood.m
View file @
d0640ddf
...
...
@@ -59,7 +59,7 @@ mXX = evalin('base', 'mXX');
fval
=
[];
cost_flag
=
1
;
if
options_
.
mode_compute
~=
1
&
any
(
xparam1
<
bayestopt_
.
lb
)
if
options_
.
mode_compute
~=
1
&
&
any
(
xparam1
<
bayestopt_
.
lb
)
k
=
find
(
xparam1
<
bayestopt_
.
lb
);
fval
=
bayestopt_
.
penalty
+
sum
((
bayestopt_
.
lb
(
k
)
-
xparam1
(
k
))
.^
2
);
cost_flag
=
0
;
...
...
@@ -67,7 +67,7 @@ if options_.mode_compute ~= 1 & any(xparam1 < bayestopt_.lb)
return
;
end
if
options_
.
mode_compute
~=
1
&
any
(
xparam1
>
bayestopt_
.
ub
)
if
options_
.
mode_compute
~=
1
&
&
any
(
xparam1
>
bayestopt_
.
ub
)
k
=
find
(
xparam1
>
bayestopt_
.
ub
);
fval
=
bayestopt_
.
penalty
+
sum
((
xparam1
(
k
)
-
bayestopt_
.
ub
(
k
))
.^
2
);
cost_flag
=
0
;
...
...
matlab/bvar_toolbox.m
View file @
d0640ddf
...
...
@@ -42,7 +42,7 @@ function [ny, nx, posterior, prior, forecast_data] = bvar_toolbox(nlags)
% - bvar_prior_{tau,decay,lambda,mu,omega,flat,train}
% Copyright (C) 2003-2007 Christopher Sims
% Copyright (C) 2007-20
09
Dynare Team
% Copyright (C) 2007-20
11
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -87,7 +87,7 @@ end
idx
=
options_
.
first_obs
+
options_
.
presample
-
train
-
nlags
:
options_
.
first_obs
+
options_
.
nobs
-
1
;
% Prepare dataset
if
options_
.
loglinear
&
~
options_
.
logdata
if
options_
.
loglinear
&
&
~
options_
.
logdata
dataset
=
log
(
dataset
);
end
if
options_
.
prefilter
...
...
@@ -106,7 +106,7 @@ mu = options_.bvar_prior_mu;
flat
=
options_
.
bvar_prior_flat
;
ny
=
size
(
dataset
,
2
);
if
options_
.
prefilter
|
options_
.
noconstant
if
options_
.
prefilter
|
|
options_
.
noconstant
nx
=
0
;
else
nx
=
1
;
...
...
@@ -204,7 +204,7 @@ else
breaks
=
[];
lbreak
=
0
;
end
if
~
isempty
(
vprior
)
&
vprior
.
w
>
0
if
~
isempty
(
vprior
)
&
&
vprior
.
w
>
0
ydum2
=
zeros
(
lags
+
1
,
nv
,
nv
);
xdum2
=
zeros
(
lags
+
1
,
nx
,
nv
);
ydum2
(
end
,:,:)
=
diag
(
vprior
.
sig
);
...
...
@@ -286,7 +286,7 @@ y = ydata(smpl,:);
% Everything now set up with input data for y=Xb+e
% Add persistence dummies
if
lambda
~=
0
|
mu
>
0
if
lambda
~=
0
|
|
mu
>
0
ybar
=
mean
(
ydata
(
1
:
lags
,:),
1
);
if
~
nox
xbar
=
mean
(
xdata
(
1
:
lags
,:),
1
);
...
...
matlab/check.m
View file @
d0640ddf
...
...
@@ -11,7 +11,7 @@ function [result,info] = check
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2001-201
0
Dynare Team
% Copyright (C) 2001-201
1
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -33,7 +33,7 @@ global M_ options_ oo_
temp_options
=
options_
;
tempex
=
oo_
.
exo_simul
;
if
~
options_
.
initval_file
&
M_
.
exo_nbr
>
1
if
~
options_
.
initval_file
&
&
M_
.
exo_nbr
>
1
oo_
.
exo_simul
=
ones
(
M_
.
maximum_lead
+
M_
.
maximum_lag
+
1
,
1
)
*
oo_
.
exo_steady_state
'
;
end
...
...
@@ -47,7 +47,7 @@ end
oo_
.
dr
=
dr
;
if
info
(
1
)
~=
0
&
info
(
1
)
~=
3
&
info
(
1
)
~=
4
if
info
(
1
)
~=
0
&
&
info
(
1
)
~=
3
&
&
info
(
1
)
~=
4
print_info
(
info
,
options_
.
noprint
);
end
...
...
@@ -76,7 +76,7 @@ if options_.noprint == 0
disp
(
sprintf
(
'\nThere are %d eigenvalue(s) larger than 1 in modulus '
,
n_explod
));
disp
(
sprintf
(
'for %d forward-looking variable(s)'
,
nyf
));
disp
(
' '
)
if
dr
.
rank
==
nyf
&
nyf
==
n_explod
if
dr
.
rank
==
nyf
&
&
nyf
==
n_explod
disp
(
'The rank condition is verified.'
)
else
disp
(
'The rank conditions ISN
''
T verified!'
)
...
...
matlab/check_model.m
View file @
d0640ddf
function
check_model
()
% Copyright (C) 2005-20
09
Dynare Team
% Copyright (C) 2005-20
11
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -29,7 +29,7 @@ if xlen > 1
' current period. Use additional endogenous variables'
])
;
end
if
(
M_
.
exo_det_nbr
>
0
)
&
(
M_
.
maximum_lag
>
1
|
M_
.
maximum_lead
>
1
)
if
(
M_
.
exo_det_nbr
>
0
)
&
&
(
M_
.
maximum_lag
>
1
|
|
M_
.
maximum_lead
>
1
)
error
([
'Exogenous deterministic variables are currently only allowed in'
...
' models with leads and lags on only one period'
])
end
...
...
matlab/csminit.m
View file @
d0640ddf
...
...
@@ -20,7 +20,7 @@ function [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,varargin)
% http://sims.princeton.edu/yftp/optimize/mfiles/csminit.m
% Copyright (C) 1993-2007 Christopher Sims
% Copyright (C) 2008-20
09
Dynare Team
% Copyright (C) 2008-20
11
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -59,7 +59,7 @@ fhat=f0;
g
=
g0
;
gnorm
=
norm
(
g
);
%
if
(
gnorm
<
1.e-12
)
&
~
badg
% put ~badg 8/4/94
if
(
gnorm
<
1.e-12
)
&
&
~
badg
% put ~badg 8/4/94
retcode
=
1
;
dxnorm
=
0
;
% gradient convergence
...
...
@@ -138,14 +138,14 @@ else
fcount
=
fcount
+
1
;
shrinkSignal
=
(
~
badg
&
(
f0
-
f
<
max
([
-
THETA
*
dfhat
*
lambda
0
])))
|
(
badg
&
(
f0
-
f
)
<
0
)
;
growSignal
=
~
badg
&
(
(
lambda
>
0
)
&
(
f0
-
f
>
-
(
1
-
THETA
)
*
dfhat
*
lambda
)
);
if
shrinkSignal
&
(
(
lambda
>
lambdaPeak
)
|
(
lambda
<
0
)
)
if
(
lambda
>
0
)
&
((
~
shrink
)
|
(
lambda
/
factor
<=
lambdaPeak
))
if
shrinkSignal
&
&
(
(
lambda
>
lambdaPeak
)
|
|
(
lambda
<
0
)
)
if
(
lambda
>
0
)
&
&
((
~
shrink
)
|
|
(
lambda
/
factor
<=
lambdaPeak
))
shrink
=
1
;
factor
=
factor
^.
6
;
while
lambda
/
factor
<=
lambdaPeak
factor
=
factor
^.
6
;
end
%if (abs(lambda)*(factor-1)*dxnorm < MINDX) | (abs(lambda)*(factor-1) < MINLAMB)
%if (abs(lambda)*(factor-1)*dxnorm < MINDX) |
|
(abs(lambda)*(factor-1) < MINLAMB)
if
abs
(
factor
-
1
)
<
MINDFAC
if
abs
(
lambda
)
<
4
retcode
=
2
;
...
...
@@ -155,12 +155,12 @@ else
done
=
1
;
end
end
if
(
lambda
<
lambdaMax
)
&
(
lambda
>
lambdaPeak
)
if
(
lambda
<
lambdaMax
)
&
&
(
lambda
>
lambdaPeak
)
lambdaMax
=
lambda
;
end
lambda
=
lambda
/
factor
;
if
abs
(
lambda
)
<
MINLAMB
if
(
lambda
>
0
)
&
(
f0
<=
fhat
)
if
(
lambda
>
0
)
&
&
(
f0
<=
fhat
)
% try going against gradient, which may be inaccurate
lambda
=
-
lambda
*
factor
^
6
else
...
...
@@ -172,11 +172,11 @@ else
done
=
1
;
end
end
elseif
(
growSignal
&
lambda
>
0
)
|
(
shrinkSignal
&
((
lambda
<=
lambdaPeak
)
&
(
lambda
>
0
)))
elseif
(
growSignal
&
&
lambda
>
0
)
|
|
(
shrinkSignal
&
&
((
lambda
<=
lambdaPeak
)
&
&
(
lambda
>
0
)))
if
shrink
shrink
=
0
;
factor
=
factor
^.
6
;
%if ( abs(lambda)*(factor-1)*dxnorm< MINDX ) | ( abs(lambda)*(factor-1)< MINLAMB)
%if ( abs(lambda)*(factor-1)*dxnorm< MINDX ) |
|
( abs(lambda)*(factor-1)< MINLAMB)
if
abs
(
factor
-
1
)
<
MINDFAC
if
abs
(
lambda
)
<
4
retcode
=
4
;
...
...
@@ -186,7 +186,7 @@ else
done
=
1
;
end
end
if
(
f
<
fPeak
)
&
(
lambda
>
0
)
if
(
f
<
fPeak
)
&
&
(
lambda
>
0
)
fPeak
=
f
;
lambdaPeak
=
lambda
;
if
lambdaMax
<=
lambdaPeak
...
...
matlab/csminwel1.m
View file @
d0640ddf
...
...
@@ -23,7 +23,7 @@ function [fh,xh,gh,H,itct,fcount,retcodeh] = csminwel1(fcn,x0,H0,grad,crit,nit,m
% http://sims.princeton.edu/yftp/optimize/mfiles/csminwel.m
% Copyright (C) 1993-2007 Christopher Sims
% Copyright (C) 2006-201
0
Dynare Team
% Copyright (C) 2006-201
1
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -105,7 +105,7 @@ while ~done
% itct=itct+1;
fcount
=
fcount
+
fc
;
% erased on 8/4/94
% if (retcode == 1) | (abs(f1-f) < crit)
% if (retcode == 1) |
|
(abs(f1-f) < crit)
% done=1;
% end
% if itct > nit
...
...
@@ -113,7 +113,7 @@ while ~done
% retcode = -retcode;
% end
if
retcode1
~=
1
if
retcode1
==
2
|
retcode1
==
4
if
retcode1
==
2
|
|
retcode1
==
4
wall1
=
1
;
badg1
=
1
;
else
if
NumGrad
...
...
@@ -134,7 +134,7 @@ while ~done
%ARGLIST
%save g1 g1 x1 f1 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13;
end
if
wall1
% & (~done) by Jinill
if
wall1
% &
&
(~done) by Jinill
% Bad gradient or back and forth on step length. Possibly at
% cliff edge. Try perturbing search direction.
%
...
...
@@ -147,7 +147,7 @@ while ~done
% P5,P6,P7,P8,P9,P10,P11,P12,P13);
fcount
=
fcount
+
fc
;
% put by Jinill
if
f2
<
f
if
retcode2
==
2
|
retcode2
==
4
if
retcode2
==
2
|
|
retcode2
==
4
wall2
=
1
;
badg2
=
1
;
else
if
NumGrad
...
...
@@ -182,7 +182,7 @@ while ~done
% P4,P5,P6,P7,P8,...
% P9,P10,P11,P12,P13);
fcount
=
fcount
+
fc
;
% put by Jinill
if
retcode3
==
2
|
retcode3
==
4
if
retcode3
==
2
|
|
retcode3
==
4
wall3
=
1
;
badg3
=
1
;
else
if
NumGrad
...
...
@@ -218,13 +218,13 @@ while ~done
f2
=
f
;
f3
=
f
;
f1
=
f
;
retcode2
=
retcode1
;
retcode3
=
retcode1
;
end
%how to pick gh and xh
if
f3
<
f
-
crit
&
badg3
==
0
&
f3
<
f2
&
f3
<
f1
if
f3
<
f
-
crit
&
&
badg3
==
0
&
&
f3
<
f2
&
&
f3
<
f1
ih
=
3
;
fh
=
f3
;
xh
=
x3
;
gh
=
g3
;
badgh
=
badg3
;
retcodeh
=
retcode3
;
elseif
f2
<
f
-
crit
&
badg2
==
0
&
f2
<
f1
elseif
f2
<
f
-
crit
&
&
badg2
==
0
&
&
f2
<
f1
ih
=
2
;
fh
=
f2
;
xh
=
x2
;
gh
=
g2
;
badgh
=
badg2
;
retcodeh
=
retcode2
;
elseif
f1
<
f
-
crit
&
badg1
==
0
elseif
f1
<
f
-
crit
&
&
badg1
==
0
ih
=
1
;
fh
=
f1
;
xh
=
x1
;
gh
=
g1
;
badgh
=
badg1
;
retcodeh
=
retcode1
;
else
...
...
@@ -271,7 +271,7 @@ while ~done
%gh
%badgh
stuck
=
(
abs
(
fh
-
f
)
<
crit
);
if
(
~
badg
)
&
(
~
badgh
)
&
(
~
stuck
)
if
(
~
badg
)
&&
(
~
badgh
)
&&
(
~
stuck
)
H
=
bfgsi
(
H
,
gh
-
g
,
xh
-
x
);
end
if
Verbose
...
...
@@ -293,7 +293,7 @@ while ~done
disp
(
'smallest step still improving too slow, reversed gradient'
)
elseif
rc
==
5
disp
(
'largest step still improving too fast'
)
elseif
(
rc
==
4
)
|
(
rc
==
2
)
elseif
(
rc
==
4
)
|
|
(
rc
==
2
)
disp
(
'back and forth on step length never finished'
)
elseif
rc
==
3
disp
(
'smallest step still improving too slow'
)
...
...
matlab/csolve.m
View file @
d0640ddf
...
...
@@ -22,7 +22,7 @@ function [x,rc] = csolve(FUN,x,gradfun,crit,itmax,varargin)
% http://sims.princeton.edu/yftp/optimize/mfiles/csolve.m
% Copyright (C) 1993-2007 Christopher Sims
% Copyright (C) 2007 Dynare Team
% Copyright (C) 2007
-2011
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -66,7 +66,7 @@ af00=af0;
itct
=
0
;
while
~
done
% disp([af00-af0 crit*max(1,af0)])
if
itct
>
3
&
af00
-
af0
<
crit
*
max
(
1
,
af0
)
&
rem
(
itct
,
2
)
==
1
if
itct
>
3
&
&
af00
-
af0
<
crit
*
max
(
1
,
af0
)
&
&
rem
(
itct
,
2
)
==
1
randomize
=
1
;
else
if
~
analyticg
...
...
@@ -117,14 +117,14 @@ while ~done
lambdamin
=
lambda
;
xmin
=
x
+
dx
;
end
if
((
lambda
>
0
)
&
(
af0
-
af
<
alpha
*
lambda
*
af0
))
|
((
lambda
<
0
)
&
(
af0
-
af
<
0
)
)
if
((
lambda
>
0
)
&
&
(
af0
-
af
<
alpha
*
lambda
*
af0
))
|
|
((
lambda
<
0
)
&
&
(
af0
-
af
<
0
)
)
if
~
shrink
factor
=
factor
^.
6
;
shrink
=
1
;
end
if
abs
(
lambda
*
(
1
-
factor
))
*
dxSize
>
.
1
*
delta
;
lambda
=
factor
*
lambda
;
elseif
(
lambda
>
0
)
&
(
factor
==.
6
)
%i.e., we've only been shrinking
elseif
(
lambda
>
0
)
&
&
(
factor
==.
6
)
%i.e., we've only been shrinking
lambda
=-.
3
;
else
%
subDone
=
1
;
...
...
@@ -138,7 +138,7 @@ while ~done
rc
=
3
;
end
end
elseif
(
lambda
>
0
)
&
(
af
-
af0
>
(
1
-
alpha
)
*
lambda
*
af0
)
elseif
(
lambda
>
0
)
&
&
(
af
-
af0
>
(
1
-
alpha
)
*
lambda
*
af0
)
if
shrink
factor
=
factor
^.
6
;
shrink
=
0
;
...
...
matlab/draw_prior_density.m
View file @
d0640ddf
...
...
@@ -113,7 +113,7 @@ end
k
=
[
1
:
length
(
dens
)];
if
pshape
(
indx
)
~=
5
[
junk
,
k1
]
=
max
(
dens
);
if
k1
==
1
|
k1
==
length
(
dens
)
if
k1
==
1
|
|
k1
==
length
(
dens
)
k
=
find
(
dens
<
10
);
end
end
...
...
matlab/dyn_ramsey_dynamic_.m
View file @
d0640ddf
...
...
@@ -213,7 +213,7 @@ k = 1:size(J,2);
for
i
=
1
:
n
if
sum
(
abs
(
J
(:,
i
)))
<
1e-8
if
m
(
i
)
<
n1
|
m
(
i
)
>
n2
if
m
(
i
)
<
n1
|
|
m
(
i
)
>
n2
k
(
i
)
=
0
;
m
(
i
)
=
0
;
end
...
...
matlab/dynare_estimation.m
View file @
d0640ddf
...
...
@@ -11,7 +11,7 @@ function dynare_estimation(var_list,varargin)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2003-201
0
Dynare Team
% Copyright (C) 2003-201
1
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -62,13 +62,13 @@ else
dynare_estimation_1
(
var_list
,
varargin
{:});
end
if
nnobs
>
1
&
horizon
>
0
if
nnobs
>
1
&
&
horizon
>
0
mh_replic
=
options_
.
mh_replic
;
rawdata
=
read_variables
(
options_
.
datafile
,
options_
.
varobs
,[],
options_
.
xls_sheet
,
options_
.
xls_range
);
gend
=
options_
.
nobs
;
rawdata
=
rawdata
(
options_
.
first_obs
:
options_
.
first_obs
+
gend
-
1
,:);
% Take the log of the variables if needed
if
options_
.
loglinear
&
~
options_
.
logdata
% and if the data are not in logs, then...
if
options_
.
loglinear
&
&
~
options_
.
logdata
% and if the data are not in logs, then...
rawdata
=
log
(
rawdata
);
end
...
...
matlab/dynare_estimation_1.m
View file @
d0640ddf
...
...
@@ -77,10 +77,10 @@ if options_.prefilter == 1
end
%% Set options related to filtered variables.
if
options_
.
filtered_vars
~=
0
&
isempty
(
options_
.
filter_step_ahead
),
if
options_
.
filtered_vars
~=
0
&
&
isempty
(
options_
.
filter_step_ahead
),
options_
.
filter_step_ahead
=
1
;
end
if
options_
.
filtered_vars
~=
0
&
options_
.
filter_step_ahead
==
0
,
if
options_
.
filtered_vars
~=
0
&
&
options_
.
filter_step_ahead
==
0
,
options_
.
filter_step_ahead
=
1
;
end
if
options_
.
filter_step_ahead
~=
0
...
...
@@ -120,7 +120,7 @@ if ~isempty(estim_params_)
end
% Test if initial values of the estimated parameters are all between
% the prior lower and upper bounds.
if
any
(
xparam1
<
bounds
(:,
1
))
|
any
(
xparam1
>
bounds
(:,
2
))
if
any
(
xparam1
<
bounds
(:,
1
))
|
|
any
(
xparam1
>
bounds
(:,
2
))
find
(
xparam1
<
bounds
(:,
1
))
find
(
xparam1
>
bounds
(:,
2
))
error
(
'Initial parameter values are outside parameter bounds'
)
...
...
@@ -684,7 +684,7 @@ if ~options_.mh_posterior_mode_estimation
end
end
if
options_
.
mode_check
==
1
&
~
options_
.
mh_posterior_mode_estimation
if
options_
.
mode_check
==
1
&
&
~
options_
.
mh_posterior_mode_estimation
mode_check
(
xparam1
,
0
,
hh
,
gend
,
data
,
lb
,
ub
,
data_index
,
number_of_observations
,
no_more_missing_observations
);
end
...
...
@@ -703,7 +703,7 @@ else
end
if
any
(
bayestopt_
.
pshape
>
0
)
&
~
options_
.
mh_posterior_mode_estimation
if
any
(
bayestopt_
.
pshape
>
0
)
&
&
~
options_
.
mh_posterior_mode_estimation
disp
(
' '
)
disp
(
'RESULTS FROM POSTERIOR MAXIMIZATION'
)
tstath
=
zeros
(
nx
,
1
);
...
...
@@ -815,7 +815,7 @@ if any(bayestopt_.pshape > 0) & ~options_.mh_posterior_mode_estimation
disp
(
' '
)
disp
(
sprintf
(
'Log data density [Laplace approximation] is %f.'
,
md_Laplace
))
disp
(
' '
)
elseif
~
any
(
bayestopt_
.
pshape
>
0
)
&
options_
.
mh_posterior_mode_estimation
elseif
~
any
(
bayestopt_
.
pshape
>
0
)
&
&
options_
.
mh_posterior_mode_estimation
disp
(
' '
)
disp
(
'RESULTS FROM MAXIMUM LIKELIHOOD'
)
tstath
=
zeros
(
nx
,
1
);
...
...
@@ -900,7 +900,7 @@ end
OutputDirectoryName
=
CheckPath
(
'Output'
);
if
any
(
bayestopt_
.
pshape
>
0
)
&
options_
.
TeX
%% Bayesian estimation (posterior mode) Latex output
if
any
(
bayestopt_
.
pshape
>
0
)
&
&
options_
.
TeX
%% Bayesian estimation (posterior mode) Latex output
if
np
filename
=
[
OutputDirectoryName
'/'
M_
.
fname
'_Posterior_Mode_1.TeX'
];
fidTeX
=
fopen
(
filename
,
'w'
);
...
...
@@ -1083,21 +1083,21 @@ if np > 0
save
([
M_
.
fname
'_params.mat'
],
'pindx'
);
end
if
(
any
(
bayestopt_
.
pshape
>
0
)
&
options_
.
mh_replic
)
|
...
(
any
(
bayestopt_
.
pshape
>
0
)
&
options_
.
load_mh_file
)
%% not ML estimation
if
(
any
(
bayestopt_
.
pshape
>
0
)
&
&
options_
.
mh_replic
)
|
|
...
(
any
(
bayestopt_
.
pshape
>
0
)
&
&
options_
.
load_mh_file
)
%% not ML estimation
bounds
=
prior_bounds
(
bayestopt_
);
bounds
(:,
1
)
=
max
(
bounds
(:,
1
),
lb
);
bounds
(:,
2
)
=
min
(
bounds
(:,
2
),
ub
);
bayestopt_
.
lb
=
bounds
(:,
1
);
bayestopt_
.
ub
=
bounds
(:,
2
);
if
any
(
xparam1
<
bounds
(:,
1
))
|
any
(
xparam1
>
bounds
(:,
2
))
if
any
(
xparam1
<
bounds
(:,
1
))
|
|
any
(
xparam1
>
bounds
(:,
2
))
find
(
xparam1
<
bounds
(:,
1
))
find
(
xparam1
>
bounds
(:,
2
))
error
(
'Mode values are outside prior bounds. Reduce prior_trunc.'
)
end
% runs MCMC
if
options_
.
mh_replic
if
options_
.
load_mh_file
&
options_
.
use_mh_covariance_matrix
if
options_
.
load_mh_file
&
&
options_
.
use_mh_covariance_matrix
invhess
=
compute_mh_covariance_matrix
;
end
if
options_
.
dsge_var
...
...
@@ -1111,7 +1111,7 @@ if (any(bayestopt_.pshape >0 ) & options_.mh_replic) | ...
CutSample
(
M_
,
options_
,
estim_params_
);
return
else
if
~
options_
.
nodiagnostic
&
options_
.
mh_replic
>
1000
&
options_
.
mh_nblck
>
1
if
~
options_
.
nodiagnostic
&
&
options_
.
mh_replic
>
1000
&
&
options_
.
mh_nblck
>
1
McMCDiagnostics
(
options_
,
estim_params_
,
M_
);
end
%% Here i discard first half of the draws:
...
...
@@ -1131,7 +1131,7 @@ if (any(bayestopt_.pshape >0 ) & options_.mh_replic) | ...
if
options_
.
moments_varendo
oo_
=
compute_moments_varendo
(
'posterior'
,
options_
,
M_
,
oo_
,
var_list_
);
end
if
options_
.
smoother
|
~
isempty
(
options_
.
filter_step_ahead
)
|
options_
.
forecast
if
options_
.
smoother
|
|
~
isempty
(
options_
.
filter_step_ahead
)
|
|
options_
.
forecast
prior_posterior_statistics
(
'posterior'
,
data
,
gend
,
data_index
,
missing_value
);
end
xparam
=
get_posterior_parameters
(
'mean'
);
...
...
@@ -1139,9 +1139,9 @@ if (any(bayestopt_.pshape >0 ) & options_.mh_replic) | ...
end
end
if
(
~
((
any
(
bayestopt_
.
pshape
>
0
)
&
options_
.
mh_replic
)
|
(
any
(
bayestopt_
.
pshape
...
>
0
)
&
options_
.
load_mh_file
))
...
|
~
options_
.
smoother
)
&
M_
.
endo_nbr
^
2
*
gend
<
1e7
&
options_
.
partial_information
==
0
% to be fixed
if
(
~
((
any
(
bayestopt_
.
pshape
>
0
)
&
&
options_
.
mh_replic
)
|
|
(
any
(
bayestopt_
.
pshape
...
>
0
)
&
&
options_
.
load_mh_file
))
...
|
|
~
options_
.
smoother
)
&
&
M_
.
endo_nbr
^
2
*
gend
<
1e7
&
&
options_
.
partial_information
==
0
% to be fixed
%% ML estimation, or posterior mode without metropolis-hastings or metropolis without bayesian smooth variable
[
atT
,
innov
,
measurement_error
,
updated_variables
,
ys
,
trend_coeff
,
aK
,
T
,
R
,
P
,
PK
,
decomp
]
=
DsgeSmoother
(
xparam1
,
gend
,
data
,
data_index
,
missing_value
);
oo_
.
Smoother
.
SteadyState
=
ys
;
...
...
@@ -1713,7 +1713,7 @@ if (~((any(bayestopt_.pshape > 0) & options_.mh_replic) | (any(bayestopt_.pshape
end
end
if
options_
.
forecast
>
0
&
options_
.
mh_replic
==
0
&
~
options_
.
load_mh_file
if
options_
.
forecast
>
0
&
&
options_
.
mh_replic
==
0
&
&
~
options_
.
load_mh_file
forecast
(
var_list_
,
'smoother'
);
end
...
...
matlab/initial_estimation_checks.m
View file @
d0640ddf
...
...
@@ -75,7 +75,7 @@ if options_.steadystate_flag
% Check if the steady state obtained from the _steadystate file is a
% steady state.
check1
=
0
;
if
isfield
(
options_
,
'unit_root_vars'
)
&
options_
.
diffuse_filter
==
0
if
isfield
(
options_
,
'unit_root_vars'
)
&
&
options_
.
diffuse_filter
==
0
if
isempty
(
options_
.
unit_root_vars
)
if
~
options_
.
bytecode
check1
=
max
(
abs
(
feval
([
M_
.
fname
'_static'
],
...
...
...
@@ -101,7 +101,7 @@ if info(1) > 0
print_info
(
info
,
options_
.
noprint
)
end
if
any
(
abs
(
oo_
.
steady_state
(
bayestopt_
.
mfys
))
>
1e-9
)
&
(
options_
.
prefilter
==
1
)
if
any
(
abs
(
oo_
.
steady_state
(
bayestopt_
.
mfys
))
>
1e-9
)
&
&
(
options_
.
prefilter
==
1
)
disp
([
'You are trying to estimate a model with a non zero steady state for the observed endogenous'
])
disp
([
'variables using demeaned data!'
])
error
(
'You should change something in your mod file...'
)
...
...
matlab/kalman/likelihood/kalman_filter.m
View file @
d0640ddf
...
...
@@ -25,7 +25,7 @@ function [LIK, lik] = kalman_filter(T,R,Q,H,P,Y,start,mf,kalman_tol,riccati_tol)
% NOTES
% The vector "lik" is used to evaluate the jacobian of the likelihood.
% Copyright (C) 2004-201
0
Dynare Team
% Copyright (C) 2004-201
1
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -55,7 +55,7 @@ oldK = Inf;
notsteady
=
1
;
% Steady state flag.
F_singular
=
1
;
while
notsteady
&
t
<
smpl
while
notsteady
&
&
t
<
smpl
t
=
t
+
1
;
v
=
Y
(:,
t
)
-
a
(
mf
);
F
=
P
(
mf
,
mf
)
+
H
;
...
...
matlab/make_ex_.m
View file @
d0640ddf
...
...
@@ -12,7 +12,7 @@ function make_ex_
% SPECIAL REQUIREMENTS
%
% Copyright (C) 1996-20
09
Dynare Team
% Copyright (C) 1996-20
11
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -36,7 +36,7 @@ options_ = set_default_option(options_,'periods',0);
if
isempty
(
oo_
.
exo_steady_state
)
oo_
.
exo_steady_state
=
zeros
(
M_
.
exo_nbr
,
1
);
end
if
M_
.
exo_det_nbr
>
1
&
isempty
(
oo_
.
exo_det_steady_state
)
if
M_
.
exo_det_nbr
>
1
&
&
isempty
(
oo_
.
exo_det_steady_state
)
oo_
.
exo_det_steady_state
=
zeros
(
M_
.
exo_det_nbr
,
1
);
end
if
isempty
(
oo_
.
exo_simul
)
...
...
matlab/marginal_density.m
View file @
d0640ddf
...
...
@@ -15,7 +15,7 @@ function [marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2005-20
09
Dynare Team
% Copyright (C) 2005-20
11
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -94,7 +94,7 @@ while check_coverage
marginal
(
linee
,:)
=
[
p
,
lpost_mode
-
log
(
tmp
/((
TotalNumberOfMhDraws
-
TODROP
)
*
nblck
))];
warning
(
warning_old_state
);
end