diff --git a/matlab/bvar_forecast.m b/matlab/bvar_forecast.m index 65a535c50..24f34673f 100644 --- a/matlab/bvar_forecast.m +++ b/matlab/bvar_forecast.m @@ -2,8 +2,6 @@ function bvar_forecast(nlags) global options_ - nvar = size(options_.varobs,1); - options_ = set_default_option(options_, 'bvar_replic', 2000); if options_.forecast == 0 error('bvar_forecast: you must specify "forecast" option') @@ -23,12 +21,11 @@ function bvar_forecast(nlags) k = ny*nlags+nx; % Declaration of the companion matrix: - Companion_matrix = diag(ones(nvar*(nlags-1),1),-nvar); + Companion_matrix = diag(ones(ny*(nlags-1),1),-ny); p = 0; d = 0; - while d<=options_.bvar_replic - d = d+1; + while d<=options_.bvar_replic Sigma = rand_inverse_wishart(ny, posterior.df, S_inv_upper_chol); @@ -39,13 +36,13 @@ function bvar_forecast(nlags) Phi = rand_matrix_normal(k, ny, posterior.PhiHat, XXi_lower_chol, Sigma_lower_chol); % All the eigenvalues of the companion matrix have to be on or inside the unit circle - Companion_matrix(1:nvar,:) = Phi(1:nvar*nlags,:)'; + Companion_matrix(1:ny,:) = Phi(1:ny*nlags,:)'; test = (abs(eig(Companion_matrix))); if any(test>1.0000000000001) p = p+1; - d = d-1; continue end + d = d+1; % Without shocks lags_data = forecast_data.initval;