PRACTICE 1: MUTUAL FUNDS EVALUATION USING MATLAB.



Similar documents
Causal, Explanatory Forecasting. Analysis. Regression Analysis. Simple Linear Regression. Which is Independent? Forecasting

THE METHOD OF LEAST SQUARES THE METHOD OF LEAST SQUARES

Online Appendix for Forecasting the Equity Risk Premium: The Role of Technical Indicators

CHAPTER 14 MORE ABOUT REGRESSION

Forecasting the Direction and Strength of Stock Market Movement

v a 1 b 1 i, a 2 b 2 i,..., a n b n i.

Lecture 14: Implementing CAPM

PSYCHOLOGICAL RESEARCH (PYC 304-C) Lecture 12

How To Calculate The Accountng Perod Of Nequalty

Latent Class Regression. Statistics for Psychosocial Research II: Structural Models December 4 and 6, 2006

Regression Models for a Binary Response Using EXCEL and JMP

) of the Cell class is created containing information about events associated with the cell. Events are added to the Cell instance

8.5 UNITARY AND HERMITIAN MATRICES. The conjugate transpose of a complex matrix A, denoted by A*, is given by

Recurrence. 1 Definitions and main statements

Analysis of Premium Liabilities for Australian Lines of Business

Gender differences in revealed risk taking: evidence from mutual fund investors

What is Candidate Sampling

Marginal Returns to Education For Teachers

CHOLESTEROL REFERENCE METHOD LABORATORY NETWORK. Sample Stability Protocol

THE DISTRIBUTION OF LOAN PORTFOLIO VALUE * Oldrich Alfons Vasicek

Can Auto Liability Insurance Purchases Signal Risk Attitude?

Economic Interpretation of Regression. Theory and Applications

L10: Linear discriminants analysis

An Alternative Way to Measure Private Equity Performance

Module 2 LOSSLESS IMAGE COMPRESSION SYSTEMS. Version 2 ECE IIT, Kharagpur

Finite Math Chapter 10: Study Guide and Solution to Problems

Simple Interest Loans (Section 5.1) :

MATLAB Workshop 15 - Linear Regression in MATLAB

CHAPTER 5 RELATIONSHIPS BETWEEN QUANTITATIVE VARIABLES

DO LOSS FIRMS MANAGE EARNINGS AROUND SEASONED EQUITY OFFERINGS?

The Mathematical Derivation of Least Squares

Approximating Cross-validatory Predictive Evaluation in Bayesian Latent Variables Models with Integrated IS and WAIC

How To Understand The Results Of The German Meris Cloud And Water Vapour Product

8 Algorithm for Binary Searching in Trees

STATISTICAL DATA ANALYSIS IN EXCEL

INVESTIGATION OF VEHICULAR USERS FAIRNESS IN CDMA-HDR NETWORKS

How Sets of Coherent Probabilities May Serve as Models for Degrees of Incoherence

5 Multiple regression analysis with qualitative information

Scale Dependence of Overconfidence in Stock Market Volatility Forecasts

total A A reag total A A r eag

An Evaluation of the Extended Logistic, Simple Logistic, and Gompertz Models for Forecasting Short Lifecycle Products and Services

Macro Factors and Volatility of Treasury Bond Returns

GRAVITY DATA VALIDATION AND OUTLIER DETECTION USING L 1 -NORM

SIMPLE LINEAR CORRELATION

Risk-based Fatigue Estimate of Deep Water Risers -- Course Project for EM388F: Fracture Mechanics, Spring 2008

The Application of Fractional Brownian Motion in Option Pricing

Portfolio Loss Distribution

The OC Curve of Attribute Acceptance Plans

Control Charts with Supplementary Runs Rules for Monitoring Bivariate Processes

Exhaustive Regression. An Exploration of Regression-Based Data Mining Techniques Using Super Computation

This circuit than can be reduced to a planar circuit

Using Series to Analyze Financial Situations: Present Value

