Hi, I am trying to work with a m file:
clear
clear global
format compact
addpath('D:\dynare\4.4.3\2021forecastmmc2\MatlabReplicationCodes\MatlabReplicationCodes\MatlabUtils');
if ~exist('current_draws','dir')
mkdir('current_draws');
end
% For which country the model was estimated?
mdlName = 'NPmodel';
tic
ErrCount1 = [ ];
%options_.use_qzdiv = 1;
% this option is in global_initialization
% otherwise we have complex numbers...
% see in evaluate smoother1.m -> resol -> dr1 line 348
% we also need to remove the qz folder
fcst_options.replic = 7; % nr of draws for future shocks
fcst_options.periods = 20; % forecast horizon
nrep = fcst_options.replic;
H = fcst_options.periods; % predictive distribution horizon
var_list = [{'y_obs'},{'p_obs'},{'R_obs'},{'oil_obs'}];
nvar = size(var_list,2);
% Forecast is calculated for every k-th MH draw
k = 10;
tic
copyfile('NPdata.mat','data.mat');
for yy = 2007% 2008:2018
for qq = 4% 1:4
display([num2str(yy),'q',num2str(qq)])
% Copies parameter draws
copyfile(['NPest/',num2str(yy),'q',num2str(qq),'/*'],'current_draws');
load(['current_draws/results.mat']);
i=yy;j=qq;
% Load and transform data
transformation = [];
if options_.loglinear && ~options_.logdata
transformation = @log;
end
xls.sheet = options_.xls_sheet;
xls.range = options_.xls_range;
global dataset_
dataset_ = initialize_dataset1(options_.datafile,options_.varobs,options_.first_obs,options_.nobs,transformation,options_.prefilter,xls);
% reads MH settings
load(['current_draws/',mdlName,'_mh_history_0.mat']);
npar = estim_params_.nvx + estim_params_.nvn + estim_params_.ncx + estim_params_.ncn + estim_params_.np;
draw_.mh_nblck = options_.mh_nblck;
draw_.NumberOfDraws = sum(record.MhDraws(:,1))-floor(options_.mh_drop*sum(record.MhDraws(:,1)));
draw_.fname = ['current_draws/',mdlName];
draw_.FirstLine = record.KeepedDraws.FirstLine;
draw_.FirstMhFile = record.KeepedDraws.FirstMhFile;
draw_.MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8);
% some parameters
n = draw_.mh_nblck;
m = floor(draw_.NumberOfDraws/k);
% initializes matices in which we will save forecast draws
f.y_obs = NaN(H,n*m*nrep);
f.p_obs = NaN(H,n*m*nrep);
f.R_obs = NaN(H,n*m*nrep);
f.oil_obs = NaN(H,n*m*nrep);
% LOOP for MH draws
for ChainNumber = 1:n
for DrawNumber = 1:m
% draw from posterior distribution of theta
fcst_options.parameter_set = ParamPosteriorDraw(draw_, ChainNumber, DrawNumber*k);
xparam = fcst_options.parameter_set;
% forecast draws from the posterior
options_.lik_init=2;
[fmean fdraws] = generate_forecast_uncond(fcst_options);
place0 = (DrawNumber-1+(ChainNumber-1)*m)*nrep + 1:(DrawNumber+(ChainNumber-1)*m)*nrep;
f.y_obs(:, place0) = cumsum(fdraws.y_obs(2:end,:)); % RER level
f.p_obs(:, place0) = cumsum(fdraws.p_obs(2:end,:)); % price level
f.R_obs(:, place0) = fdraws.R_obs(2:end,:); % current account
f.oil_obs(:, place0) = cumsum(fdraws.oil_obs(2:end,:)); % foreign price level
end
end
% saves forecast draws
save(['NPest/',num2str(yy),'q',num2str(qq),'/forecasts.mat'], 'f');
end
end
rmdir('current_draws','s');
and matlab shows:
run forecastLOOP
2007q4
Unrecognized function or variable 'initialize_dataset1'.
Error in forecastLOOP (line 54)
dataset_ = initialize_dataset1(options_.datafile,options_.varobs,options_.first_obs,options_.nobs,transformation,options_.prefilter,xls);
Error in run (line 91)
evalin('caller', strcat(script, ';'));
How can I solve this problem?