Fixed shocks decomposition bug.
(cherry picked from commit 68e7a310eda20f8f7611521ac45608a6941b31cc)time-shift
parent
608c82fd26
commit
a18b071770
|
@ -43,8 +43,7 @@ function oo = evaluate_smoother(parameters)
|
||||||
|
|
||||||
global options_ M_ bayestopt_ oo_
|
global options_ M_ bayestopt_ oo_
|
||||||
|
|
||||||
persistent load_data
|
persistent dataset_
|
||||||
persistent gend data data_index number_of_observations no_more_missing_observations
|
|
||||||
|
|
||||||
if nargin==0
|
if nargin==0
|
||||||
parameters = 'posterior_mode';
|
parameters = 'posterior_mode';
|
||||||
|
@ -79,43 +78,22 @@ if ischar(parameters)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if isempty(load_data)
|
if isempty(dataset_)
|
||||||
% Get the data.
|
% Load and transform data.
|
||||||
n_varobs = size(options_.varobs,1);
|
transformation = [];
|
||||||
rawdata = read_variables(options_.datafile,options_.varobs,[],options_.xls_sheet,options_.xls_range);
|
if options_.loglinear && ~options_.logdata
|
||||||
options_ = set_default_option(options_,'nobs',size(rawdata,1)-options_.first_obs+1);
|
transformation = @log;
|
||||||
gend = options_.nobs;
|
|
||||||
rawdata = rawdata(options_.first_obs:options_.first_obs+gend-1,:);
|
|
||||||
% Transform the data.
|
|
||||||
if options_.loglinear
|
|
||||||
if ~options_.logdata
|
|
||||||
rawdata = log(rawdata);
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
% Test if the data set is real.
|
xls.sheet = options_.xls_sheet;
|
||||||
if ~isreal(rawdata)
|
xls.range = options_.xls_range;
|
||||||
error('There are complex values in the data! Probably a wrong transformation')
|
|
||||||
|
if ~isfield(options_,'nobs')
|
||||||
|
options_.nobs = [];
|
||||||
end
|
end
|
||||||
% Detrend the data.
|
|
||||||
options_.missing_data = any(any(isnan(rawdata)));
|
dataset_ = initialize_dataset(options_.datafile,options_.varobs,options_.first_obs,options_.nobs,transformation,options_.prefilter,xls);
|
||||||
if options_.prefilter == 1
|
options_.nobs = dataset_.info.ntobs;
|
||||||
if options_.missing_data
|
|
||||||
bayestopt_.mean_varobs = zeros(n_varobs,1);
|
|
||||||
for variable=1:n_varobs
|
|
||||||
rdx = find(~isnan(rawdata(:,variable)));
|
|
||||||
m = mean(rawdata(rdx,variable));
|
|
||||||
rawdata(rdx,variable) = rawdata(rdx,variable)-m;
|
|
||||||
bayestopt_.mean_varobs(variable) = m;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
bayestopt_.mean_varobs = mean(rawdata,1)';
|
|
||||||
rawdata = rawdata-repmat(bayestopt_.mean_varobs',gend,1);
|
|
||||||
end
|
|
||||||
end
|
|
||||||
data = transpose(rawdata);
|
|
||||||
% Handle the missing observations.
|
|
||||||
[data_index,number_of_observations,no_more_missing_observations] = describe_missing_data(data,gend,n_varobs);
|
|
||||||
missing_value = ~(number_of_observations == gend*n_varobs);
|
|
||||||
% Determine if a constant is needed.
|
% Determine if a constant is needed.
|
||||||
if options_.steadystate_flag% if the *_steadystate.m file is provided.
|
if options_.steadystate_flag% if the *_steadystate.m file is provided.
|
||||||
[ys,tchek] = feval([M_.fname '_steadystate'],...
|
[ys,tchek] = feval([M_.fname '_steadystate'],...
|
||||||
|
@ -143,15 +121,15 @@ if isempty(load_data)
|
||||||
else
|
else
|
||||||
options_.noconstant = 0;
|
options_.noconstant = 0;
|
||||||
end
|
end
|
||||||
load_data = 1;
|
|
||||||
end
|
end
|
||||||
|
|
||||||
pshape_original = bayestopt_.pshape;
|
pshape_original = bayestopt_.pshape;
|
||||||
bayestopt_.pshape = Inf(size(bayestopt_.pshape));
|
bayestopt_.pshape = Inf(size(bayestopt_.pshape));
|
||||||
clear('priordens')%
|
clear('priordens')
|
||||||
|
|
||||||
|
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp] = ...
|
||||||
|
DsgeSmoother(parameters,dataset_.info.ntobs,dataset_.data,dataset_.missing.aindex,dataset_.missing.state);
|
||||||
|
|
||||||
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp] ...
|
|
||||||
= DsgeSmoother(parameters,gend,data,data_index,missing_value);
|
|
||||||
oo.Smoother.SteadyState = ys;
|
oo.Smoother.SteadyState = ys;
|
||||||
oo.Smoother.TrendCoeffs = trend_coeff;
|
oo.Smoother.TrendCoeffs = trend_coeff;
|
||||||
if options_.filter_covariance
|
if options_.filter_covariance
|
||||||
|
|
Loading…
Reference in New Issue