Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
Changed the arguments of IC (information criteria), from BVAR to Sigma and E; so to accommodate the use of IC to other estimators.
Minor bugs corrected.
  • Loading branch information
naffe15 committed May 3, 2021
1 parent 6f03277 commit 003973b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
7 changes: 4 additions & 3 deletions v4.2/IC.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [AIC, HQIC, BIC] = IC(var, T, K)
function [AIC, HQIC, BIC] = IC(S, E, T, K)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 'IC' computes various information criteria

Expand All @@ -13,8 +13,9 @@
% Revised, 9/11/2019
% Revised, 9/11/2020
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
S = var.Sigma_ols; iS = inv(S);
E = var.e_ols;
% E = var.e_ols;
% S = var.Sigma_ols;
iS = inv(S);
N = size(S,1);
llf = - (T * N / 2) * (1 + log(2 * pi)) - T / 2 * log(det(S));
llf = llf - 1 /2 * trace( iS * E' * E);
Expand Down
8 changes: 4 additions & 4 deletions v4.2/bvar_.m
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
end
end
%======================================================================
% Conjugate/Hierachical prior options
% Conjugate/Hierachical MN-IW prior options
%======================================================================
if (isfield(options,'priors')==1 && strcmp(options.priors.name,'Conjugate')==1) || (isfield(options,'priors')==1 && strcmp(options.priors.name,'conjugate')==1) || ...
(isfield(options,'prior')==1 && strcmp(options.prior.name,'Conjugate')==1) || (isfield(options,'prior')==1 && strcmp(options.prior.name,'conjugate')==1)
Expand Down Expand Up @@ -341,7 +341,7 @@
end
else
warning(['You did not provide the degrees of freedom for the Residual Covariance. ' ...
'Assume ny+1.'])
'Assume N+1 degrees of freedom.'])
prior.Sigma.df = ny + nexogenous + timetrend + 1;
while prior.Sigma.df/2 <= ny-1 % too few df
prior.Sigma.df = prior.Sigma.df +1;
Expand Down Expand Up @@ -623,7 +623,7 @@
try
posterior_int = matrictint(posterior.S, posterior.df, posterior.XXi);
catch
warning('I could not compute the likelihood');
warning('I could not compute the marginal likelihood');
posterior_int = nan;
end

Expand Down Expand Up @@ -874,7 +874,7 @@
BVAR.Phi_ols = varols.B;
BVAR.e_ols = varols.u;
BVAR.Sigma_ols = 1/(nobs-nk)*varols.u'*varols.u;
[BVAR.InfoCrit.AIC, BVAR.InfoCrit.HQIC, BVAR.InfoCrit.BIC] = IC(BVAR, nobs, nk);
[BVAR.InfoCrit.AIC, BVAR.InfoCrit.HQIC, BVAR.InfoCrit.BIC] = IC(BVAR.Sigma_ols, BVAR.e_ols, nobs, nk);
% the model with the lowest IC is preferred

% OLS irf
Expand Down
11 changes: 9 additions & 2 deletions v4.2/fevd.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
function FEVD = fevd(hor,Phi,Sigma,Omega)

% computes the forecast error variance decomposition
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% computes the forecast error variance decomposition using the VAR
% representation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

N = size(Sigma,1);
[m , k] = size(Phi);
lags = (m-1)/k;
if rem(m, n)==0
lags = m/k;
else
lags = floor((m-1)/k);
end

if nargin < 4
Omega = eye(N);
Expand Down
2 changes: 1 addition & 1 deletion v4.2/hamfilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
error('nameplot size shold be the same as the column of Y')
end
else
for v = 1 : size(Y,2)
for v = 1 : size(X,2)
eval(['titleplot{' num2str(v) '} = ''Var' num2str(v) ''';'])
end
end
Expand Down
6 changes: 5 additions & 1 deletion v4.2/iresponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
% ir = zeros(N,hor,N); % variables, horizon, shock
ir = zeros(N,hor,size(Omega,2)); % variables, horizon, shock/exogenous variable
[m , n] = size(alpha);
lags = floor((m-1)/n);
if rem(m, n)==0
lags = m/n;
else
lags = floor((m-1)/n);
end
[Q] = chol(Sigma,'lower');

% units
Expand Down

0 comments on commit 003973b

Please sign in to comment.