Commit 0448da26 authored by adjemian's avatar adjemian
Browse files

Bug fixes (BVAR-DSGE)

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1181 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 934f5f21
......@@ -194,7 +194,7 @@ if length(options_.mode_file) > 0 & options_.posterior_mode_estimation
end
%% Compute the steadyn state:
%% Compute the steady state:
if options_.steadystate_flag% if the _steadystate.m file is provided.
[oo_.steady_state,tchek] = feval([M_.fname '_steadystate'],[],[]);
else% if the steady state file is not provided.
......@@ -202,15 +202,10 @@ else% if the steady state file is not provided.
oo_.steady_state = dd.ys; clear('dd');
end
initial_estimation_checks(xparam1,gend,data);
if options_.mode_compute == 0 & length(options_.mode_file) == 0
return;
end
%% compute sample moments if needed (bvar-dsge)
if ~isempty(strmatch('dsge_prior_weight',M_.param_names))
if all(abs(oo_.steady_state)<10e-9)
if options_.noconstant
evalin('base',['[mYY,mXY,mYX,mXX,Ydata,Xdata] = ' ...
'var_sample_moments(options_.first_obs,options_.first_obs+options_.nobs-1,options_.varlag,-1);'])
else% The steady state is non zero ==> a constant in the VAR is needed!
......@@ -219,6 +214,12 @@ if ~isempty(strmatch('dsge_prior_weight',M_.param_names))
end
end
initial_estimation_checks(xparam1,gend,data);
if options_.mode_compute == 0 & length(options_.mode_file) == 0
return;
end
%% Estimation of the posterior mode or likelihood mode
if options_.mode_compute > 0 & options_.posterior_mode_estimation
if isempty(strmatch('dsge_prior_weight',M_.param_names))
......
......@@ -3,7 +3,9 @@
function steady_()
global M_ oo_ it_ options_
options_.steadystate_flag
if options_.steadystate_flag
[oo_.steady_state,check] = feval([M_.fname '_steadystate'],...
oo_.steady_state,...
......@@ -17,7 +19,7 @@ function steady_()
cheick = max(abs(feval([M_.fname '_steadystate'],...
oo_.steady_state,...
[oo_.exo_steady_state; ...
oo_.exo_det_steady_state]))) > options_.dynatol
oo_.exo_det_steady_state]))) > options_.dynatol ;
end
end
if ~isempty(options_.steadystate_partial)
......
function [YtY,XtY,YtX,XtX,Y,X] = var_sample_moments(FirstObservation,LastObservation,qlag,trend);
function [YtY,XtY,YtX,XtX,Y,X] = var_sample_moments(FirstObservation,LastObservation,qlag,var_trend_order);
global options_
X = [];
......@@ -8,12 +8,12 @@ YtX = [];
XtY = [];
XtX = [];
if exist(options_.datafile)
eval(options_.datafile);
else
eval(['load ' options_.datafile]);
end
data = [ ];
for i=1:size(options_.varobs,1)
data = [data eval(deblank(options_.varobs(i,:)))];
......@@ -25,16 +25,16 @@ if qlag > FirstObservation
end
NumberOfObservations = LastObservation-FirstObservation+1;
NumberOfVariables = size(data,2);
if trend == -1% No constant
X = zeros(NumberOfObservations,NumberOfVariables*qlag);
elseif trend == 0% Constant
if var_trend_order == -1% No constant
X = zeros(NumberOfObservations,NumberOfVariables*qlag);
elseif var_trend_order == 0% Constant
X = zeros(NumberOfObservations,NumberOfVariables*qlag+1);
indx = NumberOfVariables*qlag+1:NumberOfVariables*qlag+NumberOfVariables;
elseif trend == 1;% Constant + Trend
elseif var_trend_order == 1;% Constant + Trend
X = zeros(NumberOfObservations,NumberOfVariables*qlag+2);
indx = NumberOfVariables*qlag+1:NumberOfVariables*qlag+2;
else
disp('varols :: trend must be equal to -1,0 or 1!')
disp('var_sample_moments :: trend must be equal to -1,0 or 1!')
return
end
% I build matrices Y and X
......@@ -44,12 +44,12 @@ for t=1:NumberOfObservations
for lag = 1:qlag
X(t,(lag-1)*NumberOfVariables+1:lag*NumberOfVariables) = data(line-lag,:);
end
if trend == 0
if var_trend_order == 0
X(t,indx) = ones(1,NumberOfVariables);
elseif trend == 1
elseif var_trend_order == 1
X(t,indx) = [ 1 , t ];
end
end
end
YtY = Y'*Y;
YtX = Y'*X;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment