CS代考程序代写 matlab Excel Macro and Financial Econometrics EC5333

Macro and Financial Econometrics EC5333
Computer Project 2021
You need to answer all the questions below and record the answers in the Answer Sheet provided at the end of the document. These will count for 80% of the 􏰃nal mark on the project. The remaining 20% will be based on questions related to this project. These questions will be available for you to answer at the start of the lecture (11:00am) on Friday 5 March. You will have to hand in your answers on that same day within an hour (12:00pm).
If you need any help, you should ask during either the seminars or the lectures so that everybody can listen to the same explanation. I will not provide any ex- planation via email to avoid being unfair to others. Make sure you start working on this from now, as you will 􏰃nd it challenging.
Portfolios Analysis
You are going to conduct some analysis along the lines of Fama and French (1992) plus a simple backtest. Download the Fama and French (1992) paper from the URL:
https://onlinelibrary.wiley.com/doi/full/10.1111/j.1540-6261.1992.tb04398.x
Skim through it and try to understand the main ideas. The details are not in the scope of this course. Other courses may discuss such details. Also brie􏰄y look in Wikipedia:
https://en.wikipedia.org/wiki/Fama􏰂French_three-factor_model
Look also at the index of your book Brooks to 􏰃nd explanation of the method- ology. Also check the Fama and MacBeth regression procedure in Brooks as well
1

as the original paper:

http://ecsocman.hse.ru/data/965/126/1231/fama_macbeth_tests_1973.pdf


Try to understand the main ideas. We shall replicate some steps in the follow- ing exercises, so do not worry too much.
Download the portfolios: the Y variables (the Portfolios) and the X variables (the Factors)
Go to the URL:
http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html
Download data in csv format corresponding to 25 Portfolios Formed on Size and Book-to-Market (5 x 5) (towards the top middle of the page). You must make sure you download this dataset and not another in csv format. You can also directly download it from:
http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/25_Portfolios_5x5_CSV.zip
Download data in csv format corresponding to Fama/French 3 Factors (top of page). You must make sure you download this dataset and not another in csv format. You can also directly download it from:
http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/ F-F_Research_Data_Factors_CSV.zip
Note: Ensure that you have downloaded 􏰃les with monthly frequencies and not daily.
The portfolios are not excess returns. The risk free interest rate is in the 3- factor 􏰃le. Use this to compute excess returns on the portfolios. If you do not follow the paper, see the equation in
2

https://en.wikipedia.org/wiki/Fama􏰂French_three-factor_model
Prepare the 􏰃les
Put the zip􏰃les in a folder in your computer. For the sake of de􏰃niteness, I will suppose that the folder directory is 􏰀/media/marketdata/FRENCH/􏰁; you can use another directory. If you use Windows, I think you need to use instead of /, but both might work (I only use Linux or Mac). Unzip the 􏰃les. You will 􏰃nd the 􏰃les 25_Portfolios_5x5.CSV and F-F_Research_Data_Factors.CSV. Rename them to portfolios.csv and factors.csv, respectively. Open the 􏰃le portfolios.csv (in excel or similar) and delete the 􏰃rst 15 rows. This 􏰃le also has Average Equal Weighted Returns and other datasets that follow the top dataset. Delete the remaining data and make sure you are left only with the dataset at the top. Open the 􏰃le fac- tors.csv and delete the 􏰃rst 3 rows. This 􏰃le also has annual data that follow the monthly data towards the end of the 􏰃le. Delete the annual data and make sue you are left only with the dataset at the top. For both 􏰃les you should be left with a 􏰃le with headings on the 􏰃rst row and data below. If not, I leave to you to select how many rows to delete in order to achieve this. This makes it easier for MATALB to read the 􏰃les.
Load the Data
You must to use MATALB for the analysis. Load the data into MATLAB. To do so, use the function: importdata. I will show you the steps to make it easier for you:
myDir = ‘/media/marketdata/FRENCH/’;
portfoliosFile = ‘portfolios.csv’;
factorsFile = ‘factors.csv’; delimiter = ‘,’;
portfolios = importdata([myDir, portfoliosFile], delimiter); factors = importdata([myDir, portfoliosFile], delimiter);
I have been told that some people have problems loading the data in Mac (I think). If that so, try to follow the Matlab notes. Also, you may delete the headings (col- umn names) from the 􏰃les, but make sure that you know which is which.
The data are monthly observations. For both 􏰃les only use data for the period
3

