Commit 907e087e authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Consider options_.varobs as a cell of strings.

parent 82e49059
......@@ -59,7 +59,7 @@ R = [];
P = [];
PK = [];
decomp = [];
nobs = size(options_.varobs,1);
nobs = length(options_.varobs);
smpl = size(Y,2);
M_ = set_all_parameters(xparam1,estim_params_,M_);
......
......@@ -177,17 +177,17 @@ if nvn
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ...
posterior_moments(Draws,1,options_.mh_conf_sig);
name = deblank(options_.varobs(estim_params_.nvn_observable_correspondence(i,1),:));
name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)};
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density);
else
try
name = deblank(options_.varobs(estim_params_.nvn_observable_correspondence(i,1),:));
name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)};
[post_mean,hpd_interval,post_var] = Extractoo(oo_,name,type);
catch
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ...
posterior_moments(Draws,1,options_.mh_conf_sig);
name = deblank(options_.varobs(estim_params_.nvn_observable_correspondence(i,1),:));
name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)};
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density);
end
end
......
......@@ -89,7 +89,7 @@ for i=1:npar
eval(['pmod = oo_.posterior_mode.shocks_std.' name ';'])
end
elseif i <= nvx+nvn
name = deblank(options_.varobs(estim_params_.nvn_observable_correspondence(i-nvx,1),:));
name = options_.varobs{estim_params_.nvn_observable_correspondence(i-nvx,1)};
eval(['x1 = oo_.posterior_density.measurement_errors_std.' name '(:,1);'])
eval(['f1 = oo_.posterior_density.measurement_errors_std.' name '(:,2);'])
eval(['oo_.prior_density.mearsurement_errors_std.' name '(:,1) = x2;'])
......
......@@ -48,7 +48,7 @@ MaxNumberOfPlotPerFigure = 4;% The square root must be an integer!
MaxNumberOfBytes=options_.MaxNumberOfBytes;
endo_nbr=M_.endo_nbr;
exo_nbr=M_.exo_nbr;
nvobs = size(options_.varobs,1);
nvobs = length(options_.varobs);
nn = sqrt(MaxNumberOfPlotPerFigure);
iendo = 1:endo_nbr;
i_last_obs = gend+(1-M_.maximum_endo_lag:0);
......@@ -70,9 +70,9 @@ B = 200;
MAX_nruns = min(B,ceil(options_.MaxNumberOfBytes/(npar+2)/8));
MAX_nsmoo = min(B,ceil(MaxNumberOfBytes/((endo_nbr)*gend)/8));
MAX_ninno = min(B,ceil(MaxNumberOfBytes/(exo_nbr*gend)/8));
MAX_nerro = min(B,ceil(MaxNumberOfBytes/(size(options_.varobs,1)*gend)/8));
MAX_nerro = min(B,ceil(MaxNumberOfBytes/(length(options_.varobs)*gend)/8));
if naK
MAX_naK = min(B,ceil(MaxNumberOfBytes/(size(options_.varobs,1)* ...
MAX_naK = min(B,ceil(MaxNumberOfBytes/(length(options_.varobs)* ...
length(options_.filter_step_ahead)*gend)/8));
end
if horizon
......
......@@ -42,7 +42,7 @@ end
% Set varlist if necessary
varlist = options_.varlist;
if isempty(varlist)
varlist = options_.varobs;
varlist = char(options_.varobs);
end
options_.varlist = varlist;
nvar = size(varlist,1);
......
......@@ -70,7 +70,7 @@ switch type
TYPEarray = 4;
case 'irf_bvardsge'
CAPtype = 'IRF_BVARDSGE';
TYPEsize = [ options_.irf , size(options_.varobs,1) , M_.exo_nbr ];
TYPEsize = [ options_.irf , length(options_.varobs) , M_.exo_nbr ];
TYPEarray = 4;
case 'smooth'
CAPtype = 'SMOOTH';
......@@ -82,7 +82,7 @@ switch type
TYPEarray = 3;
case 'error'
CAPtype = 'ERROR';
TYPEsize = [ size(options_.varobs,1) , options_.nobs ];
TYPEsize = [ length(options_.varobs) , options_.nobs ];
TYPEarray = 3;
case 'innov'
CAPtype = 'INNOV';
......
......@@ -122,7 +122,7 @@ for i = 1:ny
dyn_graph=dynare_graph(dyn_graph,[ sims_no_shock_median(:, i) ...
sims_no_shock_up_conf(:, i) sims_no_shock_down_conf(:, i) ...
sims_with_shocks_up_conf(:, i) sims_with_shocks_down_conf(:, i) ], ...
options_.varobs(i, :));
options_.varobs{i});
end
dyn_saveas(dyn_graph.fh,[OutputDirectoryName '/' M_.fname '_BVAR_forecast_',num2str(nlags)],options_)
......@@ -146,8 +146,8 @@ if ~isempty(forecast_data.realized_val)
fprintf('RMSE of BVAR(%d):\n', nlags);
for i = 1:size(options_.varobs, 1)
fprintf('%s: %10.4f\n', options_.varobs(i, :), rmse(i));
for i = 1:length(options_.varobs)
fprintf('%s: %10.4f\n', options_.varobs{i}, rmse(i));
end
end
......@@ -162,8 +162,8 @@ if ~isdir(DirectoryName)
end
save([ DirectoryName '/simulations.mat'], 'sims_no_shock', 'sims_with_shocks');
for i = 1:size(options_.varobs, 1)
name = options_.varobs(i, :);
for i = 1:length(options_.varobs)
name = options_.varobs{i};
sims = squeeze(sims_with_shocks(:,i,:));
eval(['oo_.bvar.forecast.with_shocks.Mean.' name ' = mean(sims, 2);']);
......
......@@ -138,9 +138,9 @@ save([ DirectoryName '/simulations.mat'], 'sampled_irfs');
% Save results in oo_
for i=1:ny
shock_name = options_.varobs(i, :);
shock_name = options_.varobs{i};
for j=1:ny
variable_name = options_.varobs(j, :);
variable_name = options_.varobs{j};
eval(['oo_.bvar.irf.Mean.' variable_name '.' shock_name ' = posterior_mean_irfs(' int2str(j) ',' int2str(i) ',:);'])
eval(['oo_.bvar.irf.Median.' variable_name '.' shock_name ' = posterior_median_irfs(' int2str(j) ',' int2str(i) ',:);'])
eval(['oo_.bvar.irf.Var.' variable_name '.' shock_name ' = posterior_variance_irfs(' int2str(j) ',' int2str(i) ',:);'])
......
......@@ -41,7 +41,7 @@ if options_.dsge_var && options_.bayesian_irf
msg = 1;
end
end
if size(varlist,1)~=size(options_.varobs)
if size(varlist,1)~=length(options_.varobs)
msg = 1;
end
if msg
......@@ -50,7 +50,7 @@ if options_.dsge_var && options_.bayesian_irf
skipline()
end
end
varlist = options_.varobs;
varlist = char(options_.varobs);
return
end
......
......@@ -36,14 +36,14 @@ function oo_ = compute_moments_varendo(type,options_,M_,oo_,var_list_)
if strcmpi(type,'posterior')
posterior = 1;
if nargin==4
var_list_ = options_.varobs;
var_list_ = char(options_.varobs);
end
elseif strcmpi(type,'prior')
posterior = 0;
if nargin==4
var_list_ = options_.prior_analysis_endo_var_list;
if isempty(var_list_)
options_.prior_analysis_var_list = options_.varobs;
options_.prior_analysis_var_list = char(options_.varobs);
end
end
else
......
......@@ -38,7 +38,7 @@ dsge_prior_weight = M_.params(strmatch('dsge_prior_weight',M_.param_names));
DSGE_PRIOR_WEIGHT = floor(gend*(1+dsge_prior_weight));
bvar.NumberOfLags = options_.varlag;
bvar.NumberOfVariables = size(options_.varobs,1);
bvar.NumberOfVariables = length(options_.varobs);
bvar.Constant = 'no';
bvar.NumberOfEstimatedParameters = bvar.NumberOfLags*bvar.NumberOfVariables;
if ~options_.noconstant
......
......@@ -81,8 +81,8 @@ switch task
order_var = oo_.dr.order_var;
i_var_obs = [];
trend_coeffs = [];
for i=1:size(var_obs,1)
tmp = strmatch(var_obs(i,:),endo_names(i_var,:),'exact');
for i=1:length(var_obs)
tmp = strmatch(var_obs{i},endo_names(i_var,:),'exact');
if ~isempty(tmp)
i_var_obs = [ i_var_obs; tmp];
trend_coeffs = [trend_coeffs; oo_.Smoother.TrendCoeffs(i)];
......
......@@ -94,7 +94,7 @@ if nnobs > 1 && horizon > 0
end
endo_names = M_.endo_names;
n_varobs = size(options_.varobs,1);
n_varobs = length(options_.varobs);
if isempty(var_list)
var_list = endo_names;
......@@ -116,7 +116,7 @@ if nnobs > 1 && horizon > 0
IdObs = zeros(n_varobs,1);
for j=1:n_varobs
iobs = strmatch(options_.varobs(j,:),var_list,'exact');
iobs = strmatch(options_.varobs{j},var_list,'exact');
if ~isempty(iobs)
IdObs(j,1) = iobs;
end
......
......@@ -120,7 +120,7 @@ missing_value = dataset_.missing.state;
% Set number of observations
gend = options_.nobs;
% Set the number of observed variables.
n_varobs = size(options_.varobs,1);
n_varobs = length(options_.varobs);
% Get the number of parameters to be estimated.
nvx = estim_params_.nvx; % Variance of the structural innovations (number of parameters).
nvn = estim_params_.nvn; % Variance of the measurement innovations (number of parameters).
......@@ -560,9 +560,9 @@ if ~options_.cova_compute
end
if any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
%% display results table and store parameter estimates and standard errors in results
% display results table and store parameter estimates and standard errors in results
oo_=display_estimation_results_table(xparam1,stdh,M_,options_,estim_params_,bayestopt_,oo_,pnames,'Posterior','posterior');
%% Laplace approximation to the marginal log density:
% Laplace approximation to the marginal log density:
if options_.cova_compute
estim_params_nbr = size(xparam1,1);
scale_factor = -sum(log10(diag(invhess)));
......@@ -783,8 +783,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
number_of_plots_to_draw = number_of_plots_to_draw + 1;
index = cat(1,index,i);
end
eval(['oo_.SmoothedMeasurementErrors.' deblank(options_.varobs(i,:)) ...
' = measurement_error(i,:)'';']);
eval(['oo_.SmoothedMeasurementErrors.' options_.varobs{i} ' = measurement_error(i,:)'';']);
end
if ~options_.nograph
[nbplt,nr,nc,lr,lc,nstar] = pltorg(number_of_plots_to_draw);
......@@ -813,7 +812,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
hold on
plot(1:gend,measurement_error(index(k),:),marker_string{2,1},'linewidth',1)
hold off
name = deblank(options_.varobs(index(k),:));
name = deblank(options_.varobs{index(k)});
if gend>1
xlim([1 gend])
end
......@@ -827,7 +826,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
set(gca,'XTickLabel',options_.XTickLabel)
end
if options_.TeX
idx = strmatch(options_.varobs(index(k),:),M_.endo_names,'exact');
idx = strmatch(options_.varobs{index(k)},M_.endo_names,'exact');
texname = M_.endo_names_tex(idx,:);
if isempty(TeXNAMES)
TeXNAMES = ['$ ' deblank(texname) ' $'];
......@@ -888,7 +887,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
hold on
plot(1:gend,rawdata(:,k),marker_string{2,1},'linewidth',1)
hold off
name = deblank(options_.varobs(k,:));
name = options_.varobs{k};
if isempty(NAMES)
NAMES = name;
else
......@@ -902,7 +901,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
xlim([1 gend])
end
if options_.TeX
idx = strmatch(options_.varobs(k,:),M_.endo_names,'exact');
idx = strmatch(options_.varobs{k},M_.endo_names,'exact');
texname = M_.endo_names_tex(idx,:);
if isempty(TeXNAMES)
TeXNAMES = ['$ ' deblank(texname) ' $'];
......
......@@ -116,7 +116,7 @@ else
end
% Set the number of observed variables.
n_varobs = size(options_.varobs,1);
n_varobs = length(options_.varobs);
% Set priors over the estimated parameters.
if ~isempty(estim_params_)
......@@ -224,8 +224,8 @@ end
var_obs_index = [];
k1 = [];
for i=1:n_varobs
var_obs_index = [var_obs_index; strmatch(deblank(options_.varobs(i,:)),M_.endo_names(dr.order_var,:),'exact')];
k1 = [k1; strmatch(deblank(options_.varobs(i,:)),M_.endo_names, 'exact')];
var_obs_index = [var_obs_index; strmatch(options_.varobs{i},M_.endo_names(dr.order_var,:),'exact')];
k1 = [k1; strmatch(options_.varobs{i},M_.endo_names, 'exact')];
end
% Define union of observed and state variables
......@@ -380,4 +380,4 @@ if all(abs(oo_.steady_state(bayestopt_.mfys))<1e-9)
options_.noconstant = 1;
else
options_.noconstant = 0;
end
\ No newline at end of file
end
......@@ -132,7 +132,7 @@ options_.smoother=1;
options_ident.analytic_derivation_mode = options_.analytic_derivation_mode;
if isempty(dataset_),
dataset_.info.ntobs = periods;
dataset_.info.nvobs = rows(options_.varobs);
dataset_.info.nvobs = length(options_.varobs);
dataset_.info.varobs = options_.varobs;
dataset_.rawdata = [];
dataset_.missing.state = 0;
......@@ -145,17 +145,8 @@ if isempty(dataset_),
dataset_.missing.no_more_missing_observations = 1;
dataset_.descriptive.mean = [];
dataset_.data = [];
% data_info.gend = periods;
% data_info.data = [];
% data_info.data_index = [];
% data_info.number_of_observations = periods*size(options_.varobs,1);
% data_info.no_more_missing_observations = 0;
% data_info.missing_value = 0;
end
% results = prior_sampler(0,M_,bayestopt_,options_,oo_);
if prior_exist
if any(bayestopt_.pshape > 0)
if options_ident.prior_range
......
......@@ -400,9 +400,9 @@ if options_gsa.glue,
Obs.data = data;
Obs.time = [1:gend];
Obs.num = gend;
for j=1:size(options_.varobs,1)
Obs.name{j} = deblank(options_.varobs(j,:));
vj=deblank(options_.varobs(j,:));
for j=1:length(options_.varobs)
Obs.name{j} = options_.varobs{j};
vj = options_.varobs{j};
jxj = strmatch(vj,lgy_(dr_.order_var,:),'exact');
js = strmatch(vj,lgy_,'exact');
......@@ -440,7 +440,7 @@ if options_gsa.glue,
ismoo(j)=jxj;
end
jsmoo = size(options_.varobs,1);
jsmoo = length(options_.varobs);
for j=1:M_.endo_nbr,
if ~ismember(j,ismoo),
jsmoo=jsmoo+1;
......@@ -465,10 +465,10 @@ if options_gsa.glue,
Exo(j).name = deblank(tit(j,:));
end
if ~options_gsa.ppost
Lik(size(options_.varobs,1)+1).name = 'logpo';
Lik(size(options_.varobs,1)+1).ini = 'yes';
Lik(size(options_.varobs,1)+1).isam = 1;
Lik(size(options_.varobs,1)+1).data = -logpo2;
Lik(length(options_.varobs)+1).name = 'logpo';
Lik(length(options_.varobs)+1).ini = 'yes';
Lik(length(options_.varobs)+1).isam = 1;
Lik(length(options_.varobs)+1).data = -logpo2;
end
Sam.name = bayestopt_.name;
Sam.dim = [size(x) 0];
......
......@@ -24,10 +24,6 @@ nr = 3;
exo_nbr = M_.exo_nbr;
endo_names = M_.endo_names;
fname = M_.fname;
% $$$ varobs = options_.varobs;
% $$$ y = oo_.SmoothedVariables;
% $$$ ys = oo_.dr.ys;
% $$$ gend = size(y,2);
yf = oo_.forecast.Mean;
hpdinf = oo_.forecast.HPDinf;
hpdsup = oo_.forecast.HPDsup;
......@@ -44,13 +40,6 @@ for i = 1:size(var_list)
end
nvar = length(i_var);
% $$$ % build trend for smoothed variables if necessary
% $$$ trend = zeros(size(varobs,1),10);
% $$$ if isfield(oo_.Smoother,'TrendCoeffs')
% $$$ trend_coeffs = oo_.Smoother.TrendCoeffs;
% $$$ trend = trend_coeffs*(gend-9:gend);
% $$$ end
% create subdirectory <fname>/graphs if id doesn't exist
if ~exist(fname, 'dir')
mkdir('.',fname);
......
......@@ -50,7 +50,7 @@ end
for i=1:nvn
k1 = estim_params_.nvn_observable_correspondence(i,1);
name1 = deblank(options_.varobs(k1,:));
name1 = options_.varobs{k1};
xparam(m) = eval(['oo_.posterior_' type '.measurement_errors_std.' name1]);
m = m+1;
end
......@@ -69,8 +69,8 @@ end
for i=1:ncn
k1 = estim_params_.corrn_observable_correspondence(i,1);
k2 = estim_params_.corrn_observable_correspondence(i,2);
name1 = deblank(options_.varobs(k1,:));
name2 = deblank(options_.varobs(k2,:));
name1 = options_.varobs{k1};
name2 = options_.varobs{k2};
xparam(m) = eval(['oo_.posterior_' type '.measurement_errors_corr.' name1 '_' name2]);
m = m+1;
end
......
......@@ -73,7 +73,7 @@ if k <= nvx
texnam = ['$ SE_{' tname '} $'];
end
elseif k <= (nvx+nvn)
vname = deblank(options_.varobs(estim_params_.nvn_observable_correspondence(k-estim_params_.nvx,1),:));
vname = options_.varobs{estim_params_.nvn_observable_correspondence(k-estim_params_.nvx,1)};
nam=['SE_EOBS_',vname];
if TeX
tname = deblank(M_.endo_names_tex(estim_params_.var_endo(k-estim_params_.nvx,1),:));
......
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