Survival analysis methods in Insurance Applications in car insurance contracts

The announcement effect on mean and variance for underwritten and non-underwritten SEOs

1. Measuring association using correlation and regression

BERNSTEIN POLYNOMIALS

Luby s Alg. for Maximal Independent Sets using Pairwise Independence

Management Quality, Financial and Investment Policies, and. Asymmetric Information

PAS: A Packet Accounting System to Limit the Effects of DoS & DDoS. Debish Fesehaye & Klara Naherstedt University of Illinois-Urbana Champaign

HOUSEHOLDS DEBT BURDEN: AN ANALYSIS BASED ON MICROECONOMIC DATA*

Vision Mouse. Saurabh Sarkar a* University of Cincinnati, Cincinnati, USA ABSTRACT 1. INTRODUCTION

Multiple-Period Attribution: Residuals and Compounding

Although ordinary least-squares (OLS) regression

where the coordinates are related to those in the old frame as follows.

Inter-Ing INTERDISCIPLINARITY IN ENGINEERING SCIENTIFIC INTERNATIONAL CONFERENCE, TG. MUREŞ ROMÂNIA, November 2007.

Support Vector Machines

Addendum to: Importing Skill-Biased Technology

Institute of Informatics, Faculty of Business and Management, Brno University of Technology,Czech Republic

1 De nitions and Censoring

The Development of Web Log Mining Based on Improve-K-Means Clustering Analysis

THE EFFECT OF PREPAYMENT PENALTIES ON THE PRICING OF SUBPRIME MORTGAGES

A Novel Methodology of Working Capital Management for Large. Public Constructions by Using Fuzzy S-curve Regression

CS 2750 Machine Learning. Lecture 3. Density estimation. CS 2750 Machine Learning. Announcements

Proactive Secret Sharing Or: How to Cope With Perpetual Leakage

Trade Adjustment and Productivity in Large Crises. Online Appendix May Appendix A: Derivation of Equations for Productivity

YIELD CURVE FITTING 2.0 Constructing Bond and Money Market Yield Curves using Cubic B-Spline and Natural Cubic Spline Methodology.

International University of Japan Public Management & Policy Analysis Program

Meta-Analysis of Hazard Ratios

"Research Note" APPLICATION OF CHARGE SIMULATION METHOD TO ELECTRIC FIELD CALCULATION IN THE POWER CABLES *

Day-of-the-Week Trading Patterns of Individual and Institutional Investors

The Effect of Mean Stress on Damage Predictions for Spectral Loading of Fiberglass Composite Coupons 1

Calibration and Linear Regression Analysis: A Self-Guided Tutorial

the Manual on the global data processing and forecasting system (GDPFS) (WMO-No.485; available at

Efficient Project Portfolio as a tool for Enterprise Risk Management

Section 5.4 Annuities, Present Value, and Amortization

Forecasting the Demand of Emergency Supplies: Based on the CBR Theory and BP Neural Network

Calculation of Sampling Weights

7 ANALYSIS OF VARIANCE (ANOVA)

A Master Time Value of Money Formula. Floyd Vest

benefit is 2, paid if the policyholder dies within the year, and probability of death within the year is ).

Section 2.3 Present Value of an Annuity; Amortization

Part 1: quick summary 5. Part 2: understanding the basics of ANOVA 8

Transcription:

PRACTICE 1: MUTUAL FUNDS EVALUATION USING MATLAB. INDEX 1. Load data usng the Edtor wndow and m-fle 2. Learnng to save results from the Edtor wndow. 3. Computng the Sharpe Rato 4. Obtanng the Treynor Rato 5. The Alpha from the CAPM 6. The Alpha from the Fama and French three factors model. 7. Makng rankng and obtanng conclusons. Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 1/16