‘196001’ to ‘202012’ included. If you do not know how to extract the subset of the data using MATALAB, just open the 􏰃les and delete the rows outside this range and then load the data in MATLAB.
Make sure you only include this dates, as failing to do so may change the results.
Computer Exercises
All exercises in this section carry equal weight.
Exercise 1 Compute the following summary statistics for each portfolio excess re- turn: mean, variance, skewness and kurtosis. Print the plots for these summary statistics; e.g. plot(mean(portfoliosData)), plot(var(portfoliosData)), where portfo- liosData is an n × 25 matrix where n is the sample size for the period ‘196001’ to ‘202012’ included. Make sure you know to which portfolio each entry in the x axis corresponds to; e.g. the 􏰃rst entry is ‘SMALL LoBM’. Attach these 􏰃gures as an appendix to the Answer Sheet.
Record the statistics (the actual numbers) for ‘SMALL LoBM’, ‘SMALL HiBM’, ‘BIG LoBM’, ‘BIG HiBM’ in the answer sheet.
Exercise 2 (Time series regression) For each portfolio p = 1,2,…,25, consider the regression
􏰆R(p) −r 􏰇=α(p) +β(p)(R −r )+β(p)SMB+β(p)HML+ε(p) fmmfsv
where R(p) is the n×1 vector of returns on the pth portfolio in the portfolios dataset. Rm − rf (Mkt-RF) is the market excess return, SMB is small minus big, and HML is high minus low. All vectors are n × 1. These columns are labeled in the 3-factor 􏰃le. Put the model in the usual form
where
Y = Xb0 + ε,
 R(1) −r R(2) −r ··· R(25) −r 
1 f,1 1 f,1 1 f,1
 R(1) −r R(2) −r ··· R(25) −r 
Y= 2 f,1 2 f,2 2 f,2
 . . .. . 

….
 (1) (2) (25)
Rn −rf,n Rn −rf,n ··· Rn −rf,n
4

1R−r SMBHML m,1f,1 1 1
 1 Rm,2 − rf,1 SMB2 HML2  X=. . . .
….

1 Rm,n − rf,1 SMBn HMLn  α(1) α(2) ··· α(25) 
that for each portfolio p = 1, 2, …, 25,
􏰈(p) 􏰉(p) (p) (p)
 β(1) β(2) ··· β(25)  mmm
b0= (1) (2) (25) βs βs ··· βs 
β(1) β(2) · · · β(25) vvv
 ε(1) ε(2) ··· ε(25)  111
(1) (2) (25) ε2 ε2 ··· ε2 
ε= . . .. .  ….
 (1) (2) (25)  εn εn ··· εn
Save the OLS estimator in a 4 × 25 matrix, say B. Plot each column of the matrix B′ separately. Add these graphs as an appendix to the Answer Sheet.
Compute the residuals for each individual portfolio regression p = 1, 2, …, 25: (p) (p) (p)
εˆ :=Y −XB
where Y (p) is the pth column in Y , and B(p) is the pth column in B.
Compute an estimator for V ar 􏰆B(p)􏰇. In the Answer Sheet record the values of B(p) (the estimated alphas and betas) and their standard errors for the portfolios
corresponding to ‘SMALL LoBM’, ‘SMALL HiBM’, ‘BIG LoBM’, ‘BIG HiBM’. Exercise 3 (Cross-sectional regression) Suppose that there are three scalars such
ERt −rf =βmλm+βsλs+βvλv. (1)
The λ’s are the risk premia associated to the three (pricing) factors: market, size (SMB) and value (HML). To estimate them we can run the following regression. At time t (the tth row in the dataset)
􏰈R(p)−r 􏰉=α +β(p)λ +β(p)λ +β(p)λ +Z(p),p=1,2,…,25. t f,t t m m,t s s,t v v,t t
Hence you are supposing that this equation holds for each p = 1, 2, …, 25 where αt is zero when we average across t (if (1) holds) . The term Z(p) is a mean zero pricing
t
error. We want to estimate the unknown parameters λm,t,λs,t,λv,t and αt. We do
not know βm,βs,βv, but we have estimated them in the previous exercise and saved 5

