1. Homepage
  2. Programming
  3. MFIN7034 Machine Learning and Artificial Intelligence in Finance - Problem Set 1 - Factor Model

MFIN7034 Machine Learning and Artificial Intelligence in Finance - Problem Set 1 - Factor Model

Engage in a Conversation
HKUMFIN7034Machine Learning and Artificial Intelligence in FinanceFactor ModelPython

MFIN7034
Problem Set 1 – Factor Model
CourseNana.COM

Version: 2024/02/20 Due Date: 2024/03/05 CourseNana.COM

Feel free to ask about algorithm-related problems. Please learn to debug your code using Google, GitHub, Stackoverflow, and the package manual. CourseNana.COM

In this assignment, you will run regressions to understand how the factor model explains asset return and construct an investment strategy based on the factor model. CourseNana.COM

1. Datasets CourseNana.COM

Monthly Stock Returns: Monthly Stock File (upenn.edu)
Fama-French 5 Factors: Kenneth R. French - Data Library (dartmouth.edu)
Hou, Xue, Zhang q-Factor: Factors (global-q.org)
Pastor Stambaugh Liquidity Factor: Robert Stambaugh's Home Page (upenn.edu) CourseNana.COM

Please first understand how these factors are constructed so that you will know what they represent. CourseNana.COM

2. (Navie) Factor Regression CourseNana.COM

For each stock, each month, use the data from 60 months ago to the previous month (it is okay if the sample has less than 60 months as long as it can be estimated in OLS), and run regression (“rolling-window regression”): CourseNana.COM

𝑅=𝛼+∑𝛽𝐹+𝜀 𝑖,𝑡 𝑖,𝑗 𝑗,𝑡 𝑖,𝑡 CourseNana.COM

  • ⚫  𝑅𝑖,𝑡: Stock 𝑖’s return at month 𝑡. CourseNana.COM

  • ⚫  𝐹 : Factor 𝑗’s return at month 𝑡. Please use all factors provided (FF5, HXZ5, PS). CourseNana.COM

    However, both FF5 and HXZ5 contain market returns. Therefore, please only use CourseNana.COM

    market return in FF5 (“Mkt-RF”) and drop market return in HXZ5 (“R_MKT”). CourseNana.COM

  • ⚫  𝛼: Constant term of the regression. CourseNana.COM

  • ⚫  𝛽𝑖,𝑗: Coefficients of factor 𝑗 on stock 𝑖.
    For each month, you can estimate the
    𝛼 and 𝛽𝑖,𝑗. Therefore, iterating the process, you CourseNana.COM

    will have a time series of 𝛼 and 𝛽𝑖,𝑗 for stock 𝑖. Plot the time series of “Mkt-RF” and “𝛼” and explain whatever you find for stock PERMNO=10324. CourseNana.COM

    Rolling window means that, for example, for 𝛼 and 𝜷 in 201212, you use data from 200801 to 201212 to estimate. CourseNana.COM

𝑗,𝑡 CourseNana.COM

200801 200802 200803 200804 ... 201212 CourseNana.COM

201301 201302 CourseNana.COM

... ... CourseNana.COM

𝛼1,𝜷𝟏 CourseNana.COM

𝛼2,𝜷𝟐 CourseNana.COM

𝛼3,𝜷𝟑 CourseNana.COM

𝛼4,𝜷𝟒 CourseNana.COM

Then plot the time series of 𝛼 and 𝜷. CourseNana.COM

3. Fama-MacBeth Regression CourseNana.COM

If you do not know this regression, refer to this wiki: Fama–MacBeth regression - Wikipedia. Furthermore, you may search for materials on the Internet, which is relatively abundant. CourseNana.COM

By running Fama-MacBeth Regression, you can estimate the risk premium of each factor over time. You will obtain time series of 𝛾𝑡,𝑗 for factor 𝑗 (notation in the wiki) by iterating rolling-window regressions. Plot the time series of “Mkt-RF”’s risk premium and explain whatever you find. CourseNana.COM

4. LASSO Regression CourseNana.COM