1. Load data usng the Edtor wndow and mfle In ths practce you wll use a sample of Equty Mutual Funds from one of the most prestgous mutual fund database, the CRSP (Chcago Research Securty Prces). In ths database there are data from 196 untl 26, and for all mutual fund categores (equty, fxed ncome, balanced, etc). However, gven that ths s only an exercse you wll use data from 55 Equty mutual funds n the Aggressve Growth Category and from January 22 untl December 24. The frequency of the data wll be monthly (24 observatons for each fund). All ths data are n a matlab fle name DATAFUNDS.mat Moreover, you wll need some other addtonal data, as Treasure Blls returns, Market returns, or the Fama and French factors. And these addtonal data are n a fle named ADDITIONAL_DATA.mat. Frst, we must mport data usng the Edtor Wndow. Thus, we must open a new M-Fle Second, wrte some comments at the begnnng that permts you to dentfy ths code. >> %% Ths code has been created to evaluate Equty Mutual Funds - Mater n Fnance >> %% Date: February-212 Thrd, we must use the LOAD functon to mport the varable. >> clear all >> load DATAFUNDS.mat >> load ADDITIONAL_DATA.mat Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 2/16

Fourth, we run the program to check the data loaded. To get t, clck on the con save and on the con Run The data you have mported are: rmf: Ths contans the returns of all mutual funds. Each mutual fund s represented n a dfferent column. So rmf s a 24 x 55 matrx. rtblls: It s a vector (24x1) wth the monthly rsk-free rate. rmk: It contans the returns of a Market ndex. smb: A column vector wth the Small-mnus-Bg factor to be use n the Fama and Frech model. hml: A column vector wth the Hgh-mnus-Low factor for the Fama and French model. wml: A column vector wth the momentum factor for the Carhart model. You can fnd all these factors n the followng webpage: http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_lbrary.html If you want, you could plot each of the varables to check that they are rght or there are not extreme outlers, etc. >> plot(rtblls) >> plot(rmk) >> plot(smb) >> plot(hml) >> for =1:3 >> plot(rmf(:,)) >> end Or you can also use a subplot command. Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 3/16

2. Learnng to save results from the Edtor wndow. Frst, to save results you wll use the save command. I you want to save all the varables n the workspace >> save DavdResults.mat If you want to save only a varable n a Matlab fle. >> save DavdResults_X1.mat X1 If you want to save only one varable n Excel (may be to do another operatons wth t), the command wll be >> save DavdResults_X1.txt X1 -asc -tabs Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 4/16

