Changes related to the new interface for the dsge-var models.

time-shift
Stéphane Adjemian (Scylla) 2010-06-24 12:53:10 +02:00
parent 2aba780744
commit 3aaccc59e3
8 changed files with 27 additions and 27 deletions

View File

@ -1,5 +1,4 @@
function [fval,cost_flag,info,PHI,SIGMAu,iXX,prior] = DsgeVarLikelihood(xparam1,gend)
% function [fval,cost_flag,info,PHI,SIGMAu,iXX] = DsgeVarLikelihood(xparam1,gend)
% Evaluates the posterior kernel of the bvar-dsge model.
%
% INPUTS
@ -46,7 +45,7 @@ nx = nvx+nvn+ncx+ncn+np;
ns = nvx+nvn+ncx+ncn;
NumberOfObservedVariables = size(options_.varobs,1);
NumberOfLags = options_.varlag;
NumberOfLags = options_.dsge_varlag;
NumberOfParameters = NumberOfObservedVariables*NumberOfLags ;
if ~options_.noconstant
NumberOfParameters = NumberOfParameters + 1;
@ -83,7 +82,7 @@ for i=1:estim_params_.nvx
end
offset = estim_params_.nvx;
if estim_params_.nvn
disp('DsgeVarLikelihood :: Measurement errors are implemented!')
disp('DsgeVarLikelihood :: Measurement errors are not implemented!')
return
end
if estim_params_.ncx
@ -104,7 +103,6 @@ if dsge_prior_weight<(NumberOfParameters+NumberOfObservedVariables)/gend;
return;
end
%------------------------------------------------------------------------------
% 2. call model setup & reduction program
%------------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@ function varlist = check_list_of_variables(options_, M_, varlist)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
msg = 0;
if options_.bvar_dsge && options_.bayesian_irf
if options_.dsge_var && options_.bayesian_irf
if ~isempty(varlist)
for i=1:size(varlist,1)
idx = strmatch(deblank(varlist(i,:)),options_.varobs,'exact');

View File

@ -32,7 +32,7 @@ global options_ oo_ M_ oo_recursive_
%% Decide if a DSGE or DSGE-VAR has to be estimated.
if ~isempty(strmatch('dsge_prior_weight',M_.param_names))
options_.bvar_dsge = 1;
options_.dsge_var = 1;
end
var_list = check_list_of_variables(options_, M_, var_list);

View File