In running naïve factor regression, you can replace the estimation method (OLS) with LASSO (set 𝛼 = 0.001). Also, replace the factors with a 0- to 6-month lagged version. We are still using the previous 60 months (including the current month's) data to do the regression. For example, suppose we simply do CAPM by LASSO with lagged factors. It will be like this: CourseNana.COM

𝑅𝑖,𝑡 = 𝛼 + 𝛽0𝑀𝑘𝑡𝑡−0 + 𝛽1𝑀𝑘𝑡𝑡−1 + 𝛽2𝑀𝑘𝑡𝑡−2 + ⋯ + 𝛽6𝑀𝑘𝑡𝑡−6 + 𝜀𝑖,𝑡 CourseNana.COM

The candidate factors are those provided (FF5, HXZ5, and PS). Then for each stock each month, you will have a group of factors that LASSO chooses. Suppose there is 60% of stocks choose 𝑀𝑘𝑡𝑡−2 factor (2-monthly lagged market return, 𝛽2 ≠ 0). That means this factor has good explanatory power to 60% of stocks in this month. Please show the top 5 prevalent factors for each month. Given the limitation of computing power, please simply calculate the results for YYYYMM={200501, 200601, ..., 202001}. CourseNana.COM

You will produce a table like (“_l3” represents factor with a 3-month lag.): CourseNana.COM

YYYYMM 1st 2nd 3rd 4th 5th CourseNana.COM

200501 Mkt-RF_l0 AggLiq_l0 AggLiq_l3 LIV_Q_l0 LIV_Q_l1 200601 ... ... ... ... ... .................. 202001 ... ... ... ... ... CourseNana.COM

You can also try various 𝛼 to see how the results will be affected. CourseNana.COM

CourseNana.COM

5. Mean-Variance Portfolio CourseNana.COM

Recall lecture note “Lec 4 Multi-Factor Model” page 12. For every year starting 2005, estimate the mean and variance of each stock. Mean and variance is calculated by factor model using data in the previous five years, which will be covered in Lecture 5. Please be reminded that choosing appropriate factors is important in calculating variance. CourseNana.COM

After compiling the mean and variance, calculate the weight to construct the most efficient mean-variance portfolio (assuming 𝛾 = 1 and no transaction costs). Please note that you can have long or short stocks in this practice. You will hold this portfolio for the following twelve months and then adjust your portfolio based on the calculation of the next iteration (i.e., rebalancing your portfolio annually). Finally, plot the cumulative returns of this investment strategy and calculate the annualized Sharpe ratio and maximum drawdown. CourseNana.COM

6. Deliverable CourseNana.COM

The final report should contain results generated by your program. It would help if you properly visualize them and provide interpretations of the results, for example, explaining why the coefficient of a factor change over time. CourseNana.COM

You should submit a ZIP file containing ONE code file (.py or .ipynb) and ONE analysis report (.pdf).  CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
HKU代写,MFIN7034代写,Machine Learning and Artificial Intelligence in Finance代写,Factor Model代写,Python代写,HKU代编,MFIN7034代编,Machine Learning and Artificial Intelligence in Finance代编,Factor Model代编,Python代编,HKU代考,MFIN7034代考,Machine Learning and Artificial Intelligence in Finance代考,Factor Model代考,Python代考,HKUhelp,MFIN7034help,Machine Learning and Artificial Intelligence in Financehelp,Factor Modelhelp,Pythonhelp,HKU作业代写,MFIN7034作业代写,Machine Learning and Artificial Intelligence in Finance作业代写,Factor Model作业代写,Python作业代写,HKU编程代写,MFIN7034编程代写,Machine Learning and Artificial Intelligence in Finance编程代写,Factor Model编程代写,Python编程代写,HKUprogramming help,MFIN7034programming help,Machine Learning and Artificial Intelligence in Financeprogramming help,Factor Modelprogramming help,Pythonprogramming help,HKUassignment help,MFIN7034assignment help,Machine Learning and Artificial Intelligence in Financeassignment help,Factor Modelassignment help,Pythonassignment help,HKUsolution,MFIN7034solution,Machine Learning and Artificial Intelligence in Financesolution,Factor Modelsolution,Pythonsolution,