Verified Commit 202bf913 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Cosmetic changes.

parent a40f30ca
......@@ -41,23 +41,19 @@ end
% file
datafile = '';
if isfield(options, 'filename')
warning([caller, '_FILE: option FILENAME is deprecated, please use', ...
' option DATAFILE'])
warning('%s_FILE: option FILENAME is deprecated, please use option DATAFILE', caller)
if dseries_ispresent
error([caller, '_FILE: you can''t use option FILENAME and option SERIES', ...
' at the same time'])
error('%s_FILE: you can''t use option FILENAME and option SERIES at the same time', caller)
end
if isfield(options, 'datafile')
error([caller, '_FILE: you can''t use option DATAFILE and option FILENAME', ...
' at the same time'])
error('%s_FILE: you can''t use option DATAFILE and option FILENAME at the same time', caller)
end
datafile = options.filename;
end
if isfield(options, 'datafile')
if dseries_ispresent
error([caller, '_FILE: you can''t use option DATAFILE and option SERIES', ...
' at the same time'])
error('%s_FILE: you can''t use option DATAFILE and option SERIES at the same time', caller)
end
datafile = options.datafile;
end
......@@ -75,10 +71,9 @@ if datafile
elseif exist([basename '.xlsx'],'file')
extension = '.xlsx';
else
error([caller, '_FILE: Can''t find datafile: ' basename '.{m,mat,xls,xlsx}']);
error('%s_FILE: Can''t find datafile: %s.{m,mat,xls,xlsx}', caller, basename);
end
end
fullname = [basename extension];
series = dseries(fullname);
end
......@@ -87,33 +82,30 @@ end
error_flag = false;
for i = 1:M.orig_endo_nbr
if ~series.exist(M.endo_names{i})
disp(sprintf('%s_FILE: endogenous variable %s is missing', ...
caller, M.endo_names{i}))
dprintf('%s_FILE: endogenous variable %s is missing', caller, M.endo_names{i})
error_flag = true;
end
end
for i = 1:M.exo_nbr
if ~series.exist(M.exo_names{i})
disp(sprintf('%s_FILE: exogenous variable %s is missing', ...
caller, M.exo_names{i}))
dprintf('%s_FILE: exogenous variable %s is missing', caller, M.exo_names{i})
error_flag = true;
end
end
for i = 1:M.exo_det_nbr
if ~series.exist(M.exo_det_names{i})
disp(sprintf('%s_FILE: exo_det variable %s is missing', ...
caller, M.exo_det_names{i}))
dprintf('%s_FILE: exo_det variable %s is missing', caller, M.exo_det_names{i})
error_flag = true;
end
end
if error_flag
error([caller, '_FILE: some variables are missing'])
error('%s_FILE: some variables are missing', caller)
end
if exist(sprintf('+%s/dynamic_set_auxiliary_series', M.fname), 'file')
if exist(sprintf('+%s/dynamic_set_auxiliary_series.m', M.fname), 'file')
series = feval(sprintf('%s.dynamic_set_auxiliary_series', M.fname), series, M.params);
end
......@@ -133,32 +125,23 @@ last_obs_ispresent = false;
first_obs = periods(1);
if isfield(options, 'first_obs') && ~isempty(options.first_obs)
if options.first_obs < 1
error([caller, '_FILE: first_obs must be a positive number'])
error('%s_FILE: first_obs must be a positive number', caller)
elseif options.first_obs > nobs0
error(sprintf([caller, '_FILE: first_obs = %d is larger than the number', ...
' of observations in the data file (%d)'], ...
options.first_obs, nobs0))
error('%s_FILE: first_obs = %d is larger than the number of observations in the data file (%d)', ...
caller, options.first_obs, nobs0)
elseif isfield(options, 'first_simulation_period')
if options.first_obs == options.first_simulation_period ...
- M.orig_maximum_lag
if options.first_obs == options.first_simulation_period - M.orig_maximum_lag
first_obs = periods(options.first_obs);
else
error(sprintf([caller, '_FILE: first_obs = %d and', ...
' first_simulation_period = %d have values', ...
' inconsistent with a maximum lag of %d periods'], ...
options.first_obs, options.first_simulation_period, ...
M.orig_maximum_lag))
error('%s_FILE: first_obs = %d and first_simulation_period = %d have values inconsistent with a maximum lag of %d periods', ...
caller, options.first_obs, options.first_simulation_period, M.orig_maximum_lag)
end
elseif isfield(options, 'firstsimulationperiod')
if periods(options.first_obs) == options.firstsimulationperiod ...
- M.orig_maximum_lag
if periods(options.first_obs) == options.firstsimulationperiod - M.orig_maximum_lag
first_obs = periods(options.first_obs);
else
error(sprintf([caller, '_FILE: first_obs = %d and', ...
' first_simulation_period = %s have values', ...
' inconsistent with a maximum lag of %d periods'], ...
options.first_obs, options.firstsimulationperiod, ...
M.orig_maximum_lag))
error('%s_FILE: first_obs = %d and first_simulation_period = %s have values inconsistent with a maximum lag of %d periods', ...
caller, options.first_obs, options.firstsimulationperiod, M.orig_maximum_lag)
end
else
first_obs = periods(options.first_obs);
......@@ -168,26 +151,18 @@ end
if isfield(options, 'firstobs') && ~isempty(options.firstobs)
if isfield(options, 'first_simulation_period')
if options.firstobs == periods(options.first_simulation_period) ...
- M.orig_maximum_lag
if options.firstobs == periods(options.first_simulation_period) - M.orig_maximum_lag
first_obs = options.firstobs;
else
error(sprintf([caller, '_FILE: first_obs = %s and', ...
' first_simulation_period = %d have values', ...
' inconsistent with a maximum lag of %d periods'], ...
options.firstobs, options.first_simulation_period, ...
M.orig_maximum_lag))
error('%s_FILE: first_obs = %s and first_simulation_period = %d have values inconsistent with a maximum lag of %d periods', ...
caller, options.firstobs, options.first_simulation_period, M.orig_maximum_lag)
end
elseif isfield(options, 'firstsimulationperiod')
if options.firstobs == options.firstsimulationperiod ...
- M.orig_maximum_lag
if options.firstobs == options.firstsimulationperiod - M.orig_maximum_lag
first_obs = options.firstobs;
else
error(sprintf([caller, '_FILE: firstobs = %s and', ...
' first_simulation_period = %s have values', ...
' inconsistent with a maximum lag of %d periods'], ...
options.firstobs, options.firstsimulationperiod, ...
M.orig_maximum_lag))
error('%s_FILE: firstobs = %s and first_simulation_period = %s have values inconsistent with a maximum lag of %d periods', ...
caller, options.firstobs, options.firstsimulationperiod, M.orig_maximum_lag)
end
else
first_obs = options.firstobs;
......@@ -198,36 +173,28 @@ end
if ~first_obs_ispresent
if isfield(options, 'first_simulation_period')
if options.first_simulation_period < M.orig_maximum_lag
error(sprintf([caller, '_FILE: first_simulation_period = %d', ...
'must be larger than the maximum lag (%d)'], ...
options.first_simulation_period, M.orig_maximum_lag))
error('%s_FILE: first_simulation_period = %d must be larger than the maximum lag (%d)', ...
caller, options.first_simulation_period, M.orig_maximum_lag)
elseif options.first_simulation_period > nobs0
error(sprintf([caller, '_FILE: first_simulations_period = %d', ...
' is larger than the number of observations in', ...
' the data file (%d)'], ...
options.first_obs, nobs0))
error('%s_FILE: first_simulations_period = %d is larger than the number of observations in the data file (%d)', ...
caller, options.first_obs, nobs0)
else
first_obs = periods(options.first_simulation_period) - ...
M.orig_maximum_lag;
first_obs = periods(options.first_simulation_period) - M.orig_maximum_lag;
end
first_obs_ispresent = true;
elseif isfield(options, 'firstsimulationperiod')
first_obs = options.firstsimulationperiod - ...
M.orig_maximum_lag;
first_obs = options.firstsimulationperiod - M.orig_maximum_lag;
first_obs_ispresent = true;
end
end
if isfield(options, 'last_obs')
if options.last_obs > nobs0
error(sprintf([caller, '_FILE: last_obs = %d is larger than the number', ...
' of observations in the dataset (%d)'], ...
options.last_obs, nobs0))
error('%s_FILE: last_obs = %d is larger than the number of observations in the dataset (%d)', ...
caller, options.last_obs, nobs0)
elseif first_obs_ispresent
if nobs > 0 && (periods(options.last_obs) ~= first_obs + nobs - 1)
error([caller, '_FILE: FIST_OBS, LAST_OBS and NOBS contain', ...
' inconsistent information. Use only two of these', ...
' options.'])
error('%s_FILE: FIST_OBS, LAST_OBS and NOBS contain inconsistent information. Use only two of these options.', caller)
else
last_obs = periods(options.last_obs);
end
......@@ -241,14 +208,11 @@ if isfield(options, 'last_obs')
end
elseif isfield(options, 'lastobs')
if options.lastobs > series.last
error(sprintf([caller, '_FILE: last_obs = %s is larger than the number', ...
' of observations in the dataset (%s)'], ...
options.lastobs, series.last))
error('%s_FILE: last_obs = %s is larger than the number of observations in the dataset (%s)', ...
caller, options.lastobs, series.last)
elseif first_obs_ispresent
if nobs > 0 && (options.lastobs ~= first_obs + nobs - 1)
error([caller, '_FILE: FIST_OBS, LAST_OBS and NOBS contain', ...
' inconsistent information. Use only two of these', ...
' options.'])
error('%s_FILE: FIST_OBS, LAST_OBS and NOBS contain inconsistent information. Use only two of these options.', caller)
else
last_obs = options.lastobs;
end
......@@ -266,6 +230,4 @@ else
last_obs = series.last;
end
series = series(first_obs:last_obs);
series = series(first_obs:last_obs);
\ No newline at end of file
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