gretl version 1.9.9

Current session: 2012-11-14 14:01

## Black Litterman model application

## M Boldin Oct 2012

## Stock Return data

#open "C:.gdt"

? smpl --full

Full data range: 2001:01 - 2011:12 (n = 132)

## Compute Excess returns for Market and Alternative portfolios

? series MPORTret= SPYret - RF

Replaced series MPORTret (ID 30)

? series APORTret= (TGTret+IBMret+AMZNret+EBAYret+PDCOret)/5 - RF

Replaced series APORTret (ID 31)

? summary RF MKT MKTxRF SPYret MPORTret APORTret

Summary statistics, using the observations 2001:01 - 2011:12

Mean Median Minimum Maximum

RF 0.0016455 0.0013000 0.00000 0.0054000

MKT 0.0034591 0.011000 -0.18470 0.11530

MKTxRF 0.0018136 0.0082000 -0.18550 0.11530

SPYret 0.0023195 0.0089880 -0.16519 0.10915

MPORTret 0.00067407 0.0063025 -0.16599 0.10915

APORTret 0.012614 0.015517 -0.21784 0.23936

Std. Dev. C.V. Skewness Ex. kurtosis

RF 0.0014739 0.89575 0.60879 -0.89865

MKT 0.049322 14.259 -0.58275 0.89218

MKTxRF 0.049405 27.241 -0.55295 0.87372

SPYret 0.046726 20.145 -0.52343 0.70702

MPORTret 0.046806 69.438 -0.49124 0.69156

APORTret 0.071420 5.6619 0.13396 1.5455

# Set sub-sample period to estimate mean retunr and var-cov parameters

? smpl 2001:01 2007:12

Full data range: 2001:01 - 2011:12 (n = 132)

Current sample: 2001:01 - 2007:12 (n = 84)

? summary RF MKT MKTxRF SPYret MPORTret APORTret

Summary statistics, using the observations 2001:01 - 2007:12

Mean Median Minimum Maximum

RF 0.0023607 0.0021500 0.00060000 0.0054000

MKT 0.0049274 0.011600 -0.10000 0.083800

MKTxRF 0.0025667 0.0089500 -0.10320 0.081800

SPYret 0.0034229 0.0091975 -0.10473 0.084612

MPORTret 0.0010622 0.0063025 -0.10613 0.083612

APORTret 0.014947 0.014790 -0.13758 0.23936

Std. Dev. C.V. Skewness Ex. kurtosis

RF 0.0013332 0.56473 0.27736 -1.3527

MKT 0.039796 8.0764 -0.55301 0.34387

MKTxRF 0.039875 15.536 -0.54489 0.35966

SPYret 0.038062 11.120 -0.50185 0.56956

MPORTret 0.038112 35.881 -0.48887 0.58476

APORTret 0.072875 4.8757 0.62774 1.1135

? scalar rfc= mean(RF)

Replaced scalar rfc = 0.00236071

## Build matrix with return observations

? matrix Rx = MPORTret, APORTret

Replaced matrix Rx

? matrix R = meanc(Rx)

Replaced matrix R

? scalar k= cols(Rx)

Replaced scalar k = 2

? scalar n= rows(Rx)

Replaced scalar n = 84

## Variance-Covariance matrix

? S = mcov(Rx)

Replaced matrix S

? SI = inv(S)

Replaced matrix SI

? sd1 = sdc(Rx)

Replaced matrix sd1

? C1 = mcorr(Rx)

Replaced matrix C1

## Implied mean-variance optimization weights

? w1 = SI*R'

Replaced matrix w1

? w1 = w1/sumc(w1)

Replaced matrix w1

? R2 = R+rfc

Replaced matrix R2

? w2 = inv(S)*R2'

Replaced matrix w2

? w2 = w2/sumc(w2)

Replaced matrix w2

## Check results

? scalar check = sumc(w1)

Replaced scalar check = 1

? scalar check = sumc(w2)

Replaced scalar check = 1

## Two points on Computed Efficient frontier

? scalar rm1= R*w1

Replaced scalar rm1 = -0.0396636

? scalar rm2= R2*w2

Replaced scalar rm2 = -0.356467

