forked from naffe15/BVAR_
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tutorial examples that run in Octave
- Loading branch information
Showing
8 changed files
with
1,086 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Oops, something went wrong.