diff --git a/matlab/bvar_forecast.m b/matlab/bvar_forecast.m index e0f8c6ef7f8c74c1b31f7f2e52946914380a3326..24f34673f66a92a2515cac13637f9f44f64a3260 100644 --- a/matlab/bvar_forecast.m +++ b/matlab/bvar_forecast.m @@ -48,7 +48,7 @@ function bvar_forecast(nlags) lags_data = forecast_data.initval; for t = 1:options_.forecast X = [ reshape(flipdim(lags_data, 1)', 1, ny*nlags) forecast_data.xdata(t, :) ]; - y = X(:,1:k) * Phi; + y = X * Phi; lags_data = [ lags_data(2:end, :); y ]; sims_no_shock(t, :, d) = y; end @@ -58,7 +58,7 @@ function bvar_forecast(nlags) for t = 1:options_.forecast X = [ reshape(flipdim(lags_data, 1)', 1, ny*nlags) forecast_data.xdata(t, :) ]; shock = (Sigma_lower_chol * randn(ny, 1))'; - y = X(:,1:k) * Phi + shock; + y = X * Phi + shock; lags_data = [ lags_data(2:end, :); y ]; sims_with_shocks(t, :, d) = y; end diff --git a/matlab/bvar_toolbox.m b/matlab/bvar_toolbox.m index 12522f4d765a1ef55099aa490fcc6f2c8fe6fe26..41bca2e619d877af07a96fb635c62f76a0ecc1ff 100644 --- a/matlab/bvar_toolbox.m +++ b/matlab/bvar_toolbox.m @@ -94,11 +94,7 @@ function [ny, nx, posterior, prior, forecast_data] = bvar_toolbox(nlags) ydata = dataset(idx, :); T = size(ydata, 1); - if nx - xdata = ones(T,1); - else - xdata = []; - end + xdata = ones(T,nx); % Posterior density var = rfvar3([ydata; ydum], nlags, [xdata; xdum], [T; T+pbreaks], lambda, mu); @@ -131,8 +127,6 @@ function [ny, nx, posterior, prior, forecast_data] = bvar_toolbox(nlags) % Add forecast informations if nargout >= 5 forecast_data.xdata = ones(options_.forecast, nx); - % Useless if nx=0, but with the declaration of an empty matrix here we would have to add an if statement - % inside a loop (see bvar_forecast.m). forecast_data.initval = ydata(end-nlags+1:end, :); if options_.first_obs + options_.nobs <= size(dataset, 1) forecast_data.realized_val = dataset(options_.first_obs+options_.nobs:end, :);