? scalar s1= sqrt(w1'*S*w1)

Replaced scalar s1 = 0.138495

? scalar s2= sqrt(w2'*S*w2)

Replaced scalar s2 = 1.28771

## Compute Betas by regressing X on M=MKTxRF

? matrix Rm= MKTxRF

Replaced matrix Rm

? B= inv(Rm'Rm)*(Rm'Rx)

Replaced matrix B

? scalar sdRm= sdc(Rm)

Replaced scalar sdRm = 0.0396372

# CAPM Beta based Expected Returns

? scalar Em= .06/12

Replaced scalar Em = 0.005

? Rb= B'Em

Replaced matrix Rb

## Compute weights based on CAPM returns

? wb = inv(S)*Rb

Replaced matrix wb

? wb = wb/sumc(wb)

Replaced matrix wb

## Compute Expected returns and st dev

? scalar ERb= 12*Rb'wb

Replaced scalar ERb = 0.0575961

? scalar sdb= sqrt(wb'*S*wb)

Replaced scalar sdb = 0.038752

## Compute B-L adjustment for view on Alternative Portfolio

## tau is an adjustment to CAPM based prior var-cov view reflecting relative confidence

## Smaller (larger) value puts more (less) weight on CAPM-based var-cov

## P= Alternative view portfolio, use [0 1] for simple case

## Q= Alternative view Expected return

## Oa= Var-cov matrix for alternative, assumed to have 0's off-diagonal

? scalar tau= 1

Replaced scalar tau = 1

? matrix P= zeros(1,k)

Replaced matrix P

? P[1,2]= 1

Modified matrix P

? matrix Q= zeros(1,1)

Replaced matrix Q

? Q[1,1]= Rb[2] + (.03/12) # add x% per year (1/12 for monthly) for \par alternative

Modified matrix Q

? Oa= 2*S[2,2]

Replaced scalar Oa = 0.0106216

? OaI= inv(Oa)

Replaced scalar OaI = 94.1481

? Ma= P'OaI*P ## Alternative information matrix

Replaced matrix Ma

? A= P'OaI*Q

Replaced matrix A

? M = inv(inv(tau*S)+Ma) ## Combine prior and alternative var-cov views

Replaced matrix M

? ua = M*(inv(tau*S)*Rb+A) ## Combined expected returns

Replaced matrix ua

## Compute combined view weights

## delta is a risk adjustment, higher value lowers acceptable risk

## for one alternative use sdRm for delta to get a ERp = sd type result

? scalar delta = 1

Replaced scalar delta = 1

? S2= S + M

Replaced matrix S2

? ua2= (1/delta)*ua ## risk adjusted expected returns

Replaced matrix ua2

? wa2= (1/delta)*inv(S2)'ua

Replaced matrix wa2

? wa2= wa2/sumc(wa2)

Replaced matrix wa2

## Explore results

? print R

R (1 x 2)

0.0010622 0.014947

? print sd1

sd1 (1 x 2)

0.037885 0.072440

? print C1

C1 (2 x 2)

1.0000 0.76433

0.76433 1.0000

? print w1

w1 (2 x 1)

3.9332

-2.9332

? print B

B (1 x 2)

0.94326 1.4272

? print Rb

Rb (2 x 1)

0.0047163

0.0071360

? print wb

wb (2 x 1)

0.96555

0.034454

? print ua2

ua2 (2 x 1)

0.0050494

0.0079693

? print wa2

wa2 (2 x 1)

0.84475

0.15525

? print Rb

Rb (2 x 1)

0.0047163

0.0071360

? print Q

Q (1 x 1)

0.0096360

? print S

S (2 x 2)

0.0014525 0.0021229

0.0021229 0.0053108

? print M

M (2 x 2)

0.0011697 0.0014152

0.0014152 0.0035405

? print S2

S2 (2 x 2)

0.0026222 0.0035381

0.0035381 0.0088513

## Use period after sub-sample estimation

## to test performance of portfolio weights

? smpl 2008:01 2011:12

Full data range: 2001:01 - 2011:12 (n = 132)

Current sample: 2008:01 - 2011:12 (n = 48)

## Compute Excess returns for Market and Alternative portfolios

? matrix Rx = MPORTret, APORTret

Replaced matrix Rx

? series Port1 = Rx*w1

Replaced series Port1 (ID 32)

? series Portb = Rx*wb

Replaced series Portb (ID 33)

? series Porta2 = Rx*wa2

Replaced series Porta2 (ID 34)

? series Porta2xM= (Porta2-MPORTret)

Replaced series Porta2xM (ID 35)

? series Porta2xb= (Porta2-Portb)

Replaced series Porta2xb (ID 36)

## Port1 based on naive 'optimal' in-sample mean-variance weights

## Portb based on CAPM-Beta means weights

## Porta2 based on Black-Litterman + Alternative view weights

? summary MPORTret APORTret Port1 Portb Porta2 Porta2xM Porta2xb

Summary statistics, using the observations 2008:01 - 2011:12

Mean Median Minimum Maximum

MPORTret -5.1458e-006 0.0043355 -0.16599 0.10915

APORTret 0.0085326 0.016737 -0.21784 0.15141

Port1 -0.025048 -0.015994 -0.37023 0.26717

Portb 0.00028901 0.0051012 -0.16777 0.10775

Porta2 0.0013203 0.0051703 -0.17404 0.10734

Porta2xM 0.0013255 0.0020232 -0.017841 0.013903

Porta2xb 0.0010313 0.0015742 -0.013882 0.010818

Std. Dev. C.V. Skewness Ex. kurtosis

MPORTret 0.059501 11563. -0.42280 -0.096541

APORTret 0.069368 8.1298 -0.90111 2.0755

Port1 0.13494 5.3873 -0.12369 0.086784

Portb 0.059423 205.60 -0.43565 -0.039250

Porta2 0.059402 44.990 -0.48677 0.19703

Porta2xM 0.0061998 4.6774 -0.40325 0.47156

Porta2xb 0.0048239 4.6774 -0.40325 0.47156

? corr MKTxRF Port1 Portb Porta2

Correlation Coefficients, using the observations 2008:01 - 2011:12

5% critical value (two-tailed) = 0.2845 for n = 48

MKTxRF Port1 Portb Porta2

1.0000 0.4724 0.9963 0.9935 MKTxRF

1.0000 0.4798 0.4071 Port1

1.0000 0.9967 Portb

1.0000 Porta2

? plot1 <- gnuplot MPORTret APORTret --with-lines --time-series

plot1 replaced

? plot2 <- gnuplot MPORTret Port1 Portb Porta2 --with-lines --time-series

plot2 replaced

? plot3 <- gnuplot Porta2xM Porta2xb --with-lines --time-series

plot3 replaced

Plot 2 Graph