Commit 445cbf67 authored by Johannes Pfeifer 's avatar Johannes Pfeifer

endogenous_prior.m: deal with missing data

Closes #1744
parent 460895d2
......@@ -791,7 +791,7 @@ if DynareOptions.endogenous_prior==1
if DynareOptions.lik_init==2 || DynareOptions.lik_init==3
error('Endogenous prior not supported with non-stationary models')
[lnpriormom] = endogenous_prior(Y,Pstar,BayesInfo,H);
[lnpriormom] = endogenous_prior(Y,DatasetInfo,Pstar,BayesInfo,H);
fval = (likelihood-lnprior-lnpriormom);
......@@ -555,6 +555,18 @@ end
%set options for old interface from the ones for new interface
if ~isempty(dataset_)
options_.nobs = dataset_.nobs;
if options_.endogenous_prior
if dataset_info.missing.no_more_missing_observations<dataset_.nobs-10
fprintf('\ndynare_estimation_init: There are missing observations in the data.\n')
fprintf('dynare_estimation_init: I am computing the moments for the endogenous prior only\n')
fprintf('dynare_estimation_init: on the observations after the last missing one, i.e. %u.\n',dataset_info.missing.no_more_missing_observations)
fprintf('\ndynare_estimation_init: There are too many missing observations in the data.\n')
fprintf('dynare_estimation_init: The endogenous_prior-option needs a consistent sample of \n')
fprintf('dynare_estimation_init: at least 10 full observations at the end.\n')
error('The endogenous_prior-option does not support your missing data.')
% setting steadystate_check_flag option
function [lnpriormom] = endogenous_prior(data,Pstar,BayesInfo,H)
function [lnpriormom] = endogenous_prior(data,dataset_info, Pstar,BayesInfo,H)
% Computes the endogenous log prior addition to the initial prior
% data [double] n*T vector of data observations
% dataset_info [structure] various information about the dataset
% Pstar [double] k*k matrix of
% BayesInfo [structure]
......@@ -11,7 +12,7 @@ function [lnpriormom] = endogenous_prior(data,Pstar,BayesInfo,H)
% Code to implement notes on endogenous priors by Lawrence Christiano,
% specified in the appendix of:
% ’Introducing Financial Frictions and Unemployment into a Small Open Economy Model’
% Introducing Financial Frictions and Unemployment into a Small Open Economy Model
% by Lawrence J. Christiano, Mathias Trabandt and Karl Walentin (2011), Journal of Economic Dynamics and Control
% this is the 'mother' of the priors on the model parameters.
% the priors include a metric across some choosen moments of the (supposedly
......@@ -41,7 +42,8 @@ function [lnpriormom] = endogenous_prior(data,Pstar,BayesInfo,H)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <>.
[Tsamp,n]=size(Y); % sample length and number of matched moments (here set equal to nr of observables)
......@@ -85,4 +87,4 @@ Z=II(mf,:);
% below commented out line is for Del Negro Schorfheide style priors:
% lnpriormom=-.5*n*TT*log(2*pi)-.5*TT*log(det(sigma))-.5*TT*trace(inv(sigma)*(gamyy-2*phi'*gamxy+phi'*gamxx*phi));
\ No newline at end of file
Markdown is supported
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