3. Computng the Sharpe Rato Frst, we compute the average return obtaned by each mutual fund, and we can do t wth the functon mean. >>meanrmf=mean(rmf); Remember that the functon "mean" s computng the average or mean for each column n the matrx. When you have the returns of the mutual funds n rows nstead of n columns, you have to transpose the data [mean(rmf')] Second, we compute the average return obtaned by the rsk-free asset. >> meanrtblls=mean(rtblls); Thrd, we compute the standard devaton of each mutual funds, usng the functon std. >> stdrmf=std(rmf); Fourth, we can compute the Sharpe Rato as >> Sharpe=(meanrMF-meanrtblls)./ stdrmf; It s must be noted that you are usng./ and not /. Because actually you do not want to do a matrx dvson. Instead you need to dvde each mutual fund excess return by ts standard devaton. Addtonally, you could compute the Average Sharpe Rato (or the medan) for all the mutual funds, or plot the Sharpe Ratos to analyze them. >> fgure >> bar(sharpe) Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 5/16

>> ttle('sharpe Rato of Equty Mutual Funds') >> medansharpe=medan(sharpe) >> meansharpe=mean(sharpe).5 Sharpe Rato of Equty Mutual Funds.4.3.2.1 -.1 -.2 1 2 3 4 5 6 Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 6/16

4. Obtanng the Treynor Rato In ths rato we can use some of the varables computed n the prevous performance measure. Because the numerator s equal than n the Sharpe rato, we only need to compute the beta (denomnator of Treynor Rato). Frst, we compute the beta of each mutual fund In ths case we can not use matrx operators but we need to compute the beta for each mutual fund ndependently, thus we need to use the command FOR to repeat some operatons a specfc number of tmes. Moreover, we need excess returns to compute the Beta. >> for j=1:55 >> rmf2(:,j)=rmf(:,j)-rtblls; >> rmk2=rmk-rtblls; >> varanrmk2=var(rmk2); >> covarmatrx=cov(rmf2(:,j),rmk2); >> covarmf=covarmatrx(1,2); >> Beta(1,j)=covarMF/varanrMk2; >> end Second, we can compute the Treynor Rato. >> Treynor=(meanrMF-meanrtblls)./Beta; Fnally, to analyze the results we can plot t or compute some statstcs. >> meantreynor=mean(treynor); >> medantreynor=medan(treynor); >> fgure >> bar(treynor) >> ttle( Treynor Rato from Equty Mutual Funds ) Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 7/16

.3 Treynor Rato of Equty Mutual Funds.25.2.15.1.5 -.5 -.1 1 2 3 4 5 6 Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 8/16

5. Computng the Alpha from the CAPM We are computng the alpha as a coeffcent estmated n the followng regresson (solved by Ordnary Least Squeares, OLS) r r r M = ˆ α + ˆ β ( r ) + ε R where = = R r M f r f M To estmate that equaton by OLS we could use the functon regress or regstats. But we are usng regstats because ths functon wll gve us more nformaton (t-statstcs, R-squared, pvalues,...). Moreover, n the regstats functon by default we estmate a model wth a constant or ntercept and ths s the easer for us than n regress, where we have to ntroduce a colum vector of ones to use a constant. [B, BINT]=regress(Y,X) >> help regress REGRESS Multple lnear regresson usng least squares. B = REGRESS(Y,X) returns the vector B of regresson coeffcents n the lnear model Y = X*B. X s an n-by-p desgn matrx, wth rows correspondng to observatons and columns to predctor varables. Y s an n-by-1 vector of response observatons. [B,BINT] = REGRESS(Y,X) returns a matrx BINT of 95% confdence ntervals for B. [STATS]=regstats(Y,X, 'lnear') >> help regstats REGSTATS Regresson dagnostcs for lnear models. STATS = REGSTATS(RESPONSES,DATA,MODEL,WHICHSTATS) creates an output structure STATS contanng the statstcs lsted n WHICHSTATS. WHICHSTATS can be a sngle strng such as 'leverage' or a cell array of strngs such as {'leverage' 'standres' 'studres'}. By default, REGSTATS returns all statstcs. Vald statstc strngs are: Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 9/16

Name Meanng 'Q' Q from the QR Decomposton of the desgn matrx 'R' R from the QR Decomposton of the desgn matrx 'beta' Regresson coeffcents 'covb' Covarance of regresson coeffcents 'yhat' Ftted values of the response data 'r' Resduals 'mse' Mean squared error 'rsquare' R-square statstc 'adjrsquare' Adjusted R-square statstc 'leverage' Leverage 'hatmat' Hat (projecton) matrx 's2_' Delete-1 varance 'beta_' Delete-1 coeffcents 'standres' Standardzed resduals 'studres' Studentzed resduals 'dfbetas' Scaled change n regresson coeffcents 'dfft' Change n ftted values 'dffts' Scaled change n ftted values 'covrato' Change n covarance 'cookd' Cook's dstance 'tstat' t statstcs for coeffcents 'fstat' F statstc 'dwstat' Durbn Watson statstc 'all' Create all of the above statstcs Frst, we need to crate the Y and X matrxes. Y varable s very easy to compute gven that t s equal to mutual fund excess returns. >> for j=1:55 >> Y=rMF2(:,j); >> X= rmk2; >> stats=regstats(y, X,'lnear'); >> coefc=stats.beta; >> Beta(j,1)=coefc(2) >> alpha_j(j,1)=coefc(1) >> t_jensen(j,1)=stats.tstat.t(1); >> clear Y X coefc stats >> end Second, we can analyze results by plottng them. >> bar(alpha_j) Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 1/16

Remember that you can ntroduce ttles wth the command "ttle', and the text n the axes wth the commands "xlabel", "ylabel" >> hst(alpha_j) >> meanalpha=mean(alpha_j);.2 Alpha`s Jensen from Equty Mutual Funds.15.1 alpha.5 -.5 -.1 1 2 3 4 5 6 number of mutual fund 12 hstogram from alpha`s Jensen 1 8 6 4 2 -.1 -.5.5.1.15.2 Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 11/16

6. Computng the Alpha from the FF model We are computng the alpha as a coeffcent estmated n the followng multvarate regresson (solved by Ordnary Least Squeares, OLS) R R R M SMB HML = ˆ α + β ( RM ) + β ( SMB) + β ( HML) ε where = r r = r M f ˆ r f ˆ To estmate that equaton by OLS we use the functon regstats. [stats]=regstats(y,x,'lnear') ˆ Frst, we need to crate the Y and X matrxes. >> for j=1:55 >> Y=rMF2(:,j); >> X= [rmk2, SMB, HML]; >> stats=regstats(y, X,'lnear'); >> coefc=stats.beta; >> alphaff(j,1)=coefc(1) >> t_ff(j,1)=stats.tstat.t(1); >> clear Y X coefc stats >> end Second, we can analyze results by plottng them. >> bar(alphaff) >> hst(alphaff) Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 12/16

>> meanalphaff=mean(alphaff);.1 Alpha`s FF model from Equty Mutual Funds.5 alpha FF -.5 -.1 -.15 -.2 -.25 1 2 3 4 5 6 number of mutual fund 14 hstogram from alpha FF model 12 1 8 6 4 2 -.25 -.2 -.15 -.1 -.5.5.1 Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 13/16

Thrd, we can analyze the dfferences between usng Jensen s Alpha and Alpha from the FF three factors model. >> Dff_alpha=alpha-alphaFF >> fgure >> plot(dff_alpha, s-r ) >> ttle( Dfference among Alphas ), grd on.15 Dfference among Alphas.1.5 -.5 -.1 1 2 3 4 5 6 Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 14/16

7. Makng rankngs and obtanng conclusons. One of the most relevance functons of performance measures s to acheve rankngs of the mutual funds. These rankngs are publshed n newspapers, magaznes, etc. and are used by nvestors to allocate ther funds. Frst, we can sort the mutual funds wth the functon sort. >> help sort SORT order. for vectors, SORT(X) sorts the elements of X n ascendng >> [SharpeRank, SharpeRank2]=sort(Sharpe) You must note that n SharpeRank varable you have the Sharpe Rato values for each mutual fund ranked by Sharpe Rato. But n the varable SharpeRank2 you have the number (from colums n rmf) of the mutual fund n that poston. >> [TreynorRank, TreynorRank2]=sort(Treynor) >> [alpharank, alpharank2]=sort(alpha) >> [alphaffrank, alphaffrank2]=sort(alphaff) Now, we can bult a new matrx wth the ndex of each funds n the rankngs computed prevously. >> TableRank=[SharpeRank2, TreynorRank2, alpharank2, alphaffrank2 ] TableRank = 25 25 25 25 7 7 24 49 24 24 7 5 The worst fund Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 15/16

27 17 27 52 17 27 19 38 19 49 49 37 33 33 33 33 The best fund Fnally, we can analyze all performance measures together usng the command subplot >> subplot(2,2,1) >> bar(sharpe) >> subplot(2,2,2) >> bar(treynor)... >>....6 Sharpe.3 Treynor.4.2.2.1 -.2 2 4 6 -.1 2 4 6.2 alpha.1 alphaff.1 -.1 -.2 -.1 2 4 6 -.3 2 4 6 Jesús Davd Moreno (Assocate Professor Unversty Carlos III) 16/16