diff --git a/doc/dynare.texi b/doc/dynare.texi index 16528a3e75cca5d7d0242102d8fcb52dca6d3f42..220c8683e4e2c3c2202fd7c267e0c55f3d0fbdab 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -6338,7 +6338,7 @@ smoother in order of declaration of the observed variables. @defvr {MATLAB/Octave variable} oo_.Smoother.Trend Variable set by the @code{estimation} command (if used with the @code{smoother} option), or by the @code{calib_smoother} command. -Contains the trend component of the observed variables used in the +Contains the trend component of the variables used in the smoother. Fields are of the form: @@ -6351,7 +6351,8 @@ Fields are of the form: Variable set by the @code{estimation} command (if used with the @code{smoother} option), or by the @code{calib_smoother} command. Contains the constant part of the endogenous variables used in the -smoother. +smoother, accounting e.g. for the data mean when using the @code{prefilter} +option. Fields are of the form: @example diff --git a/matlab/store_smoother_results.m b/matlab/store_smoother_results.m index f502abcb8095162e78052ed1d20a087a6f6f2603..f84b31f55fdf0f9b67dc6c1a45fc15e823763063 100644 --- a/matlab/store_smoother_results.m +++ b/matlab/store_smoother_results.m @@ -28,7 +28,7 @@ function [oo_, yf]=store_smoother_results(M_,oo_,options_,bayestopt_,dataset_,da % Outputs: % oo_ [structure] storing the results: % oo_.Smoother.SteadyState: Steady states (declaration order) -% oo_.Smoother.TrendCoeffs: trend coefficients, with NaN where no trend applies (declaration order) +% oo_.Smoother.TrendCoeffs: trend coefficients, with zeros where no trend applies (declaration order) % oo_.Smoother.Variance: one-step ahead forecast error variance (declaration order) % oo_.Smoother.Constant: structure storing the constant term of the smoother % oo_.Smoother.Trend: structure storing the trend term of the smoother @@ -82,6 +82,11 @@ oo_.Smoother.TrendCoeffs = zeros(size(ys)); oo_.Smoother.TrendCoeffs(options_.varobs_id)=trend_coeff; %are in order of options_.varobs if ~isempty(Trend) + for var_iter=1:M_.endo_nbr + if isempty(strmatch(deblank(M_.endo_names(var_iter,:)),options_.varobs,'exact')) + oo_.Smoother.Trend.(deblank(M_.endo_names(var_iter,:))) = zeros(gend,1); + end + end for var_iter=1:size(options_.varobs,2) oo_.Smoother.Trend.(deblank(options_.varobs{1,var_iter})) = Trend(var_iter,:)'; end @@ -137,6 +142,7 @@ for i_endo_in_bayestopt_smoother_varlist=bayestopt_.smoother_saved_var_list' elseif options_.loglinear == 0 %unlogged steady state must be used constant_current_variable=repmat((ys(i_endo_declaration_order)),gend,1); end + oo_.Smoother.Constant.(deblank(M_.endo_names(i_endo_declaration_order,:)))=constant_current_variable; oo_.SmoothedVariables.(deblank(M_.endo_names(i_endo_declaration_order,:)))=atT(i_endo_in_dr,:)'+constant_current_variable; if ~isempty(options_.nk) && options_.nk > 0 && ~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.pshape> 0) && options_.load_mh_file)) oo_.FilteredVariables.(deblank(M_.endo_names(i_endo_declaration_order,:)))=squeeze(aK(1,i_endo_in_dr,2:end-(options_.nk-1))); @@ -146,7 +152,7 @@ end %% Add trend and constant for observed variables for pos_iter=1:length(bayestopt_.mf) - oo_.Smoother.Constant.(deblank(M_.endo_names(bayestopt_.mfys(pos_iter),:)))=constant_part(pos_iter,:); + oo_.Smoother.Constant.(deblank(M_.endo_names(bayestopt_.mfys(pos_iter),:)))=constant_part(pos_iter,:)'; if ismember(bayestopt_.mf(pos_iter),bayestopt_.smoother_var_list(bayestopt_.smoother_saved_var_list)) oo_.SmoothedVariables.(deblank(M_.endo_names(bayestopt_.mfys(pos_iter),:)))=yf(pos_iter,:)'; if ~isempty(options_.nk) && options_.nk > 0