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
1825d266
Commit
1825d266
authored
Sep 29, 2011
by
Sébastien Villemot
Browse files
Merge remote-tracking branch 'ratto/master'
parents
762f31ba
509b34aa
Changes
8
Hide whitespace changes
Inline
Side-by-side
matlab/DsgeLikelihood.m
View file @
1825d266
...
...
@@ -476,10 +476,10 @@ if ((kalman_algo==1) || (kalman_algo==3))% Multivariate Kalman Filter
end
if
analytic_derivation
if
no_DLIK
==
0
[
DLIK
]
=
score
(
T
,
R
,
Q
,
H
,
Pstar
,
Y
,
DT
,
DYss
,
DOm
,
DH
,
DP
,
start
,
mf
,
kalman_tol
,
riccati_tol
);
[
DLIK
]
=
score
(
T
,
R
,
Q
,
H
,
Pstar
,
Y
,
DT
,
DYss
,
DOm
,
DH
,
DP
,
start
,
Z
,
kalman_tol
,
riccati_tol
);
end
if
nargout
==
7
[
AHess
]
=
AHessian
(
T
,
R
,
Q
,
H
,
Pstar
,
Y
,
DT
,
DYss
,
DOm
,
DH
,
DP
,
start
,
mf
,
kalman_tol
,
riccati_tol
);
if
nargout
==
11
[
AHess
]
=
AHessian
(
T
,
R
,
Q
,
H
,
Pstar
,
Y
,
DT
,
DYss
,
DOm
,
DH
,
DP
,
start
,
Z
,
kalman_tol
,
riccati_tol
);
end
end
else
...
...
matlab/dynare_estimation_init.m
View file @
1825d266
...
...
@@ -312,9 +312,9 @@ end % if ~isempty(options_.unit_root_vars)
% Test if the data file is declared.
if
isempty
(
options_
.
datafile
)
if
gsa_flag
data
=
[];
rawdata
=
[];
data_info
=
[];
data
set_
=
[];
%
rawdata = [];
%
data_info = [];
return
else
error
(
'datafile option is missing'
)
...
...
matlab/dynare_identification.m
View file @
1825d266
...
...
@@ -114,14 +114,26 @@ options_.nomoments=0;
options_
=
set_default_option
(
options_
,
'datafile'
,[]);
options_
.
mode_compute
=
0
;
options_
.
plot_priors
=
0
;
[
data
,
rawdata
,
xparam1
,
data_info
]
=
dynare_estimation_init
(
M_
.
endo_names
,
fname_
,
1
);
if
isempty
(
data_info
),
data_info
.
gend
=
periods
;
data_info
.
data
=
[];
data_info
.
data_index
=
[];
data_info
.
number_of_observations
=
periods
*
size
(
options_
.
varobs
,
1
);
data_info
.
no_more_missing_observations
=
0
;
data_info
.
missing_value
=
0
;
[
dataset_
,
xparam1
,
M_
,
options_
,
oo_
,
estim_params_
,
bayestopt_
]
=
dynare_estimation_init
(
M_
.
endo_names
,
fname_
,
1
,
M_
,
options_
,
oo_
,
estim_params_
,
bayestopt_
);
if
isempty
(
dataset_
),
dataset_
.
info
.
ntobs
=
periods
;
dataset_
.
info
.
nvobs
=
rows
(
options_
.
varobs
);
dataset_
.
info
.
varobs
=
options_
.
varobs
;
dataset_
.
rawdata
=
[];
dataset_
.
missing
.
state
=
0
;
dataset_
.
missing
.
aindex
=
[];
dataset_
.
missing
.
vindex
=
[];
dataset_
.
missing
.
number_of_observations
=
[];
dataset_
.
missing
.
no_more_missing_observations
=
[];
dataset_
.
descriptive
.
mean
=
[];
dataset_
.
data
=
[];
% data_info.gend = periods;
% data_info.data = [];
% data_info.data_index = [];
% data_info.number_of_observations = periods*size(options_.varobs,1);
% data_info.no_more_missing_observations = 0;
% data_info.missing_value = 0;
end
% results = prior_sampler(0,M_,bayestopt_,options_,oo_);
...
...
@@ -240,7 +252,7 @@ if iload <=0,
disp
(
'Testing current parameter values'
)
end
[
idehess_point
,
idemoments_point
,
idemodel_point
,
idelre_point
,
derivatives_info_point
]
=
...
identification_analysis
(
params
,
indx
,
indexo
,
options_ident
,
data
_info
,
prior_exist
,
name_tex
,
1
);
identification_analysis
(
params
,
indx
,
indexo
,
options_ident
,
data
set_
,
prior_exist
,
name_tex
,
1
);
idehess_point
.
params
=
params
;
% siH = idemodel_point.siH;
% siJ = idemoments_point.siJ;
...
...
@@ -274,7 +286,7 @@ if iload <=0,
params
=
prior_draw
();
end
[
dum1
,
ideJ
,
ideH
,
ideGP
,
dum2
,
info
]
=
...
identification_analysis
(
params
,
indx
,
indexo
,
options_MC
,
data
_info
,
prior_exist
,
name_tex
,
0
);
identification_analysis
(
params
,
indx
,
indexo
,
options_MC
,
data
set_
,
prior_exist
,
name_tex
,
0
);
if
iteration
==
0
,
MAX_tau
=
min
(
SampleSize
,
ceil
(
MaxNumberOfBytes
/(
size
(
ideH
.
siH
,
1
)
*
nparam
)/
8
));
stoH
=
zeros
([
size
(
ideH
.
siH
,
1
),
nparam
,
MAX_tau
]);
...
...
@@ -429,10 +441,10 @@ if SampleSize > 1,
fprintf
(
'\n'
)
tittxt
=
'Draw with HIGHEST condition number'
;
fprintf
(
'\n'
)
disp
([
'Testing '
,
tittxt
,
'. Press ENTER'
]),
pause
,
disp
([
'Testing '
,
tittxt
,
'. Press ENTER'
]),
pause
(
5
)
,
if
~
iload
,
[
idehess_max
,
idemoments_max
,
idemodel_max
,
idelre_max
,
derivatives_info_max
]
=
...
identification_analysis
(
pdraws
(
jmax
,:),
indx
,
indexo
,
options_ident
,
data
_info
,
prior_exist
,
name_tex
,
1
);
identification_analysis
(
pdraws
(
jmax
,:),
indx
,
indexo
,
options_ident
,
data
set_
,
prior_exist
,
name_tex
,
1
);
save
([
IdentifDirectoryName
'/'
M_
.
fname
'_identif.mat'
],
'idehess_max'
,
'idemoments_max'
,
'idemodel_max'
,
'idelre_max'
,
'jmax'
,
'-append'
);
end
disp_identification
(
pdraws
(
jmax
,:),
idemodel_max
,
idemoments_max
,
name
);
...
...
@@ -442,10 +454,10 @@ if SampleSize > 1,
fprintf
(
'\n'
)
tittxt
=
'Draw with SMALLEST condition number'
;
fprintf
(
'\n'
)
disp
([
'Testing '
,
tittxt
,
'. Press ENTER'
]),
pause
,
disp
([
'Testing '
,
tittxt
,
'. Press ENTER'
]),
pause
(
5
)
,
if
~
iload
,
[
idehess_min
,
idemoments_min
,
idemodel_min
,
idelre_min
,
derivatives_info_min
]
=
...
identification_analysis
(
pdraws
(
jmin
,:),
indx
,
indexo
,
options_ident
,
data
_info
,
prior_exist
,
name_tex
,
1
);
identification_analysis
(
pdraws
(
jmin
,:),
indx
,
indexo
,
options_ident
,
data
set_
,
prior_exist
,
name_tex
,
1
);
save
([
IdentifDirectoryName
'/'
M_
.
fname
'_identif.mat'
],
'idehess_min'
,
'idemoments_min'
,
'idemodel_min'
,
'idelre_min'
,
'jmin'
,
'-append'
);
end
disp_identification
(
pdraws
(
jmin
,:),
idemodel_min
,
idemoments_min
,
name
);
...
...
@@ -455,10 +467,10 @@ if SampleSize > 1,
for
j
=
1
:
length
(
jcrit
),
tittxt
=
[
'Rank deficient draw n. '
,
int2str
(
j
)];
fprintf
(
'\n'
)
disp
([
'Testing '
,
tittxt
,
'. Press ENTER'
]),
pause
,
disp
([
'Testing '
,
tittxt
,
'. Press ENTER'
]),
pause
(
5
)
,
if
~
iload
,
[
idehess_
(
j
),
idemoments_
(
j
),
idemodel_
(
j
),
idelre_
(
j
),
derivatives_info_
(
j
)]
=
...
identification_analysis
(
pdraws
(
jcrit
(
j
),:),
indx
,
indexo
,
options_ident
,
data
_info
,
prior_exist
,
name_tex
,
1
);
identification_analysis
(
pdraws
(
jcrit
(
j
),:),
indx
,
indexo
,
options_ident
,
data
set_
,
prior_exist
,
name_tex
,
1
);
end
disp_identification
(
pdraws
(
jcrit
(
j
),:),
idemodel_
(
j
),
idemoments_
(
j
),
name
);
close
all
,
...
...
matlab/dynare_sensitivity.m
View file @
1825d266
...
...
@@ -24,6 +24,9 @@ function x0=dynare_sensitivity(options_gsa)
global
M_
options_
oo_
bayestopt_
estim_params_
fname_
=
M_
.
fname
;
if
~
isfield
(
M_
,
'dname'
),
M_
.
dname
=
M_
.
fname
;
end
lgy_
=
M_
.
endo_names
;
x0
=
[];
...
...
@@ -57,7 +60,8 @@ if ~isempty(options_gsa.datafile) || isempty(bayestopt_),
options_
.
mode_compute
=
0
;
options_
.
filtered_vars
=
1
;
options_
.
plot_priors
=
0
;
[
data
,
rawdata
,
xparam1
,
data_info
]
=
dynare_estimation_init
([],
fname_
,
1
);
% [data,rawdata,xparam1,data_info]=dynare_estimation_init([],fname_,1);
[
dataset_
,
xparam1
,
M_
,
options_
,
oo_
,
estim_params_
,
bayestopt_
]
=
dynare_estimation_init
(
M_
.
endo_names
,
fname_
,
1
,
M_
,
options_
,
oo_
,
estim_params_
,
bayestopt_
);
% computes a first linear solution to set up various variables
else
if
isempty
(
options_
.
qz_criterium
)
...
...
matlab/identification_analysis.m
View file @
1825d266
...
...
@@ -129,13 +129,14 @@ if info(1)==0,
options_
.
irf
=
0
;
options_
.
noprint
=
1
;
options_
.
order
=
1
;
options_
.
periods
=
data_info
.
gend
+
100
;
options_
.
periods
=
data_info
.
info
.
ntobs
+
100
;
options_
.
kalman_algo
=
1
;
info
=
stoch_simul
(
options_
.
varobs
);
data
x
=
oo_
.
endo_simul
(
options_
.
varobs_id
,
100
+
1
:
end
);
data
_info
.
data
=
oo_
.
endo_simul
(
options_
.
varobs_id
,
100
+
1
:
end
);
% datax=data;
derivatives_info
.
no_DLIK
=
1
;
[
fval
,
cost_flag
,
ys
,
trend_coeff
,
info
,
DLIK
,
AHess
]
=
DsgeLikelihood
(
params
'
,
data_info
.
gend
,
datax
,
data_info
.
data_index
,
data_info
.
number_of_observations
,
data_info
.
no_more_missing_observations
,
derivatives_info
);
[
fval
,
cost_flag
,
ys
,
trend_coeff
,
info
,
M_
,
options_
,
bayestopt_
,
oo_
,
DLIK
,
AHess
]
=
DsgeLikelihood
(
params
'
,
data_info
,
options_
,
M_
,
estim_params_
,
bayestopt_
,
oo_
,
derivatives_info
);
% fval = DsgeLikelihood(xparam1,data_info,options_,M_,estim_params_,bayestopt_,oo_);
AHess
=-
AHess
;
ide_hess
.
AHess
=
AHess
;
deltaM
=
sqrt
(
diag
(
AHess
));
...
...
matlab/plot_identification.m
View file @
1825d266
...
...
@@ -94,7 +94,7 @@ if SampleSize == 1,
if
advanced
,
disp
(
' '
)
disp
(
'Press ENTER to display advanced diagnostics'
),
pause
,
disp
(
'Press ENTER to display advanced diagnostics'
),
pause
(
5
)
,
figure
(
'Name'
,[
tittxt
,
' - Sensitivity plot'
]),
subplot
(
211
)
mmm
=
(
siJnorm
)
'.
/
max
(
siJnorm
);
...
...
@@ -258,7 +258,7 @@ else
if
options_
.
nograph
,
close
(
gcf
);
end
if
advanced
,
disp
(
' '
)
disp
(
'Press ENTER to display advanced diagnostics'
),
pause
,
disp
(
'Press ENTER to display advanced diagnostics'
),
pause
(
5
)
,
options_
.
nograph
=
1
;
figure
(
'Name'
,
'MC Condition Number'
),
subplot
(
221
)
...
...
tests/Makefile.am
View file @
1825d266
...
...
@@ -74,6 +74,9 @@ MODFILES = \
external_function/example1_no_deriv_functions_provided.mod
\
external_function/example1_no_deriv_functions_provided_dll.mod
\
seeds.mod
\
gsa/ls2003.mod
\
identificaton/kim/kim2.mod
\
identificaton/as2007/as2007.mod
\
simul/example1.mod
\
conditional_forecasts/fs2000_cal.mod
\
conditional_forecasts/fs2000_est.mod
\
...
...
tests/gsa/ls2003.mod
View file @
1825d266
...
...
@@ -65,7 +65,7 @@ end;
disp(' ');
disp('NOW I DO STABILITY MAPPING and prepare sample for Reduced form Mapping');
disp(' ');
disp('Press ENTER to continue'); pause;
disp('Press ENTER to continue'); pause
(5)
;
dynare_sensitivity(redform=1, //create sample of reduced form coefficients
alpha2_stab=0.4,
...
...
@@ -76,7 +76,7 @@ ksstat=0);
disp(' ');
disp('ANALYSIS OF REDUCED FORM COEFFICIENTS');
disp(' ');
disp('Press ENTER to continue'); pause;
disp('Press ENTER to continue'); pause
(5)
;
dynare_sensitivity(load_stab=1, // loead previously generated sample analysed for stability
redform=1, // do the reduced form mapping
...
...
@@ -94,7 +94,7 @@ disp(' ');
disp('dynare_sensitivity(alpha2_stab=0.4, ksstat=0, redform=1,')
disp('logtrans_redform=1, namendo=(pie,R), namexo=(e_R), namlagendo=(R));')
disp(' ');
disp('Press ENTER to continue'); pause;
disp('Press ENTER to continue'); pause
(5)
;
//dynare_sensitivity(
//alpha2_stab=0.4,
//ksstat=0,
...
...
@@ -109,7 +109,7 @@ disp('Press ENTER to continue'); pause;
disp(' ');
disp('MC FILTERING(rmse=1), TO MAP THE FIT FROM PRIORS');
disp('Press ENTER to continue'); pause;
disp('Press ENTER to continue'); pause
(5)
;
dynare_sensitivity(datafile=data_ca1,first_obs=8,nobs=79,prefilter=1, // also presample=2,loglinear, are admissible
load_stab=1, // load prior sample
...
...
@@ -132,7 +132,7 @@ disp('logtrans_redform=1, namendo=(pie,R), namexo=(e_R), namlagendo=(R),')
disp('datafile=data_ca1,first_obs=8,nobs=79,prefilter=1,')
disp('istart_rmse=2, rmse=1, pfilt_rmse=0.1, alpha2_rmse=0.3, alpha_rmse=1);')
disp(' ');
disp('Press ENTER to continue'); pause;
disp('Press ENTER to continue'); pause
(5)
;
//dynare_sensitivity(
//alpha2_stab=0.4,
//ksstat=0,
...
...
@@ -156,7 +156,7 @@ disp('Press ENTER to continue'); pause;
disp(' ');
disp('I ESTIMATE THE MODEL');
disp(' ');
disp('Press ENTER to continue'); pause;
disp('Press ENTER to continue'); pause
(5)
;
// run this to generate posterior mode and Metropolis files if not yet done
//estimation(datafile=data_ca1,first_obs=8,nobs=79,mh_nblocks=2,
...
...
@@ -173,7 +173,7 @@ disp(' ');
disp('WE DO STABILITY MAPPING AGAIN, BUT FOR MULTIVARIATE SAMPLE AT THE POSTERIOR MODE (or ML) and Hessian (pprior=0 & ppost=0)');
disp('Typical for ML estimation, also feasible for posterior mode');
disp(' ');
disp('Press ENTER to continue'); pause;
disp('Press ENTER to continue'); pause
(5)
;
dynare_sensitivity(pprior=0,Nsam=2048,alpha2_stab=0.4,
mode_file=ls2003_mode // specifies the mode file where the mode and Hessian are stored
...
...
@@ -183,7 +183,7 @@ mode_file=ls2003_mode // specifies the mode file where the mode and Hessian are
disp(' ');
disp('RMSE ANALYSIS FOR MULTIVARIATE SAMPLE AT THE POSTERIOR MODE');
disp(' ');
disp('Press ENTER to continue'); pause;
disp('Press ENTER to continue'); pause
(5)
;
dynare_sensitivity(mode_file=ls2003_mode,
datafile=data_ca1,first_obs=8,nobs=79,prefilter=1,
pprior=0,
...
...
@@ -201,7 +201,7 @@ disp('dynare_sensitivity(pprior=0,Nsam=2048,alpha2_stab=0.4,mode_file=ls2003_mod
disp('datafile=data_ca1,first_obs=8,nobs=79,prefilter=1,')
disp('rmse=1, alpha2_rmse=1, alpha_rmse=1);')
disp(' ');
disp('Press ENTER to continue'); pause;
disp('Press ENTER to continue'); pause
(5)
;
//dynare_sensitivity(pprior=0,Nsam=2048,alpha2_stab=0.4,mode_file=ls2003_mode,
//datafile=data_ca1,first_obs=8,nobs=79,prefilter=1,
//rmse=1,
...
...
@@ -212,7 +212,7 @@ disp('Press ENTER to continue'); pause;
disp(' ');
disp('RMSE ANALYSIS FOR POSTERIOR MCMC sample (ppost=1)');
disp('Needs a call to dynare_estimation to load all MH environment');
disp('Press ENTER to continue'); pause;
disp('Press ENTER to continue'); pause
(5)
;
estimation(datafile=data_ca1,first_obs=8,nobs=79,mh_nblocks=2, mode_file=ls2003_mode, load_mh_file,
prefilter=1,mh_jscale=0.5,mh_replic=0, mode_compute=0, nograph, mh_drop=0.6);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment