UNIVARIATE BAYESIAN MODELING
Spanish Treasury Bills 12m
Enrique M. Quilis
CONTENTS
Exploratory analysis
AR modeling
Litterman prior
Calibration
Estimation
Estimation
Analysis
MATLAB CODE: Commands
>> cstr=cal(1987,6,12)
cstr =
beg_yr: 1987
beg_yr: 1987
beg_per: 6
freq: 12
SERIES
10 12 14 16
Jan850 Jan90 Jan95 Jan00 Jan05
MATLAB CODE: Commands
SERIES: CORRELOGRAMS
0.6 0.8 1
Sample autocorrelation coefficients
s a c f v a lu e s 0.6 0.8 1
Sample partial autocorrelation coefficients
s p a c f v a lu e s
0 10 20 30 -0.2 0 0.2 0.4 k-values s a c f v a lu e s
MATLAB CODE: Commands
>> pmax=14
pmax =
14
14
ORDER SELECTION
0.45 0.5 0.55 0.6 0.65
AIC
0.55 0.6 0.65 0.7
BIC
0 5 10 15
0.2 0.25 0.3 0.35 0.4
AR order
0 5 10 15
0.35 0.4 0.45 0.5
LITTERMAN PRIOR
Underlying model: univariate
autoregression with exogenous variables
t
h
t
p
1
h
h
t
t
b
'
x
z
u
z
=
+
+
−
+
=
LITTERMAN PRIOR
ARX model in compact notation:
1
[
]
t
t
t
t
p
t
t
u
X
u
z
L
x
1
'
b
z
+
=
+
LITTERMAN PRIOR
u
z
)
B
1
(
−
=
µ
+
Mean centered around a random walk with
drift:
t
t
u
z
)
B
1
LITTERMAN PRIOR: Variance
=
=
)
(
)
(
v
)
V
(
diag
2
σ
θ
µ
µ
∀
=
=
h
)
)
(
g
(
)
(
v
)
V
(
diag
2
2
h
1
h
θ
θ
σ
φ
LITTERMAN PRIOR: Variance
θ
µ
>0
θ
b
>0
θ
>0
σ
derived from BARX(p) model (unrestricted
LITTERMAN PRIOR: Variance
Temporal decay
≤
≤
=
1
h
1
0
1
g
θ
θ
∞
<
≤
=
−
1
h
0
h
g
1
θ
LITTERMAN PRIOR: Variance
Temporal decay
0.6 0.7 0.8 0.9 1 Geometric 0.1 0.5 0.9 0.6 0.7 0.8 0.9 1 Harmonic 0.1 0.5 0.91 2 3 4 5 6 0 0.1 0.2 0.3 0.4 0.5 Lag
LITTERMAN PRIOR: Variance
0.6 0.8 1 1.2
Prior on phi parameters: th1=0.1 th2=0.5
1 1.5 2
Prior on phi parameters: th1=1 th2=0.5
0 1 2 3 4 5 6 7 -0.2
0 0.2 0.4 0.6
0 1 2 3 4 5 6 7 -1
LITTERMAN PRIOR: Calibration
1.325 1.33 1.335
MSE
1.326 1.328 1.33 1.332 1.334
0.01
0.41
0.91
1.41 0.01
0.41
0.91
1.41 1.31
1.315 1.32
th2 th1
LITTERMAN PRIOR: Calibration
1.315 1.316 1.317
MSE
1.3145 1.315 1.3155 1.316
0.01
0.01
0.10 1.31
1.311 1.312 1.313 1.314
LITTERMAN PRIOR: Calibration
θ
µ
θ
1
θ
2
σ
2
0.00
0.04
0.05
0.07
θ
µ
θ
1
θ
2
σ
2
MATLAB CODE: Prior generation
close all; clc; clear all;
% Yield on Letras 12m: 1987.06 - 2007.03 z = load('y1.prn');
% Exogenous variables rex.X = [];
% Intercept: yes (1) or not (0) rex.opC = 1;
% Basic variable rex.z = z;
% Order of AR model rex.p = 6;
%---% Generating Litterman prior
%Type of decay function: harmonic (1) or geometric (2) rex.type = 1;
rex.th_mu = 1000; rex.th_b = 1000; rex.th = [0.10 0.05];
LITTERMAN PRIOR: Calibration
0.6 0.7 0.8 0.9 1
Decay function: harmonic
0.6 0.8 1 1.2
Prior on phi parameters
0 1 2 3 4 5 6 7 0
0.1 0.2 0.3 0.4 0.5 0.6
Lag
0 1 2 3 4 5 6 7 -0.2
0 0.2 0.4 0.6
MATLAB OUTPUT: Estimation
********************************************************************** ARX MODEL: BAYESIAN ESTIMATION
********************************************************************** LITTERMAN PRIOR
Hyperparameters: tightness Intercept 0.0000 Exogenous 1000.0000 Decay function: harmonic
Global 0.1000 Decay 0.0500
********************************************************************** Number of observations : 239
Number of effective observations : 233 Number of effective observations : 233 Number of series : 1 Number of lags : 6
********************************************************************** mu: Estimate, standard deviation and t-ratio (read columnwise)
---0.0000 ---0.0000 0.0001
---phi: Lag, estimate, standard deviation and t-ratio (read columnwise)
MATLAB CODE: Estimation
********************************************************************** ARX MODEL: BAYESIAN ESTIMATION
**********************************************************************
---RESIDUALS: standard deviation 0.2693
---Model performance (read columnwise):
- log-likelihood - log-likelihood - AIC and BIC - BIC
---24.9411 0.2742 0.3779
MATLAB CODE: Estimation
0.2 0.4 0.6 0.8 1Sample autocorrelation coefficients
s a c f v a lu e s 0.2 0.4 0.6 0.8 1
Sample partial autocorrelation coefficients
MATLAB CODE: Outliers
0.5 1 1.5
Jul87 Jan90 Jul92 Jan95 Jul97 Jan00 Jul02 Jan05
MATLAB CODE: Analytics
0 10 20 30 40 0
0.5 1 1.5 2
PHI-WEIGHTS
0 2 4 6 8
-1.5 -1 -0.5 0 0.5
PI-WEIGHTS
lag lag
-0.5 0 0.5 1
6 ROOTS
2 4 6 8 10
MATLAB CODE: Forecasting
close all; clc; clear all;
% Yield on Letras 12m: 1987.06 - 2007.03 z = load('y1.prn');
% Exogenous variables: unit step 1999.01 - 2007.12 (EMU) rex.X = [];
% Intercept: yes (1) or not (0) rex.opC = 1;
% Basic variable % Basic variable rex.z = z;
% Order of AR model rex.p = 6;
%---% Generating Litterman prior
%Type of decay function: harmonic (1) or geometric (2) rex.type = 1;
rex.th_mu = 0.0000000001; rex.th_b = 1000;
rex.th = [0.10 0.05];
rex.plt = 0; %Plots or no plots
MATLAB CODE: Forecasting
---% Calling estimation function
res = barx(rex,prior);
%---% Number of forecasts
rex.npred = 9;
% Preparing forecasts of exogenous variables % rex.Xf = ones(rex.npred,1);
rex.Xf = [];
% Generating forecasts fore = upredict(rex,res);
% Joining forecasts and data
zz = [z fore.zf]; zli = [z
fore.zf - fore.sf]; zls = [z
MATLAB CODE: Forecasting
4 4.5 5 5.5
Forecasts and +/- s.e.
2004 2005 2006 2007 1.5
2 2.5 3 3.5