Skip to content

Commit

Permalink
Added tutorial examples that run in Octave
Browse files Browse the repository at this point in the history
  • Loading branch information
naffe15 committed Dec 18, 2020
1 parent 9f656e0 commit 39e5cec
Show file tree
Hide file tree
Showing 8 changed files with 1,086 additions and 0 deletions.
54 changes: 54 additions & 0 deletions v4.1/BVAR tutorial Octave/example_0_minn.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
%% BVAR tutorial: Inference with Minnesota Prior
% Author: Filippo Ferroni
% Date: 27/02/2020

clear all
close all
clc
addpath ../../cmintools/
addpath ../../v4.1/
pkg load statistics

%% %=========================================================================
%%% INFERENCE %%%
%%=========================================================================

% load the data
load('../BVAR tutorial/Data.mat')
y= [IPI HICP CORE Euribor1Y M3 EXRATE];% collect the variables used in the VAR

%% Ex1/ Minnesota Prior

lags = 6;
options.max_minn_hyper = 1;
options.minn_prior_tau = 10; % set tau
options.index_est = [3 4]; % define the hyper-parameters over which to maximize
options.lb = [0 0]; % sets the lower bounds
options.ub = [20 20]; % sets the upper bounds
options.max_compute = 3; % optimization by Matlab Simplex
BVAR = bvar(y,lags,options);

%% Ex2/ Minnesota Prior

clear options
lags = 6;
% setting the default values for the hyperparameters
hyperpara(1) = 3; % tau
hyperpara(2) = 0.5; % decay
hyperpara(3) = 5; % lambda
hyperpara(4) = 2; % mu
hyperpara(5) = 2; % omega
% setting the options
options.index_est = 1:1; % hyper-parameter over which maximize
options.max_compute = 3; % maximize using Matlab fmincon function
options.lb = [0.05]; % Lower bound
[postmode,logmlike,HH] = bvar_max_hyper(hyperpara,y,lags,options);


%% Ex3

hyperpara(1) = postmode(1); % use as starting value previous mode
options.index_est = 1:3; % set hyper-parameters over which maximize
options.lb = [0.05 0.05 0.05]; % Lower bounds
options.ub = [50 50 50]; % Upper bounds
[postmode,log_dnsty,HH] = bvar_max_hyper(hyperpara,y,lags,options);
Loading

0 comments on commit 39e5cec

Please sign in to comment.