@ -331,7 +331,7 @@ end
%% compute sample moments if needed (bvar-dsge)
if options_.bvar_dsge
if options_.dsge_var
if options_.missing_data
error('I cannot estimate a DSGE-VAR model with missing observations!')
end
@ -339,12 +339,12 @@ if options_.bvar_dsge
evalin('base',...
['[mYY,mXY,mYX,mXX,Ydata,Xdata] = ' ...
'var_sample_moments(options_.first_obs,' ...
'options_.first_obs+options_.nobs-1,options_.varlag,-1,' ...
'options_.first_obs+options_.nobs-1,options_.dsge_varlag,-1,' ...
'options_.datafile, options_.varobs,options_.xls_sheet,options_.xls_range);'])
else% The steady state is non zero ==> a constant in the VAR is needed!
evalin('base',['[mYY,mXY,mYX,mXX,Ydata,Xdata] = ' ...
'var_sample_moments(options_.first_obs,' ...
'options_.first_obs+options_.nobs-1,options_.varlag,0,' ...
'options_.first_obs+options_.nobs-1,options_.dsge_varlag,0,' ...
'options_.datafile, options_.varobs,options_.xls_sheet,options_.xls_range);'])
end
end
@ -391,7 +391,7 @@ end
%% Estimation of the posterior mode or likelihood mode
if options_.mode_compute > 0 & options_.posterior_mode_estimation
if ~options_.bvar_dsge
if ~options_.dsge_var
fh=str2func('DsgeLikelihood');
else
fh=str2func('DsgeVarLikelihood');
@ -403,7 +403,7 @@ if options_.mode_compute > 0 & options_.posterior_mode_estimation
if isfield(options_,'optim_opt')
eval(['optim_options = optimset(optim_options,' options_.optim_opt ');']);
end
if ~options_.bvar_dsge
if ~options_.dsge_var
[xparam1,fval,exitflag,output,lamdba,grad,hessian_fmincon] = ...
fmincon(fh,xparam1,[],[],[],[],lb,ub,[],optim_options,gend,data,data_index,number_of_observations,no_more_missing_observations);
else
@ -417,7 +417,7 @@ if options_.mode_compute > 0 & options_.posterior_mode_estimation
if isfield(options_,'optim_opt')
eval(['optim_options = optimset(optim_options,' options_.optim_opt ');']);
end
if ~options_.bvar_dsge
if ~options_.dsge_var
[xparam1,fval,exitflag] = fminunc(fh,xparam1,optim_options,gend,data,data_index,number_of_observations,no_more_missing_observations);
else
[xparam1,fval,exitflag] = fminunc(fh,xparam1,optim_options,gend);
@ -427,7 +427,7 @@ if options_.mode_compute > 0 & options_.posterior_mode_estimation
crit = 1e-7;
nit = 1000;
verbose = 2;
if ~options_.bvar_dsge
if ~options_.dsge_var
[fval,xparam1,grad,hessian_csminwel,itct,fcount,retcodehat] = ...
csminwel('DsgeLikelihood',xparam1,H0,[],crit,nit,options_.gradient_method,options_.gradient_epsilon,gend,data,data_index,number_of_observations,no_more_missing_observations);
disp(sprintf('Objective function at mode: %f',fval))
@ -459,7 +459,7 @@ if options_.mode_compute > 0 & options_.posterior_mode_estimation
else
nit=1000;
end
if ~options_.bvar_dsge
if ~options_.dsge_var
[xparam1,hh,gg,fval,invhess] = newrat('DsgeLikelihood',xparam1,hh,gg,igg,crit,nit,flag,gend,data,data_index,number_of_observations,no_more_missing_observations);
else
[xparam1,hh,gg,fval,invhess] = newrat('DsgeVarLikelihood',xparam1,hh,gg,igg,crit,nit,flag,gend);
@ -467,7 +467,7 @@ if options_.mode_compute > 0 & options_.posterior_mode_estimation
parameter_names = bayestopt_.name;
save([M_.fname '_mode.mat'],'xparam1','hh','gg','fval','invhess','parameter_names');
case 6
if ~options_.bvar_dsge
if ~options_.dsge_var
fval = DsgeLikelihood(xparam1,gend,data,data_index,number_of_observations,no_more_missing_observations);
else
fval = DsgeVarLikelihood(xparam1,gend);
@ -504,7 +504,7 @@ if options_.mode_compute > 0 & options_.posterior_mode_estimation
else
flag = 'LastCall';
end
if ~options_.bvar_dsge
if ~options_.dsge_var
[xparam1,PostVar,Scale,PostMean] = ...
gmhmaxlik('DsgeLikelihood',xparam1,bounds,options_.Opt6Numb,Scale,flag,MeanPar,CovJump,gend,data,...
data_index,number_of_observations,no_more_missing_observations);
@ -526,7 +526,7 @@ if options_.mode_compute > 0 & options_.posterior_mode_estimation
else
flag = 'LastCall';
end
if ~options_.bvar_dsge
if ~options_.dsge_var
[xparam1,PostVar,Scale,PostMean] = ...
gmhmaxlik('DsgeLikelihood',xparam1,bounds,...
options_.Opt6Numb,Scale,flag,PostMean,PostVar,gend,data,data_index,number_of_observations,no_more_missing_observations);
@ -553,7 +553,7 @@ if options_.mode_compute > 0 & options_.posterior_mode_estimation
if isfield(options_,'optim_opt')
eval(['optim_options = optimset(optim_options,' options_.optim_opt ');']);
end
if ~options_.bvar_dsge
if ~options_.dsge_var
[xparam1,fval,exitflag] = fminsearch(fh,xparam1,optim_options,gend,data,data_index,number_of_observations,no_more_missing_observations);
else
[xparam1,fval,exitflag] = fminsearch(fh,xparam1,optim_options,gend);
@ -602,7 +602,7 @@ if options_.mode_compute > 0 & options_.posterior_mode_estimation
disp(['c vector ' num2str(c')]);
% keyboard
if ~options_.bvar_dsge
if ~options_.dsge_var
[xparam1, fval, nacc, nfcnev, nobds, ier, t, vm] = sa(fh,xparam1,maxy,rt_,eps,ns,nt ...
,neps,maxevl,LB,UB,c,idisp ,t,vm,gend,data,data_index,number_of_observations,no_more_missing_observations);
else
@ -611,7 +611,7 @@ if options_.mode_compute > 0 & options_.posterior_mode_estimation
end
otherwise
if ischar(options_.mode_compute)
if options_.bvar_dsge
if options_.dsge_var
[xparam1, fval, retcode ] = feval(options_.mode_compute,fh,xparam1,gend,data);
else
[xparam1, fval, retcode ] = feval(options_.mode_compute, ...
@ -625,7 +625,7 @@ if options_.mode_compute > 0 & options_.posterior_mode_estimation
% if options_.mode_compute ~= 5
if options_.mode_compute ~= 6
if options_.cova_compute == 1
if ~options_.bvar_dsge
if ~options_.dsge_var
hh = reshape(hessian('DsgeLikelihood',xparam1, ...
options_.gstep,gend,data,data_index,number_of_observations,...
no_more_missing_observations),nx,nx);
@ -777,7 +777,7 @@ if any(bayestopt_.pshape > 0) & options_.posterior_mode_estimation
estim_params_nbr = size(xparam1,1);
scale_factor = -sum(log10(diag(invhess)));
log_det_invhess = -estim_params_nbr*log(scale_factor)+log(det(scale_factor*invhess));
if ~options_.bvar_dsge
if ~options_.dsge_var
md_Laplace = .5*estim_params_nbr*log(2*pi) + .5*log_det_invhess ...
- DsgeLikelihood(xparam1,gend,data,data_index,number_of_observations,no_more_missing_observations);
else
@ -1073,7 +1073,7 @@ if (any(bayestopt_.pshape >0 ) & options_.mh_replic) | ...
if options_.load_mh_file & options_.use_mh_covariance_matrix
invhess = compute_mh_covariance_matrix;
end
if options_.bvar_dsge
if options_.dsge_var
feval(options_.posterior_sampling_method,'DsgeVarLikelihood',options_.proposal_distribution,xparam1,invhess,bounds,gend);
else
feval(options_.posterior_sampling_method,'DsgeLikelihood',options_.proposal_distribution,xparam1,invhess,bounds,gend,data,...

View File

@ -48,7 +48,7 @@ for i = 1:size(M_.endo_names,1)
end
if ~isempty(strmatch('dsge_prior_weight',M_.param_names))
options_.bvar_dsge = 1;
options_.dsge_var = 1;
end
if options_.order > 1

View File

@ -54,7 +54,7 @@ if (number_of_observations==gend*nv)% No missing observations...
end
end
if ~isempty(strmatch('dsge_prior_weight',M_.param_names))
if options_.dsge_var
[fval,cost_flag,info] = DsgeVarLikelihood(xparam1,gend);
else
[fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data,data_index,number_of_observations,no_more_missing_observations);

View File

@ -39,7 +39,7 @@ global bayestopt_ M_ options_
TeX = options_.TeX;
[ s_min, k ] = min(diag(hessian)) ;
if options_.bvar_dsge
if options_.dsge_var
fval = DsgeVarLikelihood(x,gend);
else
fval = DsgeLikelihood(x,gend,data,data_index,number_of_observations,no_more_missing_observations);
@ -87,7 +87,7 @@ for plt = 1:nbplt,
end
for i=1:length(z)
xx(kk) = z(i);
if options_.bvar_dsge
if options_.dsge_var
[fval,cost_flag] = DsgeVarLikelihood(xx,gend);
if cost_flag
y(i,1) = fval;

View File

@ -56,6 +56,8 @@ if ~noprint
error('The steady state is complex.')
case 30
error('Variance can''t be computed')
case 51
error('You are estimating a DSGE-VAR model, but the value of the dsge prior weight is too low!')
otherwise
error('This case shouldn''t happen. Contact the authors of Dynare')
end