them in the matrix B. We suppose that the estimated betas in B′ are the matrix of explanatory variables and regress at time t the 25 portfolio returns on columns 2 to 4 in B′; this is made clear next. To do so, let Rt be the 25×1 vector of returns at time t where the pth row corresponds to the pth portfolio. At each time t, run the regression supposing the true model
where
Y = Xb0 + ε
 R(1) − r 
t f,1
 R(2) − r 
Y= t f,t
 . 

….
 (25) Rt
.

 1
X =  . . . .
− rf,t βˆ(1)
 1βm βs βv 
βˆ(1) msv
βˆ(1) ˆ(2) ˆ(2) ˆ(2)
 ˆ(25) ˆ(25) ˆ(25) 
1βm βs βv  αt 
 λm,t  b0 =  
 λs,t  λv,t
 ε(1)  t
ε= .  .
 (25)  εt
 αˆt  ˆ λˆm,t
(2)
εt 
Your goal is to 􏰃nd the estimator b =  ˆ for b0. Repeat the procedure for  λs,t 
λˆv,t
each t and save ˆb as the t column in the 4 × n matrix riskPremia. You have
just computed a time series of risk premia. Plot the time series of risk premia for all three factors separately and the pricing errors αt’s. Compute the following statistics for the three risk premia and the pricing error: mean, variance, skewness and kurtosis. Record these sample statistics in the Answer Sheet.
6

Exercise 4 (Backtest) Use the excess returns on the 25 portfolios to compute the sample covariance matrix on the sample period 201001-201512. Denote by COV this sample covariance. Compute the shrunk covariance matrix COV S = (1 − a) ∗ mean (diag (COV )) ∗ eye (25) + a ∗ COV with a = .5. Ensure that you understand what 􏰀mean (diag (COV )) ∗ eye (25)􏰁 is.
Compute the portfolio weights that solve the minimum variance portfolio prob- lem, with weights summing to one, using the two di􏰅erent estimators of the co- variance matrix and denote them by w and ws. Also consider the equally weighted portfolio, and denote its weights by wEW. Carry out a backtest of the three port- folios. To do so, you must use data unseen by the estimators w and ws. Hence, consider the testing period 201601-202012 to compute the portfolio excess returns for the strategy that uses w, ws and wEW as portfolio weights. (Conducting a backtest on data used for estimation is said to be subject to forward looking bias and must be avoided when possible.) Also, consider the excess returns on the mar- ket (Rm,t −rf,t) as benchmark. Compute the mean, variance, skewness and kurtosis for the three portfolios and the benchmark and report their values in the Answer Sheet. Plot the cumulative (monthly compounded) excess returns of the portfolios and the benchmark and put them in an appendix. The excess returns are in per- centage points. Hence, make sure that you divide them by 100 in order to compute the cumulative compounded returns so that for example, 0.15 means 15%. If Rs is the one month simple return at time s, the cumulative compounded return at time tisCt =􏰊ts=1(1+Rs). TheplotisthegraphofCt againstt.
7

Answer Sheet: Record Your Answers Here Put Graphs in an Appendix
Name____________________ Last Name____________________
Question Q1
mean var skewness kurtosis Q2
αˆ value (s.e.) βˆmvalue (s.e.) βˆs value (s.e.) βˆv value (s.e.) Q3
mean var skewness kurtosis Q4
mean var skewness kurtosis
Student Number______________ Answer
‘SMALL LoBM’
‘SMALL LoBM’
αˆ
w
‘SMALL HiBM’
‘SMALL HiBM’
λˆm
ws
‘BIG LoBM’
‘BIG LoBM’
λˆs
wEW
‘BIG HiBM’
‘BIG HiBM’
λˆv
benchmark
8

Leave a Reply

Your email address will not be published. Required fields are marked *