data analysis

for those functions.

Solve the following tasks, and you should keep in mind that shorter codes have a positive impact on your mark.

Tasks:

  1. You are going to work with datasets dataOLS.txt and IndustriesUS.txt. The first dataset contains 4 variables: sorted as date, Market excess returns, SMB factor, HML factor and risk-free asset returns. Dataset IndustriesUS.txt contains 18 variables: sorted as date and 17 industry portfolio returns. You should load these two datasets. All returns in both datasets are in percentage, so you need to divide your data by 100. In addition, you should only work with the last 200 observations.
  2. Run a backtest analysis similar to the one in the m-file OLS.m. This is, you should construct an OLS out-of-sample analysis to forecast market returns using the 17 in- dustry portfolios given in dataset IndustriesUS.txt. Read the slide 16 of our Matlab session for more information about the backtest. To do that, run a rolling-window experiment where you regress market return over 17 industry portfolio returns and use the expected market return estimated from your model to predict the next period market return. At the end of the analysis, print the mean squared forecast error, plot the estimated betas and the estimated and actual market returns. Your estimation window for this task and the following must be of M=120 observations. The file OLS.m contains a sample on how to do this. Hint: Read lines 116-130 in OLS.m to see how we can do a backtest analysis and compute forecast errors (the square) in line 128.
  3. Now, re-run the same analysis using ridge regression rather than OLS. Your estimated coe cients then have the following expression

    bRidge =(X0X+IN)1(X0Y), 1

where is a positive scalar and IN is the identity matrix with the same size as X0X. You should find the value of that reduces the mean squared forecast error. Plot the mean squared forecast error for di↵erent values of . Plot the estimated betas for that that minimizes your mean squared forecast error.

4. Re-run the same analysis as before, but now rather than using OLS or ridge regression, you should estimate the betas of your model using the following model:

XT

min {yi ↵ 1×1 … 17×17}2

↵,
i=1

subject to ↵, 0,

where is the vector of 17 coe cients. Are the results better than those obtained with ridge-regression? Hint: Use fmincon and stop warnings using warning off. Fmincon looks like

x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options,inputs).

This part of the analysis can take some time, so don’t expect to obtain results straight away. You can also use the command quadprog as we did in our Matlab session. You would only have to keep in mind that coe cients are restricted to be non-negative.

Submission deadline: You should submit your assignment by noon 6th of January, 2016.

Last hints:

Read carefully comments on Matlab file OLS.m
Save your data and Matlab files (scripts) in the same folder.

Change your current directory to the folder where your have saved your data and your Matlab files.

Remember: to set your current directory, use cd(’C: My Directory’).

2